Skip to content

Commit c179391

Browse files
committed
Add support for additional emulator flags in DeviceService
Enhance the Android emulator launch process by allowing users to specify extra flags through the ANDROID_EMULATOR_FLAGS environment variable. This change improves flexibility for emulator configurations and provides logging for the applied flags.
1 parent 61458be commit c179391

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

maestro-client/src/main/java/maestro/device/DeviceService.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,26 @@ object DeviceService {
5656
Platform.ANDROID -> {
5757
val emulatorBinary = requireEmulatorBinary()
5858

59-
ProcessBuilder(
59+
val emulatorArgs = mutableListOf(
6060
emulatorBinary.absolutePath,
6161
"-avd",
6262
device.modelId,
6363
"-netdelay",
6464
"none",
6565
"-netspeed",
6666
"full"
67-
).start().waitFor(10,TimeUnit.SECONDS)
67+
)
68+
69+
// Support additional emulator flags via ANDROID_EMULATOR_FLAGS environment variable
70+
// Example: ANDROID_EMULATOR_FLAGS="-no-window -no-audio -gpu swiftshader_indirect"
71+
val extraFlags = System.getenv("ANDROID_EMULATOR_FLAGS")
72+
if (!extraFlags.isNullOrBlank()) {
73+
emulatorArgs.addAll(extraFlags.split("\\s+".toRegex()).filter { it.isNotBlank() })
74+
logger.info("Using additional emulator flags: $extraFlags")
75+
}
76+
77+
ProcessBuilder(emulatorArgs)
78+
.start().waitFor(10, TimeUnit.SECONDS)
6879

6980
var lastException: Exception? = null
7081

0 commit comments

Comments
 (0)