Reputation: 24727
If my device has opened itself up to Wireless ADB, how can I determine if another device has connected to my device? Currently there's no warning (at least on my device) alerting me when somebody successfully connects to my phone.
I know I have to go out of my way to allow wireless connections and it's pretty stupid to leave that on when you're not planning to use it, I'm just curious if it's programmatically possible to know these things.
Is there a dump
I can run or a path I can cat
to see if something's connected? Can my code be notified when something tries to connect? If I can tell if something is connected, how much information can I get on what connected, if any? Is root required for any of this?
Upvotes: 2
Views: 907
Reputation: 331
I was in the same boat, here how I got what I need:
netstat -lptu | grep -E '5555.*ESTABLISHED' | cut -s -d ':' -f2 | awk '{print $2}'
This shows the IP of the one connected to the android device! You can change the port with no problem
Then you can use the information in a "IF" statement for example to grep the IP on a white or black list!
You can use Scripting Layering For Android and make a Toast Notification whenever someone tries to connect or make a Push Notification with the ability to display a dialog asking for some action like disabling the adb wireless.
Here is a way to Enable/Disable ADB Wireless:
Enable:
setprop service.adb.tcp.port 5555 ; stop adbd ; start adbd
Disable:
setprop service.adb.tcp.port -1 ; stop adbd ; start adbd
Upvotes: 1