Commit 439fa0ef by Kim Jinsung

#60932 【Android 13 @form】バックグランドだと、プッシュメッセージが通知されない

添付ファイルの権限問題対応
parent 2396603b
......@@ -36,6 +36,10 @@
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<!-- Android13 -->
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<supports-screens android:anyDensity="true" android:xlargeScreens="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="false"/>
......
......@@ -57,10 +57,19 @@ public abstract class ABVSplashActivity extends ABVNoAuthenticatedActivity {
protected void onResume() {
super.onResume();
boolean chekcFlg = PreferenceUtil.getUserPref(this, AppDefType.UserPrefKey.ALL_PERMISSION_CHECK, true);
ABookPermissionHelper helper = new ABookPermissionHelper(this);
if (chekcFlg) {
PreferenceUtil.putUserPref(this, AppDefType.UserPrefKey.ALL_PERMISSION_CHECK, false);
ABookPermissionHelper helper = new ABookPermissionHelper(this);
mPermissionArray = helper.checkMultiPermissions();
} else {
mPermissionArray = helper.checkAndroidVersionUpPermissions();
}
commonCheckPermission();
}
/**
* 権限チェック後、画面表示
*/
private void commonCheckPermission() {
if (mPermissionArray.size() == 0) {
abookMode();
} else {
......@@ -68,9 +77,6 @@ public abstract class ABVSplashActivity extends ABVNoAuthenticatedActivity {
mPermissionArray.toArray(new String[mPermissionArray.size()]),
REQUEST_PERMISSIONS);
}
} else {
abookMode();
}
}
@Override
......
......@@ -77,6 +77,7 @@ public interface AppDefType {
String OPERATION_GROUP_MASERT_ID = "operation_group_master_id"; // 作業種別のID
String OPERATION_SORT_CONDITION = "operation_sort_condition"; // 作業のソート
String OPERATION_AUTO_SYNC = "operationAutoSync";
String ANDROID_13_PERMISSION_CHECK = "android13PermissionCheck";
}
/**
......
......@@ -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.cl.util.PreferenceUtil;
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;
......@@ -44,6 +45,32 @@ public class ABookPermissionHelper {
public ABookPermissionHelper(Context context) {
mContext = context;
}
/**
* AndroidOSバージョンアップ時の追加権限チェック
* @return 権限文字列の配列
*/
public ArrayList<String> checkAndroidVersionUpPermissions() {
ArrayList<String> reqPermissions = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { //Android13以上
boolean chekcPermissionFlg = PreferenceUtil.getUserPref(mContext, AppDefType.UserPrefKey.ANDROID_13_PERMISSION_CHECK, true);
if (chekcPermissionFlg) {
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.READ_MEDIA_VIDEO);
}
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.READ_MEDIA_IMAGES);
}
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.POST_NOTIFICATIONS);
}
PreferenceUtil.putUserPref(mContext, AppDefType.UserPrefKey.ANDROID_13_PERMISSION_CHECK, false);
}
}
return reqPermissions;
}
public ArrayList<String> checkMultiPermissions() {
......@@ -62,6 +89,21 @@ public class ABookPermissionHelper {
reqPermissions.add(android.Manifest.permission.ACCESS_COARSE_LOCATION);
}
// ストレージ
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { //Android13以上
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.READ_MEDIA_VIDEO);
}
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.READ_MEDIA_IMAGES);
}
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.POST_NOTIFICATIONS);
}
PreferenceUtil.putUserPref(mContext, AppDefType.UserPrefKey.ANDROID_13_PERMISSION_CHECK, false);
} else {
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.READ_EXTERNAL_STORAGE);
......@@ -70,6 +112,8 @@ public class ABookPermissionHelper {
android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
reqPermissions.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
}
// カメラ
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
......@@ -111,9 +155,21 @@ public class ABookPermissionHelper {
switch (mPermitionType) {
case Constant.ABookPermissionType.ReadExternalStorage:
// ストレージ
boolean permissionGranted = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { //Android13以上
if (ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.READ_MEDIA_IMAGES) != PERMISSION_GRANTED) {
permissionGranted = false;
}
} else {
// ストレージ
if (ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(mContext, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PERMISSION_GRANTED) {
if (mContext instanceof HTMLWebViewActivity || mContext instanceof OperationListActivity) {
permissionGranted = false;
}
}
if (!permissionGranted) {
if (mContext instanceof HTMLWebViewActivity ||
mContext instanceof OperationListActivity) {
// リソースパターンの適用
permitionTextResourceId = PatternStringUtil.patternToInt(mContext,
R.string.msg_permission_dialog_storage_album,
......@@ -124,7 +180,6 @@ public class ABookPermissionHelper {
R.string.msg_permission_dialog_storage_update,
getUserPref(mContext, AppDefType.UserPrefKey.RESOURCE_PATTERN_TYPE, 0));
}
}
break;
case Constant.ABookPermissionType.AccessFineLocation:
......
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