We have test suite where adb clients connect to multiple android devices.
Our test suite raises these requests to connect, get device state and run applications in it.
I would like to simulate a scenario where adb server hangs.
I tried issuing "adb kill-server" but any adb request from client starts the adb server.
Is there anyway we can stop the adb server from listening to adb client requests ?
Of course there is a long way of compiling adb service and changing the code our self.
But any easy way to get this done?
Do you need to still have a connection (that doesn't respond to commands), or is it fine to kill the connection altogether? Sounds to me like killing the connection would be fine since you say that you tried adb kill-server.
In that case, how about trying to connect to the device in TCP/IP mode without having set up the adb server to listen on a network port? I.e. something like:
adb tcpip 12345
Another suggestion would be to actually disable adb interface totally in the device. While this may or may not stop the adb server, you would still get your desired result i.e no connection for adb clients.
The way this could be done is that on a ROOTED device, do
adb shell
su
echo 1 > /sys/class/android_usb/f_adb/on
This one is what I could do on an HTC Vivid which I have on hand. For other devices, the paths might be different but they should all be similar. Once your reboot the phone, adb starts working again.
Related
Everytime I want to connect my adb server to my device, I need to explicitly give the port.
adb connect localhost:<port>
On my case, the port is randomly defined so I have to find it on the interface.
I try to netstat my computer but the port does not appear, except if I adb connect, and just a moment after I adb disconnect. But then it disapear again.
An other thing I thought was to brut force all ports but it takes like an ethernity..
If you have a suggestion I would be glad to read and test it.
Thanks
I am beginner in android.My problem is I had connect my mobile device with adb through adb tcpip 5555 and adb connect command in the cmd (first time via cable) and it successfully work and work wireless in android studio but on the next day when I am reconnecting with my device it does not work until I repeat the process again that is for the first time do all the process via cable and make connection.
So My Question is, Is there is any solution available that adb connection require only one time setting and after that it work until I dissconnet manually, Also I want the solution without rooting the android phone
You need to follow this step first time at least
1)adb tcpip 5555
2)adb connect 192.168.0.101:5555
after that badly your device disconnect then you need to do above step again but one thing is there first hit this command and then follow above two step
1.adb kill-server
2.abb start-server
By the way it does not required root phone.
I'm using Android tablet communicating with a USB device through USB port, the tablet only has one usb port, so I use adb wifi as my debug tool. However, when I connect adb through WIFI, the connection won't keep long(only a few minutes us usually), how to keep the adb wifi connection online all the time?
Another question, is it possible to use USB HUB to connect the tablet with both USB flash-drive and my computer, and keep adb running?
Many thanks!!!
After lots of unsuccessful attempts,I have noticed that turning Allow ADB debugging in charge only mode specification on , solved the problem . It makes the device online and accessable over wifi to ADB.
You can find it under Developer options section.
Here is what I found out from researching everywhere and developing on my own for more than a week.
Q1. adb service often crashes if it is not doing any executions for a long long time.
A1. calling adb commands time to time keeps adb server online.
Q2. wifi connected device sometimes disconnect.
A2. Before you check your wifi on the connected device, check the wifi that your ADB server is running on. Ping to google and if it is well connected, ping to the device.
Wireless can disconnect on its own and even wired connection is sometimes disconnected. so calling "adb connect ..." when the device is not already connected is necessary. You could do this easily by saving "adb devices > device.txt" and query out whether your expected wifi is on the list. If not, connect again..(do this in another thread).
Q3. wifi connected device is sometimes offline.
A3. This is because by TCP/IP connection your ADB server is now on Time_Wait stance. The last connection was interrupted that the next connection is now offline because the last connection is not completely shut down. You can either manually disconnect/connect your device's wifi or restart TCPIP connection by ex) "adb tcpip 5555"
If you want to do this automatically, you are going to have to disconnect/connect your device's wifi programmatically.
Leave any other questions and I can answer on the comments.
When connection is lost and adb devices shows device is offline, like this:
prompt> adb devices
List of devices attached
192.168.1.1:5555 offline
then adb disconnect IP followed by adb connect IP will often work:
prompt> adb disconnect 192.168.1.1
disconnected 192.168.1.1
prompt> adb devices
List of devices attached
prompt> adb connect 192.168.1.1
connected to 192.168.1.1
prompt> adb devices
List of devices attached
192.168.1.1:5555 device
Use adb over wi-fi without any third-party apps. Follow the steps.
Connect device via USB
Open your terminal and check your device is listed with adb devices command
Type adb tcpip 5555 and enter (or use another port instead of 5555)
Plug out your USB cable. You don't need it anymore.
Take your Android phone and go Settings/About/Status
Check the IP address part. Let's say your IP address is 192.168.x.y
In your terminal, write the command adb connect 192.168.x.y
Now, you have connected your device via wi-fi.
You can see your device in adb devices
Enjoy it! :)
This seems like an issue with your wifi. As a precaution, just keep the terminal open and whenever you need to test just press the 'UP arrow' key to get to previously ran adb connect "<ip>" command.
I tried many ways but this one worked out for me:
force the display on and of in a loop would keep the device online
adb shell input keyevent 224
timeout 2
adb shell input keyevent 26
timeout 58
this turns the display on every minute for 2 seconds
So, I'm using Scrcpy and Adb to wirelessly connect to my Phone(for developing Flutter Apps) and since the screen wasn't staying awake even by Scrcpy --stay-awake command.
I had to change Lock Settings=>Lock Screen => Sleep, and settings to Never Sleep.
this is my steps:
adb connect 'my android IP address'
connected
adb reboot //in this step my phone is rebooting and the process is hang.
What can be the problem, is there any fix or workaround?
When i working on ADB with USB cable it's working well.
thanks
Somewhat speculation, but adb reboot may shut the phone down abruptly enough that the ADBD on the phone never gets to properly close the TCP connection to the ADB server on your development machine. This would be a lot like the way "hung" TCP connections can result from pulling out a network cable - TCP is designed to survive intermittent communication failures, and so doesn't give up on the possibility of the other end answering until a fairly substantial amount of time (in human terms) has passed.
It's entirely plausible that the ADB server isn't written to take into account the combination of two features which are even individually a bit on the obscure side - TCP connection with rebooting.
If that is the case, your practical options may be to have something kill the ADB server immediately after issuing the reboot, or else modify ADB (it's open source after all) to more intelligently handle this, for example automatically disconnecting after a second or two of non-response if it has issued a reset command.
Can I dump logs from an android phone over wifi (using tcp/ip) using adb? adb connect can be used, but it needs some server to be running on the phone (at 5555 port). How do I start this server?
Or the only way to get logs from a phone is by connecting it as a USB device?
Install adbWireless on your phone. Run the application and click on the big button (you cannot miss it!). It will activate ADB over Wifi and display the URL to use to connect to it with the adb command.
On your computer, run the adb command with the connect parameter. The usage for adb says:
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
Obviously the computer and the smartphone must be on the same Wifi network.
zero4
All you are trying to do is drop adb logcat command on the device & send output stream to a remote location. I would suggest, read this post about how to run shell commands in your app.
The summary is
Run "adb logcat"
Collect Output Stream of the command in a file on device
& Finally post that file to your local server OR Manually pull that file from device
The post contains link to everything you are looking for.
Android is very paranoid when it comes to network access. Without root access, you can't really run any servers, just clients. In short, without root, look at the answer from 100rabh.
If you do have root, you could either open up your network stack for incoming connections on port 5555, or you could hack adb to do the inverse connection (that is, connect to your client). The latter is way more secure and shouldn't really be to hard to do. (I haven't looked at the code for a while, though.) The communication bits for all parts of adb is handled in one and the same library, for all three parts of adb (server, daemon and client).
By the way, what you refer to as a server on the phone is really the adb daemon.