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

Commit 11cd1868 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 am: 40821208

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



Change-Id: I972dec461530b78556c83e84aecba38ff49495eb
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 86f1914c 40821208
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -951,6 +951,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 = () -> {
@@ -995,11 +998,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