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

Commit 0ea02e61 authored by Naomi Musgrave's avatar Naomi Musgrave Committed by Android (Google) Code Review
Browse files

Revert "Stop active MediaProjection callbacks before registering new callbacks"

This reverts commit 1bc7a325.

Reason for revert: b/300463606 test failure blocking presubmit

Change-Id: I32a87ae52cb7ba793f93fecb18f8ac3bf229984d
parent 1bc7a325
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