TAPL: verify input events
This will catch cases, for example, when the platform stops delivering
injected events to Launcher, or injects unexpected events, like Back
Button.
Also optimizing and fixing incorrect behavior of calculating the start
time for the event collection.
Change-Id: I2ba0108e6bfa112f2905a05bcb327b148ec08f77
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8066d38..06f3453 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -76,6 +76,7 @@
import android.view.KeyboardShortcutInfo;
import android.view.LayoutInflater;
import android.view.Menu;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
@@ -121,6 +122,7 @@
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.qsb.QsbContainerView;
import com.android.launcher3.states.RotationHelper;
+import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.AllAppsSwipeController;
import com.android.launcher3.touch.ItemClickHandler;
@@ -1778,10 +1780,21 @@
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
+ TestLogging.recordEvent("Key event: " + event);
+ }
return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event);
}
@Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ if (Utilities.IS_RUNNING_IN_TEST_HARNESS && ev.getAction() != MotionEvent.ACTION_MOVE) {
+ TestLogging.recordEvent("Touch event: " + ev);
+ }
+ return super.dispatchTouchEvent(ev);
+ }
+
+ @Override
public void onBackPressed() {
if (finishAutoCancelActionMode()) {
return;