Fix corner cases for BTMediaDeviceNotPairedTest
The test is failing for the first execution on just flashed build.
After open Bluetooth Audio page the issue in not reproducible.
Test execution:
```
/ssddrive/main/out/host/linux-x86/catbox/android-catbox/tools/catbox-tradefed run commandAndExit catbox-functional-bluetooth-tests --{phone}serial 875X00GEB --{auto}serial c4ba9d70 --mobly-host:mobly-par-file-name BTMediaDeviceNotPairedTest --log-level verbose
```
Bug: 306461539
Test: [log](https://paste.googleplex.com/6267065391382528)
Merged-In: I3eccec9c6602b2a8c74bd60dce86a2d3d304243e
Change-Id: I3eccec9c6602b2a8c74bd60dce86a2d3d304243e
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
index 2f2c3c4..14d99fc 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
@@ -216,4 +216,11 @@
* <p>This method is return is Bluetooth Audio disconnected label visible.
*/
boolean isBluetoothAudioDisconnectedLabelVisible();
+
+ /**
+ * Setup expectations: on home screen.
+ *
+ * <p>This method is used to open Bluetooth Audio screen.
+ */
+ void openBluetoothMediaApp();
}
diff --git a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
index 067579b..1fd9160 100644
--- a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
+++ b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
@@ -68,6 +68,7 @@
"STOP_SETTING_APP_COMMAND": "am force-stop com.android.car.settings",
"OPEN_SETTINGS_COMMAND": "am start -a android.settings.SETTINGS",
"MEDIA_LAUNCH_COMMAND": "am start -a android.car.intent.action.MEDIA_TEMPLATE -e android.car.intent.extra.MEDIA_COMPONENT com.android.bluetooth/com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService",
+ "MEDIA_LAUNCH_BLUETOOTH_AUDIO_COMMAND": "am start -a android.car.intent.action.MEDIA_TEMPLATE -e android.car.intent.extra.MEDIA_COMPONENT com.google.android.bluetooth/com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService",
"NIGHT_MODE_COMMAND": "dumpsys activity service com.android.car/.CarService day-night-mode night",
"DAY_MODE_COMMAND": "dumpsys activity service com.android.car/.CarService day-night-mode day",
"OPEN_SYSTEM_UI": "am crash com.android.systemui",
diff --git a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
index 4c9ef1c..65160ae 100644
--- a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
+++ b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
@@ -285,6 +285,7 @@
// Media Center Screen
public static final String PLAY_PAUSE_BUTTON = "PLAY_PAUSE_BUTTON";
public static final String MEDIA_SONGS_LIST = "MEDIA_SONGS_LIST";
+ public static final String MEDIA_LAUNCH_BLUETOOTH_AUDIO_COMMAND = "MEDIA_LAUNCH_BLUETOOTH_AUDIO_COMMAND";
// NEXT_BUTTON from Account Settings
public static final String PREVIOUS_BUTTON = "PREVIOUS_BUTTON";
public static final String SHUFFLE_BUTTON = "SHUFFLE_BUTTON";
diff --git a/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java b/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java
index b8471f9..89f4b05 100644
--- a/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java
+++ b/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java
@@ -493,4 +493,14 @@
return object;
}
+ /** {@inheritDoc} */
+ @Override
+ public void openBluetoothMediaApp() {
+ getSpectatioUiUtil().pressHome();
+ getSpectatioUiUtil().waitForIdle();
+ getSpectatioUiUtil()
+ .executeShellCommand(
+ getCommandFromConfig(AutomotiveConfigConstants.MEDIA_LAUNCH_BLUETOOTH_AUDIO_COMMAND));
+ }
+
}
diff --git a/tests/automotive/mobly_tests/utilities/spectatio_utils.py b/tests/automotive/mobly_tests/utilities/spectatio_utils.py
index 04df918..1fcc6ec 100644
--- a/tests/automotive/mobly_tests/utilities/spectatio_utils.py
+++ b/tests/automotive/mobly_tests/utilities/spectatio_utils.py
@@ -15,14 +15,16 @@
import logging
import time
-
from mobly.controllers import android_device
from mbs_utils import constants
""" This exception may be expanded in the future to provide better error discoverability."""
+
+
class CallUtilsError(Exception):
pass
+
class CallUtils:
"""Calling sequence utility for BT calling test using Spectatio UI APIs.
@@ -41,13 +43,11 @@
logging.info('Dial phone number <%s>', callee_number)
self.device.mbs.dialANumber(callee_number)
-
def end_call(self):
""" End the call. Throws an error if non call is currently ongoing. """
logging.info('End the call')
self.device.mbs.endCall()
-
def execute_shell_on_device(self, device_target, shell_command):
"""Execute any shell command on any device"""
logging.info(
@@ -57,7 +57,6 @@
)
return device_target.adb.shell(shell_command)
-
def get_dialing_number(self):
""" Get dialing phone number"""
return self.device.mbs.getDialedNumber()
@@ -127,7 +126,6 @@
logging.info('Attempting to press \'Forget\'')
self.device.mbs.pressForget()
-
def press_home_screen_on_status_bar(self):
"""Presses the Home screen button on the status bar
(to return the device to the home screen."""
@@ -183,10 +181,9 @@
def open_bluetooth_media_app(self):
""" Open Bluetooth Audio app """
logging.info('Open Bluetooth Audio app')
- self.device.mbs.openMediaApp();
+ self.device.mbs.openBluetoothMediaApp();
self.wait_with_log(constants.WAIT_ONE_SEC)
-
def open_bluetooth_palette(self):
logging.info('Open Bluetooth Palette')
self.device.mbs.openBluetoothPalette()
@@ -217,10 +214,5 @@
actual_timezone, expected_timezone)
if expected_timezone not in actual_timezone:
raise CallUtilsError(
- "Time Zone did not set properly."
- )
- def is_bluetooth_hfp_error_displayed(self):
- logging.info('Verify Bluetooth HFP error is displayed,'
- 'when bluetooth is disconnected')
- return self.device.mbs.isBluetoothHfpErrorDisplayed()
-
+ "Time Zone did not set properly."
+ )
diff --git a/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java b/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java
index 4f3329e..3a954cf 100644
--- a/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java
+++ b/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java
@@ -81,4 +81,9 @@
public boolean isBluetoothAudioDisconnectedLabelVisible() {
return mAutoMediaHelper.get().isBluetoothAudioDisconnectedLabelVisible();
}
+
+ @Rpc(description = "Open Bluetooth Audio app")
+ public void openBluetoothMediaApp() {
+ mAutoMediaHelper.get().openBluetoothMediaApp();
+ }
}
\ No newline at end of file