Skip to content

Commit

Permalink
Kill existing adb server if running
Browse files Browse the repository at this point in the history
  • Loading branch information
DonnchaC committed Dec 18, 2023
1 parent e96cdd4 commit 16c2e17
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions adb/adb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func New() (*ADB, error) {
}
log.Debugf("ADB found at path: %s", adb.ExePath)

log.Debug("Killing existing ADB server if running")
adb.KillServer()
return &adb, nil
}

Expand Down Expand Up @@ -129,3 +131,15 @@ func (a *ADB) ListFiles(remotePath string, recursive bool) ([]string, error) {

return remoteFiles, nil
}

func (a *ADB) KillServer() (string, error) {
log.Debug("Killing adb server")
out, err := exec.Command(a.ExePath, "kill-server").Output()
if err != nil {
log.Debug("kill-server failed")
return "", err
}

log.Debug("kill-server ok")
return strings.TrimSpace(string(out)), nil
}

0 comments on commit 16c2e17

Please sign in to comment.