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

Commit 40821208 authored by Naomi Musgrave's avatar Naomi Musgrave Committed by Automerger Merge Worker
Browse files

Merge "Revert "Stop active MediaProjection callbacks before registering new...

Merge "Revert "Stop active MediaProjection callbacks before registering new callbacks"" into udc-qpr-dev am: 97e3f828

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24759513



Change-Id: I903b2b064a4cc185e2d1a51c9844a9a4a2ead8ed
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 5a9291a4 97e3f828
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -975,6 +975,9 @@ public final class MediaProjectionManagerService extends SystemService
                    throw new SecurityException("Media projections require a foreground service"
                            + " of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION");
                }

                mCallback = callback;
                registerCallback(mCallback);
                try {
                    mToken = callback.asBinder();
                    mDeathEater = () -> {
@@ -1019,11 +1022,6 @@ public final class MediaProjectionManagerService extends SystemService
                    }
                }
                startProjectionLocked(this);

                // Register new callbacks after stop has been dispatched to previous session.
                mCallback = callback;
                registerCallback(mCallback);

                // Mark this token as used when the app gets the MediaProjection instance.
                mCountStarts++;
            }
+0 −21
Original line number Diff line number Diff line
@@ -201,24 +201,6 @@ public class MediaProjectionManagerServiceTest {
        assertThat(secondProjection).isNotEqualTo(projection);
    }

    @Test
    public void testCreateProjection_priorProjectionGrant() throws NameNotFoundException {
        // Create a first projection.
        MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
        FakeIMediaProjectionCallback callback1 = new FakeIMediaProjectionCallback();
        projection.start(callback1);

        // Create a second projection.
        MediaProjectionManagerService.MediaProjection secondProjection =
                startProjectionPreconditions();
        FakeIMediaProjectionCallback callback2 = new FakeIMediaProjectionCallback();
        secondProjection.start(callback2);

        // Check that the second projection's callback hasn't been stopped.
        assertThat(callback1.mStopped).isTrue();
        assertThat(callback2.mStopped).isFalse();
    }

    @Test
    public void testCreateProjection_attemptReuse_noPriorProjectionGrant()
            throws NameNotFoundException {
@@ -803,11 +785,8 @@ public class MediaProjectionManagerServiceTest {
    }

    private static class FakeIMediaProjectionCallback extends IMediaProjectionCallback.Stub {
        boolean mStopped = false;

        @Override
        public void onStop() throws RemoteException {
            mStopped = true;
        }

        @Override