fix: improve package running check and enhance logging in UIA2Driver

This commit is contained in:
lilong.129
2025-06-28 10:17:09 +08:00
parent e8f7516422
commit 3424844815
2 changed files with 25 additions and 16 deletions
+10 -1
View File
@@ -728,7 +728,16 @@ func (d *Device) IsPackageInstalled(packageName string) bool {
}
func (d *Device) IsPackageRunning(packageName string) bool {
output, err := d.RunShellCommand("pidof", packageName)
packageName = strings.TrimSpace(packageName)
if packageName == "" {
log.Error().Msg("package name is empty, skip checking package running")
return false
}
// Use ps -ef command with grep to check if package is running
// ps -ef shows full command line which includes package name as argument
// This works for both regular apps and instrumentation test processes
output, err := d.RunShellCommand("ps -ef | grep " + packageName + " | grep -v grep")
if err != nil {
return false
}