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

Commit d9bc1b38 authored by Kyrylo Mikos's avatar Kyrylo Mikos Committed by Steve Kondik
Browse files

Show panels on lockscreen in expanded desktop mode.

Change-Id: Iaa2d712130707169c7a08156f8ea5afc247fc4cf
parent 8d172e67
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3204,6 +3204,12 @@ public final class Settings {
         */
        public static final String EXPANDED_DESKTOP_STYLE = "expanded_desktop_style";

        /**
         * Expanded desktop system bars visibility in locked state
         * @hide
         */
        public static final String EXPANDED_DESKTOP_SYSTEM_BARS_VISIBILITY = "expanded_desktop_system_bars_visibility";

        /**
         * Use EdgeGesture Service for system gestures in PhoneWindowManager
         * @hide
+68 −28
Original line number Diff line number Diff line
@@ -366,6 +366,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    boolean mIsLongPress;
    boolean mCameraKeyPressable = false;
    private boolean mClearedBecauseOfForceShow;
    private boolean mShowSystemBarOnKeyguard;
    private boolean mWindowIsKeyguardWithBars;

    private final class PointerLocationPointerEventListener implements PointerEventListener {
        @Override
@@ -644,6 +646,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.EXPANDED_DESKTOP_STYLE), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.System.EXPANDED_DESKTOP_SYSTEM_BARS_VISIBILITY), false, this,
                    UserHandle.USER_ALL);
            resolver.registerContentObserver(Settings.System.getUriFor(
                    Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this,
                    UserHandle.USER_ALL);
@@ -1561,9 +1566,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {

            mExpandedDesktopStyle = Settings.System.getIntForUser(resolver,
                    Settings.System.EXPANDED_DESKTOP_STYLE, 0, UserHandle.USER_CURRENT);
            mShowSystemBarOnKeyguard = Settings.System.getIntForUser(resolver,
                    Settings.System.EXPANDED_DESKTOP_SYSTEM_BARS_VISIBILITY,
                    0, UserHandle.USER_CURRENT) == 1;
            if (Settings.System.getIntForUser(resolver,
                        Settings.System.EXPANDED_DESKTOP_STATE, 0, UserHandle.USER_CURRENT) == 0) {
                mExpandedDesktopStyle = 0;
                mShowSystemBarOnKeyguard = false;
            }

            mNavigationBarLeftInLandscape = Settings.System.getInt(resolver,
@@ -3178,7 +3187,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    @Override
    public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) {
        final int fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs.flags);
        final int fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs);
        final int systemUiVisibility = updateSystemUiVisibilityFlagsForExpandedDesktop(
                attrs.systemUiVisibility|attrs.subtreeSystemUiVisibility);

@@ -3330,6 +3339,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            boolean updateSysUiVisibility = false;
            if (mNavigationBar != null) {
                boolean transientNavBarShowing = mNavigationBarController.isTransientShowing();
                boolean simulateTransientBarShowing = expandedDesktopHidesNavigationBar()
                        && navVisible;
                // Force the navigation bar to its appropriate place and
                // size.  We need to do this directly, instead of relying on
                // it to bubble up from the nav bar, because this needs to
@@ -3343,8 +3354,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    if (!expandedDesktopHidesNavigationBar()) {
                        mStableFullscreenBottom = mTmpNavigationFrame.top;
                    }
                    if (transientNavBarShowing
                            || (navVisible && expandedDesktopHidesNavigationBar())) {
                    if (transientNavBarShowing || simulateTransientBarShowing) {
                        mNavigationBarController.setBarShowingLw(true);
                    } else if (navVisible) {
                        mNavigationBarController.setBarShowingLw(true);
@@ -3403,8 +3413,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    if (!expandedDesktopHidesNavigationBar()) {
                        mStableFullscreenRight = mTmpNavigationFrame.left;
                    }
                    if (transientNavBarShowing
                            || (navVisible && expandedDesktopHidesNavigationBar())) {
                    if (transientNavBarShowing || simulateTransientBarShowing) {
                        mNavigationBarController.setBarShowingLw(true);
                    } else if (navVisible) {
                        mNavigationBarController.setBarShowingLw(true);
@@ -3569,8 +3578,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                ? attached.getFrameLw() : df);
    }

    private void applyStableConstraints(int sysui, int fl, Rect r) {
        fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(fl);
    private void applyStableConstraints(int sysui, WindowManager.LayoutParams attrs, Rect r) {
        final int fl = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs);
        if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) {
            // If app is requesting a stable layout, don't let the
            // content insets go below the stable values.
@@ -3782,7 +3791,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth;
                        cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight;
                    }
                    applyStableConstraints(sysUiFl, fl, cf);
                    applyStableConstraints(sysUiFl, attrs, cf);
                    if (adjust != SOFT_INPUT_ADJUST_NOTHING) {
                        vf.left = mCurLeft;
                        vf.top = mCurTop;
@@ -3890,7 +3899,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            + mRestrictedScreenHeight;
                }

                applyStableConstraints(sysUiFl, fl, cf);
                applyStableConstraints(sysUiFl, attrs, cf);

                if (adjust != SOFT_INPUT_ADJUST_NOTHING) {
                    vf.left = mCurLeft;
@@ -3987,19 +3996,24 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (expandedDesktopHidesNavigationBar()) {
            if ((vis & View.SYSTEM_UI_FLAG_SHOW_NAVIGATION_IN_EXPANDED_DESKTOP) == 0) {
                vis |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
                vis &= ~View.STATUS_BAR_TRANSLUCENT;
            }
        }
        if (expandedDesktopHidesStatusBar()) {
            vis |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
            vis &= ~View.NAVIGATION_BAR_TRANSLUCENT;
        }
        return vis;
    }

    private int updateWindowManagerVisibilityFlagsForExpandedDesktop(int vis) {
        if (mExpandedDesktopStyle != 0) {
            vis |= FLAG_FULLSCREEN;
    private int updateWindowManagerVisibilityFlagsForExpandedDesktop(WindowManager.LayoutParams lp) {
        if (mExpandedDesktopStyle == 0) {
            return lp.flags;
        }
        return vis;
        if (lp.type == TYPE_KEYGUARD && mShowSystemBarOnKeyguard) {
            return lp.flags;
        }
        return  (lp.flags | FLAG_FULLSCREEN) & ~FLAG_FORCE_NOT_FULLSCREEN;
    }

    private boolean expandedDesktopHidesNavigationBar() {
@@ -4054,6 +4068,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                                WindowManager.LayoutParams attrs) {
        if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw="
                + win.isVisibleOrBehindKeyguardLw());
        final int flags = updateWindowManagerVisibilityFlagsForExpandedDesktop(attrs);
        if (mTopFullscreenOpaqueWindowState == null && (win.getAttrs().privateFlags
                &WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_NAV_BAR) != 0
                || (win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD)) {
@@ -4064,7 +4079,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
        if (mTopFullscreenOpaqueWindowState == null &&
                win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) {
            if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
            if ((flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) {
                if (attrs.type == TYPE_KEYGUARD) {
                    mForceStatusBarFromKeyguard = true;
                } else {
@@ -4091,12 +4106,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) {
                if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win);
                mTopFullscreenOpaqueWindowState = win;
                if ((attrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) {
                if ((flags & FLAG_SHOW_WHEN_LOCKED) != 0) {
                    if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mHideLockScreen to true by win " + win);
                    mHideLockScreen = true;
                    mForceStatusBarFromKeyguard = false;
                }
                if ((attrs.flags & FLAG_DISMISS_KEYGUARD) != 0
                if ((flags & FLAG_DISMISS_KEYGUARD) != 0
                        && mDismissKeyguard == DISMISS_KEYGUARD_NONE) {
                    if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mDismissKeyguard true by win " + win);
                    mDismissKeyguard = mWinDismissingKeyguard == win ?
@@ -4104,7 +4119,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mWinDismissingKeyguard = win;
                    mForceStatusBarFromKeyguard = mShowingLockscreen && isKeyguardSecure();
                }
                if ((attrs.flags & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) {
                if ((flags & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) {
                    mAllowLockscreenWhenOn = true;
                }
            }
@@ -4133,8 +4148,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar
                    + " forcefkg=" + mForceStatusBarFromKeyguard
                    + " top=" + mTopFullscreenOpaqueWindowState);
            if ((mForceStatusBar || mForceStatusBarFromKeyguard)
                    && !expandedDesktopHidesStatusBar()) {
            if (mForceStatusBar || mForceStatusBarFromKeyguard) {
                if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced");
                if (mStatusBarController.setBarShowingLw(true)) {
                    changes |= FINISH_LAYOUT_REDO_LAYOUT;
@@ -5931,7 +5945,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        // about hiding after timeout. This should not happen if next window is keyguard because
        // transient state have more priority than translucent (why?) and cause bad UX
        if (wasCleared && !mClearedBecauseOfForceShow
                && (tmpVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0) {
                && (tmpVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0
                && !mWindowIsKeyguardWithBars) {
            mNavigationBarController.showTransient();
            tmpVisibility |= View.NAVIGATION_BAR_TRANSIENT;
            mWindowManagerFuncs.addSystemUIVisibilityFlag(View.NAVIGATION_BAR_TRANSIENT);
@@ -5971,12 +5986,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        WindowState transWin = mKeyguard != null && mKeyguard.isVisibleLw() && !mHideLockScreen
                ? mKeyguard
                : mTopFullscreenOpaqueWindowState;
        if (!expandedDesktopHidesStatusBar()) {
        vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis);
        }
        if (!expandedDesktopHidesNavigationBar()) {
        vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis);
        }

        // prevent status bar interaction from clearing certain flags
        boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR;
@@ -5990,10 +6001,33 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            vis = (vis & ~flags) | (oldVis & flags);
        }

        final boolean windowWasKeyguardWithBars = mWindowIsKeyguardWithBars;
        mWindowIsKeyguardWithBars =
                mShowSystemBarOnKeyguard && mKeyguard != null && mKeyguard.isVisibleLw();
        if (mWindowIsKeyguardWithBars) {
            vis &= ~(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }

        if (!areTranslucentBarsAllowed()) {
            vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT);
        }

        if (windowWasKeyguardWithBars && !mWindowIsKeyguardWithBars
                && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0) {
            // Keyguard was unlocked and system bars was visible. Make it transient now.
            if (expandedDesktopHidesStatusBar()) {
                mStatusBarController.showTransient();
                vis |= View.STATUS_BAR_TRANSIENT;
                mWindowManagerFuncs.addSystemUIVisibilityFlag(View.STATUS_BAR_TRANSIENT);
            }
            if (expandedDesktopHidesNavigationBar()) {
                mNavigationBarController.showTransient();
                vis |= View.NAVIGATION_BAR_TRANSIENT;
                mWindowManagerFuncs.addSystemUIVisibilityFlag(View.NAVIGATION_BAR_TRANSIENT);
            }
        }

        // update status bar
        boolean immersiveSticky =
                (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0;
@@ -6006,15 +6040,21 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        boolean hideNavBarSysui =
                (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0;

        // Deny transient state when keyguard visible
        boolean windowIsKeyguardWithBars = mShowSystemBarOnKeyguard && transWin != null
                && transWin.getAttrs().type == TYPE_KEYGUARD;

        boolean transientStatusBarAllowed =
                mStatusBar != null && (
                hideStatusBarWM
                || (hideStatusBarSysui && immersiveSticky)
                || statusBarHasFocus);
                || statusBarHasFocus)
                && !windowIsKeyguardWithBars;

        boolean transientNavBarAllowed =
                mNavigationBar != null &&
                hideNavBarSysui && immersiveSticky;
                hideNavBarSysui && immersiveSticky
                && !windowIsKeyguardWithBars;

        boolean denyTransientStatus = mStatusBarController.isTransientShowRequested()
                && !transientStatusBarAllowed && hideStatusBarSysui;