summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shijian Li <shijianli@google.com> 2017-01-12 03:07:10 +0000
committer android-build-merger <android-build-merger@google.com> 2017-01-12 03:07:10 +0000
commitae21066a59d0d371d08603daf2c2863bca28137a (patch)
treed18e56fa9f71c83e9590db203c37a253bc1e1f6b
parent0b7b79a882e4a7680132bfcc24d003baf70d79d5 (diff)
parent5e7fc7ccc8b995dce816d2166c747a63ffe91923 (diff)
Sync the startConsentUiIfNeeded logics to master. We are missing the package name when starting the activity now.
am: 5e7fc7ccc8 Change-Id: I4214dc072d3155cd417ee3577918570e515fa1cf
-rw-r--r--services/core/java/com/android/server/BluetoothManagerService.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/BluetoothManagerService.java b/services/core/java/com/android/server/BluetoothManagerService.java
index 677d3786fe27..2a6f9d2b8569 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;
@@ -719,8 +720,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission");
- if (!isEnabled() && mPermissionReviewRequired) {
- startConsentUi(packageName, callingUid, BluetoothAdapter.ACTION_REQUEST_ENABLE);
+ if (!isEnabled() && mPermissionReviewRequired
+ && startConsentUiIfNeeded(packageName, callingUid,
+ BluetoothAdapter.ACTION_REQUEST_ENABLE)) {
return false;
}
}
@@ -754,8 +756,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
"Need BLUETOOTH ADMIN permission");
- if (isEnabled() && mPermissionReviewRequired) {
- startConsentUi(packageName, callingUid, BluetoothAdapter.ACTION_REQUEST_DISABLE);
+ if (isEnabled() && mPermissionReviewRequired
+ && startConsentUiIfNeeded(packageName, callingUid,
+ BluetoothAdapter.ACTION_REQUEST_DISABLE)) {
return false;
}
}
@@ -775,8 +778,8 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
return true;
}
- private void startConsentUi(String packageName, int callingUid, String intentAction)
- throws RemoteException {
+ private boolean startConsentUiIfNeeded(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,9 +791,18 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
+ " not in uid " + callingUid);
}
- // Permission review mode, trigger a user prompt
Intent intent = new Intent(intentAction);
- mContext.startActivity(intent);
+ intent.putExtra(Intent.EXTRA_PACKAGE_NAME, packageName);
+ 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) {
throw new RemoteException(e.getMessage());
}