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

Commit 380b3932 authored by Li Li's avatar Li Li
Browse files

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
Change-Id: I3fb20327979eca8774f7ddf143b2b8f2386e6b56
Merged-In: I3fb20327979eca8774f7ddf143b2b8f2386e6b56
parent 64a1987b
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line Diff line number Diff line
@@ -2868,7 +2868,16 @@ public final class DisplayManagerService extends SystemService {


    // Check if the target app is in cached mode
    // Check if the target app is in cached mode
    private boolean isUidCached(int uid) {
    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;
            return false;
        }
        }
        int procState = mActivityManagerInternal.getUidProcessState(uid);
        int procState = mActivityManagerInternal.getUidProcessState(uid);