In permission review mode, always request user's consent to toggle BT.
Bug: 33155221
Test: Manual: flash the watch, check that the consent UI was
displayed in both apps (the one with CompileSDK=21 and
TargetSDK=21, and the one with CompileSDK=25 and
TargetSDK=25).
Change-Id: Ic1ed987bbaf282892a2aef354a8ca0add2c829ba
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 86bbca7..36ef3e9 100644
--- a/services/core/java/com/android/server/BluetoothManagerService.java
+++ b/services/core/java/com/android/server/BluetoothManagerService.java
@@ -717,9 +717,8 @@
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission");
- if (!isEnabled() && mPermissionReviewRequired
- && startConsentUiIfNeeded(packageName, callingUid,
- BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
+ if (!isEnabled() && mPermissionReviewRequired) {
+ startConsentUi(packageName, callingUid, BluetoothAdapter.ACTION_REQUEST_ENABLE);
return false;
}
}
@@ -753,9 +752,8 @@
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission");
- if (isEnabled() && mPermissionReviewRequired
- && startConsentUiIfNeeded(packageName, callingUid,
- BluetoothAdapter.ACTION_REQUEST_DISABLE)) {
+ if (isEnabled() && mPermissionReviewRequired) {
+ startConsentUi(packageName, callingUid, BluetoothAdapter.ACTION_REQUEST_DISABLE);
return false;
}
}
@@ -775,8 +773,8 @@
return true;
}
- private boolean startConsentUiIfNeeded(String packageName,
- int callingUid, String intentAction) throws RemoteException {
+ private void startConsentUi(String packageName, int callingUid, String intentAction)
+ throws RemoteException {
try {
// Validate the package only if we are going to use it
ApplicationInfo applicationInfo = mContext.getPackageManager()
@@ -788,16 +786,12 @@
+ " not in uid " + callingUid);
}
- // 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);
- return true;
- }
+ // Permission review mode, trigger a user prompt
+ Intent intent = new Intent(intentAction);
+ mContext.startActivity(intent);
} catch (PackageManager.NameNotFoundException e) {
throw new RemoteException(e.getMessage());
}
- return false;
}
public void unbindAndFinish() {