Merge "(3/N)[MediaProjection] Fix NPE on IMediaProjection" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a262e87a4a
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user