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): detect device reboot during data clear #949

Merged
merged 1 commit into from
Jun 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ interface AndroidDevice : Device, LogProducer, Screenshottable {
suspend fun installPackage(absolutePath: String, reinstall: Boolean, optionalParams: List<String>): ShellCommandResult?
suspend fun installSplitPackages(absolutePaths: List<String>, reinstall: Boolean, optionalParams: List<String>): String
suspend fun safeUninstallPackage(appPackage: String, keepData: Boolean = false): ShellCommandResult?
suspend fun safeClearPackage(packageName: String): ShellCommandResult?
suspend fun clearPackage(packageName: String): ShellCommandResult?

suspend fun safeStartScreenRecorder(remoteFilePath: String, options: VideoConfiguration)
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ abstract class BaseAndroidDevice(
}


override suspend fun safeClearPackage(packageName: String): ShellCommandResult? =
safeExecuteShellCommand("pm clear $packageName", "Could not clear package $packageName on device: $serialNumber")
override suspend fun clearPackage(packageName: String): ShellCommandResult? =
criticalExecuteShellCommand("pm clear $packageName", "Could not clear package $packageName on device: $serialNumber")

protected suspend fun clearLogcat() = safeExecuteShellCommand("logcat -c", "Could not clear logcat on device: $serialNumber")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ class AndroidDeviceTestRunner(private val device: AdamAndroidDevice, private val
info: InstrumentationInfo
) {
if (androidConfiguration.applicationPmClear) {
device.safeClearPackage(info.applicationPackage)?.output?.trim()?.also {
device.clearPackage(info.applicationPackage)?.output?.trim()?.also {
logger.debug { "Package ${info.applicationPackage} cleared: $it" }
}
}
if (androidConfiguration.testApplicationPmClear) {
device.safeClearPackage(info.instrumentationPackage)?.output?.trim()?.also {
device.clearPackage(info.instrumentationPackage)?.output?.trim()?.also {
logger.debug { "Package ${info.instrumentationPackage} cleared: $it" }
}
}
Expand Down
Loading