有些APP启动时会动态申请权限,Android10更新了权限申请的方式,这块代码是在packages/apps/PermissionControlle目录下
代码修改在./src/com/android/packageinstaller/permission/ui/handheld/ReviewPermissionsFragment.java
修改如下:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Activity activity = getActivity();
if (activity == null) {
return;
}
PackageInfo packageInfo = getArguments().getParcelable(EXTRA_PACKAGE_INFO);
if (packageInfo == null) {
activity.finish();
return;
}
mAppPermissions = new AppPermissions(activity, packageInfo, false, true,
() -> getActivity().finish());
boolean reviewRequired = false;
for (AppPermissionGroup group : mAppPermissions.getPermissionGroups()) {
if (group.isReviewRequired() || (group.getBackgroundPermissions() != null
&& group.getBackgroundPermissions().isReviewRequired())) {
reviewRequired = true;
break;
}
}
//start 修改如下,添加代码
?if ("pacakgename".equals(mPkgName) || "pacakgename".equals(mPkgName)) {
? ? ? ? ? ? confirmPermissionsReview();
? ? ? ? ? ? executeCallback(true);
? ? ? ? ? ? activity.finish();
? ? ? ? }
//end 如果所有app都不想弹框,可以把下面的reviewRequired的值改为false;
if (!reviewRequired) {
// If the system called for a review but no groups are found, this means that all groups
// are restricted. Hence there is nothing to review and instantly continue.
confirmPermissionsReview();
executeCallback(true);
activity.finish();
}
}
|