aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index faf864550d..453d60c6cd 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -377,6 +377,12 @@ public final class BluetoothAdapter {
private static final int ADDRESS_LENGTH = 17;
+ private static final int CONTROLLER_ENERGY_UPDATE_TIMEOUT_MILLIS = 30;
+ /** @hide */
+ public static final int ACTIVITY_ENERGY_INFO_CACHED = 0;
+ /** @hide */
+ public static final int ACTIVITY_ENERGY_INFO_REFRESHED = 1;
+
/**
* Lazily initialized singleton. Guaranteed final after first object
* constructed.
@@ -935,6 +941,43 @@ public final class BluetoothAdapter {
}
/**
+ * Return the record of {@link BluetoothActivityEnergyInfo} object that
+ * has the activity and energy info. This can be used to ascertain what
+ * the controller has been up to, since the last sample.
+ * @param updateType Type of info, cached vs refreshed.
+ *
+ * @return a record with {@link BluetoothActivityEnergyInfo} or null if
+ * report is unavailable or unsupported
+ * @hide
+ */
+ public BluetoothActivityEnergyInfo getControllerActivityEnergyInfo(int updateType) {
+ if (getState() != STATE_ON) return null;
+ try {
+ BluetoothActivityEnergyInfo record;
+ if (!mService.isActivityAndEnergyReportingSupported()) {
+ return null;
+ }
+ synchronized(this) {
+ if (updateType == ACTIVITY_ENERGY_INFO_REFRESHED) {
+ mService.getActivityEnergyInfoFromController();
+ wait(CONTROLLER_ENERGY_UPDATE_TIMEOUT_MILLIS);
+ }
+ record = mService.reportActivityInfo();
+ if (record.isValid()) {
+ return record;
+ } else {
+ return null;
+ }
+ }
+ } catch (InterruptedException e) {
+ Log.e(TAG, "getControllerActivityEnergyInfoCallback wait interrupted: " + e);
+ } catch (RemoteException e) {
+ Log.e(TAG, "getControllerActivityEnergyInfoCallback: " + e);
+ }
+ return null;
+ }
+
+ /**
* Return the set of {@link BluetoothDevice} objects that are bonded
* (paired) to the local adapter.
* <p>If Bluetooth state is not {@link #STATE_ON}, this API