From 95ee50bb1109b4b8bfd61b4e11097a89eaae0c9a Mon Sep 17 00:00:00 2001 From: Tarek Belkahia Date: Fri, 30 Aug 2024 22:11:29 +0100 Subject: [PATCH] Delete apks after using them (#1947) --- .../src/main/java/maestro/drivers/AndroidDriver.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt b/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt index 569452ef9e..871b063b6d 100644 --- a/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt +++ b/maestro-client/src/main/java/maestro/drivers/AndroidDriver.kt @@ -525,6 +525,7 @@ class AndroidDriver( val appNameResult = runCatching { val apkFile = AndroidAppFiles.getApkFile(dadb, appId) val appName = ApkFile(apkFile).apkMeta.name + apkFile.delete() appName } if (appNameResult.isSuccess) { @@ -775,7 +776,9 @@ class AndroidDriver( private fun setAllPermissions(appId: String, permissionValue: String) { val permissionsResult = runCatching { val apkFile = AndroidAppFiles.getApkFile(dadb, appId) - ApkFile(apkFile).apkMeta.usesPermissions + val permissions = ApkFile(apkFile).apkMeta.usesPermissions + apkFile.delete() + permissions } if (permissionsResult.isSuccess) { permissionsResult.getOrNull()?.let { @@ -964,6 +967,7 @@ class AndroidDriver( if (!isPackageInstalled("dev.mobile.maestro")) { throw IllegalStateException("dev.mobile.maestro was not installed") } + maestroAppApk.delete() } private fun installMaestroServerApp() { @@ -981,6 +985,7 @@ class AndroidDriver( if (!isPackageInstalled("dev.mobile.maestro.test")) { throw IllegalStateException("dev.mobile.maestro.test was not installed") } + maestroServerApk.delete() } private fun installMaestroApks() {