aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
authorPrerepa Viswanadham <dham@google.com>2014-07-22 17:00:09 -0700
committerPrerepa Viswanadham <dham@google.com>2014-07-23 18:54:46 +0000
commit53c97aee16c15ca9a3932bde283e604812d74fc4 (patch)
treed2b677a2aae56cd68a34ad7f0539bb975ab94319 /framework/java/android/bluetooth/BluetoothAdapter.java
parentb4799c5c2cfabc5e7da05261d054b0a30d42184f (diff)
Bug 15564216: Report Bluetooth tx/rx/idle activity info and energy reporting
Change-Id: I66fd83d8d59fbd93dec8886dfd313a81575e38a5
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