Not assuming that all accessibility events contain bundle
Bundles come from Launcher being explicitly asked a question.
When waiting for ANY event, it may contain any parcelable, so it's
incorrect to cast it to Bundle.
See this:
https://sponge.corp.google.com/target?show=FAILED&sortBy=STATUS&id=9b8d0d26-f81d-427f-8857-b8d71e012504&target=android.test.appsmoke
Bug: 110103162
Test: will watch for reducing flakes in platform tests.
Change-Id: I989cee018183140d7fd672c0a925f03441ca339c
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 09bf403..1066476 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -26,6 +26,7 @@
import android.app.Instrumentation;
import android.app.UiAutomation;
import android.os.Bundle;
+import android.os.Parcelable;
import android.provider.Settings;
import android.view.accessibility.AccessibilityEvent;
@@ -160,14 +161,14 @@
}
}
- private Bundle executeAndWaitForEvent(Runnable command,
+ private Parcelable executeAndWaitForEvent(Runnable command,
UiAutomation.AccessibilityEventFilter eventFilter, String message) {
try {
final AccessibilityEvent event =
mInstrumentation.getUiAutomation().executeAndWaitForEvent(
command, eventFilter, WAIT_TIME_MS);
assertNotNull("executeAndWaitForEvent returned null (this can't happen)", event);
- return (Bundle) event.getParcelableData();
+ return event.getParcelableData();
} catch (TimeoutException e) {
fail(message);
return null;
@@ -177,7 +178,7 @@
Bundle getAnswerFromLauncher(UiObject2 view, String requestTag) {
// Send a fake set-text request to Launcher to initiate a response with requested data.
final String responseTag = requestTag + TestProtocol.RESPONSE_MESSAGE_POSTFIX;
- return executeAndWaitForEvent(
+ return (Bundle) executeAndWaitForEvent(
() -> view.setText(requestTag),
event -> responseTag.equals(event.getClassName()),
"Launcher didn't respond to request: " + requestTag);