Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): screenrecorder pid parsing should validate the output f… #828

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Versions {
val marathon = System.getenv("GIT_TAG_NAME") ?: "0.8.2"
val marathon = System.getenv("GIT_TAG_NAME") ?: "0.8.5"

val kotlin = "1.8.20"
val coroutines = "1.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ internal class ScreenRecorderStopper(private val device: AndroidDevice) {
if (output.isBlank()) {
return ""
}
val split = output.split("\\s+".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
val pid = split[1]

val lastLine = output.lines().last { it.isNotEmpty() }
val split = lastLine.split(' ').filter { it.isNotBlank() }
val pid = split.getOrNull(1)?.let { it.toIntOrNull()?.toString() } ?: ""
logger.trace("Extracted PID {} from output {}", pid, output)
return pid
}
Expand All @@ -37,7 +39,7 @@ internal class ScreenRecorderStopper(private val device: AndroidDevice) {
device.safeExecuteShellCommand("kill -2 $pid")
return true
} else {
logger.trace("Did not kill any screen recording process")
logger.warn { "Did not kill any screen recording process" }
}
} catch (e: Exception) {
logger.error("Error while killing recording processes", e)
Expand Down