Commit 6c7935c6 by Kim Jinsung

Android13端末対応で、通知権限とストレージファイル参照権限を追加

parent e2ebd58c
......@@ -40,6 +40,9 @@
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<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"/>
......
package jp.agentec.abook.abv.cl.helper;
import android.content.Context;
import java.util.Arrays;
import java.util.List;
import jp.agentec.abook.abv.bl.common.log.Logger;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
interface MigrationVersion {
//Android13対応で、「通知」「イメージ・動画」権限追加され、バージョンアップ後、起動時に再度権限ダイアログ表示する処理追加
String VER_1_4_520 = "VER_1_4_520";
}
/**
* アプリ内のマイグレーション処理クラス
*/
public class AppMigrationHelper {
private static final String TAG = "AppMigrationHelper";
private static final String[] MIGRATION_ARRAY = {MigrationVersion.VER_1_4_520};
/**
* アプリマイグレーションを実行
* @param context コンテキスト
*/
public void runMigration(Context context) {
Logger.d(TAG, "runMigration");
boolean chekcFlg = PreferenceUtil.getUserPref(context, AppDefType.UserPrefKey.ALL_PERMISSION_CHECK, true);
List<String> migrationList = Arrays.asList(MIGRATION_ARRAY);
for (String version : migrationList) {
if (chekcFlg) {//新規インストール&データ初期化
PreferenceUtil.put(context, version, true);
} else { //上書きインストール
boolean migrationFinished = PreferenceUtil.getUserPref(context, version, false);
if (!migrationFinished) {
if (version.equals(MigrationVersion.VER_1_4_520)) {
resetAllPermissionCheckFlg(context);
}
PreferenceUtil.putUserPref(context, version, true);
}
}
}
}
/**
* アプリ起動時の権限チェック済みフラグを初期化
* @param context コンテキスト
*/
private void resetAllPermissionCheckFlg(Context context) {
Logger.i(TAG, "resetPermissionCheck");
PreferenceUtil.putUserPref(context, AppDefType.UserPrefKey.ALL_PERMISSION_CHECK, true);
}
}
......@@ -19,6 +19,7 @@ import jp.agentec.abook.abv.bl.download.ContentDownloader;
import jp.agentec.abook.abv.bl.dto.MemberInfoDto;
import jp.agentec.abook.abv.bl.logic.AbstractLogic;
import jp.agentec.abook.abv.bl.logic.UserAuthenticateLogic;
import jp.agentec.abook.abv.cl.helper.AppMigrationHelper;
import jp.agentec.abook.abv.cl.util.PreferenceUtil;
import jp.agentec.abook.abv.launcher.android.R;
import jp.agentec.abook.abv.ui.common.appinfo.AppDefType;
......@@ -51,10 +52,15 @@ public abstract class ABVSplashActivity extends ABVNoAuthenticatedActivity {
setContentView(R.layout.ac_splash1);
getABVUIDataCache().isFirstLaunching = true;
//app migration
AppMigrationHelper appMigrationHelper = new AppMigrationHelper();
appMigrationHelper.runMigration(this);
}
@Override
protected void onResume() {
Logger.i(TAG, "onResume");
super.onResume();
boolean chekcFlg = PreferenceUtil.getUserPref(this, AppDefType.UserPrefKey.ALL_PERMISSION_CHECK, true);
if (chekcFlg) {
......
......@@ -63,6 +63,20 @@ public class ABookPermissionHelper {
android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
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);
}
} else {
// ストレージ
if (ContextCompat.checkSelfPermission(mContext,
android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
......@@ -72,6 +86,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) {
......@@ -106,9 +122,19 @@ public class ABookPermissionHelper {
int permitionTextResourceId = -1;
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) {
permissionGranted = false;
}
}
if (!permissionGranted) {
if (mContext instanceof HTMLWebViewActivity ||
mContext instanceof OperationListActivity ||
mContext instanceof DeviceImageListActivity) {
......
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