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

Commit 690ca30b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Modify Bluetooth Class of Device from Android stack"

parents 8d1a1c07 0d06f00c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -217,6 +217,18 @@ class AdapterProperties {
        }
    }

    /**
     * Set the Bluetooth Class of Device (CoD) of the adapter.
     *
     * @param bytes BluetoothClass of the device
     */
    boolean setBluetoothClass(byte[] bytes) {
        synchronized (mObject) {
            return mService.setAdapterPropertyNative(
                    AbstractionLayer.BT_PROPERTY_CLASS_OF_DEVICE, bytes);
        }
    }

    /**
     * @return the mClass
     */
+20 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
@@ -866,6 +867,17 @@ public class AdapterService extends Service {
            return service.setName(name);
        }

        public boolean setBluetoothClass(BluetoothClass bluetoothClass) {
            if (!Utils.checkCaller()) {
                Log.w(TAG, "setBluetoothClass() - Not allowed for non-active user");
                return false;
            }

            AdapterService service = getService();
            if (service == null) return false;
            return service.setBluetoothClass(bluetoothClass);
        }

        public int getScanMode() {
            if (!Utils.checkCallerAllowManagedProfiles(mService)) {
                Log.w(TAG, "getScanMode() - Not allowed for non-active user");
@@ -1469,6 +1481,13 @@ public class AdapterService extends Service {
        return mAdapterProperties.setName(name);
    }

    boolean setBluetoothClass(BluetoothClass bluetoothClass) {
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH PRIVILEGED permission");

        return mAdapterProperties.setBluetoothClass(bluetoothClass.getClassOfDeviceBytes());
    }

    int getScanMode() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");