screenrecord: allow recording without a time limit
Screen recording was limited to 3 minutes. The limitation
seems arbitrary so lets remove it.
Test: run `adb shell screenrecord --time-limit 0` and wait for 3 minutes and 1 second
Fixes: 237019907
Change-Id: Ic6710a123ef9fdf99a0f3df308937b8a33b9afcb
diff --git a/cmds/screenrecord/screenrecord.cpp b/cmds/screenrecord/screenrecord.cpp
index 2e0b678..b277bed 100644
--- a/cmds/screenrecord/screenrecord.cpp
+++ b/cmds/screenrecord/screenrecord.cpp
@@ -1026,7 +1026,8 @@
" Add additional information, such as a timestamp overlay, that is helpful\n"
" in videos captured to illustrate bugs.\n"
"--time-limit TIME\n"
- " Set the maximum recording time, in seconds. Default / maximum is %d.\n"
+ " Set the maximum recording time, in seconds. Default is %d. Set to 0\n"
+ " to remove the time limit.\n"
"--display-id ID\n"
" specify the physical display ID to record. Default is the primary display.\n"
" see \"dumpsys SurfaceFlinger --display-id\" for valid display IDs.\n"
@@ -1113,14 +1114,27 @@
}
break;
case 't':
- gTimeLimitSec = atoi(optarg);
- if (gTimeLimitSec == 0 || gTimeLimitSec > kMaxTimeLimitSec) {
- fprintf(stderr,
- "Time limit %ds outside acceptable range [1,%d]\n",
- gTimeLimitSec, kMaxTimeLimitSec);
+ {
+ char *next;
+ const int64_t timeLimitSec = strtol(optarg, &next, 10);
+ if (next == optarg || (*next != '\0' && *next != ' ')) {
+ fprintf(stderr, "Error parsing time limit argument\n");
return 2;
}
+ if (timeLimitSec > std::numeric_limits<uint32_t>::max() || timeLimitSec < 0) {
+ fprintf(stderr,
+ "Time limit %" PRIi64 "s outside acceptable range [0,%u] seconds\n",
+ timeLimitSec, std::numeric_limits<uint32_t>::max());
+ return 2;
+ }
+ gTimeLimitSec = (timeLimitSec == 0) ?
+ std::numeric_limits<uint32_t>::max() : timeLimitSec;
+ if (gVerbose) {
+ printf("Time limit set to %u seconds\n", gTimeLimitSec);
+ fflush(stdout);
+ }
break;
+ }
case 'u':
gWantInfoScreen = true;
gWantFrameTime = true;