faster adb commands (skip delay in each command) - android

I send debug commands via adb in windows to my rooted android device.
command is in a loop:
adb shell input tap 200 200
but it seems there is a second or fewer delay in each command to run in device.
is there any way to send commands on device without delay or decrease it?
Note: I used tasker and result was same as adb in windows.

There is no delay "between" the commands. It just takes about a second (depending on the device) to run the input command.

Related

How to end an emergency call using adb commands on an Android phone

The recommended command is
adb shell input keyevent 6
But this only works with non-emergency calls. The device doesn't respond to this command during an emergency 911 call.
Any idea how would I go about ending a 911 call using adb commands ?

Nohup alternative - Running persistent scripts after closing adb

I'm having a problem keeping scripts running (in background) through ADB on my non-rooted Mate 10 after the phone has been unplugged.
I've tried to use the nohup command which has always worked for me with other Android devices, to no avail. I know that nohup only protects from SIGHUP and SIGQUIT signals and so the device might be sending a different signal to kill the process.
I have also tried spawning a child task which runs the script to try to 'hide' the spawned process and tried calling /system/bin/sh to spawn a shell within a shell which have both also failed.
Does anyone have some ideas on alternatives to nohup for non-rooted Android OS or any other ideas on how to solve this issue?
Edit: disown and screen are not present in the Mate 10's shell so they cannot be used.
there are several options:
disown
You can combine disown and & to push your script to the background
$ disown [your_command] &
[your_command] can be checked by the jobs command. Once typed you will
$ jobs
[1]+ Running [your_command]
screen
Is a virtual terminal. Screen will keep running even if your session gets disconnected. When you reconnect to the server you can reconnect to the screen session and everything will be as if nothing happened.
link: gnu screen manual
background push
[your_command] &>/dev/null &
&>/dev/null redirects all the command output to a black hole.
& runs the process in the background.

Detect if ADB server is running on Android?

I am trying to detect if the adb server is running on the Android device for part of an anti-cheating implementation for my free game.
Specifically, I want to stop use of adb shell input tap x,y, since the game is a competitive multiplayer puzzle game.
Things I have tried:
Using battery info I can detect if USB is plugged in. Well, that is also a legit use.
Using Settings.Secure or Settings.Global, I can query ADB_ENABLED, but that always returns 1 if adb is enabled. It DOES NOT take into account adb connected or not!
Querying all system services, but I cannot see anything that looks like an adb service.
At this point, I am out of ideas. Hopefully someone else knows how to do this?
You can check for running adbd process or query init.svc.adbd system property:
$ ps adbd
USER PID PPID VSIZE RSS WCHAN PC NAME
root 14947 1 4596 208 ffffffff 00019358 S /sbin/adbd
$ getprop init.svc.adbd
running
In Android the adb driver is implemented as a function of universal usb driver. You can check the (comma separated) list of currently enabled usb functions to see if it includes "adb":
$ cat /sys/devices/virtual/android_usb/android0/functions
mtp,adb
But you would not be able stop cheating while your app is running completely on the user controlled device.

How to make adb server not respond?

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.

adb wait-for-device is a dirty liar [duplicate]

I'm writing a python script that makes calls to adb to perform JUnit tests. I've used 'adb get-state' and 'adb wait-for-device' to wait for when the emulator is booted and ready to go, but for some reason, both of these kick off too early. After these functions return, I get this error when I start to run my tests:
android.util.AndroidException: Can't connect to activity manager; is the system running?
Is there a way I can get the status of the activity manager? If I could just poll that status that should be sufficient.
Thanks!
adb wait-for-device tells you if the adbd on the device is responsive. However, that it a linux-level daemon on the device, well below the level of the android platform which is normally started after (except in the case where ADB has just been enabled from the settings menu).
Particularly on emulators, starting up the java-level android runtime is a lengthy process, so there can be a period of seconds to minutes when adbd is responsive, but there is no ActivityManager to talk to.
After adb wait-for-server, putting an attempt to do whatever you are trying to do (presumably run the 'am' command) in a loop with a one second delay and checking the output may be the simplest solution.

Categories

Resources