Search code examples
androidadb

How long adb will keep tcpip session active?


I develop on my android phone and I usually connect to adb over WiFi.

So I connect through USB, use adb tcpip to open the server on my device and then use adb connect to actually establish the connection. I have always done both steps because I was sure adb was going to close itself after some time there was no connection.

A couple of minutes ago though, let's say at 4:40 pm, I tried adb connect without opening the client first. I had opened the client, with adb tcpip this morning, let's say around 12:30 pm, and I expected to see nothing happen.

To my surprise, it connected.

So, long story short, how long will an adb server listen on a specified port? Will it ever stop listening?


Solution

  • Edit (Adding OP's comment to the answer)

    They probably changed that in android 11, because there is an option to disable automatic revocation of authorisation, which says it will expire after 7 days source .


    I guess to answer to the question will be, as long as that instance of adb session lasts. Even though we are not working on the device through android studio, the adb is still running in the background.

    So unless you restart the adb server or use the disconnect command, that session should run its course.

    Consideration should be paid to various cases that directly or indirectly affects the adb session, for instance, low battery, restarting or putting device in hibernate mode, etc.