Loading core/java/android/app/AppOpsManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -197,7 +197,9 @@ public class AppOpsManager { /** @hide */ public static final int OP_WIFI_CHANGE = 43; /** @hide */ public static final int _NUM_OP = 44; public static final int OP_BLUETOOTH_CHANGE = 44; /** @hide */ public static final int _NUM_OP = 45; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = Loading Loading @@ -265,6 +267,7 @@ public class AppOpsManager { OP_COARSE_LOCATION, OP_COARSE_LOCATION, OP_WIFI_CHANGE, OP_BLUETOOTH_CHANGE, }; /** Loading Loading @@ -316,6 +319,7 @@ public class AppOpsManager { OPSTR_MONITOR_LOCATION, OPSTR_MONITOR_HIGH_POWER_LOCATION, null, null, }; /** Loading Loading @@ -367,6 +371,7 @@ public class AppOpsManager { "MONITOR_LOCATION", "MONITOR_HIGH_POWER_LOCATION", "WIFI_CHANGE", "BLUETOOTH_CHANGE", }; /** Loading Loading @@ -418,6 +423,7 @@ public class AppOpsManager { null, // no permission for generic location monitoring null, // no permission for high power location monitoring android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.BLUETOOTH, }; /** Loading Loading @@ -468,6 +474,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ALLOWED, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ALLOWED, // OP_WIFI_CHANGE AppOpsManager.MODE_ALLOWED, // OP_BLUETOOTH_CHANGE }; /** Loading Loading @@ -518,6 +525,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ASK, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ASK, // OP_WIFI_CHANGE AppOpsManager.MODE_ASK, // OP_BLUETOOTH_CHANGE }; Loading Loading @@ -573,6 +581,7 @@ public class AppOpsManager { false, false, false, false, }; private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); Loading core/java/android/bluetooth/BluetoothAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package android.bluetooth; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.ActivityThread; import android.content.Context; import android.os.Binder; import android.os.IBinder; Loading Loading @@ -518,7 +519,7 @@ public final class BluetoothAdapter { return true; } try { return mManagerService.enable(); return mManagerService.enable(ActivityThread.currentPackageName()); } catch (RemoteException e) {Log.e(TAG, "", e);} return false; } Loading core/java/android/bluetooth/IBluetoothManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ interface IBluetoothManager void registerStateChangeCallback(in IBluetoothStateChangeCallback callback); void unregisterStateChangeCallback(in IBluetoothStateChangeCallback callback); boolean isEnabled(); boolean enable(); boolean enable(String callingPackage); boolean enableNoAutoConnect(); boolean disable(boolean persist); IBluetoothGatt getBluetoothGatt(); Loading core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1357,5 +1357,6 @@ <item>Trying to access location</item> <item>Trying to access location</item> <item>Trying to turn on/off Wifi</item> <item>Trying to turn on/off bluetooth</item> </string-array> </resources> services/java/com/android/server/BluetoothManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.app.AppOpsManager; import android.os.Binder; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -388,7 +389,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { return true; } public boolean enable() { public boolean enable(String callingPackage) { if ((Binder.getCallingUid() != Process.SYSTEM_UID) && (!checkIfCallerIsForegroundUser())) { Log.w(TAG,"enable(): not allowed for non-active and non system user"); Loading @@ -402,6 +403,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { " mBinding = " + mBinding); } AppOpsManager appOps = (AppOpsManager)mContext.getSystemService(Context.APP_OPS_SERVICE); int callingUid = Binder.getCallingUid(); if (appOps.noteOp(AppOpsManager.OP_BLUETOOTH_CHANGE, callingUid, callingPackage) != AppOpsManager.MODE_ALLOWED) return false; synchronized(mReceiver) { mQuietEnableExternal = false; mEnableExternal = true; Loading Loading
core/java/android/app/AppOpsManager.java +10 −1 Original line number Diff line number Diff line Loading @@ -197,7 +197,9 @@ public class AppOpsManager { /** @hide */ public static final int OP_WIFI_CHANGE = 43; /** @hide */ public static final int _NUM_OP = 44; public static final int OP_BLUETOOTH_CHANGE = 44; /** @hide */ public static final int _NUM_OP = 45; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = Loading Loading @@ -265,6 +267,7 @@ public class AppOpsManager { OP_COARSE_LOCATION, OP_COARSE_LOCATION, OP_WIFI_CHANGE, OP_BLUETOOTH_CHANGE, }; /** Loading Loading @@ -316,6 +319,7 @@ public class AppOpsManager { OPSTR_MONITOR_LOCATION, OPSTR_MONITOR_HIGH_POWER_LOCATION, null, null, }; /** Loading Loading @@ -367,6 +371,7 @@ public class AppOpsManager { "MONITOR_LOCATION", "MONITOR_HIGH_POWER_LOCATION", "WIFI_CHANGE", "BLUETOOTH_CHANGE", }; /** Loading Loading @@ -418,6 +423,7 @@ public class AppOpsManager { null, // no permission for generic location monitoring null, // no permission for high power location monitoring android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.BLUETOOTH, }; /** Loading Loading @@ -468,6 +474,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ALLOWED, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ALLOWED, // OP_WIFI_CHANGE AppOpsManager.MODE_ALLOWED, // OP_BLUETOOTH_CHANGE }; /** Loading Loading @@ -518,6 +525,7 @@ public class AppOpsManager { AppOpsManager.MODE_ALLOWED, // OP_MONITOR_LOCATION AppOpsManager.MODE_ASK, // OP_MONITOR_HIGH_POWER_LOCATION AppOpsManager.MODE_ASK, // OP_WIFI_CHANGE AppOpsManager.MODE_ASK, // OP_BLUETOOTH_CHANGE }; Loading Loading @@ -573,6 +581,7 @@ public class AppOpsManager { false, false, false, false, }; private static HashMap<String, Integer> sOpStrToOp = new HashMap<String, Integer>(); Loading
core/java/android/bluetooth/BluetoothAdapter.java +2 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ package android.bluetooth; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.ActivityThread; import android.content.Context; import android.os.Binder; import android.os.IBinder; Loading Loading @@ -518,7 +519,7 @@ public final class BluetoothAdapter { return true; } try { return mManagerService.enable(); return mManagerService.enable(ActivityThread.currentPackageName()); } catch (RemoteException e) {Log.e(TAG, "", e);} return false; } Loading
core/java/android/bluetooth/IBluetoothManager.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ interface IBluetoothManager void registerStateChangeCallback(in IBluetoothStateChangeCallback callback); void unregisterStateChangeCallback(in IBluetoothStateChangeCallback callback); boolean isEnabled(); boolean enable(); boolean enable(String callingPackage); boolean enableNoAutoConnect(); boolean disable(boolean persist); IBluetoothGatt getBluetoothGatt(); Loading
core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1357,5 +1357,6 @@ <item>Trying to access location</item> <item>Trying to access location</item> <item>Trying to turn on/off Wifi</item> <item>Trying to turn on/off bluetooth</item> </string-array> </resources>
services/java/com/android/server/BluetoothManagerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.app.AppOpsManager; import android.os.Binder; import android.os.Handler; import android.os.IBinder; Loading Loading @@ -388,7 +389,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub { return true; } public boolean enable() { public boolean enable(String callingPackage) { if ((Binder.getCallingUid() != Process.SYSTEM_UID) && (!checkIfCallerIsForegroundUser())) { Log.w(TAG,"enable(): not allowed for non-active and non system user"); Loading @@ -402,6 +403,12 @@ class BluetoothManagerService extends IBluetoothManager.Stub { " mBinding = " + mBinding); } AppOpsManager appOps = (AppOpsManager)mContext.getSystemService(Context.APP_OPS_SERVICE); int callingUid = Binder.getCallingUid(); if (appOps.noteOp(AppOpsManager.OP_BLUETOOTH_CHANGE, callingUid, callingPackage) != AppOpsManager.MODE_ALLOWED) return false; synchronized(mReceiver) { mQuietEnableExternal = false; mEnableExternal = true; Loading