From 8c035ba57fe232146004b737e41a83f477a62bd3 Mon Sep 17 00:00:00 2001 From: chuanhsiao <49941275+chuanhsiao@users.noreply.github.com> Date: Wed, 15 Jan 2020 11:38:58 +0800 Subject: Add a Rpc "btIsA2dpPlaying" to BluetoothA2dpSnippet (#128) A RPC method is used to check A2DP audio path is enabled or not. --- .../snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/main') 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()) { -- cgit v1.2.3