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

Commit 8638815a authored by Zach Johnson's avatar Zach Johnson Committed by android-build-merger
Browse files

Merge "Simplify getting/setting class of device" am: 53ef71b5

am: 5e4db775

Change-Id: I6ed9d1b49b0d7c06f8357d18c475d66c1de30a82
parents a34837d0 5e4db775
Loading
Loading
Loading
Loading
+9 −32
Original line number Diff line number Diff line
@@ -601,17 +601,6 @@ public class AdapterService extends Service {
                getContentResolver(), Settings.Global.BLUETOOTH_CLASS_OF_DEVICE, 0);
    }

    private boolean storeBluetoothClassConfig(int bluetoothClass) {
        boolean result = Settings.Global.putInt(
                getContentResolver(), Settings.Global.BLUETOOTH_CLASS_OF_DEVICE, bluetoothClass);

        if (!result) {
            Log.e(TAG, "Error storing BluetoothClass config - " + bluetoothClass);
        }

        return result;
    }

    void startProfileServices() {
        debugLog("startCoreServices()");
        Class[] supportedProfileServices = Config.getSupportedProfiles();
@@ -1218,7 +1207,7 @@ public class AdapterService extends Service {

            enforceBluetoothAdminPermission(service);

            return service.getBluetoothClass();
            return service.mAdapterProperties.getBluetoothClass();
        }

        @Override
@@ -1235,7 +1224,14 @@ public class AdapterService extends Service {

            enforceBluetoothPrivilegedPermission(service);

            return service.setBluetoothClass(bluetoothClass);
            if (!service.mAdapterProperties.setBluetoothClass(bluetoothClass)) {
              return false;
            }

            return Settings.Global.putInt(
                    service.getContentResolver(),
                    Settings.Global.BLUETOOTH_CLASS_OF_DEVICE,
                    bluetoothClass.getClassOfDevice());
        }

        @Override
@@ -2105,25 +2101,6 @@ public class AdapterService extends Service {
        return mAdapterProperties.getName();
    }

    BluetoothClass getBluetoothClass() {
        return mAdapterProperties.getBluetoothClass();
    }

    /**
     * Sets the Bluetooth CoD on the local adapter and also modifies the storage config for it.
     *
     * <p>Once set, this value persists across reboots.
     */
    boolean setBluetoothClass(BluetoothClass bluetoothClass) {
        debugLog("setBluetoothClass() to " + bluetoothClass);
        boolean result = mAdapterProperties.setBluetoothClass(bluetoothClass);
        if (!result) {
            Log.e(TAG, "setBluetoothClass() to " + bluetoothClass + " failed");
        }

        return result && storeBluetoothClassConfig(bluetoothClass.getClassOfDevice());
    }

    private boolean validateInputOutputCapability(int capability) {
        if (capability < 0 || capability >= BluetoothAdapter.IO_CAPABILITY_MAX) {
            Log.e(TAG, "Invalid IO capability value - " + capability);