Added Bluetooth Major Class resolver
This commit is contained in:
@@ -212,6 +212,15 @@ public class BluetoothLeDevice implements Parcelable {
|
||||
return BluetoothClassResolver.resolveDeviceClass(mDevice.getBluetoothClass().getDeviceClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bluetooth device major class name.
|
||||
*
|
||||
* @return the bluetooth device major class name
|
||||
*/
|
||||
public String getBluetoothDeviceMajorClassName() {
|
||||
return BluetoothClassResolver.resolveMajorDeviceClass(mDevice.getBluetoothClass().getMajorDeviceClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the device.
|
||||
*
|
||||
|
||||
@@ -110,4 +110,33 @@ public class BluetoothClassResolver {
|
||||
return "Unknown, Unknown (class=" + btClass + ")";
|
||||
}
|
||||
}
|
||||
|
||||
public static String resolveMajorDeviceClass(final int majorBtClass) {
|
||||
switch (majorBtClass) {
|
||||
case BluetoothClass.Device.Major.AUDIO_VIDEO:
|
||||
return "Audio/ Video";
|
||||
case BluetoothClass.Device.Major.COMPUTER:
|
||||
return "Computer";
|
||||
case BluetoothClass.Device.Major.HEALTH:
|
||||
return "Health";
|
||||
case BluetoothClass.Device.Major.IMAGING:
|
||||
return "Imaging";
|
||||
case BluetoothClass.Device.Major.MISC:
|
||||
return "Misc";
|
||||
case BluetoothClass.Device.Major.NETWORKING:
|
||||
return "Networking";
|
||||
case BluetoothClass.Device.Major.PERIPHERAL:
|
||||
return "Peripheral";
|
||||
case BluetoothClass.Device.Major.PHONE:
|
||||
return "Phone";
|
||||
case BluetoothClass.Device.Major.TOY:
|
||||
return "Toy";
|
||||
case BluetoothClass.Device.Major.UNCATEGORIZED:
|
||||
return "Uncategorized";
|
||||
case BluetoothClass.Device.Major.WEARABLE:
|
||||
return "Wearable";
|
||||
default:
|
||||
return "Unknown (" +majorBtClass+ ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,11 +55,13 @@ public class DeviceDetailsActivity extends AppCompatActivity {
|
||||
final TextView tvName = (TextView) lt.findViewById(R.id.deviceName);
|
||||
final TextView tvAddress = (TextView) lt.findViewById(R.id.deviceAddress);
|
||||
final TextView tvClass = (TextView) lt.findViewById(R.id.deviceClass);
|
||||
final TextView tvMajorClass = (TextView) lt.findViewById(R.id.deviceMajorClass);
|
||||
final TextView tvBondingState = (TextView) lt.findViewById(R.id.deviceBondingState);
|
||||
|
||||
tvName.setText(device.getName());
|
||||
tvAddress.setText(device.getAddress());
|
||||
tvClass.setText(device.getBluetoothDeviceClassName());
|
||||
tvMajorClass.setText(device.getBluetoothDeviceMajorClassName());
|
||||
tvBondingState.setText(device.getBluetoothDeviceBondState());
|
||||
|
||||
adapter.addView(lt);
|
||||
|
||||
@@ -42,6 +42,16 @@
|
||||
android:id="@+id/deviceClass"
|
||||
style="@style/GridLayoutDataTextView"/>
|
||||
|
||||
<TextView
|
||||
style="@style/GridLayoutTitleTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_device_major_class"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deviceMajorClass"
|
||||
style="@style/GridLayoutDataTextView"/>
|
||||
|
||||
<TextView
|
||||
style="@style/GridLayoutTitleTextView"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<string name="label_desc">Desc:</string>
|
||||
<string name="label_device_address">Device address:</string>
|
||||
<string name="label_device_class">Device Class:</string>
|
||||
<string name="label_device_major_class">Major Class:</string>
|
||||
<string name="label_device_name">Device Name:</string>
|
||||
<string name="label_distance">Distance:</string>
|
||||
<string name="label_first_rssi">First RSSI:</string>
|
||||
|
||||
Reference in New Issue
Block a user