Commit cb424a43 by Kim Jinsung

内部バージョンアップ時、READ_EXTERNAL_STORAGE権限チェックしない

parent 111eb8b6
......@@ -310,60 +310,54 @@ public abstract class ABVNoAuthenticatedActivity extends ABVActivity {
return null;
}
};
//パーミッションチェック
ABookPermissionHelper helper = new ABookPermissionHelper(this, Constant.ABookPermissionType.ReadExternalStorage, resultCallback);
if (helper.checkMultiPermissions(true)) {
// showAlert
ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(mContext);
dialog.setTitle(R.string.app_update);
dialog.setMessage(R.string.need_to_application_update);
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// バージョンアップフラグをON
PreferenceUtil.put(getApplicationContext(), AppDefType.DefPrefKey.APP_VERSIONUP_PROCESSING, true);
// Android8以上でバックグラウンドをフォアグラウンドで処理
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent serviceIntent = new Intent(mContext, BackgroundDownloadService.class);
startForegroundService(serviceIntent);
} else {
// Download 開始
DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
String currentDate = DateTimeUtil.toString(DateTimeUtil.getCurrentTimestamp(), DateTimeFormat.yyyyMMddHHmmss000_none);
String downloadUrl = AcmsApis.getDownloadApplicationFileUrl(abvEnvironment.acmsAddress, dataCache.getUrlPath(), dataCache.getMemberInfo().sid, currentDate);
Logger.d(TAG, "downloadUrl=%s", downloadUrl);
Request request = new Request(Uri.parse(downloadUrl));
request.setDescription("ABook Plus New Version File");
//LANケーブル接続のタイプ(ETHERNET TYPE)がないため、セットしない
// request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
File file = new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), ABVEnvironment.APK_FILE_NAME);
Logger.d(TAG, "download local file=%s", file.getAbsolutePath());
File[] childs = file.getParentFile().listFiles();
if (childs != null && childs.length > 0 && childs[0].exists()) {
childs[0].delete();
}
request.setDestinationUri(Uri.fromFile(file));
downloadManager.enqueue(request);
registerReceiver(new OnAppDownloadReceiver(), new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
// アプリを閉じる
saveLeaveAppTime();
moveTaskToBack(true);
}
});
dialog.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
moveToHome();
}
});
showAlertDialog(dialog);
} else {
Logger.w(TAG,"ReadExternalStorage checkMultiPermissions false");
}
// showAlert
ABookAlertDialog dialog = AlertDialogUtil.createABookAlertDialog(mContext);
dialog.setTitle(R.string.app_update);
dialog.setMessage(R.string.need_to_application_update);
dialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// バージョンアップフラグをON
PreferenceUtil.put(getApplicationContext(), AppDefType.DefPrefKey.APP_VERSIONUP_PROCESSING, true);
// Android8以上でバックグラウンドをフォアグラウンドで処理
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent serviceIntent = new Intent(mContext, BackgroundDownloadService.class);
startForegroundService(serviceIntent);
} else {
// Download 開始
DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
String currentDate = DateTimeUtil.toString(DateTimeUtil.getCurrentTimestamp(), DateTimeFormat.yyyyMMddHHmmss000_none);
String downloadUrl = AcmsApis.getDownloadApplicationFileUrl(abvEnvironment.acmsAddress, dataCache.getUrlPath(), dataCache.getMemberInfo().sid, currentDate);
Logger.d(TAG, "downloadUrl=%s", downloadUrl);
Request request = new Request(Uri.parse(downloadUrl));
request.setDescription("ABook Plus New Version File");
//LANケーブル接続のタイプ(ETHERNET TYPE)がないため、セットしない
// request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
File file = new File(getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), ABVEnvironment.APK_FILE_NAME);
Logger.d(TAG, "download local file=%s", file.getAbsolutePath());
File[] childs = file.getParentFile().listFiles();
if (childs != null && childs.length > 0 && childs[0].exists()) {
childs[0].delete();
}
request.setDestinationUri(Uri.fromFile(file));
downloadManager.enqueue(request);
registerReceiver(new OnAppDownloadReceiver(), new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}
// アプリを閉じる
saveLeaveAppTime();
moveTaskToBack(true);
}
});
dialog.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
moveToHome();
}
});
showAlertDialog(dialog);
} else {
moveToHome();
}
......
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