Commit 61718ac1 by Takatoshi Miura

Task #49379【Android12】API31対応 Bluetooth Permissionを追加

parent 091d434d
......@@ -127,6 +127,7 @@ public class Constant {
int AccessFineLocation = 1;
int Camera = 2;
int Audio =3;
int Bluetooth = 4;
}
public interface TaskReportLevel {
......
......@@ -21,8 +21,10 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><!-- an app to access precise location from location sources such as GPS, cell towers, and Wi-Fi -->
<uses-permission android:name="android.permission.RECORD_AUDIO" /><!-- AudioPlayView -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
......
......@@ -1535,6 +1535,7 @@
<string name="msg_over_used">使用回数が上限を超えました。他の機器を使用してください。</string>
<string name="msg_power_off">機器の電源がOFFになりました。電源を入れて再接続してください。</string>
<string name="alcohol_checker">アルコールチェッカー</string>
<string name="msg_permission_dialog_bluetooth">Bluetooth利用権限が必要です。\nアプリ設定画面へ遷移します。</string>
<!-- atForm -->
<string name="msg_disconnected_device">デバイスと切断されました。</string>
......
......@@ -1540,6 +1540,7 @@
<string name="msg_over_used">사용 횟수가 상한을 넘었습니다.다른 기기를 사용해 주십시오.</string>
<string name="msg_power_off">기기의 전원이 OFF되었습니다.전원을 켜고 다시 연결해 주십시오.</string>
<string name="alcohol_checker">알코올 검사기</string>
<string name="msg_permission_dialog_bluetooth">Bluetooth 이용권한이 필요합니다. \n앱설정화면으로 이동합니다.</string>
<!-- atform -->
<string name="pairing_search_scan">주사</string>
<string name="pairing_search_stop">멈추다</string>
......
......@@ -1536,6 +1536,7 @@
<string name="msg_over_used">The number of uses has exceeded the upper limit. Please use other device.</string>
<string name="msg_power_off">The power of the device has been turned off. Turn on the power and reconnect.</string>
<string name="alcohol_checker">Alcohol Checker</string>
<string name="msg_permission_dialog_bluetooth">Bluetooth usage authority is required. \n To transition to the application setting screen.</string>
<!-- Form -->
<string name="msg_connection_timeout">Could not connect to device.</string>
<string name="msg_disconnected_device">Disconnected from the device.</string>
......
......@@ -501,6 +501,11 @@ public class ABookSettingFragment extends PreferenceFragment {
@Override
public boolean onPreferenceClick(Preference preference) {
try {
// アプリ側のBluetooth許可チェック
ABookPermissionHelper helper = new ABookPermissionHelper(getActivity(), Constant.ABookPermissionType.Bluetooth, null);
if (!helper.checkMultiPermissions(true)) {
return true;
}
// ペアリング設定画面(BLE通信)
Intent intent = new Intent();
intent.setClass(getActivity(), BlePairingSettingActivity.class);
......
......@@ -14,6 +14,7 @@ import java.util.ArrayList;
import jp.agentec.abook.abv.bl.common.Callback;
import jp.agentec.abook.abv.bl.common.Constant;
import jp.agentec.abook.abv.bl.data.ABVDataCache;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
import jp.agentec.abook.abv.ui.common.dialog.ABookAlertDialog;
import jp.agentec.abook.abv.ui.common.util.AlertDialogUtil;
......@@ -82,6 +83,18 @@ public class ABookPermissionHelper {
android.Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.RECORD_AUDIO);
}
// アルコールチェッカーHW設定がONかつAndroid12以上の場合のみ
if (ABVDataCache.getInstance().serviceOption.isAlcoholCheckerHw() && Build.VERSION.SDK_INT > 30) {
// Bluetooth
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.BLUETOOTH_CONNECT);
}
if (ContextCompat.checkSelfPermission(mContext ,
android.Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.BLUETOOTH_SCAN);
}
}
return reqPermissions;
}
......@@ -151,6 +164,27 @@ public class ABookPermissionHelper {
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
case Constant.ABookPermissionType.Bluetooth:
// Android12未満では実施しない
if (Build.VERSION.SDK_INT < 31) {
break;
}
// Bluetooth
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.BLUETOOTH_CONNECT) != PERMISSION_GRANTED) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_bluetooth,
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.BLUETOOTH_SCAN) != PERMISSION_GRANTED) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_bluetooth,
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
break;
}
if (permitionTextResourceId > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment