Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit b31f11d

Browse files
committed
fix: fix without pid
1 parent 4fa3d78 commit b31f11d

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/perfmonUtil/process.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"errors"
2323
"fmt"
2424
"io/ioutil"
25-
"log"
2625
"math"
2726
"regexp"
2827
"strconv"
@@ -40,7 +39,7 @@ func getStatOnPid(client *adb.Device, pid string) (stat *entity.ProcessStat, err
4039
}
4140
data, err := ioutil.ReadAll(lines)
4241
if err != nil {
43-
log.Panic(err)
42+
return
4443
}
4544
return newProcessStat(string(data))
4645
}
@@ -52,7 +51,7 @@ func GetPidOnPackageName(client *adb.Device, appName string) (pid string, err er
5251
}
5352
data, err := ioutil.ReadAll(dumpsysData)
5453
if err != nil {
55-
log.Panic(err)
54+
return
5655
}
5756

5857
reg := regexp.MustCompile(fmt.Sprintf("ACTIVITY\\s%s.*\\d", appName))
@@ -103,7 +102,7 @@ func getStatusOnPid(client *adb.Device, pid string) (status *entity.ProcessStatu
103102
}
104103
data, err := ioutil.ReadAll(lines)
105104
if err != nil {
106-
log.Panic(err)
105+
return
107106
}
108107
scanner := bufio.NewScanner(strings.NewReader(string(data)))
109108
status = &entity.ProcessStatus{}
@@ -425,7 +424,7 @@ func GetProcessInfo(client *adb.Device, pid string, packageName string, perfOpti
425424
processInfo.FPS = &fps
426425
}
427426
if processInfo != nil {
428-
processInfo.Name = status.Name
427+
processInfo.Name = packageName
429428
processInfo.Pid = status.Pid
430429
}
431430

0 commit comments

Comments
 (0)