diff options
9 files changed, 34 insertions, 21 deletions
diff --git a/api/removed.txt b/api/removed.txt index 94ba45244b9f..239eab657008 100644 --- a/api/removed.txt +++ b/api/removed.txt @@ -179,6 +179,10 @@ package android.os { ctor public BatteryManager(); } + public class Build { + field public static final boolean PERMISSIONS_REVIEW_REQUIRED; + } + public final class PowerManager { method public void goToSleep(long); method public deprecated void userActivity(long, boolean); diff --git a/api/test-removed.txt b/api/test-removed.txt index 94ba45244b9f..239eab657008 100644 --- a/api/test-removed.txt +++ b/api/test-removed.txt @@ -179,6 +179,10 @@ package android.os { ctor public BatteryManager(); } + public class Build { + field public static final boolean PERMISSIONS_REVIEW_REQUIRED; + } + public final class PowerManager { method public void goToSleep(long); method public deprecated void userActivity(long, boolean); diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index c180c7f5ef4d..5b51002120d6 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -847,6 +847,7 @@ public class Build { * is installed. * * @hide + * @removed */ @SystemApi public static final boolean PERMISSIONS_REVIEW_REQUIRED = diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java index 8b243e7f751a..9d880202f7a2 100644 --- a/services/core/java/com/android/server/BluetoothManagerService.java +++ b/services/core/java/com/android/server/BluetoothManagerService.java @@ -28,6 +28,7 @@ import android.bluetooth.IBluetoothManager; import android.bluetooth.IBluetoothManagerCallback; import android.bluetooth.IBluetoothProfileServiceConnection; import android.bluetooth.IBluetoothStateChangeCallback; +import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ContentResolver; @@ -248,8 +249,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { mContext = context; - mPermissionReviewRequired = Build.PERMISSIONS_REVIEW_REQUIRED - || context.getResources().getBoolean( + mPermissionReviewRequired = context.getResources().getBoolean( com.android.internal.R.bool.config_permissionReviewRequired); mBluetooth = null; @@ -742,7 +742,15 @@ class BluetoothManagerService extends IBluetoothManager.Stub { // Legacy apps in permission review mode trigger a user prompt if (applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) { Intent intent = new Intent(intentAction); - mContext.startActivity(intent); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK + | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); + try { + mContext.startActivity(intent); + } catch (ActivityNotFoundException e) { + // Shouldn't happen + Slog.e(TAG, "Intent to handle action " + intentAction + " missing"); + return false; + } return true; } } catch (PackageManager.NameNotFoundException e) { diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 3ebd87cd7b12..5f305ae1f7bb 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -368,7 +368,7 @@ public final class ActiveServices { // we do not start the service and launch a review activity if the calling app // is in the foreground passing it a pending intent to start the service when // review is completed. - if (mAm.mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) { + if (mAm.mPermissionReviewRequired) { if (!requestStartTargetPermissionsReviewIfNeededLocked(r, callingPackage, callingUid, service, callerFg, userId)) { return null; @@ -912,7 +912,7 @@ public final class ActiveServices { // we schedule binding to the service but do not start its process, then // we launch a review activity to which is passed a callback to invoke // when done to start the bound service's process to completing the binding. - if (mAm.mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) { + if (mAm.mPermissionReviewRequired) { if (mAm.getPackageManagerInternalLocked().isPermissionsReviewRequired( s.packageName, s.userId)) { diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 09a3a172c79f..e8ae60ec6a5c 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -10766,7 +10766,7 @@ public final class ActivityManagerService extends ActivityManagerNative // If permissions need a review before any of the app components can run, // we return no provider and launch a review activity if the calling app // is in the foreground. - if (mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) { + if (mPermissionReviewRequired) { if (!requestTargetProviderPermissionsReviewIfNeededLocked(cpi, r, userId)) { return null; } diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 9f875a1f3efa..1816ef49ef08 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -416,8 +416,7 @@ class ActivityStarter { // If permissions need a review before any of the app components can run, we // launch the review activity and pass a pending intent to start the activity // we are to launching now after the review is completed. - if ((mService.mPermissionReviewRequired - || Build.PERMISSIONS_REVIEW_REQUIRED) && aInfo != null) { + if (mService.mPermissionReviewRequired && aInfo != null) { if (mService.getPackageManagerInternalLocked().isPermissionsReviewRequired( aInfo.packageName, userId)) { IIntentSender target = mService.getIntentSenderLocked( diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java index 219e0958a8fe..6b3be7a03fcd 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -625,7 +625,7 @@ public final class BroadcastQueue { // the broadcast and if the calling app is in the foreground and the broadcast is // explicit we launch the review UI passing it a pending intent to send the skipped // broadcast. - if (mService.mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) { + if (mService.mPermissionReviewRequired) { if (!requestStartTargetPermissionsReviewIfNeededLocked(r, filter.packageName, filter.owningUserId)) { r.delivery[index] = BroadcastRecord.DELIVERY_SKIPPED; @@ -1131,8 +1131,7 @@ public final class BroadcastQueue { // the broadcast and if the calling app is in the foreground and the broadcast is // explicit we launch the review UI passing it a pending intent to send the skipped // broadcast. - if ((mService.mPermissionReviewRequired - || Build.PERMISSIONS_REVIEW_REQUIRED) && !skip) { + if (mService.mPermissionReviewRequired && !skip) { if (!requestStartTargetPermissionsReviewIfNeededLocked(r, info.activityInfo.packageName, UserHandle.getUserId( info.activityInfo.applicationInfo.uid))) { diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index ab83c11bd8e6..4770b564d3af 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -3998,7 +3998,7 @@ public class PackageManagerService extends IPackageManager.Stub { // their permissions as always granted runtime ones since we need // to keep the review required permission flag per user while an // install permission's state is shared across all users. - if ((mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) + if (mPermissionReviewRequired && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M && bp.isRuntime()) { return; @@ -4109,7 +4109,7 @@ public class PackageManagerService extends IPackageManager.Stub { // their permissions as always granted runtime ones since we need // to keep the review required permission flag per user while an // install permission's state is shared across all users. - if ((mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) + if (mPermissionReviewRequired && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M && bp.isRuntime()) { return; @@ -9947,8 +9947,7 @@ public class PackageManagerService extends IPackageManager.Stub { // their permissions as always granted runtime ones since we need // to keep the review required permission flag per user while an // install permission's state is shared across all users. - if (!appSupportsRuntimePermissions && !mPermissionReviewRequired - && !Build.PERMISSIONS_REVIEW_REQUIRED) { + if (!appSupportsRuntimePermissions && !mPermissionReviewRequired) { // For legacy apps dangerous permissions are install time ones. grant = GRANT_INSTALL; } else if (origPermissions.hasInstallPermission(bp.name)) { @@ -10034,7 +10033,7 @@ public class PackageManagerService extends IPackageManager.Stub { changedRuntimePermissionUserIds, userId); } // If the app supports runtime permissions no need for a review. - if ((mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) + if (mPermissionReviewRequired && appSupportsRuntimePermissions && (flags & PackageManager .FLAG_PERMISSION_REVIEW_REQUIRED) != 0) { @@ -10043,8 +10042,7 @@ public class PackageManagerService extends IPackageManager.Stub { changedRuntimePermissionUserIds = ArrayUtils.appendInt( changedRuntimePermissionUserIds, userId); } - } else if ((mPermissionReviewRequired - || Build.PERMISSIONS_REVIEW_REQUIRED) + } else if (mPermissionReviewRequired && !appSupportsRuntimePermissions) { // For legacy apps that need a permission review, every new // runtime permission is granted but it is pending a review. @@ -16533,7 +16531,7 @@ public class PackageManagerService extends IPackageManager.Stub { // If permission review is enabled and this is a legacy app, mark the // permission as requiring a review as this is the initial state. int flags = 0; - if ((mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) + if (mPermissionReviewRequired && ps.pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) { flags |= FLAG_PERMISSION_REVIEW_REQUIRED; } @@ -20408,7 +20406,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); // permissions to keep per user flag state whether review is needed. // Hence, if a new user is added we have to propagate dangerous // permission grants for these legacy apps. - if (mPermissionReviewRequired || Build.PERMISSIONS_REVIEW_REQUIRED) { + if (mPermissionReviewRequired) { updatePermissionsLPw(null, null, UPDATE_PERMISSIONS_ALL | UPDATE_PERMISSIONS_REPLACE_ALL); } @@ -20862,7 +20860,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); public boolean isPermissionsReviewRequired(String packageName, int userId) { synchronized (mPackages) { // If we do not support permission review, done. - if (!mPermissionReviewRequired && !Build.PERMISSIONS_REVIEW_REQUIRED) { + if (!mPermissionReviewRequired) { return false; } |