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

Commit c763dfe7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MediaProjection: Temporarily disable f/g service requirement."

parents 25f736b6 13c60c37
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import java.util.Map;
 */
public final class MediaProjectionManagerService extends SystemService
        implements Watchdog.Monitor {
    private static final boolean REQUIRE_FG_SERVICE_FOR_PROJECTION = false;
    private static final String TAG = "MediaProjectionManagerService";

    private final Object mLock = new Object(); // Protects the list of media projections
@@ -100,6 +101,7 @@ public final class MediaProjectionManagerService extends SystemService
                false /*allowIsolated*/);
        mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY, mMediaRouterCallback,
                MediaRouter.CALLBACK_FLAG_PASSIVE_DISCOVERY);
        if (REQUIRE_FG_SERVICE_FOR_PROJECTION) {
            mActivityManagerInternal.registerProcessObserver(new IProcessObserver.Stub() {
                @Override
                public void onForegroundActivitiesChanged(int pid, int uid, boolean fg) {
@@ -116,6 +118,7 @@ public final class MediaProjectionManagerService extends SystemService
                }
            });
        }
    }

    @Override
    public void onSwitchUser(int userId) {
@@ -462,7 +465,8 @@ public final class MediaProjectionManagerService extends SystemService
                    return;
                }

                if (targetSdkVersion >= Build.VERSION_CODES.Q
                if (REQUIRE_FG_SERVICE_FOR_PROJECTION
                        && targetSdkVersion >= Build.VERSION_CODES.Q
                        && !mActivityManagerInternal.hasRunningForegroundService(
                                uid, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION)) {
                    throw new SecurityException("Media projections require a foreground service"