Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 896c4cca authored by Will McVicker's avatar Will McVicker
Browse files

[TouchLatency] Add intent extra arg to set the mode on start

To make automation testing with the TouchLatency app more reliable, add
an extra intent argument that lets you change the action mode to BALL
when the app launches. Currently, we have scripting that uses
uiautomator to get the action_settings button coordinates in order to
switch the mode.  This can be flaky if the options menu is open or the
app is already in BALL mode due to a previous state.

With this change, you can launch the app in bouncy ball mode with the
following command:

  adb shell am start -n \
    com.prefabulated.touchlatency/.TouchLatencyActivity \
    --ei action_mode_on_create 1

Bug: 414642844
Flag: TEST_ONLY
Test: verify with various intent extra args
Change-Id: Ib697887e467ff4e92051ad6a347c3991b2e1d7f8
parent 4c922b1d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ public class TouchLatencyActivity extends AppCompatActivity {
    private float mSliderPreferredRefreshRate;
    private DisplayManager mDisplayManager;

    public static final String ACTION_MODE_ON_CREATE = "action_mode_on_create";

    private final DisplayManager.DisplayListener mDisplayListener =
            new DisplayManager.DisplayListener() {
        @Override
@@ -112,6 +114,15 @@ public class TouchLatencyActivity extends AppCompatActivity {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_touch_latency, mMenu);
        updateOptionsMenu();
        int initActionMode = getIntent().getIntExtra(ACTION_MODE_ON_CREATE, 0);
        if (initActionMode < mTouchView.ACTION_MODES.length) {
            MenuItem menuItem = mMenu.findItem(R.id.action_settings);
            // Calling changeMode() cycles through the supported modes. So loop
            // through the modes to get the request one.
            for (int i = 0; i < initActionMode; i++) {
                mTouchView.changeMode(menuItem);
            }
        }
        Trace.endSection();
        return true;
    }
+3 −4
Original line number Diff line number Diff line
@@ -198,16 +198,15 @@ class TouchLatencyView extends View implements View.OnTouchListener {

    public void changeMode(MenuItem item) {
        Trace.beginSection("TouchLatencyView changeMode");
        final int NUM_MODES = 2;
        final String modes[] = {"Touch", "Ball"};
        mMode = (mMode + 1) % NUM_MODES;
        mMode = (mMode + 1) % ACTION_MODES.length;
        invalidate();
        item.setTitle(modes[mMode]);
        item.setTitle(ACTION_MODES[mMode]);
        Trace.endSection();
    }

    private final Paint mBluePaint, mGreenPaint, mYellowPaint, mRedPaint, mTextPaint;
    private int mMode;
    public static final String ACTION_MODES[] = {"Touch", "Ball"};

    private boolean mTouching;
    private float mTouchX, mTouchY;