diff options
author | chuanhsiao <49941275+chuanhsiao@users.noreply.github.com> | 2020-01-15 11:38:58 +0800 |
---|---|---|
committer | Ang Li <angli@google.com> | 2020-01-14 19:38:58 -0800 |
commit | 8c035ba57fe232146004b737e41a83f477a62bd3 (patch) | |
tree | 01fa86c7815ca9eaf71f6623acd954cf2f6a91d4 | |
parent | 58820984f8e79b250bc63d6b47b5f2910876a631 (diff) | |
download | mobly-bundled-snippets-8c035ba57fe232146004b737e41a83f477a62bd3.tar.gz |
Add a Rpc "btIsA2dpPlaying" to BluetoothA2dpSnippet (#128)
A RPC method is used to check A2DP audio path is enabled or not.
-rw-r--r-- | src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java index ec148ca..60ed1ec 100644 --- a/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java +++ b/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java @@ -96,6 +96,12 @@ public class BluetoothA2dpSnippet implements Snippet { return mJsonSerializer.serializeBluetoothDeviceList(sA2dpProfile.getConnectedDevices()); } + @Rpc(description = "Checks if a device is streaming audio via A2DP profile.") + public boolean btIsA2dpPlaying(String deviceAddress) throws Throwable { + BluetoothDevice device = getConnectedBluetoothDevice(deviceAddress); + return sA2dpProfile.isA2dpPlaying(device); + } + private BluetoothDevice getConnectedBluetoothDevice(String deviceAddress) throws BluetoothA2dpSnippetException { for (BluetoothDevice device : sA2dpProfile.getConnectedDevices()) { |