summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorHansong Zhang <hsz@google.com>2018-03-28 16:53:10 -0700
committerHansong Zhang <hsz@google.com>2018-04-04 14:54:07 -0700
commit3b8f09b3c56fc81148a06af68dde58022bc042fe (patch)
treec2cdbb1e432af930ba32e93661b8af6fbf199ef1 /core/java
parent3a2d4143eeca73c557df24cb78428629a9bb5546 (diff)
Hearing Aid: change get/set active device (3/3)
* setActiveDevice() returns false in error case, e.g. when the device is not connected * add getActiveDevices() instead of isActiveDevice(), which returns a list that must have two elements: left and right, or empty list on error Test: manual Bug: 69623109 Change-Id: I48f3388c56434d0c21e09bd8b794e58848cd8794 (cherry picked from commit 8d799f8340d0219280f27cc35f0c02dae5922b74)
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/bluetooth/BluetoothHearingAid.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/core/java/android/bluetooth/BluetoothHearingAid.java b/core/java/android/bluetooth/BluetoothHearingAid.java
index 8f8083ed73e2..159e165d594f 100644
--- a/core/java/android/bluetooth/BluetoothHearingAid.java
+++ b/core/java/android/bluetooth/BluetoothHearingAid.java
@@ -421,29 +421,29 @@ public final class BluetoothHearingAid implements BluetoothProfile {
}
/**
- * Check whether the device is active.
+ * Get the connected physical Hearing Aid devices that are active
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH}
* permission.
*
- * @return the connected device that is active or null if no device
- * is active
+ * @return the list of active devices. The first element is the left active
+ * device; the second element is the right active device. If either or both side
+ * is not active, it will be null on that position. Returns empty list on error.
* @hide
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
- public boolean isActiveDevice(@Nullable BluetoothDevice device) {
- if (VDBG) log("isActiveDevice()");
+ public List<BluetoothDevice> getActiveDevices() {
+ if (VDBG) log("getActiveDevices()");
try {
mServiceLock.readLock().lock();
- if (mService != null && isEnabled()
- && ((device == null) || isValidDevice(device))) {
- return mService.isActiveDevice(device);
+ if (mService != null && isEnabled()) {
+ return mService.getActiveDevices();
}
if (mService == null) Log.w(TAG, "Proxy not attached to service");
- return false;
+ return new ArrayList<>();
} catch (RemoteException e) {
Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
- return false;
+ return new ArrayList<>();
} finally {
mServiceLock.readLock().unlock();
}