diff options
| author | 2012-11-30 11:14:05 -0800 | |
|---|---|---|
| committer | 2012-11-30 11:14:05 -0800 | |
| commit | d5dcb6d4e9ffcaf5d74b89a3bcd5f2dab6d09f9f (patch) | |
| tree | 78ceaee4e6025ac15a031695cbcf6e8735bfe10e | |
| parent | 0f6f21026451f516a0179ae4f13bcdfcb0fd19a9 (diff) | |
| parent | 1b3a4362a08d816d78fdbb04ef115b31c8674420 (diff) | |
am 1b3a4362: am f77445cd: am b1a01ab0: Merge "Allow the NFC process to call Bluetooth APIs." into jb-mr1.1-dev
* commit '1b3a4362a08d816d78fdbb04ef115b31c8674420':
Allow the NFC process to call Bluetooth APIs.
| -rwxr-xr-x | services/java/com/android/server/BluetoothManagerService.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/services/java/com/android/server/BluetoothManagerService.java b/services/java/com/android/server/BluetoothManagerService.java index e05fcf4d408b..5d83f00b4469 100755 --- a/services/java/com/android/server/BluetoothManagerService.java +++ b/services/java/com/android/server/BluetoothManagerService.java @@ -43,8 +43,6 @@ import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.util.Log; -import java.util.ArrayList; -import java.util.List; class BluetoothManagerService extends IBluetoothManager.Stub { private static final String TAG = "BluetoothManagerService"; private static final boolean DBG = true; @@ -330,9 +328,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Log.d(TAG,"enableNoAutoConnect(): mBluetooth =" + mBluetooth + " mBinding = " + mBinding); } - if (Binder.getCallingUid() != Process.NFC_UID) { + int callingAppId = UserHandle.getAppId(Binder.getCallingUid()); + + if (callingAppId != Process.NFC_UID) { throw new SecurityException("no permission to enable Bluetooth quietly"); } + Message msg = mHandler.obtainMessage(MESSAGE_ENABLE); msg.arg1=0; //No persist msg.arg2=1; //Quiet mode @@ -968,11 +969,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private boolean checkIfCallerIsForegroundUser() { int foregroundUser; int callingUser = UserHandle.getCallingUserId(); + int callingUid = Binder.getCallingUid(); long callingIdentity = Binder.clearCallingIdentity(); + int callingAppId = UserHandle.getAppId(callingUid); boolean valid = false; try { foregroundUser = ActivityManager.getCurrentUser(); - valid = (callingUser == foregroundUser); + valid = (callingUser == foregroundUser) || + callingAppId == Process.NFC_UID; if (DBG) { Log.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid + " callingUser=" + callingUser |