From ee41a691a822b9a647b7890ac205a041d2405471 Mon Sep 17 00:00:00 2001 From: shengxiang Date: Fri, 22 Dec 2017 15:37:47 +0800 Subject: [PATCH] add system version, memory, cpuinfo --- install.bat | 2 +- tunnelproxy.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/install.bat b/install.bat index d2fd6bc..b290272 100644 --- a/install.bat +++ b/install.bat @@ -8,6 +8,6 @@ REM adb install app-debug-androidTest.apk adb push atx-agent /data/local/tmp adb shell chmod 777 /data/local/tmp/atx-agent -adb shell /data/local/tmp/atx-agent -d -t 10.240.187.224:8080 -nouia +adb shell /data/local/tmp/atx-agent -d -t 10.240.187.224:8000 -nouia REM adb shell /data/local/tmp/atx-agent -d -t 10.246.46.160:8200 -nouia REM pause \ No newline at end of file diff --git a/tunnelproxy.go b/tunnelproxy.go index 5b947fb..1253e4f 100644 --- a/tunnelproxy.go +++ b/tunnelproxy.go @@ -4,6 +4,7 @@ import ( "errors" "log" "os" + "strconv" "strings" "time" @@ -21,8 +22,10 @@ func getDeviceInfo() *proto.DeviceInfo { Serial: getProperty("ro.serialno"), Brand: getProperty("ro.product.brand"), Model: getProperty("ro.product.model"), + Version: getProperty("ro.build.version.release"), AgentVersion: version, } + devInfo.Sdk, _ = strconv.Atoi(getProperty("ro.build.version.sdk")) devInfo.HWAddr, _ = androidutils.HWAddrWLAN() display, _ := androidutils.WindowSize() devInfo.Display = &display @@ -30,6 +33,25 @@ func getDeviceInfo() *proto.DeviceInfo { battery.Update() devInfo.Battery = &battery + memory, err := androidutils.MemoryInfo() + if err != nil { + log.Println("get memory error:", err) + } else { + devInfo.Memory = &proto.MemoryInfo{ + Total: memory["MemTotal"], + } + } + + hardware, processors, err := androidutils.ProcessorInfo() + if err != nil { + log.Println("get cpuinfo error:", err) + } else { + devInfo.Cpu = &proto.CpuInfo{ + Hardware: hardware, + Cores: len(processors), + } + } + // Udid is ${Serial}-${MacAddress}-${model} udid := getProperty("ro.serialno") + "-" + devInfo.HWAddr + "-" + strings.Replace(getProperty("ro.product.model"), " ", "_", -1) devInfo.Udid = udid