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

Commit d039e55f 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

am: 8638815a

Change-Id: Ie3bf5c2f4696c3f697af720fe285bf57382c619f
parents f2644116 8638815a
Loading
Loading
Loading
Loading
+9 −32
Original line number Original line Diff line number Diff line
@@ -601,17 +601,6 @@ public class AdapterService extends Service {
                getContentResolver(), Settings.Global.BLUETOOTH_CLASS_OF_DEVICE, 0);
                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() {
    void startProfileServices() {
        debugLog("startCoreServices()");
        debugLog("startCoreServices()");
        Class[] supportedProfileServices = Config.getSupportedProfiles();
        Class[] supportedProfileServices = Config.getSupportedProfiles();
@@ -1218,7 +1207,7 @@ public class AdapterService extends Service {


            enforceBluetoothAdminPermission(service);
            enforceBluetoothAdminPermission(service);


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


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


            enforceBluetoothPrivilegedPermission(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
        @Override
@@ -2105,25 +2101,6 @@ public class AdapterService extends Service {
        return mAdapterProperties.getName();
        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) {
    private boolean validateInputOutputCapability(int capability) {
        if (capability < 0 || capability >= BluetoothAdapter.IO_CAPABILITY_MAX) {
        if (capability < 0 || capability >= BluetoothAdapter.IO_CAPABILITY_MAX) {
            Log.e(TAG, "Invalid IO capability value - " + capability);
            Log.e(TAG, "Invalid IO capability value - " + capability);