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

Commit b28fb721 authored by Charles Chen's avatar Charles Chen
Browse files

Trust System UI owned display to receive keys

A11y service cannot get focus of bubbles because it's not a
System owned display. This patch makes System UI owned display
a trusted display. Moreover, this patch refactors the logic to
identify a trusted display by introducing FLAG_TRUSTED and
removes the trusted display check along with supportsSystemDecorations()
because the check has been included in supportsSystemDecorations().

fixes: 155823002
Bug: 152416787
Test: atest DisplayContentTests
Test: atest WindowFocusTests
Test: atest TaskDisplayAreaTests
Test: atest MultiDisplaySystemDecorationTests
Test: atest DisplayTest
Change-Id: Ie684c6488904e5aa8cae166a455c6d55455e5f55
parent 316f0d36
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -5103,6 +5103,7 @@ package android.view {
    method @NonNull public android.graphics.ColorSpace[] getSupportedWideColorGamut();
    method @NonNull public android.graphics.ColorSpace[] getSupportedWideColorGamut();
    method public int getType();
    method public int getType();
    method public boolean hasAccess(int);
    method public boolean hasAccess(int);
    field public static final int FLAG_TRUSTED = 128; // 0x80
    field public static final int TYPE_EXTERNAL = 2; // 0x2
    field public static final int TYPE_EXTERNAL = 2; // 0x2
    field public static final int TYPE_INTERNAL = 1; // 0x1
    field public static final int TYPE_INTERNAL = 1; // 0x1
    field public static final int TYPE_OVERLAY = 4; // 0x4
    field public static final int TYPE_OVERLAY = 4; // 0x4
+12 −0
Original line number Original line Diff line number Diff line
@@ -303,13 +303,25 @@ public final class DisplayManager {
    /**
    /**
     * Virtual display flag: Indicates that the display should support system decorations. Virtual
     * Virtual display flag: Indicates that the display should support system decorations. Virtual
     * displays without this flag shouldn't show home, IME or any other system decorations.
     * displays without this flag shouldn't show home, IME or any other system decorations.
     * <p>This flag doesn't work without {@link #VIRTUAL_DISPLAY_FLAG_TRUSTED}</p>
     *
     *
     * @see #createVirtualDisplay
     * @see #createVirtualDisplay
     * @see #VIRTUAL_DISPLAY_FLAG_TRUSTED
     * @hide
     * @hide
     */
     */
    // TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
    // TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
    public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 9;
    public static final int VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 9;


    /**
     * Virtual display flags: Indicates that the display is trusted to show system decorations and
     * receive inputs without users' touch.
     *
     * @see #createVirtualDisplay
     * @see #VIRTUAL_DISPLAY_FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
     * @hide
     */
    public static final int VIRTUAL_DISPLAY_FLAG_TRUSTED = 1 << 10;

    /** @hide */
    /** @hide */
    public DisplayManager(Context context) {
    public DisplayManager(Context context) {
        mContext = context;
        mContext = context;
+24 −0
Original line number Original line Diff line number Diff line
@@ -241,12 +241,25 @@ public final class Display {
     * This flag identifies secondary displays that should show system decorations, such as status
     * This flag identifies secondary displays that should show system decorations, such as status
     * bar, navigation bar, home activity or IME.
     * bar, navigation bar, home activity or IME.
     * </p>
     * </p>
     * <p>Note that this flag doesn't work without {@link #FLAG_TRUSTED}</p>
     *
     *
     * @see #getFlags()
     * @hide
     * @hide
     */
     */
    // TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
    // TODO (b/114338689): Remove the flag and use IWindowManager#setShouldShowSystemDecors
    public static final int FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 6;
    public static final int FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS = 1 << 6;


    /**
     * Flag: The display is trusted to show system decorations and receive inputs without users'
     * touch.
     * @see #FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
     *
     * @see #getFlags()
     * @hide
     */
    @TestApi
    public static final int FLAG_TRUSTED = 1 << 7;

    /**
    /**
     * Display flag: Indicates that the contents of the display should not be scaled
     * Display flag: Indicates that the contents of the display should not be scaled
     * to fit the physical screen dimensions.  Used for development only to emulate
     * to fit the physical screen dimensions.  Used for development only to emulate
@@ -564,6 +577,7 @@ public final class Display {
     * @see #FLAG_SUPPORTS_PROTECTED_BUFFERS
     * @see #FLAG_SUPPORTS_PROTECTED_BUFFERS
     * @see #FLAG_SECURE
     * @see #FLAG_SECURE
     * @see #FLAG_PRIVATE
     * @see #FLAG_PRIVATE
     * @see #FLAG_ROUND
     */
     */
    public int getFlags() {
    public int getFlags() {
        return mFlags;
        return mFlags;
@@ -1222,6 +1236,16 @@ public final class Display {
                Display.FLAG_PRESENTATION;
                Display.FLAG_PRESENTATION;
    }
    }


    /**
     * @return {@code true} if the display is a trusted display.
     *
     * @see #FLAG_TRUSTED
     * @hide
     */
    public boolean isTrusted() {
        return (mFlags & FLAG_TRUSTED) == FLAG_TRUSTED;
    }

    private void updateDisplayInfoLocked() {
    private void updateDisplayInfoLocked() {
        // Note: The display manager caches display info objects on our behalf.
        // Note: The display manager caches display info objects on our behalf.
        DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId);
        DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId);
+9 −0
Original line number Original line Diff line number Diff line
@@ -717,6 +717,15 @@ public final class DisplayInfo implements Parcelable {
        if ((flags & Display.FLAG_ROUND) != 0) {
        if ((flags & Display.FLAG_ROUND) != 0) {
            result.append(", FLAG_ROUND");
            result.append(", FLAG_ROUND");
        }
        }
        if ((flags & Display.FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0) {
            result.append(", FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD");
        }
        if ((flags & Display.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0) {
            result.append(", FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS");
        }
        if ((flags & Display.FLAG_TRUSTED) != 0) {
            result.append(", FLAG_TRUSTED");
        }
        return result.toString();
        return result.toString();
    }
    }
}
}
+4 −0
Original line number Original line Diff line number Diff line
@@ -5026,6 +5026,10 @@
    <permission android:name="android.permission.ACCESS_TV_DESCRAMBLER"
    <permission android:name="android.permission.ACCESS_TV_DESCRAMBLER"
        android:protectionLevel="signature|privileged|vendorPrivileged" />
        android:protectionLevel="signature|privileged|vendorPrivileged" />


    <!-- Allows an application to create trusted displays. @hide -->
    <permission android:name="android.permission.ADD_TRUSTED_DISPLAY"
                android:protectionLevel="signature" />

    <!-- @hide @SystemApi Allows an application to access locusId events in the usage stats. -->
    <!-- @hide @SystemApi Allows an application to access locusId events in the usage stats. -->
    <permission android:name="android.permission.ACCESS_LOCUS_ID_USAGE_STATS"
    <permission android:name="android.permission.ACCESS_LOCUS_ID_USAGE_STATS"
                android:protectionLevel="signature|appPredictor" />
                android:protectionLevel="signature|appPredictor" />
Loading