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

Commit cf5732e9 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Move canBeHiddenByKeyguardLw and correct its condition for activity"

parents eb867fde 009bc0ac
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
@@ -4301,7 +4301,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
@@ -1337,8 +1337,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;
    }

@@ -3830,6 +3829,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) {