Skip to content

Commit

Permalink
fix: fix without pid
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Feb 7, 2023
1 parent 4fa3d78 commit b31f11d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/perfmonUtil/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"math"
"regexp"
"strconv"
Expand All @@ -40,7 +39,7 @@ func getStatOnPid(client *adb.Device, pid string) (stat *entity.ProcessStat, err
}
data, err := ioutil.ReadAll(lines)
if err != nil {
log.Panic(err)
return
}
return newProcessStat(string(data))
}
Expand All @@ -52,7 +51,7 @@ func GetPidOnPackageName(client *adb.Device, appName string) (pid string, err er
}
data, err := ioutil.ReadAll(dumpsysData)
if err != nil {
log.Panic(err)
return
}

reg := regexp.MustCompile(fmt.Sprintf("ACTIVITY\\s%s.*\\d", appName))
Expand Down Expand Up @@ -103,7 +102,7 @@ func getStatusOnPid(client *adb.Device, pid string) (status *entity.ProcessStatu
}
data, err := ioutil.ReadAll(lines)
if err != nil {
log.Panic(err)
return
}
scanner := bufio.NewScanner(strings.NewReader(string(data)))
status = &entity.ProcessStatus{}
Expand Down Expand Up @@ -425,7 +424,7 @@ func GetProcessInfo(client *adb.Device, pid string, packageName string, perfOpti
processInfo.FPS = &fps
}
if processInfo != nil {
processInfo.Name = status.Name
processInfo.Name = packageName
processInfo.Pid = status.Pid
}

Expand Down

0 comments on commit b31f11d

Please sign in to comment.