From a21ed69d3a2efb0ff90b88dd53c28c9af029aec5 Mon Sep 17 00:00:00 2001 From: shirou Date: Sun, 15 Sep 2019 09:49:07 +0900 Subject: [PATCH] Revert "Merge pull request #763 from Iqoqo/add-android-support-for-host" This reverts commit f58b2e367743e24f7d4e5b69fa04cf738e15ce86, reversing changes made to 84e6215770ea4a60ebed2284c4b5e57432891f22. --- internal/common/common_android.go | 95 ------------------------------- internal/common/common_linux.go | 2 +- 2 files changed, 1 insertion(+), 96 deletions(-) delete mode 100644 internal/common/common_android.go diff --git a/internal/common/common_android.go b/internal/common/common_android.go deleted file mode 100644 index 17e1b86..0000000 --- a/internal/common/common_android.go +++ /dev/null @@ -1,95 +0,0 @@ -// +build android - -package common - -import ( - "context" - "os/exec" - "sync/atomic" - "bufio" - - "golang.org/x/sys/unix" -) - -func NumProcs() (uint64, error) { - ps, err := exec.LookPath("ps") - if err != nil { - return 0, err - } - cmd := exec.Command(ps, "-A", "-o", "PID") - stdout, err := cmd.StdoutPipe() - if err != nil { - return 0, err - } - - if err := cmd.Start(); err != nil { - return 0, err - } - - var cnt uint64 - - scanner := bufio.NewScanner(stdout) - for scanner.Scan() { - cnt++ - } - - if err := scanner.Err(); err != nil { - return cnt, err - } - - if err := cmd.Wait(); err != nil { - return 0, err - } - - return cnt, err -} - -// cachedBootTime must be accessed via atomic.Load/StoreUint64 -var cachedBootTime uint64 - -func BootTimeWithContext(ctx context.Context) (uint64, error) { - t := atomic.LoadUint64(&cachedBootTime) - if t != 0 { - return t, nil - } - - sysinfo := &unix.Sysinfo_t{} - - if err := unix.Sysinfo(sysinfo); err != nil { - return 0, err - } - - uptime := uint64(sysinfo.Uptime) - atomic.StoreUint64(&uptime, t) - return uptime, nil -} - -func Virtualization() (string, string, error) { - return VirtualizationWithContext(context.Background()) -} - -func VirtualizationWithContext(ctx context.Context) (string, string, error) { - return "", "", nil -} - -func GetOSRelease() (platform string, version string, err error) { - getprop, err := exec.LookPath("getprop") - if err != nil { - return "", "", err - } - flavorCmd := exec.Command(getprop, "ro.build.flavor") - platformProp, err := flavorCmd.Output() - - if err != nil { - return "", "", err - } - - versionCmd := exec.Command(getprop, "ro.build.version.release") - versionProp, err := versionCmd.Output() - - if err != nil { - return "", "", err - } - - return string(platformProp), string(versionProp), nil -} diff --git a/internal/common/common_linux.go b/internal/common/common_linux.go index 70c6209..f558b74 100644 --- a/internal/common/common_linux.go +++ b/internal/common/common_linux.go @@ -1,4 +1,4 @@ -// +build linux,!android +// +build linux package common