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

Commit 9508c59b authored by Pulkit Bhuwalka's avatar Pulkit Bhuwalka Committed by android-build-merger
Browse files

Merge "Modify Bluetooth Class of Device from Android stack" am: 690ca30b am: cfb51df4

am: 06022ab6

Change-Id: Iebff94e30d4e06519f686f8d14279fe6bc655047
parents ebe13ccc 06022ab6
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");