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

Commit 90c0b155 authored by Jing Ji's avatar Jing Ji
Browse files

Track the media projection FGS types per UID

The apps with active media projection should have a foreground
service with the type "mediaProjection" - the condition here is,
any process with such a FGS within this app would be sufficient,
it doesn't necessarily need to be in the same process with the
active media projection serssion.

Bug: 229699207
Test: atest CtsMediaProjectionTestCases:MediaProjectionManagerTest
Test: atest CtsMediaProjectionTestCases:MediaProjectionTest
Test: atest FrameworksServicesTests:MediaProjectionManagerServiceTest
Test: atest FrameworksServicesTests:DisplayManagerServiceTest
Change-Id: I015d2adc67f9e3d304281f4c9106ceced6d99a02
parent d06a6b54
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -18201,16 +18201,17 @@ public class ActivityManagerService extends IActivityManager.Stub
        @Override
        public boolean hasRunningForegroundService(int uid, int foregroundServicetype) {
            synchronized (ActivityManagerService.this) {
                return mProcessList.searchEachLruProcessesLOSP(true, app -> {
                    if (app.uid != uid) {
                        return null;
                final UidRecord uidRec = mProcessList.mActiveUids.get(uid);
                if (uidRec == null) {
                    return false;
                }
                for (int i = uidRec.getNumOfProcs() - 1; i >= 0; i--) {
                    final ProcessRecord app = uidRec.getProcessRecordByIndex(i);
                    if ((app.mServices.containsAnyForegroundServiceTypes(foregroundServicetype))) {
                        return Boolean.TRUE;
                        return true;
                    }
                    return null;
                }) != null;
                }
                return false;
            }
        }
+4 −1
Original line number Diff line number Diff line
@@ -232,7 +232,10 @@ public final class MediaProjectionManagerService extends SystemService
                return;
            }

            if ((serviceTypes & ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION) != 0) {
            if (mActivityManagerInternal.hasRunningForegroundService(
                    uid, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)) {
                // If there is any process within this UID running a FGS
                // with the mediaProjection type, that's Okay.
                return;
            }