Loading core/java/android/app/AppOpsManager.java +6 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,8 @@ public class AppOpsManager { public static final int OP_WRITE_CLIPBOARD = 30; /** @hide */ public static final int OP_WIFI_CHANGE = 31; public static final int _NUM_OP = 32; public static final int OP_BLUETOOTH_CHANGE = 32; public static final int _NUM_OP = 33; /** * Map to check if each operation is strict or not, to determine default Loading Loading @@ -143,6 +144,7 @@ public class AppOpsManager { false, //OP_READ_CLIPBOARD false, //OP_WRITE_CLIPBOARD true, //OP_WIFI_CHANGE true, //OP_BLUETOOTH_CHANGE }; /** Loading Loading @@ -186,6 +188,7 @@ public class AppOpsManager { OP_READ_CLIPBOARD, OP_WRITE_CLIPBOARD, OP_WIFI_CHANGE, OP_BLUETOOTH_CHANGE, }; /** Loading Loading @@ -225,6 +228,7 @@ public class AppOpsManager { "READ_CLIPBOARD", "WRITE_CLIPBOARD", "WIFI_CHANGE", "BLUETOOTH_CHANGE", }; /** Loading Loading @@ -264,6 +268,7 @@ public class AppOpsManager { null, // no permission for reading clipboard null, // no permission for writing clipboard android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.BLUETOOTH, }; /** 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/cm_arrays.xml +1 −0 Original line number Diff line number Diff line Loading @@ -86,5 +86,6 @@ <item>Trying to read clipboard</item> <item>Trying to modify clipboard</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 +11 −3 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.HandlerThread; Loading Loading @@ -392,7 +393,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 @@ -406,6 +407,13 @@ 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 +6 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,8 @@ public class AppOpsManager { public static final int OP_WRITE_CLIPBOARD = 30; /** @hide */ public static final int OP_WIFI_CHANGE = 31; public static final int _NUM_OP = 32; public static final int OP_BLUETOOTH_CHANGE = 32; public static final int _NUM_OP = 33; /** * Map to check if each operation is strict or not, to determine default Loading Loading @@ -143,6 +144,7 @@ public class AppOpsManager { false, //OP_READ_CLIPBOARD false, //OP_WRITE_CLIPBOARD true, //OP_WIFI_CHANGE true, //OP_BLUETOOTH_CHANGE }; /** Loading Loading @@ -186,6 +188,7 @@ public class AppOpsManager { OP_READ_CLIPBOARD, OP_WRITE_CLIPBOARD, OP_WIFI_CHANGE, OP_BLUETOOTH_CHANGE, }; /** Loading Loading @@ -225,6 +228,7 @@ public class AppOpsManager { "READ_CLIPBOARD", "WRITE_CLIPBOARD", "WIFI_CHANGE", "BLUETOOTH_CHANGE", }; /** Loading Loading @@ -264,6 +268,7 @@ public class AppOpsManager { null, // no permission for reading clipboard null, // no permission for writing clipboard android.Manifest.permission.CHANGE_WIFI_STATE, android.Manifest.permission.BLUETOOTH, }; /** 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/cm_arrays.xml +1 −0 Original line number Diff line number Diff line Loading @@ -86,5 +86,6 @@ <item>Trying to read clipboard</item> <item>Trying to modify clipboard</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 +11 −3 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.HandlerThread; Loading Loading @@ -392,7 +393,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 @@ -406,6 +407,13 @@ 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