Merge "Set recording duration and file size limits" into rvc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
index 626f298..390ac09 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
@@ -63,7 +63,7 @@
/**
* A service which records the device screen and optionally microphone input.
*/
-public class RecordingService extends Service {
+public class RecordingService extends Service implements MediaRecorder.OnInfoListener {
public static final int REQUEST_CODE = 2;
private static final int NOTIFICATION_ID = 1;
@@ -85,6 +85,8 @@
private static final int VIDEO_FRAME_RATE = 30;
private static final int AUDIO_BIT_RATE = 16;
private static final int AUDIO_SAMPLE_RATE = 44100;
+ private static final int MAX_DURATION_MS = 60 * 60 * 1000;
+ private static final long MAX_FILESIZE_BYTES = 5000000000L;
private final RecordingController mController;
private MediaProjection mMediaProjection;
@@ -250,6 +252,8 @@
mMediaRecorder.setVideoSize(screenWidth, screenHeight);
mMediaRecorder.setVideoFrameRate(VIDEO_FRAME_RATE);
mMediaRecorder.setVideoEncodingBitRate(VIDEO_BIT_RATE);
+ mMediaRecorder.setMaxDuration(MAX_DURATION_MS);
+ mMediaRecorder.setMaxFileSize(MAX_FILESIZE_BYTES);
// Set up audio
if (mUseAudio) {
@@ -274,6 +278,7 @@
null,
null);
+ mMediaRecorder.setOnInfoListener(this);
mMediaRecorder.start();
mController.updateState(true);
} catch (IOException e) {
@@ -454,4 +459,10 @@
return new Intent(context, RecordingService.class).setAction(ACTION_DELETE)
.putExtra(EXTRA_PATH, path);
}
+
+ @Override
+ public void onInfo(MediaRecorder mr, int what, int extra) {
+ Log.d(TAG, "Media recorder info: " + what);
+ onStartCommand(getStopIntent(this), 0, 0);
+ }
}