Loading services/java/com/android/server/BluetoothManagerService.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -43,8 +43,6 @@ import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.util.Log; import android.util.Log; import java.util.ArrayList; import java.util.List; class BluetoothManagerService extends IBluetoothManager.Stub { class BluetoothManagerService extends IBluetoothManager.Stub { private static final String TAG = "BluetoothManagerService"; private static final String TAG = "BluetoothManagerService"; private static final boolean DBG = true; private static final boolean DBG = true; Loading Loading @@ -330,9 +328,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Log.d(TAG,"enableNoAutoConnect(): mBluetooth =" + mBluetooth + Log.d(TAG,"enableNoAutoConnect(): mBluetooth =" + mBluetooth + " mBinding = " + mBinding); " 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"); throw new SecurityException("no permission to enable Bluetooth quietly"); } } Message msg = mHandler.obtainMessage(MESSAGE_ENABLE); Message msg = mHandler.obtainMessage(MESSAGE_ENABLE); msg.arg1=0; //No persist msg.arg1=0; //No persist msg.arg2=1; //Quiet mode msg.arg2=1; //Quiet mode Loading Loading @@ -968,11 +969,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private boolean checkIfCallerIsForegroundUser() { private boolean checkIfCallerIsForegroundUser() { int foregroundUser; int foregroundUser; int callingUser = UserHandle.getCallingUserId(); int callingUser = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); long callingIdentity = Binder.clearCallingIdentity(); long callingIdentity = Binder.clearCallingIdentity(); int callingAppId = UserHandle.getAppId(callingUid); boolean valid = false; boolean valid = false; try { try { foregroundUser = ActivityManager.getCurrentUser(); foregroundUser = ActivityManager.getCurrentUser(); valid = (callingUser == foregroundUser); valid = (callingUser == foregroundUser) || callingAppId == Process.NFC_UID; if (DBG) { if (DBG) { Log.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid Log.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid + " callingUser=" + callingUser + " callingUser=" + callingUser Loading Loading
services/java/com/android/server/BluetoothManagerService.java +8 −4 Original line number Original line Diff line number Diff line Loading @@ -43,8 +43,6 @@ import android.os.SystemClock; import android.os.UserHandle; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.util.Log; import android.util.Log; import java.util.ArrayList; import java.util.List; class BluetoothManagerService extends IBluetoothManager.Stub { class BluetoothManagerService extends IBluetoothManager.Stub { private static final String TAG = "BluetoothManagerService"; private static final String TAG = "BluetoothManagerService"; private static final boolean DBG = true; private static final boolean DBG = true; Loading Loading @@ -330,9 +328,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { Log.d(TAG,"enableNoAutoConnect(): mBluetooth =" + mBluetooth + Log.d(TAG,"enableNoAutoConnect(): mBluetooth =" + mBluetooth + " mBinding = " + mBinding); " 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"); throw new SecurityException("no permission to enable Bluetooth quietly"); } } Message msg = mHandler.obtainMessage(MESSAGE_ENABLE); Message msg = mHandler.obtainMessage(MESSAGE_ENABLE); msg.arg1=0; //No persist msg.arg1=0; //No persist msg.arg2=1; //Quiet mode msg.arg2=1; //Quiet mode Loading Loading @@ -968,11 +969,14 @@ class BluetoothManagerService extends IBluetoothManager.Stub { private boolean checkIfCallerIsForegroundUser() { private boolean checkIfCallerIsForegroundUser() { int foregroundUser; int foregroundUser; int callingUser = UserHandle.getCallingUserId(); int callingUser = UserHandle.getCallingUserId(); int callingUid = Binder.getCallingUid(); long callingIdentity = Binder.clearCallingIdentity(); long callingIdentity = Binder.clearCallingIdentity(); int callingAppId = UserHandle.getAppId(callingUid); boolean valid = false; boolean valid = false; try { try { foregroundUser = ActivityManager.getCurrentUser(); foregroundUser = ActivityManager.getCurrentUser(); valid = (callingUser == foregroundUser); valid = (callingUser == foregroundUser) || callingAppId == Process.NFC_UID; if (DBG) { if (DBG) { Log.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid Log.d(TAG, "checkIfCallerIsForegroundUser: valid=" + valid + " callingUser=" + callingUser + " callingUser=" + callingUser Loading