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

Commit c33444a7 authored by Matthew Xie's avatar Matthew Xie
Browse files

Implement getRemoteType of IBluetooth.aidl

Bring the device type from hal to app api
bug 8529188

Change-Id: Id4a9837afc7234cb50ab6abf73da4bdc010db392
parent adbcef8d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -742,6 +742,17 @@ public class AdapterService extends Service {
            return service.getRemoteName(device);
        }

        public int getRemoteType(BluetoothDevice device) {
            if (!Utils.checkCaller()) {
                Log.w(TAG,"getRemoteType(): not allowed for non-active user");
                return BluetoothDevice.DEVICE_TYPE_UNKNOWN;
            }

            AdapterService service = getService();
            if (service == null) return BluetoothDevice.DEVICE_TYPE_UNKNOWN;
            return service.getRemoteType(device);
        }

        public String getRemoteAlias(BluetoothDevice device) {
            if (!Utils.checkCaller()) {
                Log.w(TAG,"getRemoteAlias(): not allowed for non-active user");
@@ -1199,6 +1210,13 @@ public class AdapterService extends Service {
        return deviceProp.getName();
    }

     int getRemoteType(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        if (deviceProp == null) return BluetoothDevice.DEVICE_TYPE_UNKNOWN;
        return deviceProp.getDeviceType();
    }

     String getRemoteAlias(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
+2 −1
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@ final class RemoteDevices {
        }

        /**
         *
         * @return mDeviceType
         */
        int getDeviceType() {
@@ -290,6 +289,8 @@ final class RemoteDevices {
                            sendUuidIntent(bdDevice);
                            break;
                        case AbstractionLayer.BT_PROPERTY_TYPE_OF_DEVICE:
                            // The device type from hal layer, defined in bluetooth.h,
                            // matches the type defined in BluetoothDevice.java
                            device.mDeviceType = Utils.byteArrayToInt(val);
                            break;
                        case AbstractionLayer.BT_PROPERTY_REMOTE_RSSI: