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

Commit 016f891c authored by Linus Tufvesson's avatar Linus Tufvesson Committed by Android (Google) Code Review
Browse files

Merge "Allow 3p apps to hide non system overlay windows"

parents 02465ca6 f57a88f0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ package android {
    field public static final String GET_PACKAGE_SIZE = "android.permission.GET_PACKAGE_SIZE";
    field @Deprecated public static final String GET_TASKS = "android.permission.GET_TASKS";
    field public static final String GLOBAL_SEARCH = "android.permission.GLOBAL_SEARCH";
    field public static final String HIDE_OVERLAY_WINDOWS = "android.permission.HIDE_OVERLAY_WINDOWS";
    field public static final String INSTALL_LOCATION_PROVIDER = "android.permission.INSTALL_LOCATION_PROVIDER";
    field public static final String INSTALL_PACKAGES = "android.permission.INSTALL_PACKAGES";
    field public static final String INSTALL_SHORTCUT = "com.android.launcher.permission.INSTALL_SHORTCUT";
@@ -49424,6 +49425,7 @@ package android.view {
    method public void setFlags(int, int);
    method public void setFormat(int);
    method public void setGravity(int);
    method @RequiresPermission(android.Manifest.permission.HIDE_OVERLAY_WINDOWS) public final void setHideOverlayWindows(boolean);
    method public void setIcon(@DrawableRes int);
    method public void setLayout(int, int);
    method public void setLocalFocus(boolean, boolean);
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ package android {
    field public static final String HANDLE_CAR_MODE_CHANGES = "android.permission.HANDLE_CAR_MODE_CHANGES";
    field public static final String HARDWARE_TEST = "android.permission.HARDWARE_TEST";
    field public static final String HDMI_CEC = "android.permission.HDMI_CEC";
    field public static final String HIDE_NON_SYSTEM_OVERLAY_WINDOWS = "android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS";
    field @Deprecated public static final String HIDE_NON_SYSTEM_OVERLAY_WINDOWS = "android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS";
    field public static final String INJECT_EVENTS = "android.permission.INJECT_EVENTS";
    field public static final String INSTALL_DYNAMIC_SYSTEM = "android.permission.INSTALL_DYNAMIC_SYSTEM";
    field public static final String INSTALL_GRANT_RUNTIME_PERMISSIONS = "android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS";
+25 −0
Original line number Diff line number Diff line
@@ -16,7 +16,11 @@

package android.view;

import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
import static android.Manifest.permission.HIDE_OVERLAY_WINDOWS;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.annotation.ColorInt;
import android.annotation.DrawableRes;
@@ -24,6 +28,7 @@ import android.annotation.IdRes;
import android.annotation.LayoutRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.StyleRes;
import android.annotation.SystemApi;
import android.annotation.TestApi;
@@ -990,6 +995,26 @@ public abstract class Window {
        mRestrictedCaptionAreaRect = listener != null ? new Rect() : null;
    }

    /**
     * Prevent non-system overlay windows from being drawn on top of this window.
     *
     * @param hide whether non-system overlay windows should be hidden.
     */
    @RequiresPermission(HIDE_OVERLAY_WINDOWS)
    public final void setHideOverlayWindows(boolean hide) {
        // This permission check is here to throw early and let the developer know that they need
        // to hold HIDE_OVERLAY_WINDOWS for the flag to have any effect. The WM verifies that the
        // owner of the window has the permission before applying the flag, but this is done
        // asynchronously.
        if (mContext.checkSelfPermission(HIDE_NON_SYSTEM_OVERLAY_WINDOWS) != PERMISSION_GRANTED
                && mContext.checkSelfPermission(HIDE_OVERLAY_WINDOWS) != PERMISSION_GRANTED) {
            throw new SecurityException(
                    "Permission denial: setHideOverlayWindows: HIDE_OVERLAY_WINDOWS");
        }
        setPrivateFlags(hide ? SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS : 0,
                SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
    }

    /**
     * Take ownership of this window's surface.  The window's view hierarchy
     * will no longer draw into the surface, though it will otherwise continue
+5 −0
Original line number Diff line number Diff line
@@ -2732,6 +2732,10 @@
    <permission android:name="android.permission.TOGGLE_AUTOMOTIVE_PROJECTION"
                android:protectionLevel="signature|privileged" />

    <!-- Allows an app to prevent non-system-overlay windows from being drawn on top of it -->
    <permission android:name="android.permission.HIDE_OVERLAY_WINDOWS"
                android:protectionLevel="normal" />

    <!-- ================================== -->
    <!-- Permissions affecting the system wallpaper -->
    <!-- ================================== -->
@@ -3286,6 +3290,7 @@
         {@link android.view.WindowManager.LayoutsParams#SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS}
         to hide non-system-overlay windows.
         <p>Not for use by third-party applications.
         @deprecated Use {@link android.Manifest.permission#HIDE_OVERLAY_WINDOWS} instead
         @hide
    -->
    <permission android:name="android.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS"
+3 −0
Original line number Diff line number Diff line
@@ -364,6 +364,9 @@
    <!-- Permissions required for CTS tests to close system dialogs -->
    <uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />

    <!-- Permission required for CTS test - HideOverlayWindowsTest -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <application android:label="@string/app_label"
                android:theme="@android:style/Theme.DeviceDefault.DayNight"
                android:defaultToDeviceProtectedStorage="true"
Loading