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

Commit 009bc0ac authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Move canBeHiddenByKeyguardLw and correct its condition for activity

- Fix an accidental behavior change by commit cb239e07.
  Originally, all windows belonging to an activity should not be
  always hidden by keyguard, e.g. starting window.
- Reduce unnecessary abstract invocation.

Bug: 207587841
Bug: 163976519
Test: CtsActivityManagerDeviceTestCases
Change-Id: I1a6f38535800e40669e8c31a0aa65477e25b1d46
parent 487a20d5
Loading
Loading
Loading
Loading
+0 −29
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVE
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
@@ -189,14 +188,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         */
        String getOwningPackage();

        /**
         * Retrieve the current LayoutParams of the window.
         *
         * @return WindowManager.LayoutParams The window's internal LayoutParams
         *         instance.
         */
        public WindowManager.LayoutParams getAttrs();

        /**
         * Retrieve the type of the top-level window.
         *
@@ -657,26 +648,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     */
    public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);

    /**
     * @return whether {@param win} can be hidden by Keyguard
     */
    default boolean canBeHiddenByKeyguardLw(WindowState win) {
        // Keyguard visibility of window from activities are determined over activity visibility.
        if (win.getBaseType() == TYPE_BASE_APPLICATION) {
            return false;
        }
        switch (win.getAttrs().type) {
            case TYPE_NOTIFICATION_SHADE:
            case TYPE_STATUS_BAR:
            case TYPE_NAVIGATION_BAR:
            case TYPE_WALLPAPER:
                return false;
            default:
                // Hide only windows below the keyguard host window.
                return getWindowLayerLw(win) < getWindowLayerFromTypeLw(TYPE_NOTIFICATION_SHADE);
        }
    }

    /**
     * Create and return an animation to re-display a window that was force hidden by Keyguard.
     */
+1 −1
Original line number Diff line number Diff line
@@ -4288,7 +4288,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            boolean subtle) {
        final WindowManagerPolicy policy = mWmService.mPolicy;
        forAllWindows(w -> {
            if (w.mActivityRecord == null && policy.canBeHiddenByKeyguardLw(w)
            if (w.mActivityRecord == null && w.canBeHiddenByKeyguard()
                    && w.wouldBeVisibleIfPolicyIgnored() && !w.isVisible()) {
                w.startAnimation(policy.createHiddenByKeyguardExit(
                        onWallpaper, goingToShade, subtle));
+2 −2
Original line number Diff line number Diff line
@@ -1738,7 +1738,7 @@ public class DisplayPolicy {
     * @param imeTarget The current IME target window.
     */
    private void applyKeyguardPolicy(WindowState win, WindowState imeTarget) {
        if (mService.mPolicy.canBeHiddenByKeyguardLw(win)) {
        if (win.canBeHiddenByKeyguard()) {
            if (shouldBeHiddenByKeyguard(win, imeTarget)) {
                win.hide(false /* doAnimation */, true /* requestAnim */);
            } else {
@@ -1767,7 +1767,7 @@ public class DisplayPolicy {
        // Show IME over the keyguard if the target allows it.
        final boolean showImeOverKeyguard = imeTarget != null && imeTarget.isVisible()
                && win.mIsImWindow && (imeTarget.canShowWhenLocked()
                        || !mService.mPolicy.canBeHiddenByKeyguardLw(imeTarget));
                        || !imeTarget.canBeHiddenByKeyguard());
        if (showImeOverKeyguard) {
            return false;
        }
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {
        final WindowManagerPolicy policy = service.mPolicy;
        service.mRoot.forAllWindows(nonAppWindow -> {
            // Animation on the IME window is controlled via Insets.
            if (nonAppWindow.mActivityRecord == null && policy.canBeHiddenByKeyguardLw(nonAppWindow)
            if (nonAppWindow.mActivityRecord == null && nonAppWindow.canBeHiddenByKeyguard()
                    && nonAppWindow.wouldBeVisibleIfPolicyIgnored() && !nonAppWindow.isVisible()
                    && nonAppWindow != service.mRoot.getCurrentInputMethodWindow()) {
                final NonAppWindowAnimationAdapter nonAppAdapter = new NonAppWindowAnimationAdapter(
+19 −2
Original line number Diff line number Diff line
@@ -1338,8 +1338,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        outFrame.set(0, 0, mWindowFrames.mCompatFrame.width(), mWindowFrames.mCompatFrame.height());
    }

    @Override
    public WindowManager.LayoutParams getAttrs() {
    WindowManager.LayoutParams getAttrs() {
        return mAttrs;
    }

@@ -3835,6 +3834,24 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return (mAttrs.insetsFlags.behavior & BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE) != 0;
    }

    boolean canBeHiddenByKeyguard() {
        // Keyguard visibility of window from activities are determined over activity visibility.
        if (mActivityRecord != null) {
            return false;
        }
        switch (mAttrs.type) {
            case TYPE_NOTIFICATION_SHADE:
            case TYPE_STATUS_BAR:
            case TYPE_NAVIGATION_BAR:
            case TYPE_WALLPAPER:
                return false;
            default:
                // Hide only windows below the keyguard host window.
                return mPolicy.getWindowLayerLw(this)
                        < mPolicy.getWindowLayerFromTypeLw(TYPE_NOTIFICATION_SHADE);
        }
    }

    private int getRootTaskId() {
        final Task rootTask = getRootTask();
        if (rootTask == null) {