summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2014-12-05 13:01:51 -0500
committerJason Monk <jmonk@google.com>2014-12-05 13:01:51 -0500
commit465bbd2160749d9e0a3f3aabeb4e20bb51573001 (patch)
treeb1b41d9a5d21fe492df748b412dbeffc88301ada /src
parent42a756a0362820b268136d8357bc0ab3befea129 (diff)
downloadandroid_packages_apps_Bluetooth-465bbd2160749d9e0a3f3aabeb4e20bb51573001.tar.gz
android_packages_apps_Bluetooth-465bbd2160749d9e0a3f3aabeb4e20bb51573001.tar.bz2
android_packages_apps_Bluetooth-465bbd2160749d9e0a3f3aabeb4e20bb51573001.zip
Allow SystemUI access to bluetooth from user 0
SystemUI always runs in the owner user, so when a secondary user if foreground we need a special case to allow it access to bluetooth. Bug: 18151285 Change-Id: I555dc2e4b4ff4929f9796fb888dd845fd066b368
Diffstat (limited to 'src')
-rw-r--r--src/com/android/bluetooth/Utils.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/Utils.java b/src/com/android/bluetooth/Utils.java
index 6b19a78cb..81dc40b81 100644
--- a/src/com/android/bluetooth/Utils.java
+++ b/src/com/android/bluetooth/Utils.java
@@ -17,6 +17,7 @@
package com.android.bluetooth;
import android.app.ActivityManager;
+import android.app.ActivityThread;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
@@ -24,7 +25,6 @@ import android.content.ContextWrapper;
import android.content.pm.UserInfo;
import android.os.Binder;
import android.os.ParcelUuid;
-import android.os.Process;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -197,12 +197,19 @@ final public class Utils {
// Get the caller's user id then clear the calling identity
// which will be restored in the finally clause.
int callingUser = UserHandle.getCallingUserId();
+ int callingUid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
try {
// With calling identity cleared the current user is the foreground user.
int foregroundUser = ActivityManager.getCurrentUser();
ok = (foregroundUser == callingUser);
+ if (!ok) {
+ // Always allow SystemUI access.
+ int systemUiUid = ActivityThread.getPackageManager().getPackageUid(
+ "com.android.systemui", UserHandle.USER_OWNER);
+ ok = systemUiUid == callingUid;
+ }
} catch (Exception ex) {
Log.e(TAG, "checkIfCallerIsSelfOrForegroundUser: Exception ex=" + ex);
ok = false;
@@ -221,6 +228,7 @@ final public class Utils {
// id, then clear the calling identity
// which will be restored in the finally clause.
int callingUser = UserHandle.getCallingUserId();
+ int callingUid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
try {
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
@@ -230,6 +238,12 @@ final public class Utils {
int foregroundUser = ActivityManager.getCurrentUser();
ok = (foregroundUser == callingUser) ||
(foregroundUser == parentUser);
+ if (!ok) {
+ // Always allow SystemUI access.
+ int systemUiUid = ActivityThread.getPackageManager().getPackageUid(
+ "com.android.systemui", UserHandle.USER_OWNER);
+ ok = systemUiUid == callingUid;
+ }
} catch (Exception ex) {
Log.e(TAG, "checkCallerAllowManagedProfiles: Exception ex=" + ex);
ok = false;