修复 XAPK 在 Android 12 授权后无法解压的问题
This commit is contained in:
@ -295,11 +295,6 @@ public class MainActivity extends BaseActivity {
|
||||
checkDialog();
|
||||
}
|
||||
|
||||
// handler.postDelayed(() -> {
|
||||
// PushHelper.postPushClickAction(this.getApplicationContext(), null);
|
||||
// }, 2000);
|
||||
|
||||
|
||||
// 耗时操作
|
||||
AppExecutor.getIoExecutor().execute(() -> {
|
||||
// 上传数据
|
||||
@ -312,9 +307,6 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
// 初始化PlatformUtils
|
||||
PlatformUtils.getInstance(getApplicationContext());
|
||||
// // 友盟记录启动
|
||||
// PushAgent.getInstance(this).onAppStart();
|
||||
|
||||
HomePluggableHelper.activationFilterData();
|
||||
});
|
||||
|
||||
@ -336,6 +328,9 @@ public class MainActivity extends BaseActivity {
|
||||
postAttentionVideoRecord();
|
||||
deleteSimulatorGame();
|
||||
|
||||
// 检查是否需要触发 XAPK 安装
|
||||
AppExecutor.getUiExecutor().executeWithDelay(this::resumeXapkInstallIfNeeded, 150);
|
||||
|
||||
QuickLoginHelper.getPhoneInfo(this);
|
||||
WechatBindHelper.getWechatConfig(null);
|
||||
initWBSDK();
|
||||
@ -1033,4 +1028,23 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新触发 XAPK 安装流程
|
||||
* 因为 Android 12 起授予应用安装未知应用权限以后不触发进程重启,导致应用一直无法读写 android/data 目录
|
||||
* 所以这里再手动重启应用进程时再触发一回安装
|
||||
*/
|
||||
private void resumeXapkInstallIfNeeded() {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
|
||||
String xapkUrl = SPUtils.getString(Constants.SP_XAPK_URL);
|
||||
if (!TextUtils.isEmpty(xapkUrl)) {
|
||||
DownloadEntity downloadEntity = DownloadManager.getInstance().getDownloadEntityByUrl(xapkUrl);
|
||||
if (downloadEntity != null) {
|
||||
PackageInstaller.install(this, downloadEntity, false);
|
||||
}
|
||||
}
|
||||
SPUtils.setString(Constants.SP_XAPK_UNZIP_ACTIVITY, "");
|
||||
SPUtils.setString(Constants.SP_XAPK_URL, "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user