diff options
author | Jason Monk <jmonk@google.com> | 2014-12-08 14:01:21 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-12-08 14:01:23 +0000 |
commit | c493bf3669d606a18604d201ac52617e65da4958 (patch) | |
tree | dafd475788a49e085412bd6ab56fee823bf86344 /src | |
parent | fa9d203017d7d78d45b48ff4362a56cb1300521a (diff) | |
parent | 465bbd2160749d9e0a3f3aabeb4e20bb51573001 (diff) | |
download | android_packages_apps_Bluetooth-c493bf3669d606a18604d201ac52617e65da4958.tar.gz android_packages_apps_Bluetooth-c493bf3669d606a18604d201ac52617e65da4958.tar.bz2 android_packages_apps_Bluetooth-c493bf3669d606a18604d201ac52617e65da4958.zip |
Merge "Allow SystemUI access to bluetooth from user 0" into lmp-mr1-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/bluetooth/Utils.java | 16 |
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; |