Add error code for BluetoothDevice#getBatteryLevel to represent
Bluetooth is off
Bug: 147428695
Test: Manual
Merged-In: I07c2fa49954632da6aa6a93706883e4cdfd32fa6
Change-Id: I07c2fa49954632da6aa6a93706883e4cdfd32fa6
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index 6e5f914..eab7a03 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -231,6 +231,13 @@
public static final int BATTERY_LEVEL_UNKNOWN = -1;
/**
+ * Used as an error value for {@link #getBatteryLevel()} to represent bluetooth is off
+ *
+ * @hide
+ */
+ public static final int BATTERY_LEVEL_BLUETOOTH_OFF = -100;
+
+ /**
* Used as a Parcelable {@link BluetoothDevice} extra field in every intent
* broadcast by this class. It contains the {@link BluetoothDevice} that
* the intent applies to.
@@ -1112,9 +1119,9 @@
/**
* Get the most recent identified battery level of this Bluetooth device
*
- * @return Battery level in percents from 0 to 100, or {@link #BATTERY_LEVEL_UNKNOWN} if
- * Bluetooth is disabled, or device is disconnected, or does not have any battery reporting
- * service, or return value is invalid
+ * @return Battery level in percents from 0 to 100, {@link #BATTERY_LEVEL_BLUETOOTH_OFF} if
+ * Bluetooth is disabled or {@link #BATTERY_LEVEL_UNKNOWN} if device is disconnected, or does
+ * not have any battery reporting service, or return value is invalid
* @hide
*/
@SystemApi
@@ -1123,7 +1130,7 @@
final IBluetooth service = sService;
if (service == null) {
Log.e(TAG, "Bluetooth disabled. Cannot get remote device battery level");
- return BATTERY_LEVEL_UNKNOWN;
+ return BATTERY_LEVEL_BLUETOOTH_OFF;
}
try {
return service.getBatteryLevel(this);
@@ -1727,7 +1734,9 @@
/**
* Sets whether the message access is allowed to this device.
*
- * @param value is the value we are setting the message access permission to
+ * @param value Can be {@link #ACCESS_UNKNOWN} if the device is unbonded,
+ * {@link #ACCESS_ALLOWED} if the permission is being granted, or {@link #ACCESS_REJECTED} if
+ * the permission is not being granted.
* @return Whether the value has been successfully set.
* @hide
*/
@@ -1774,8 +1783,9 @@
/**
* Sets whether the Sim access is allowed to this device.
*
- * @param value Can be {@link #ACCESS_UNKNOWN}, {@link #ACCESS_ALLOWED} or {@link
- * #ACCESS_REJECTED}.
+ * @param value Can be {@link #ACCESS_UNKNOWN} if the device is unbonded,
+ * {@link #ACCESS_ALLOWED} if the permission is being granted, or {@link #ACCESS_REJECTED} if
+ * the permission is not being granted.
* @return Whether the value has been successfully set.
* @hide
*/