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

Commit 093c7a8e authored by Phil Weaver's avatar Phil Weaver Committed by Android (Google) Code Review
Browse files

Merge "Back-port fixes for b/62196835" into mnc-dev

parents 5d46833d d4a5fd1c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ package android {
    field public static final java.lang.String GLOBAL_SEARCH = "android.permission.GLOBAL_SEARCH";
    field public static final java.lang.String HARDWARE_TEST = "android.permission.HARDWARE_TEST";
    field public static final java.lang.String HDMI_CEC = "android.permission.HDMI_CEC";
    field public static final java.lang.String HIDE_NON_SYSTEM_OVERLAY_WINDOWS = "android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS";
    field public static final java.lang.String INJECT_EVENTS = "android.permission.INJECT_EVENTS";
    field public static final java.lang.String INSTALL_GRANT_RUNTIME_PERMISSIONS = "android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS";
    field public static final java.lang.String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER";
+28 −0
Original line number Diff line number Diff line
@@ -569,6 +569,25 @@ public interface WindowManager extends ViewManager {
         */
        public static final int LAST_SYSTEM_WINDOW      = 2999;

        /**
         * Return true if the window type is an alert window.
         *
         * @param type The window type.
         * @return If the window type is an alert window.
         * @hide
         */
        public static boolean isSystemAlertWindowType(int type) {
            switch (type) {
                case TYPE_PHONE:
                case TYPE_PRIORITY_PHONE:
                case TYPE_SYSTEM_ALERT:
                case TYPE_SYSTEM_ERROR:
                case TYPE_SYSTEM_OVERLAY:
                    return true;
            }
            return false;
        }

        /** @deprecated this is ignored, this value is set automatically when needed. */
        @Deprecated
        public static final int MEMORY_TYPE_NORMAL = 0;
@@ -1127,6 +1146,15 @@ public interface WindowManager extends ViewManager {
         */
        public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;

        /**
         * Flag to indicate that any window added by an application process that is of type
         * {@link #TYPE_TOAST} or that requires
         * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when
         * this window is visible.
         * @hide
         */
        public static final int PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000;

        /**
         * Control flags that are private to the platform.
         * @hide
+9 −0
Original line number Diff line number Diff line
@@ -1845,6 +1845,15 @@
    <permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"
        android:protectionLevel="signature" />

    <!-- @SystemApi Allows an application to use
        {@link android.view.WindowManager.LayoutsParams#PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS}
        to hide non-system-overlay windows.
        <p>Not for use by third-party applications.
        @hide
    -->
    <permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"
        android:protectionLevel="signature|installer" />

    <!-- @SystemApi Allows an application to manage (create, destroy,
         Z-order) application tokens in the window manager.
         <p>Not for use by third-party applications.
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package com.android.server.wm;

import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import android.view.IWindowId;
import android.view.IWindowSessionCallback;
import com.android.internal.view.IInputContext;
@@ -61,6 +65,8 @@ final class Session extends IWindowSession.Stub
    final int mUid;
    final int mPid;
    final String mStringName;
    final boolean mCanAddInternalSystemWindow;
    final boolean mCanHideNonSystemOverlayWindows;
    SurfaceSession mSurfaceSession;
    int mNumWindow = 0;
    boolean mClientDead = false;
@@ -74,6 +80,10 @@ final class Session extends IWindowSession.Stub
        mInputContext = inputContext;
        mUid = Binder.getCallingUid();
        mPid = Binder.getCallingPid();
        mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission(
                INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED;
        mCanHideNonSystemOverlayWindows = service.mContext.checkCallingOrSelfPermission(
                HIDE_NON_SYSTEM_OVERLAY_WINDOWS) == PERMISSION_GRANTED;
        mLastReportedAnimatorScale = service.getCurrentAnimatorScale();
        StringBuilder sb = new StringBuilder();
        sb.append("Session{");
+37 −0
Original line number Diff line number Diff line
@@ -415,6 +415,9 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    final ArrayList<WindowState> mForceRemoves = new ArrayList<>();
    /** List of window currently causing non-system overlay windows to be hidden. */
    private ArrayList<WindowState> mHidingNonSystemOverlayWindows = new ArrayList<WindowState>();
    /**
     * Windows that clients are waiting to have drawn.
     */
@@ -2551,6 +2554,9 @@ public class WindowManagerService extends IWindowManager.Stub
                }
            }
            final boolean hideSystemAlertWindows = !mHidingNonSystemOverlayWindows.isEmpty();
            win.setForceHideNonSystemOverlayWindowIfNeeded(hideSystemAlertWindows);
            if (type == TYPE_APPLICATION_STARTING && token.appWindowToken != null) {
                token.appWindowToken.startingWindow = win;
                if (DEBUG_STARTING_WINDOW) Slog.v (TAG, "addWindow: " + token.appWindowToken
@@ -2833,6 +2839,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mPendingRemove.remove(win);
        mResizingWindows.remove(win);
        updateNonSystemOverlayWindowsVisibilityIfNeeded(win, false /* surfaceShown */);
        mWindowsChanged = true;
        if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG, "Final remove of window: " + win);
@@ -11856,6 +11863,36 @@ public class WindowManagerService extends IWindowManager.Stub
        return mWindowMap;
    }
    void updateNonSystemOverlayWindowsVisibilityIfNeeded(WindowState win, boolean surfaceShown) {
        if (!win.hideNonSystemOverlayWindowsWhenVisible()) {
            return;
        }
        final boolean systemAlertWindowsHidden = !mHidingNonSystemOverlayWindows.isEmpty();
        if (surfaceShown) {
            if (!mHidingNonSystemOverlayWindows.contains(win)) {
                mHidingNonSystemOverlayWindows.add(win);
            }
        } else {
            mHidingNonSystemOverlayWindows.remove(win);
        }
        final boolean hideSystemAlertWindows = !mHidingNonSystemOverlayWindows.isEmpty();
        if (systemAlertWindowsHidden == hideSystemAlertWindows) {
            return;
        }
        final int numDisplays = mDisplayContents.size();
        for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
            final WindowList windows = mDisplayContents.valueAt(displayNdx).getWindowList();
            final int numWindows = windows.size();
            for (int winNdx = 0; winNdx < numWindows; ++winNdx) {
                final WindowState w = windows.get(winNdx);
                w.setForceHideNonSystemOverlayWindowIfNeeded(hideSystemAlertWindows);
            }
        }
    }
    private final class LocalService extends WindowManagerInternal {
        @Override
        public void requestTraversalFromDisplayManager() {
Loading