summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-02-26 23:53:25 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-02-26 23:53:25 +0000
commit4ad907d3d036626e3409a65c24e65a19719f485d (patch)
treed070281523a5730349a6841bde7c72902725b5a6
parentf16dce6f209d5d8bb439712717f7cea447d4063a (diff)
parent26fefde74025f6831aea640ba7d39f902a6a3096 (diff)
Merge "Set recording duration and file size limits" into rvc-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingService.java
index 626f298055a0..390ac0969b21 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 @@ import javax.inject.Inject;
/**
* 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 @@ public class RecordingService extends Service {
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 @@ public class RecordingService extends Service {
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 @@ public class RecordingService extends Service {
null,
null);
+ mMediaRecorder.setOnInfoListener(this);
mMediaRecorder.start();
mController.updateState(true);
} catch (IOException e) {
@@ -454,4 +459,10 @@ public class RecordingService extends Service {
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);
+ }
}