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

Commit 13c60c37 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

MediaProjection: Temporarily disable f/g service requirement.

This new behaviour is gated on targeting Q, which breaks a few
use cases for apps that have recently started targeting Q. Temporarily
relax this requirement until we can address these breakages.

Test: manual
Bug: 124753835
Change-Id: I87616d85eed308eea10f0b0bf2e742b95de03701
parent 8180db88
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"