From e8d2bb560d2934883e2e1d0e536a1b3d0183fef2 Mon Sep 17 00:00:00 2001 From: Radha Nakade Date: Wed, 18 Nov 2026 12:16:46 -0800 Subject: [PATCH 1/2] Add deviceaction to install apps only if there are any apps to install --- .../ci/devicerun/DeviceRunController.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt index 8ed5683..cbdc034 100644 --- a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt +++ b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt @@ -121,22 +121,24 @@ internal class DeviceRunController( val deviceActions = mutableListOf() // App installation - deviceActions.add( - DeviceAction( - androidInstallPackages = AndroidInstallPackagesDeviceAction( - targetApp = appApk?.let { - AndroidInstallable( - files = listOf(InputFile(gcsInputFile = GcsPath(path = appApk.gcsPath.path))) - ) - }, - postTargetAppInstallables = deviceSetup?.additionalApks?.map { - AndroidInstallable( - files = listOf(InputFile(gcsInputFile = GcsPath(path = it.gcsPath.path))) - ) - } + if (appApk != null || deviceSetup?.additionalApks?.isNotEmpty() == true) { + deviceActions.add( + DeviceAction( + androidInstallPackages = AndroidInstallPackagesDeviceAction( + targetApp = appApk?.let { + AndroidInstallable( + files = listOf(InputFile(gcsInputFile = GcsPath(path = appApk.gcsPath.path))) + ) + }, + postTargetAppInstallables = deviceSetup?.additionalApks?.map { + AndroidInstallable( + files = listOf(InputFile(gcsInputFile = GcsPath(path = it.gcsPath.path))) + ) + } + ) ) ) - ) + } // Orientation & Locale deviceActions.add(DeviceAction(androidOrientation = AndroidOrientationDeviceAction(orientation = orientation))) From 3ca3f85d83f53a9b8d8e725058e9349d588ff8b4 Mon Sep 17 00:00:00 2001 From: Radha Nakade Date: Wed, 18 Nov 2026 13:11:51 -0800 Subject: [PATCH 2/2] add test --- .../ci/devicerun/DeviceRunControllerTest.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt index c4db2c4..c3d023c 100644 --- a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt +++ b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt @@ -340,6 +340,30 @@ internal class DeviceRunControllerTest { assertThat(postInstallPaths).containsExactly(extraApk1.gcsPath.path, extraApk2.gcsPath.path).inOrder() } + @Test + fun testSubmitTests_noAdditionalApks() = runBlocking { + val testApk = createUploadedApk("test.apk") + val devices = listOf(AndroidDevice("tokay", "34", "en_US", "portrait")) + + val session = controller.submitTests( + appApk = null, + testApk = testApk, + devicePicker = { devices }, + deviceSetup = DeviceSetup(), + pullScreenshots = false, + testTargets = null, + flakyTestAttempts = 0, + testTimeoutSeconds = 900, + gcsResultPath = "gs://results", + gcsSmartShardingFilePath = "gs://smartShardingFile" + ) + + val job = session.sessionConfig.jobConfigs.first() + val installPackages = job.allocationConfig.deviceConfigs.first().actions + ?.firstNotNullOfOrNull { it.androidInstallPackages } + assertThat(installPackages).isNull() + } + @Test fun testSubmitTests_pullScreenshotsAndDirectoriesToPull() = runBlocking { val appApk = createUploadedApk("app.apk")