Loading packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/RecordingServiceTest.java +8 −7 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ public class RecordingServiceTest extends SysuiTestCase { public void testOnSystemRequestedStop_recordingInProgress_endsRecording() throws IOException { doReturn(true).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mScreenMediaRecorder).end(eq(StopReason.STOP_UNKNOWN)); } Loading @@ -209,7 +209,7 @@ public class RecordingServiceTest extends SysuiTestCase { public void testOnSystemRequestedStop_recordingInProgress_updatesState() { doReturn(true).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); assertUpdateState(false); } Loading @@ -219,7 +219,7 @@ public class RecordingServiceTest extends SysuiTestCase { throws IOException { doReturn(false).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mScreenMediaRecorder, never()).end(StopReason.STOP_UNKNOWN); } Loading @@ -230,7 +230,7 @@ public class RecordingServiceTest extends SysuiTestCase { doReturn(true).when(mController).isRecording(); doThrow(new RuntimeException()).when(mScreenMediaRecorder).end(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mScreenMediaRecorder).release(); } Loading @@ -239,7 +239,7 @@ public class RecordingServiceTest extends SysuiTestCase { public void testOnSystemRequestedStop_whenRecordingInProgress_showsNotifications() { doReturn(true).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); // Processing notification ArgumentCaptor<Notification> notifCaptor = ArgumentCaptor.forClass(Notification.class); Loading Loading @@ -274,7 +274,7 @@ public class RecordingServiceTest extends SysuiTestCase { doReturn(true).when(mController).isRecording(); doThrow(new RuntimeException()).when(mScreenMediaRecorder).end(anyInt()); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mRecordingService).createErrorSavingNotification(any()); ArgumentCaptor<Notification> notifCaptor = ArgumentCaptor.forClass(Notification.class); Loading @@ -292,7 +292,8 @@ public class RecordingServiceTest extends SysuiTestCase { doReturn(true).when(mController).isRecording(); doThrow(new OutOfMemoryError()).when(mScreenMediaRecorder).end(anyInt()); assertThrows(Throwable.class, () -> mRecordingService.onStopped(StopReason.STOP_UNKNOWN)); assertThrows(Throwable.class, () -> mRecordingService.onStopped( mContext.getUserId(), StopReason.STOP_UNKNOWN)); verify(mScreenMediaRecorder).release(); } Loading packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java +6 −9 Original line number Diff line number Diff line Loading @@ -489,13 +489,10 @@ public class RecordingService extends Service implements ScreenMediaRecorderList getTag(), notificationIdForGroup, groupNotif, currentUser); } private void stopService(@StopReason int stopReason) { stopService(USER_ID_NOT_SPECIFIED, stopReason); } private void stopService(int userId, @StopReason int stopReason) { if (userId == USER_ID_NOT_SPECIFIED) { userId = mUserContextTracker.getUserContext().getUserId(); Log.w(getTag(), "Stopping service without specifying user! " + userId); } UserHandle currentUser = new UserHandle(userId); Log.d(getTag(), "notifying for user " + userId); Loading Loading @@ -583,7 +580,6 @@ public class RecordingService extends Service implements ScreenMediaRecorderList return new RecordingServiceStrings(getResources()); } /** * Get an intent to stop the recording service. * @param context Context from the requesting activity Loading Loading @@ -621,10 +617,11 @@ public class RecordingService extends Service implements ScreenMediaRecorderList } @Override public void onStopped(@StopReason int stopReason) { public void onStopped(int userId, @StopReason int stopReason) { if (mController.isRecording()) { Log.d(getTag(), "Stopping recording because the system requested the stop"); stopService(stopReason); Log.d(getTag(), "Stopping recording for user " + userId + " because the system requested the stop"); stopService(userId, stopReason); } } } packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java +2 −2 Original line number Diff line number Diff line Loading @@ -334,7 +334,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback { @Override public void onStop() { Log.d(TAG, "The system notified about stopping the projection"); mListener.onStopped(StopReason.STOP_UNKNOWN); mListener.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); } private void stopInternalAudioRecording() { Loading Loading @@ -464,7 +464,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback { * For example, this might happen when doing partial screen sharing of an app * and the app that is being captured is closed. */ void onStopped(@StopReason int stopReason); void onStopped(int userId, @StopReason int stopReason); } /** Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/screenrecord/RecordingServiceTest.java +8 −7 Original line number Diff line number Diff line Loading @@ -200,7 +200,7 @@ public class RecordingServiceTest extends SysuiTestCase { public void testOnSystemRequestedStop_recordingInProgress_endsRecording() throws IOException { doReturn(true).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mScreenMediaRecorder).end(eq(StopReason.STOP_UNKNOWN)); } Loading @@ -209,7 +209,7 @@ public class RecordingServiceTest extends SysuiTestCase { public void testOnSystemRequestedStop_recordingInProgress_updatesState() { doReturn(true).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); assertUpdateState(false); } Loading @@ -219,7 +219,7 @@ public class RecordingServiceTest extends SysuiTestCase { throws IOException { doReturn(false).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mScreenMediaRecorder, never()).end(StopReason.STOP_UNKNOWN); } Loading @@ -230,7 +230,7 @@ public class RecordingServiceTest extends SysuiTestCase { doReturn(true).when(mController).isRecording(); doThrow(new RuntimeException()).when(mScreenMediaRecorder).end(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mScreenMediaRecorder).release(); } Loading @@ -239,7 +239,7 @@ public class RecordingServiceTest extends SysuiTestCase { public void testOnSystemRequestedStop_whenRecordingInProgress_showsNotifications() { doReturn(true).when(mController).isRecording(); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); // Processing notification ArgumentCaptor<Notification> notifCaptor = ArgumentCaptor.forClass(Notification.class); Loading Loading @@ -274,7 +274,7 @@ public class RecordingServiceTest extends SysuiTestCase { doReturn(true).when(mController).isRecording(); doThrow(new RuntimeException()).when(mScreenMediaRecorder).end(anyInt()); mRecordingService.onStopped(StopReason.STOP_UNKNOWN); mRecordingService.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); verify(mRecordingService).createErrorSavingNotification(any()); ArgumentCaptor<Notification> notifCaptor = ArgumentCaptor.forClass(Notification.class); Loading @@ -292,7 +292,8 @@ public class RecordingServiceTest extends SysuiTestCase { doReturn(true).when(mController).isRecording(); doThrow(new OutOfMemoryError()).when(mScreenMediaRecorder).end(anyInt()); assertThrows(Throwable.class, () -> mRecordingService.onStopped(StopReason.STOP_UNKNOWN)); assertThrows(Throwable.class, () -> mRecordingService.onStopped( mContext.getUserId(), StopReason.STOP_UNKNOWN)); verify(mScreenMediaRecorder).release(); } Loading
packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java +6 −9 Original line number Diff line number Diff line Loading @@ -489,13 +489,10 @@ public class RecordingService extends Service implements ScreenMediaRecorderList getTag(), notificationIdForGroup, groupNotif, currentUser); } private void stopService(@StopReason int stopReason) { stopService(USER_ID_NOT_SPECIFIED, stopReason); } private void stopService(int userId, @StopReason int stopReason) { if (userId == USER_ID_NOT_SPECIFIED) { userId = mUserContextTracker.getUserContext().getUserId(); Log.w(getTag(), "Stopping service without specifying user! " + userId); } UserHandle currentUser = new UserHandle(userId); Log.d(getTag(), "notifying for user " + userId); Loading Loading @@ -583,7 +580,6 @@ public class RecordingService extends Service implements ScreenMediaRecorderList return new RecordingServiceStrings(getResources()); } /** * Get an intent to stop the recording service. * @param context Context from the requesting activity Loading Loading @@ -621,10 +617,11 @@ public class RecordingService extends Service implements ScreenMediaRecorderList } @Override public void onStopped(@StopReason int stopReason) { public void onStopped(int userId, @StopReason int stopReason) { if (mController.isRecording()) { Log.d(getTag(), "Stopping recording because the system requested the stop"); stopService(stopReason); Log.d(getTag(), "Stopping recording for user " + userId + " because the system requested the stop"); stopService(userId, stopReason); } } }
packages/SystemUI/src/com/android/systemui/screenrecord/ScreenMediaRecorder.java +2 −2 Original line number Diff line number Diff line Loading @@ -334,7 +334,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback { @Override public void onStop() { Log.d(TAG, "The system notified about stopping the projection"); mListener.onStopped(StopReason.STOP_UNKNOWN); mListener.onStopped(mContext.getUserId(), StopReason.STOP_UNKNOWN); } private void stopInternalAudioRecording() { Loading Loading @@ -464,7 +464,7 @@ public class ScreenMediaRecorder extends MediaProjection.Callback { * For example, this might happen when doing partial screen sharing of an app * and the app that is being captured is closed. */ void onStopped(@StopReason int stopReason); void onStopped(int userId, @StopReason int stopReason); } /** Loading