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

Commit e57ff819 authored by Charles He's avatar Charles He
Browse files

SysUI: fix Home and Recents button in LockTask.

Previously, we couldn't disable the Recents button independently from
the Home button in LockTask mode. This was intentional so that the user
could exit screen pinning mode by the Back + Recents gesture.  However
this logic didn't distinguish between screen pinning and LockTask modes.

This CL removes this constraint for LockTask mode, and ensures both Back
and Recents buttons are shown for screen pinning mode.

Bug: 68273844
Test: CTS verifier > Managed provisioning > Device owner tests
      > LockTask UI
Test: runtest systemui

Change-Id: I252dd802c4862b76b12ba12b0205ab107a74f212
parent a34524e7
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -449,9 +449,17 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        // Always disable recents when alternate car mode UI is active.
        boolean disableRecent = mUseCarModeUi
                || ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
        final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)

        boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)
                && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);

        if ((disableRecent || disableBack) && inScreenPinning()) {
            // Don't hide back and recents buttons when in screen pinning mode, as they are used for
            // exiting.
            disableBack = false;
            disableRecent = false;
        }

        ViewGroup navButtons = (ViewGroup) getCurrentView().findViewById(R.id.nav_buttons);
        if (navButtons != null) {
            LayoutTransition lt = navButtons.getLayoutTransition();
@@ -461,20 +469,16 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
                }
            }
        }
        if (inLockTask() && disableRecent && !disableHome) {
            // Don't hide recents when in lock task, it is used for exiting.
            // Unless home is hidden, then in DPM locked mode and no exit available.
            disableRecent = false;
        }

        getBackButton().setVisibility(disableBack      ? View.INVISIBLE : View.VISIBLE);
        getHomeButton().setVisibility(disableHome      ? View.INVISIBLE : View.VISIBLE);
        getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);
    }

    private boolean inLockTask() {
    private boolean inScreenPinning() {
        try {
            return ActivityManager.getService().isInLockTaskMode();
            return ActivityManager.getService().getLockTaskModeState()
                    == ActivityManager.LOCK_TASK_MODE_PINNED;
        } catch (RemoteException e) {
            return false;
        }