Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b71626a9 authored by Matthew Xie's avatar Matthew Xie Committed by Android (Google) Code Review
Browse files

Merge "Change pairing api/intent permission from PRIVILEGED to ADMIN" into klp-dev

parents 57479e1f d2b2dc63
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -85,8 +85,6 @@ public class AdapterService extends Service {
    static final String BLUETOOTH_ADMIN_PERM =
        android.Manifest.permission.BLUETOOTH_ADMIN;
    static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;
    static final String BLUETOOTH_PRIVILEGED_PERM =
        android.Manifest.permission.BLUETOOTH_PRIVILEGED;

    private static final int ADAPTER_SERVICE_TYPE=Service.START_STICKY;

@@ -1050,8 +1048,8 @@ public class AdapterService extends Service {
    }

     boolean createBond(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED_PERM,
            "Need BLUETOOTH PRIVILEGED permission");
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
            "Need BLUETOOTH ADMIN permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        if (deviceProp != null && deviceProp.getBondState() != BluetoothDevice.BOND_NONE) {
            return false;
@@ -1270,8 +1268,8 @@ public class AdapterService extends Service {
    }

     boolean setPin(BluetoothDevice device, boolean accept, int len, byte[] pinCode) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED_PERM,
                                       "Need BLUETOOTH PRIVILEGED permission");
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                       "Need BLUETOOTH ADMIN permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDING) {
            return false;
@@ -1294,8 +1292,8 @@ public class AdapterService extends Service {
    }

     boolean setPairingConfirmation(BluetoothDevice device, boolean accept) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED_PERM,
                                       "Need BLUETOOTH PRIVILEGED permission");
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                       "Need BLUETOOTH ADMIN permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDING) {
            return false;
+3 −3
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ final class RemoteDevices {
        intent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pin);
        intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
                    BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_PRIVILEGED_PERM);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_ADMIN_PERM);
    }

    void devicePropertyChangedCallback(byte[] address, int[] types, byte[][] values) {
@@ -354,7 +354,7 @@ final class RemoteDevices {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, getDevice(address));
        intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT,
                BluetoothDevice.PAIRING_VARIANT_PIN);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_PRIVILEGED_PERM);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_ADMIN_PERM);
        return;
    }

@@ -396,7 +396,7 @@ final class RemoteDevices {
            intent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, passkey);
        }
        intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, variant);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_PRIVILEGED_PERM);
        mAdapterService.sendOrderedBroadcast(intent, mAdapterService.BLUETOOTH_ADMIN_PERM);
    }

    void aclStateChangeCallback(int status, byte[] address, int newState) {