Loading services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading
services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -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; Loading
services/tests/servicestests/src/com/android/server/media/projection/MediaProjectionManagerServiceTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading