1 原理
在弹窗的位置上修改代码 或者是直接授权,不让弹窗弹出来。
2 解决方案(Android O)@2 系统级APP(针对system priv-app && system app)不弹权限弹窗 解决方案
在文件frameworks/base/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java中做如下修改:
@@ -739,6 +739,12 @@ final class DefaultPermissionGrantPolicy {
STORAGE_PERMISSIONS, true, userId);
}
+ //XXX Launcher
+ PackageParser.Package XXXPckg = getPackageLPr("com.XXX.launcher");
+ if(XXXPckg !=null){
+ grantRuntimePermissionsLPw(XXXPckg,STORAGE_PERMISSIONS,userId);
+ grantRuntimePermissionsLPw(XXXPckg,LOCATION_PERMISSIONS,userId);
+ //...
+ }
mService.mSettings.onDefaultRuntimePermissionsGrantedLPr(userId);
}
}
@3 普通APP 不弹权限弹窗 解决方案
在文件 frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java 中做如下修改:
@@ -1680,8 +1680,9 @@ public class PackageManagerService extends IPackageManager.Stub
InstallArgs args = data.args;
PackageInstalledInfo parentRes = data.res;
- final boolean grantPermissions = (args.installFlags
- & PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS) != 0;
+ /*final boolean grantPermissions = (args.installFlags
+ & PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS) != 0;*/
+ final boolean grantPermissions = true;
final boolean killApp = (args.installFlags
& PackageManager.INSTALL_DONT_KILL_APP) == 0;
final boolean virtualPreload = ((args.installFlags
@4 USB权限 对话框 不弹窗 解决方案
在文件 frameworks/base/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java 中做如下修改:
@@ -110,8 +110,9 @@ public class UsbPermissionActivity extends AlertActivity
com.android.internal.R.id.clearDefaultHint);
mClearDefaultHint.setVisibility(View.GONE);
- setupAlert();
-
+ //setupAlert();
+ mPermissionGranted = true;
+ finish();
}
@Override
@5 ANR/Crash 对话框 不弹窗 解决方案
在文件 frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java 中做如下修改:
@@ -626,7 +626,9 @@ public class ActivityManagerService extends IActivityManager.Stub
// Whether we should show our dialogs (ANR, crash, etc) or just perform their
// default action automatically. Important for devices without direct input
// devices.
- private boolean mShowDialogs = true;
+ //private boolean mShowDialogs = true;
+ private boolean mShowDialogs = false;
+
private final VrController mVrController;