I want to know if the phone is currently connected to a host that can run adb commands from within the phone, no matter if it's using an app, a shell command constantly running, or any other method that doesn't require the host or an external server.

From the host, I can just run adb devices. Ideally, I would like to have something equivalent inside the phone, say adbdaemon host-info that let's my phone know that there is an existing adb connection with a computer.

  • Host side (adb) initiates the connection, phone side (adbd) responds to the received commands. You are looking for the inverse. adbd doesn't keep track of the connection, the host side does. Neither adbd provides a method to query current connection status. All that you can know is that phone is connected to a PC and adbd is running. // Btw why do you want to do that? It doesn't make sense normally. Isn't adbd configured to authenticate the connections? Commented Mar 3, 2020 at 2:49
  • I don't know a way to check if adb is connected to a PC. Using netstat (and filter of lines with adb) you could only check if adb is active, but it does not show if it is connected via USB (adb over Wifi connections should be displayed).
    – Robert
    Commented Mar 3, 2020 at 19:02
  • @IrfanLatif I have a setup where my adb connection is a bit dodgy and the phone disappears from adb devices. I've seen that disabling and enabling usb debugging from the phone when that happens solves the issue, and I want to automate it, preferably without relying on an extra server. My phone is rooted, so I have full control of it. Commented Mar 3, 2020 at 19:34


You must log in to answer this question.

Browse other questions tagged .