diff options
| author | lumark <lumark@google.com> | 2019-01-07 15:58:38 +0800 |
|---|---|---|
| committer | lumark <lumark@google.com> | 2019-03-04 14:59:41 +0800 |
| commit | ec75b42179579f6c7fedb91629c372b05cf278f7 (patch) | |
| tree | 2aea4b44053986413d6916902337c07673e5dcbe /core/java/android/view/Display.java | |
| parent | 5af401bd35a188a4a8c928f66993bf2c22247f2c (diff) | |
Add the check for UID presence to Display#hasAccess()
It would be nice if there is a common & reliable method for both outer
& internal modules to check the UID presense of the display.
Add more check in Display#hasAccess() to ask system if calling UID can
precense on the specific display, to consolidate only few special UIDs
& display flag checking.
Bug: 117347985
Test: atest ActivityManagerMultiDisplayTests
Change-Id: I2f8989598c99c0962e925c5aa65500972b4fc62b
Diffstat (limited to 'core/java/android/view/Display.java')
| -rw-r--r-- | core/java/android/view/Display.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java index dbb207196f15..b3d98b8de0a3 100644 --- a/core/java/android/view/Display.java +++ b/core/java/android/view/Display.java @@ -21,6 +21,7 @@ import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.RequiresPermission; +import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.app.KeyguardManager; import android.content.res.CompatibilityInfo; @@ -1096,16 +1097,19 @@ public final class Display { * Returns true if the specified UID has access to this display. * @hide */ + @TestApi public boolean hasAccess(int uid) { - return Display.hasAccess(uid, mFlags, mOwnerUid); + return hasAccess(uid, mFlags, mOwnerUid, mDisplayId); } /** @hide */ - public static boolean hasAccess(int uid, int flags, int ownerUid) { + public static boolean hasAccess(int uid, int flags, int ownerUid, int displayId) { return (flags & Display.FLAG_PRIVATE) == 0 || uid == ownerUid || uid == Process.SYSTEM_UID - || uid == 0; + || uid == 0 + // Check if the UID is present on given display. + || DisplayManagerGlobal.getInstance().isUidPresentOnDisplay(uid, displayId); } /** |
