How to run adb software server via tcp

How can I run the adb server via tcp programmatically in android ... with root privileges I found that this command will be ...

setprop service.adb.tcp.port 5555 

Is there any way to execute this programmatically in android

+4
source share
1 answer

This requires root access. Otherwise, it will be a serious security problem. You can use a library like libsuperuser to run root commands.

An example of using libsuperuser:

 String[] commands = { "setprop service.adb.tcp.port 5555", "stop adbd", "start adbd" }; Shell.SU.run(commands); // Get the WiFi IP address WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int ip = mWifiManager.getConnectionInfo().getIpAddress(); String wifiIp = (ip & 0xFF) + "." + ((ip >> 8) & 0xFF) + "." + ((ip >> 16) & 0xFF) + "." + ((ip >> 24) & 0xFF); // Tell the user what the next step is. Toast.makeText(context, String.format("Run 'adb connect %s:5555' in terminal/command-prompt", wifiIp), Toast.LENGTH_LONG).show(); 
0
source

Source: https://habr.com/ru/post/1485006/


All Articles