Skip to content

Commit

Permalink
Disable Fuchsia device scan when SDK is not found (#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
kocdemir authored Aug 26, 2022
1 parent 35f18e8 commit 1b1818d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cmd/gapis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ func run(ctx context.Context) error {
adb.ADB = file.Abs(*adbPath)
}

// Check if FFX SDK path is set, which is necessary to scan Fuchsia devices
if *scanFuchsiaDevs {
_, ffxFound := os.LookupEnv("FUCHSIA_FFX_PATH")
if !ffxFound {
// Disable Fuchsia device scanning when there is no SDK, to avoid runtime errors
log.W(ctx, "FUCHSIA_FFX_PATH is not set, disabling Fuchsia device monitoring.")
*scanFuchsiaDevs = false
}
}

r := bind.NewRegistry()
ctx = bind.PutRegistry(ctx, r)
m := replay.New(ctx)
Expand Down
2 changes: 1 addition & 1 deletion core/os/android/adb/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func Monitor(ctx context.Context, r *bind.Registry, interval time.Duration) erro
for {
if err := scanDevices(ctx); err != nil {
if time.Since(lastErrorPrinted).Seconds() > printScanErrorsEveryNSeconds {
log.E(ctx, "Couldn't scan devices: %v", err)
log.E(ctx, "Couldn't scan Android devices: %v", err)
lastErrorPrinted = time.Now()
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion core/os/fuchsia/ffx/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func Monitor(ctx context.Context, r *bind.Registry, interval time.Duration) erro
err := scanDevices(ctx)
if err != nil {
if time.Since(lastErrorPrinted).Seconds() > printScanErrorsEveryNSeconds {
log.E(ctx, "Couldn't scan devices: %v", err)
log.E(ctx, "Couldn't scan Fuchsia devices: %v", err)
lastErrorPrinted = time.Now()
}
} else {
Expand Down

0 comments on commit 1b1818d

Please sign in to comment.