summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-11-29 10:14:16 -0800
committerMartijn Coenen <maco@google.com>2012-11-29 10:17:47 -0800
commit8385c5afbd92da5f2e8bc13d153114bc3a7cb0f5 (patch)
tree56e78d921875662d10428b3a58177b293dc4fd71 /services/java
parent02053d1cce52f11ef1bc3b562279940208f9c54e (diff)
downloadframeworks_base-8385c5afbd92da5f2e8bc13d153114bc3a7cb0f5.zip
frameworks_base-8385c5afbd92da5f2e8bc13d153114bc3a7cb0f5.tar.gz
frameworks_base-8385c5afbd92da5f2e8bc13d153114bc3a7cb0f5.tar.bz2
Allow the NFC process to call Bluetooth APIs.
The NFC process used to be only running as user 0, and it may be calling into Bluetooth. Most of the handover code has now moved to a separate process running as the current user. Fix the existing checks to take into account the correct NFC UID, whatever user it is running as. Bug: 7309141 Change-Id: I953cfb263a28aef7fe1be5880b053425dc359a29
Diffstat (limited to 'services/java')
-rwxr-xr-xservices/java/com/android/server/BluetoothManagerService.java12
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 69ccbc7..beb2215 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;
@@ -334,9 +332,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
@@ -943,11 +944,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