Align with Bluetooth metadata API changes
* Align with the changes of Bluetooth metadata APIs. * Move metadata utils from Settings to SettingsLib. Bug: 124448651 Test: make RunSettingsRoboTests Change-Id: Ic9ad91536ef3ff6807a08bbffa3dd796ef1ad523
This commit is contained in:
@@ -47,8 +47,6 @@ public final class Utils {
|
||||
static final boolean V = BluetoothUtils.V; // verbose logging
|
||||
static final boolean D = BluetoothUtils.D; // regular logging
|
||||
|
||||
public static final int META_INT_ERROR = -1;
|
||||
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
@@ -154,30 +152,4 @@ public final class Utils {
|
||||
return Settings.Global.getInt(context.getContentResolver(),
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
||||
}
|
||||
|
||||
public static boolean getBooleanMetaData(BluetoothDevice bluetoothDevice, int key) {
|
||||
if (bluetoothDevice == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Boolean.parseBoolean(bluetoothDevice.getMetadata(key));
|
||||
}
|
||||
|
||||
public static String getStringMetaData(BluetoothDevice bluetoothDevice, int key) {
|
||||
if (bluetoothDevice == null) {
|
||||
return null;
|
||||
}
|
||||
return bluetoothDevice.getMetadata(key);
|
||||
}
|
||||
|
||||
public static int getIntMetaData(BluetoothDevice bluetoothDevice, int key) {
|
||||
if (bluetoothDevice == null) {
|
||||
return META_INT_ERROR;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(bluetoothDevice.getMetadata(key));
|
||||
} catch (NumberFormatException e) {
|
||||
return META_INT_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user