summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Li <dualli@google.com>2023-10-16 16:04:30 -0700
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-10-23 22:36:55 +0000
commit157a391419962f794ffa86dd3b13ac06b180068b (patch)
tree73c452fda63b35c784d6e680ec9990e12f4539d7
parent8f74745e0a069c53bab4217baf4d4ec96e049c7b (diff)
downloadbase-157a391419962f794ffa86dd3b13ac06b180068b.tar.gz
DMS: check cached mode for user apps only
Android Studio uses adb to launch a process for screen mirroring. This kind of processes is not managed by AMS and run with uid shell or root. In such a case, that process behaves like a gone Android app so it will miss display events. This won't impact any normal Android apps. Check if the uid belongs to an Android app for Android Studio. Bug: 303684492 Test: Enable display mirroring in Android Studio and check logs (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:380b3932bda7ad87f3180b8f1949d7b2b710b9d6) Merged-In: I3fb20327979eca8774f7ddf143b2b8f2386e6b56 Change-Id: I3fb20327979eca8774f7ddf143b2b8f2386e6b56
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index 6466b440b3a0..bc7e15635035 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2868,7 +2868,16 @@ public final class DisplayManagerService extends SystemService {
// Check if the target app is in cached mode
private boolean isUidCached(int uid) {
- if (mActivityManagerInternal == null) {
+ // Only query procState and importance for Android apps, which have UIDs starting
+ // from FIRST_APPLICATION_UID. .
+ //
+ // Other processes with UID < FIRST_APPLICATION_UID can also register to DMS for
+ // display events. E.g. Android Studio executes a screen sharing process to provide
+ // display mirroring functionality. That process inherits the UID of adb. Depending
+ // on adb mode, it can be shell (2000) or root (0). Those processes are not Android
+ // apps and not managed by AMS. Treat them as non-cached so never ignore or defer
+ // display events to them.
+ if (mActivityManagerInternal == null || uid < FIRST_APPLICATION_UID) {
return false;
}
int procState = mActivityManagerInternal.getUidProcessState(uid);