From 4cf8626cb9b7672b1b43f42513a44b58d3e783cb Mon Sep 17 00:00:00 2001 From: PJ Date: Wed, 10 Jun 2026 12:08:49 +0530 Subject: [PATCH] fix(android): make device prep best-effort so OEM-blocked commands don't abort the run --- internal/android/android.go | 8 ++++++-- internal/testrun/testrun.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/android/android.go b/internal/android/android.go index 17753f9..9c3ff29 100644 --- a/internal/android/android.go +++ b/internal/android/android.go @@ -59,7 +59,11 @@ func EnsureDevice(ctx context.Context, serial, avdName string, stdout io.Writer) // run. The fuzzer drives whatever is on screen, so a sleeping or locked device // would have it explore system UI instead of the app. A secure lock // (PIN/password) cannot be dismissed here and must be unlocked out of band. -func PrepareDevice(ctx context.Context, serial string) error { +// +// Every step is best effort: some OEM builds restrict or kill these commands +// (e.g. HyperOS SIGKILLs `svc power stayon`), and none is required for a run to +// proceed, so a failure is logged and skipped rather than aborting the run. +func PrepareDevice(ctx context.Context, serial string, stdout io.Writer) error { adb, err := AdbBinary() if err != nil { return err @@ -75,7 +79,7 @@ func PrepareDevice(ctx context.Context, serial string) error { } args = append(append(args, "shell"), shellCommand...) if err := exec.CommandContext(ctx, adb, args...).Run(); err != nil { - return fmt.Errorf("adb %s: %w", strings.Join(shellCommand, " "), err) + fmt.Fprintf(stdout, "device prep: skipping `adb %s` (%v)\n", strings.Join(shellCommand, " "), err) } } return nil diff --git a/internal/testrun/testrun.go b/internal/testrun/testrun.go index b0fc730..9133ee8 100644 --- a/internal/testrun/testrun.go +++ b/internal/testrun/testrun.go @@ -50,7 +50,7 @@ func Execute(ctx context.Context, options Options, stdout io.Writer) error { if err := android.EnsureDevice(ctx, options.Device, options.AVD, stdout); err != nil { return err } - if err := android.PrepareDevice(ctx, options.Device); err != nil { + if err := android.PrepareDevice(ctx, options.Device, stdout); err != nil { return err } case "ios":