In permission review mode, always request user's consent to toggle BT. am: d2d32b1f32

am: 0368be4523

Change-Id: I677252c7b488637ca1b24595b9d5dba09d77b06b
This commit is contained in:
Ivan Podogov
2017-01-03 11:16:31 +00:00
committed by android-build-merger

View File

@@ -755,9 +755,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission"); "Need BLUETOOTH ADMIN permission");
if (!isEnabled() && mPermissionReviewRequired if (!isEnabled() && mPermissionReviewRequired) {
&& startConsentUiIfNeeded(packageName, callingUid, startConsentUi(packageName, callingUid, BluetoothAdapter.ACTION_REQUEST_ENABLE);
BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
return false; return false;
} }
} }
@@ -791,9 +790,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission"); "Need BLUETOOTH ADMIN permission");
if (isEnabled() && mPermissionReviewRequired if (isEnabled() && mPermissionReviewRequired) {
&& startConsentUiIfNeeded(packageName, callingUid, startConsentUi(packageName, callingUid, BluetoothAdapter.ACTION_REQUEST_DISABLE);
BluetoothAdapter.ACTION_REQUEST_DISABLE)) {
return false; return false;
} }
} }
@@ -813,8 +811,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
return true; return true;
} }
private boolean startConsentUiIfNeeded(String packageName, private void startConsentUi(String packageName, int callingUid, String intentAction)
int callingUid, String intentAction) throws RemoteException { throws RemoteException {
try { try {
// Validate the package only if we are going to use it // Validate the package only if we are going to use it
ApplicationInfo applicationInfo = mContext.getPackageManager() ApplicationInfo applicationInfo = mContext.getPackageManager()
@@ -826,16 +824,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
+ " not in uid " + callingUid); + " not in uid " + callingUid);
} }
// Legacy apps in permission review mode trigger a user prompt // Permission review mode, trigger a user prompt
if (applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) { Intent intent = new Intent(intentAction);
Intent intent = new Intent(intentAction); mContext.startActivity(intent);
mContext.startActivity(intent);
return true;
}
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
throw new RemoteException(e.getMessage()); throw new RemoteException(e.getMessage());
} }
return false;
} }
public void unbindAndFinish() { public void unbindAndFinish() {