Merge "Diagnose when lab device sends fake touch screen events to test" into sc-v2-dev am: 0a39f6daec am: da4e9793bb

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15482523

Change-Id: I345353d5b08e8e9a9fd4eaaafd27d79b0125b485
This commit is contained in:
TreeHugger Robot authored and Automerger Merge Worker committed 2021-08-09 11:40:08 +00:00
commit f145aa39b3
6 files changed
+44 -2

No files matched your search

+1 -1
View File
@@ -1930,7 +1930,7 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event);
TestLogging.recordKeyEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event);
return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event);
}
@@ -130,13 +130,18 @@ public class TestInformationHandler implements ResourceBasedOverride {
case TestProtocol.REQUEST_IS_TWO_PANELS:
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
mDeviceProfile.isTwoPanels);
mDeviceProfile.isTwoPanels);
return response;
case TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT:
TestProtocol.sForcePauseTimeout = Long.parseLong(arg);
return response;
case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS:
response.putBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest);
return response;
default:
return null;
}
@@ -17,6 +17,7 @@
package com.android.launcher3.testing;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import com.android.launcher3.Utilities;
@@ -25,6 +26,7 @@ import java.util.function.BiConsumer;
public final class TestLogging {
private static BiConsumer<String, String> sEventConsumer;
public static boolean sHadEventsNotFromTest;
private static void recordEventSlow(String sequence, String event) {
Log.d(TestProtocol.TAPL_EVENTS_TAG, sequence + " / " + event);
@@ -46,9 +48,17 @@ public final class TestLogging {
}
}
public static void recordKeyEvent(String sequence, String message, KeyEvent event) {
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
recordEventSlow(sequence, message + ": " + event);
if (event.getDeviceId() != -1) sHadEventsNotFromTest = true;
}
}
public static void recordMotionEvent(String sequence, String message, MotionEvent event) {
if (Utilities.IS_RUNNING_IN_TEST_HARNESS && event.getAction() != MotionEvent.ACTION_MOVE) {
recordEventSlow(sequence, message + ": " + event);
if (event.getDeviceId() != -1) sHadEventsNotFromTest = true;
}
}
@@ -93,6 +93,7 @@ public final class TestProtocol {
public static final String REQUEST_RECENT_TASKS_LIST = "recent-tasks-list";
public static final String REQUEST_START_EVENT_LOGGING = "start-event-logging";
public static final String REQUEST_GET_TEST_EVENTS = "get-test-events";
public static final String REQUEST_GET_HAD_NONTEST_EVENTS = "get-had-nontest-events";
public static final String REQUEST_STOP_EVENT_LOGGING = "stop-event-logging";
public static final String REQUEST_CLEAR_DATA = "clear-data";
public static final String REQUEST_IS_TABLET = "is-tablet";