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

Commit 8e6973df authored by Daniel Norman's avatar Daniel Norman
Browse files

Add an explicit delay before taking a screenshot in A11yMenu.

Even when we request to hide the UI before taking a screenshot it was
still appearing in ~1/30 screenshots. By adding a slight delay I haven't
been able to capture it in a screenshot again.

Uses the same flag as before, but I've rolled back this flag to 0%
rollout in order to re-land.

Bug: 292020123
Test: Take 100 screenshots as fast as I can using A11yMenu;
      No screenshot contains A11yMenu UI.
Change-Id: I4e0a07f73082181254c46e8c35b7f8a38ab7158b
parent 1acb8c1b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class AccessibilityMenuService extends AccessibilityService

    private static final String TAG = "A11yMenuService";
    private static final long BUFFER_MILLISECONDS_TO_PREVENT_UPDATE_FAILURE = 100L;
    private static final long TAKE_SCREENSHOT_DELAY_MS = 100L;

    private static final int BRIGHTNESS_UP_INCREMENT_GAMMA =
            (int) Math.ceil(BrightnessUtils.GAMMA_SPACE_MAX * 0.11f);
@@ -301,8 +302,15 @@ public class AccessibilityMenuService extends AccessibilityService
        } else if (viewTag == ShortcutId.ID_NOTIFICATION_VALUE.ordinal()) {
            performGlobalActionInternal(GLOBAL_ACTION_NOTIFICATIONS);
        } else if (viewTag == ShortcutId.ID_SCREENSHOT_VALUE.ordinal()) {
            if (Flags.a11yMenuHideBeforeTakingAction()) {
                // Delay before taking a screenshot to give time for the UI to close.
                mHandler.postDelayed(
                        () -> performGlobalActionInternal(GLOBAL_ACTION_TAKE_SCREENSHOT),
                        TAKE_SCREENSHOT_DELAY_MS);
            } else {
                performGlobalActionInternal(GLOBAL_ACTION_TAKE_SCREENSHOT);
            }
        }

        if (!Flags.a11yMenuHideBeforeTakingAction()) {
            mA11yMenuLayout.hideMenu();