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

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

Merge changes I29521e80,I67a9fbb3

* changes:
  Clean up isVisibleLw and isDimming of WindowManagerPolicy#WindowState
  Clean up hideLw and showLw of WindowManagerPolicy#WindowState
parents 79f3adcf f9ca2d48
Loading
Loading
Loading
Loading
+0 −65
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.Manifest.permission.SYSTEM_ALERT_WINDOW;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.AppOpsManager.OP_TOAST_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.content.Context.CONTEXT_RESTRICTED;
import static android.content.Context.WINDOW_SERVICE;
import static android.content.pm.PackageManager.FEATURE_AUTOMOTIVE;
@@ -45,10 +44,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.LAST_SYSTEM_WINDOW;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
@@ -178,7 +175,6 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerPolicyConstants;
import android.view.accessibility.AccessibilityEvent;
@@ -603,8 +599,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    private final MutableBoolean mTmpBoolean = new MutableBoolean(false);

    private boolean mAodShowing;

    private boolean mPerDisplayFocusEnabled = false;
    private volatile int mTopFocusedDisplayId = INVALID_DISPLAY;

@@ -2267,44 +2261,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    private boolean shouldBeHiddenByKeyguard(WindowState win, WindowState imeTarget) {
        final LayoutParams attrs = win.getAttrs();

        boolean hideDockDivider = attrs.type == TYPE_DOCK_DIVIDER
                && !mWindowManagerInternal.isStackVisibleLw(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
        if (hideDockDivider) {
            return true;
        }

        // If AOD is showing, the IME should be hidden. However, sometimes the AOD is considered
        // hidden because it's in the process of hiding, but it's still being shown on screen.
        // In that case, we want to continue hiding the IME until the windows have completed
        // drawing. This way, we know that the IME can be safely shown since the other windows are
        // now shown.
        final boolean hideIme = win.isInputMethodWindow()
                && (mAodShowing || !mDefaultDisplayPolicy.isWindowManagerDrawComplete());
        if (hideIme) {
            return true;
        }

        final boolean showImeOverKeyguard = imeTarget != null && imeTarget.isVisibleLw()
                && (imeTarget.canShowWhenLocked() || !canBeHiddenByKeyguardLw(imeTarget));

        // Show IME over the keyguard if the target allows it
        boolean allowWhenLocked = win.isInputMethodWindow() && showImeOverKeyguard;

        final boolean isKeyguardShowing = mKeyguardDelegate.isShowing();

        if (isKeyguardShowing && isKeyguardOccluded()) {
            // Show SHOW_WHEN_LOCKED windows if Keyguard is occluded.
            allowWhenLocked |= win.canShowWhenLocked()
                    // Show error dialogs over apps that are shown on lockscreen
                    || (attrs.privateFlags & PRIVATE_FLAG_SYSTEM_ERROR) != 0;
        }

        return isKeyguardShowing && !allowWhenLocked && win.getDisplayId() == DEFAULT_DISPLAY;
    }

    /** {@inheritDoc} */
    @Override
    public StartingSurface addSplashScreen(IBinder appToken, String packageName, int theme,
@@ -3440,18 +3396,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mNavBarVirtualKeyHapticFeedbackEnabled = enabled;
    }

    /** {@inheritDoc} */
    @Override
    public void applyKeyguardPolicyLw(WindowState win, WindowState imeTarget) {
        if (canBeHiddenByKeyguardLw(win)) {
            if (shouldBeHiddenByKeyguard(win, imeTarget)) {
                win.hideLw(false /* doAnimation */);
            } else {
                win.showLw(false /* doAnimation */);
            }
        }
    }

    /** {@inheritDoc} */
    @Override
    public void setKeyguardCandidateLw(WindowState win) {
@@ -5636,15 +5580,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    @Override
    public boolean setAodShowing(boolean aodShowing) {
        if (mAodShowing != aodShowing) {
            mAodShowing = aodShowing;
            return true;
        }
        return false;
    }

    private class HdmiVideoExtconUEventObserver extends ExtconStateObserver<Boolean> {
        private static final String HDMI_EXIST = "HDMI=1";
        private static final String NAME = "hdmi";
+0 −48
Original line number Diff line number Diff line
@@ -206,45 +206,12 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
         */
        public IApplicationToken getAppToken();

        /**
         * Is this window visible?  It is not visible if there is no
         * surface, or we are in the process of running an exit animation
         * that will remove the surface.
         */
        boolean isVisibleLw();

        /**
         * Return true if this window (or a window it is attached to, but not
         * considering its app token) is currently animating.
         */
        boolean isAnimatingLw();

        /**
         * Can be called by the policy to force a window to be hidden,
         * regardless of whether the client or window manager would like
         * it shown.  Must be called with the window manager lock held.
         * Returns true if {@link #showLw} was last called for the window.
         */
        public boolean hideLw(boolean doAnimation);

        /**
         * Can be called to undo the effect of {@link #hideLw}, allowing a
         * window to be shown as long as the window manager and client would
         * also like it to be shown.  Must be called with the window manager
         * lock held.
         * Returns true if {@link #hideLw} was last called for the window.
         */
        public boolean showLw(boolean doAnimation);

        /**
         * Check whether the window is currently dimming.
         */
        public boolean isDimming();

        public boolean isInputMethodWindow();

        public int getDisplayId();

        /**
         * Returns true if the window owner can add internal system windows.
         * That is, they have {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}.
@@ -787,14 +754,6 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     */
    void setTopFocusedDisplay(int displayId);

    /**
     * Apply the keyguard policy to a specific window.
     *
     * @param win The window to apply the keyguard policy.
     * @param imeTarget The current IME target window.
     */
    void applyKeyguardPolicyLw(WindowState win, WindowState imeTarget);

    /**
     * Called when the state of allow-lockscreen-when-on of the display is changed. See
     * {@link WindowManager.LayoutParams#FLAG_ALLOW_LOCK_WHILE_SCREEN_ON}
@@ -1210,11 +1169,4 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     * A new window on default display has been focused.
     */
    default void onDefaultDisplayFocusChangedLw(WindowState newFocus) {}

    /**
     * Updates the flag about whether AOD is showing.
     *
     * @return whether the value was changed.
     */
    boolean setAodShowing(boolean aodShowing);
}
+3 −3
Original line number Diff line number Diff line
@@ -857,7 +857,7 @@ final class AccessibilityController {
            private void populateWindowsOnScreenLocked(SparseArray<WindowState> outWindows) {
                mTempLayer = 0;
                mDisplayContent.forAllWindows((w) -> {
                    if (w.isOnScreen() && w.isVisibleLw()
                    if (w.isOnScreen() && w.isVisible()
                            && (w.mAttrs.alpha != 0)) {
                        mTempLayer++;
                        outWindows.put(mTempLayer, w);
@@ -1517,7 +1517,7 @@ final class AccessibilityController {
            }

            dc.forAllWindows(w -> {
                if (w.isVisibleLw()) {
                if (w.isVisible()) {
                    tempWindowStatesList.add(w);
                }
            }, false /* traverseTopToBottom */);
@@ -1529,7 +1529,7 @@ final class AccessibilityController {
                    return;
                }

                if (w.isVisibleLw() && tempWindowStatesList.contains(parentWindow)) {
                if (w.isVisible() && tempWindowStatesList.contains(parentWindow)) {
                    tempWindowStatesList.add(tempWindowStatesList.lastIndexOf(parentWindow), w);
                }
            }, false /* traverseTopToBottom */);
+1 −1
Original line number Diff line number Diff line
@@ -760,7 +760,7 @@ public class AppTransitionController {
                ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
                        "New transit away from wallpaper: %s",
                                AppTransition.appTransitionOldToString(transit));
            } else if (wallpaperTarget != null && wallpaperTarget.isVisibleLw()
            } else if (wallpaperTarget != null && wallpaperTarget.isVisible()
                    && openingApps.contains(wallpaperTarget.mActivityRecord)
                    && topOpeningApp == wallpaperTarget.mActivityRecord
                    && transit != TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE) {
+6 −6
Original line number Diff line number Diff line
@@ -862,7 +862,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
        }

        if (obscuredChanged && w.isVisibleLw() && mWallpaperController.isWallpaperTarget(w)) {
        if (obscuredChanged && w.isVisible() && mWallpaperController.isWallpaperTarget(w)) {
            // This is the wallpaper target and its obscured state changed... make sure the
            // current wallpaper's visibility has been updated accordingly.
            mWallpaperController.updateWallpaperVisibility();
@@ -2584,7 +2584,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                return;
            }

            if (w.isOnScreen() && w.isVisibleLw() && w.getFrame().contains(x, y)) {
            if (w.isOnScreen() && w.isVisible() && w.getFrame().contains(x, y)) {
                targetWindowType[0] = w.mAttrs.type;
                return;
            }
@@ -2629,7 +2629,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                mTouchExcludeRegion.op(mTmpRect2, Region.Op.UNION);
            }
        }
        if (mInputMethodWindow != null && mInputMethodWindow.isVisibleLw()) {
        if (mInputMethodWindow != null && mInputMethodWindow.isVisible()) {
            // If the input method is visible and the user is typing, we don't want these touch
            // events to be intercepted and used to change focus. This would likely cause a
            // disappearance of the input method.
@@ -2638,7 +2638,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
        for (int i = mTapExcludedWindows.size() - 1; i >= 0; i--) {
            final WindowState win = mTapExcludedWindows.get(i);
            if (!win.isVisibleLw()) {
            if (!win.isVisible()) {
                continue;
            }
            win.getTouchableRegion(mTmpRegion);
@@ -2781,7 +2781,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    void adjustForImeIfNeeded() {
        final WindowState imeWin = mInputMethodWindow;
        final boolean imeVisible = imeWin != null && imeWin.isVisibleLw()
        final boolean imeVisible = imeWin != null && imeWin.isVisible()
                && imeWin.isDisplayed();
        final int imeHeight = mDisplayFrames.getInputMethodWindowVisibleHeight();
        mPinnedStackControllerLocked.setAdjustedForIme(imeVisible, imeHeight);
@@ -3068,7 +3068,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        final int y = (int) yf;
        final WindowState touchedWin = getWindow(w -> {
            final int flags = w.mAttrs.flags;
            if (!w.isVisibleLw()) {
            if (!w.isVisible()) {
                return false;
            }
            if ((flags & FLAG_NOT_TOUCHABLE) != 0) {
Loading