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

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

Merge "(3/N)[MediaProjection] Fix NPE on IMediaProjection" into udc-dev am: a262e87a

parents 92a868d1 a262e87a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -395,8 +395,8 @@ public final class MediaProjectionManagerService extends SystemService
        synchronized (mLock) {
            final boolean consentGranted =
                    consentResult == RECORD_CONTENT_DISPLAY || consentResult == RECORD_CONTENT_TASK;
            if (consentGranted && projection == null || !isCurrentProjection(
                    projection.asBinder())) {
            if (consentGranted && !isCurrentProjection(
                    projection == null ? null : projection.asBinder())) {
                Slog.v(TAG, "Reusing token: Ignore consent result of " + consentResult + " for a "
                        + "token that isn't current");
                return;
+19 −0
Original line number Diff line number Diff line
@@ -445,6 +445,25 @@ public class MediaProjectionManagerServiceTest {
                eq(mWaitingDisplaySession));
    }

    @Test
    public void testSetUserReviewGrantedConsentResult_projectionNull_consentNotGranted()
            throws Exception {
        MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();
        projection.start(mIMediaProjectionCallback);
        assertThat(mService.isCurrentProjection(projection)).isTrue();
        doReturn(true).when(mWindowManagerInternal).setContentRecordingSession(
                any(ContentRecordingSession.class));
        // Some other token.
        final IMediaProjection otherProjection = null;
        // Waiting for user to review consent.
        mService.setContentRecordingSession(mWaitingDisplaySession);
        mService.setUserReviewGrantedConsentResult(RECORD_CANCEL, otherProjection);

        // Display result is ignored; only the first session is set.
        verify(mWindowManagerInternal, times(1)).setContentRecordingSession(
                eq(mWaitingDisplaySession));
    }

    @Test
    public void testSetUserReviewGrantedConsentResult_noVirtualDisplay() throws Exception {
        MediaProjectionManagerService.MediaProjection projection = startProjectionPreconditions();