mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(android): make device prep best-effort so OEM-blocked commands don't abort the run
This commit is contained in:
1 parent
0f8c0b4f97
commit
4cf8626cb9
2 files changed
+7
-3
No files matched your search
@@ -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
|
// 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
|
// 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.
|
// (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()
|
adb, err := AdbBinary()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -75,7 +79,7 @@ func PrepareDevice(ctx context.Context, serial string) error {
|
|||||||
}
|
}
|
||||||
args = append(append(args, "shell"), shellCommand...)
|
args = append(append(args, "shell"), shellCommand...)
|
||||||
if err := exec.CommandContext(ctx, adb, args...).Run(); err != nil {
|
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
|
return nil
|
||||||
|
|||||||
@@ -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 {
|
if err := android.EnsureDevice(ctx, options.Device, options.AVD, stdout); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := android.PrepareDevice(ctx, options.Device); err != nil {
|
if err := android.PrepareDevice(ctx, options.Device, stdout); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "ios":
|
case "ios":
|
||||||
|
|||||||
Reference in new issue
Block a user