| // Copyright 2026 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| package androidtools |
| |
| import ( |
| "context" |
| "sync" |
| |
| "go.chromium.org/infra/cros/recovery/ctr" |
| "go.chromium.org/infra/cros/recovery/internal/components/mh" |
| "go.chromium.org/infra/cros/recovery/internal/env" |
| ) |
| |
| var ( |
| // Store cache of decision if tools are in container or not. |
| runningInContainer bool |
| once sync.Once |
| ) |
| |
| // UsesContainer tells is ABD and Fastbot running in container. |
| func UsesContainer(ctx context.Context) bool { |
| once.Do(func() { |
| if env.IsToolsPathSpecified() { |
| runningInContainer = false |
| } else if ctr.IsUp(ctx) { |
| runningInContainer = true |
| } else if mh.IsMH { |
| runningInContainer = false |
| } |
| }) |
| return runningInContainer |
| } |