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

Commit d235269f 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 b5706272
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -742,6 +742,17 @@ public class AdapterService extends Service {
            return service.getRemoteName(device);
            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) {
        public String getRemoteAlias(BluetoothDevice device) {
            if (!Utils.checkCaller()) {
            if (!Utils.checkCaller()) {
                Log.w(TAG,"getRemoteAlias(): not allowed for non-active user");
                Log.w(TAG,"getRemoteAlias(): not allowed for non-active user");
@@ -1199,6 +1210,13 @@ public class AdapterService extends Service {
        return deviceProp.getName();
        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) {
     String getRemoteAlias(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
+2 −1
Original line number Original line Diff line number Diff line
@@ -156,7 +156,6 @@ final class RemoteDevices {
        }
        }


        /**
        /**
         *
         * @return mDeviceType
         * @return mDeviceType
         */
         */
        int getDeviceType() {
        int getDeviceType() {
@@ -290,6 +289,8 @@ final class RemoteDevices {
                            sendUuidIntent(bdDevice);
                            sendUuidIntent(bdDevice);
                            break;
                            break;
                        case AbstractionLayer.BT_PROPERTY_TYPE_OF_DEVICE:
                        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);
                            device.mDeviceType = Utils.byteArrayToInt(val);
                            break;
                            break;
                        case AbstractionLayer.BT_PROPERTY_REMOTE_RSSI:
                        case AbstractionLayer.BT_PROPERTY_REMOTE_RSSI: