From cc4944b1333cb80637b66837842b6b4fa5db1cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E6=B3=93=E9=93=AE?= Date: Mon, 18 Mar 2024 14:49:03 +0800 Subject: [PATCH] fix: adb device parse attributes error --- hrp/pkg/gadb/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hrp/pkg/gadb/client.go b/hrp/pkg/gadb/client.go index 1c867dd1..eb6b9d8c 100644 --- a/hrp/pkg/gadb/client.go +++ b/hrp/pkg/gadb/client.go @@ -108,7 +108,7 @@ func (c Client) DeviceList() (devices []*Device, err error) { } fields := strings.Fields(line) - if len(fields) < 5 || len(fields[0]) == 0 { + if len(fields) < 4 || len(fields[0]) == 0 { log.Error().Str("line", line).Msg("get unexpected line") continue } @@ -117,6 +117,9 @@ func (c Client) DeviceList() (devices []*Device, err error) { mapAttrs := map[string]string{} for _, field := range sliceAttrs { split := strings.Split(field, ":") + if len(split) == 1 { + continue + } key, val := split[0], split[1] mapAttrs[key] = val }