Implement getRemoteType of IBluetooth.aidl

Bring the device type from hal to app api
bug 8529188

Change-Id: Id4a9837afc7234cb50ab6abf73da4bdc010db392
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java
index bc5851a..f96d1f7 100755
--- a/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/src/com/android/bluetooth/btservice/AdapterService.java
@@ -742,6 +742,17 @@
             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 @@
         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);
diff --git a/src/com/android/bluetooth/btservice/RemoteDevices.java b/src/com/android/bluetooth/btservice/RemoteDevices.java
index dd9af02..04bc1c2 100755
--- a/src/com/android/bluetooth/btservice/RemoteDevices.java
+++ b/src/com/android/bluetooth/btservice/RemoteDevices.java
@@ -156,7 +156,6 @@
         }
 
         /**
-         *
          * @return mDeviceType
          */
         int getDeviceType() {
@@ -290,6 +289,8 @@
                             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: