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

Commit 911b04f0 authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Add forciblyShownTypes for privileged window to show insets forcibly" into udc-qpr-dev

parents 5e475c5d 0cb3e5c4
Loading
Loading
Loading
Loading
+22 −28
Original line number Diff line number Diff line
@@ -3138,15 +3138,6 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 1 << 10;

        /**
         * Flag to force the status bar window to be visible all the time. If the bar is hidden when
         * this flag is set it will be shown again.
         * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
         *
         * {@hide}
         */
        public static final int PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR = 1 << 11;

        /**
         * Flag to indicate that the window frame should be the requested frame adding the display
         * cutout frame. This will only be applied if a specific size smaller than the parent frame
@@ -3237,15 +3228,6 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_NOT_MAGNIFIABLE = 1 << 22;

        /**
         * Flag to indicate that the status bar window is in a state such that it forces showing
         * the navigation bar unless the navigation bar window is explicitly set to
         * {@link View#GONE}.
         * It only takes effects if this is set by {@link LayoutParams#TYPE_STATUS_BAR}.
         * @hide
         */
        public static final int PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION = 1 << 23;

        /**
         * Flag to indicate that the window is color space agnostic, and the color can be
         * interpreted to any color space.
@@ -3334,7 +3316,6 @@ public interface WindowManager extends ViewManager {
                PRIVATE_FLAG_SYSTEM_ERROR,
                PRIVATE_FLAG_OPTIMIZE_MEASURE,
                PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
                PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR,
                PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT,
                PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
                PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
@@ -3345,7 +3326,6 @@ public interface WindowManager extends ViewManager {
                PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
                PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION,
                PRIVATE_FLAG_NOT_MAGNIFIABLE,
                PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
                PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
                PRIVATE_FLAG_USE_BLAST,
                PRIVATE_FLAG_APPEARANCE_CONTROLLED,
@@ -3400,10 +3380,6 @@ public interface WindowManager extends ViewManager {
                        mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
                        equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
                        name = "DISABLE_WALLPAPER_TOUCH_EVENTS"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR,
                        equals = PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR,
                        name = "FORCE_STATUS_BAR_VISIBLE"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT,
                        equals = PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT,
@@ -3444,10 +3420,6 @@ public interface WindowManager extends ViewManager {
                        mask = PRIVATE_FLAG_NOT_MAGNIFIABLE,
                        equals = PRIVATE_FLAG_NOT_MAGNIFIABLE,
                        name = "NOT_MAGNIFIABLE"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
                        equals = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
                        name = "STATUS_FORCE_SHOW_NAVIGATION"),
                @ViewDebug.FlagToString(
                        mask = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
                        equals = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
@@ -4411,6 +4383,16 @@ public interface WindowManager extends ViewManager {
         */
        public InsetsFrameProvider[] providedInsets;

        /**
         * Specifies which {@link InsetsType}s should be forcibly shown. The types shown by this
         * method won't affect the app's layout. This field only takes effects if the caller has
         * {@link android.Manifest.permission#STATUS_BAR_SERVICE} or the caller has the same uid as
         * the recents component.
         *
         * @hide
         */
        public @InsetsType int forciblyShownTypes;

        /**
         * {@link LayoutParams} to be applied to the window when layout with a assigned rotation.
         * This will make layout during rotation change smoothly.
@@ -4869,6 +4851,7 @@ public interface WindowManager extends ViewManager {
            out.writeInt(mBlurBehindRadius);
            out.writeBoolean(mWallpaperTouchEventsEnabled);
            out.writeTypedArray(providedInsets, 0 /* parcelableFlags */);
            out.writeInt(forciblyShownTypes);
            checkNonRecursiveParams();
            out.writeTypedArray(paramsForRotation, 0 /* parcelableFlags */);
            out.writeInt(mDisplayFlags);
@@ -4940,6 +4923,7 @@ public interface WindowManager extends ViewManager {
            mBlurBehindRadius = in.readInt();
            mWallpaperTouchEventsEnabled = in.readBoolean();
            providedInsets = in.createTypedArray(InsetsFrameProvider.CREATOR);
            forciblyShownTypes = in.readInt();
            paramsForRotation = in.createTypedArray(LayoutParams.CREATOR);
            mDisplayFlags = in.readInt();
        }
@@ -5245,6 +5229,11 @@ public interface WindowManager extends ViewManager {
                changes |= LAYOUT_CHANGED;
            }

            if (forciblyShownTypes != o.forciblyShownTypes) {
                forciblyShownTypes = o.forciblyShownTypes;
                changes |= PRIVATE_FLAGS_CHANGED;
            }

            if (paramsForRotation != o.paramsForRotation) {
                if ((changes & LAYOUT_CHANGED) == 0) {
                    if (paramsForRotation != null && o.paramsForRotation != null
@@ -5482,6 +5471,11 @@ public interface WindowManager extends ViewManager {
                    sb.append(prefix).append("    ").append(providedInsets[i]);
                }
            }
            if (forciblyShownTypes != 0) {
                sb.append(System.lineSeparator());
                sb.append(prefix).append("  forciblyShownTypes=").append(
                        WindowInsets.Type.toString(forciblyShownTypes));
            }
            if (paramsForRotation != null && paramsForRotation.length != 0) {
                sb.append(System.lineSeparator());
                sb.append(prefix).append("  paramsForRotation:");
+3 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import android.view.IWindow;
import android.view.IWindowSession;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManagerGlobal;
@@ -401,9 +402,9 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW
    private void applyForceShowNavigationFlag(NotificationShadeWindowState state) {
        if (state.panelExpanded || state.bouncerShowing
                || ENABLE_REMOTE_INPUT && state.remoteInputActive) {
            mLpChanged.privateFlags |= LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
            mLpChanged.forciblyShownTypes |= WindowInsets.Type.navigationBars();
        } else {
            mLpChanged.privateFlags &= ~LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
            mLpChanged.forciblyShownTypes &= ~WindowInsets.Type.navigationBars();
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.view.WindowInsets.Type.statusBars;
import static android.view.WindowInsets.Type.tappableElement;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;

import static com.android.systemui.util.leak.RotationUtils.ROTATION_LANDSCAPE;
import static com.android.systemui.util.leak.RotationUtils.ROTATION_NONE;
@@ -44,6 +43,7 @@ import android.view.InsetsFrameProvider;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.WindowManager;

import com.android.internal.policy.SystemBarUtils;
@@ -361,9 +361,9 @@ public class StatusBarWindowController {
                || state.mIsLaunchAnimationRunning
                // Don't force-show the status bar if the user has already dismissed it.
                || state.mOngoingProcessRequiresStatusBarVisible) {
            mLpChanged.privateFlags |= PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
            mLpChanged.forciblyShownTypes |= WindowInsets.Type.statusBars();
        } else {
            mLpChanged.privateFlags &= ~PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
            mLpChanged.forciblyShownTypes &= ~WindowInsets.Type.statusBars();
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -269,6 +269,8 @@ public class DisplayPolicy {

    private boolean mIsFreeformWindowOverlappingWithNavBar;

    private @InsetsType int mForciblyShownTypes;

    private boolean mIsImmersiveMode;

    // The windows we were told about in focusChanged.
@@ -1402,6 +1404,7 @@ public class DisplayPolicy {
        mAllowLockscreenWhenOn = false;
        mShowingDream = false;
        mIsFreeformWindowOverlappingWithNavBar = false;
        mForciblyShownTypes = 0;
    }

    /**
@@ -1459,6 +1462,10 @@ public class DisplayPolicy {
            }
        }

        if (win.mSession.mCanForceShowingInsets) {
            mForciblyShownTypes |= win.mAttrs.forciblyShownTypes;
        }

        if (!affectsSystemUi) {
            return;
        }
@@ -1640,6 +1647,10 @@ public class DisplayPolicy {
        mService.mPolicy.setAllowLockscreenWhenOn(getDisplayId(), mAllowLockscreenWhenOn);
    }

    boolean areTypesForciblyShownTransiently(@InsetsType int types) {
        return (mForciblyShownTypes & types) == types;
    }

    /**
     * Applies the keyguard policy to a specific window.
     *
+3 −16
Original line number Diff line number Diff line
@@ -23,8 +23,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.view.InsetsSource.ID_IME;
import static android.view.WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;

import android.annotation.NonNull;
@@ -473,7 +471,7 @@ class InsetsPolicy {
            // we will dispatch the real visibility of status bar to the client.
            return mPermanentControlTarget;
        }
        if (forceShowsStatusBarTransiently() && !fake) {
        if (mPolicy.areTypesForciblyShownTransiently(Type.statusBars()) && !fake) {
            // Status bar is forcibly shown transiently, and its new visibility won't be
            // dispatched to the client so that we can keep the layout stable. We will dispatch the
            // fake control to the client, so that it can re-show the bar during this scenario.
@@ -505,7 +503,7 @@ class InsetsPolicy {
        if (imeWin != null && imeWin.isVisible() && !mHideNavBarForKeyboard) {
            // Force showing navigation bar while IME is visible and if navigation bar is not
            // configured to be hidden by the IME.
            return null;
            return mPermanentControlTarget;
        }
        if (!fake && isTransient(Type.navigationBars())) {
            return mTransientControlTarget;
@@ -533,7 +531,7 @@ class InsetsPolicy {
            // bar, and we will dispatch the real visibility of navigation bar to the client.
            return mPermanentControlTarget;
        }
        if (forceShowsNavigationBarTransiently() && !fake) {
        if (mPolicy.areTypesForciblyShownTransiently(Type.navigationBars()) && !fake) {
            // Navigation bar is forcibly shown transiently, and its new visibility won't be
            // dispatched to the client so that we can keep the layout stable. We will dispatch the
            // fake control to the client, so that it can re-show the bar during this scenario.
@@ -603,17 +601,6 @@ class InsetsPolicy {
                && focusedWin.getAttrs().type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
    }

    private boolean forceShowsStatusBarTransiently() {
        final WindowState win = mPolicy.getStatusBar();
        return win != null && (win.mAttrs.privateFlags & PRIVATE_FLAG_FORCE_SHOW_STATUS_BAR) != 0;
    }

    private boolean forceShowsNavigationBarTransiently() {
        final WindowState win = mPolicy.getNotificationShade();
        return win != null
                && (win.mAttrs.privateFlags & PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION) != 0;
    }

    private void dispatchTransientSystemBarsVisibilityChanged(
            @Nullable WindowState focusedWindow,
            boolean areVisible,
Loading