Hello,
I'm developing a program for Windows users that is able to push text to the device.
The problem is that it is veeery slow. Do You know any way to improve the speed?
The code looks like this:
HTML:
adb shell input keyevent 42
adb shell input keyevent 43
adb shell input keyevent 62
adb shell input keyevent 32
adb shell input keyevent 43
adb shell input keyevent 30
adb shell input keyevent 46
adb shell input keyevent 29
adb shell input keyevent 62
adb shell input keyevent 48
The problem is you are opening a new shell for every key, this makes it very slow but also your key is transfered to a shell which is immediately killed, so is your key-press.
Normally you would like to wait for a series of keys which make a command and then transfer this on enter so the command can be executed. This will make it quicker but would also make more sense.
requist said:
The problem is you are opening a new shell for every key, this makes it very slow but also your key is transfered to a shell which is immediately killed, so is your key-press.
Normally you would like to wait for a series of keys which make a command and then transfer this on enter so the command can be executed. This will make it quicker but would also make more sense.
Click to expand...
Click to collapse
The problem is that I tried using it in both ways and it still takes long. The program waits until the user hits enter and then send all of the commands in one shell, so all of the keycodes are send at one time.
Ok found it.
The code has to be like that
HTML:
adb shell input text "here the text"
Now my only problem is that space isn't supported but I know how to make it work
good luck
Hello,
I'm developing a program for Windows users that is able to push text to the device.
The problem is that it is veeery slow. Do You know any way to improve the speed?
The code looks like this:
HTML:
adb shell input keyevent 42
adb shell input keyevent 43
adb shell input keyevent 62
adb shell input keyevent 32
adb shell input keyevent 43
adb shell input keyevent 30
adb shell input keyevent 46
adb shell input keyevent 29
adb shell input keyevent 62
adb shell input keyevent 48
I have installed cygwin64 and when I run adb shell, I get no shell prompt, but I can still run commands.
However, if I run adb shell from cmd.exe, it does show the phone's shell after running adb shell. Here is the phone's shell that is shown to me in cmd.exe:
bullhead:/ $
I've run into this same issue. Have you discovered a solution?
For now, I'm using Windows PowerShell (instead of cmd.exe) to access adb shell.
Prank Android phone users with ADB:
Connect to phone wirelessly:
Connect phone via USB
adb tcpip 5555
adb connect <Your phone IP>:5555
Disconnect USB
(To get IP address type adb shell ip -f inet addr show wlan0)
(To return to using USB for adb, type adb usb)
Record Screen:
adb shell screenrecord /sdcard/demo.mp4
(to record)
adb pull /sdcard/demo.mp4
(to copy the file)
Send Text:
adb shell input text "This%Sis%Stext"
(%S is a space)
Send Keypress:
adb shell input keyevent <keycode>
(This can be used to quit to the launcher, send random keys, etc.)
(Keycodes listed here: https:<double slash>elementalx<dot>org<slash>button-mapper<slash>android-key-codes<slash>)
I found I can use these ADB commands to turn on and of the WiFi of a rooted phone:
Code:
adb shell su -c 'svc wifi enable'
adb shell su -c 'svc wifi disable'
However, I'm interested in doing it without having to root the phone for an automatic testing I'm doing. Do you guys know if this is possible?
I found this project which allows me to connect to a WiFi through ADB commands not being a root user. I was wondering if anyone knows how to disconnect also from ADB and not being a root user.
UPDATE:
I've been recently trying:
Code:
C:\adb>adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
adb server is out of date. killing...
* daemon started successfully *
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
Warning: Activity not started, its current task has been brought to the front
and
Code:
C:\adb>adb -s serial_number shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
Warning: Activity not started, its current task has been brought to the front
I also found doing this type of command:
Code:
adb shell input keyevent 20 & adb shell input keyevent 23
I can navigate and click. The problem seems to be that I always finish in a different state so the next time I input the command
Code:
adb -s serial_number shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
I start in a different place and start clicking elsewhere. I've tried returning home, but that doesn't fix the issue. Is there any way to start always from the same point inside the WiFi settings?
Thanks!
natiya said:
I found I can use these ADB commands to turn on and of the WiFi of a rooted phone:
Code:
adb shell su -c 'svc wifi enable'
adb shell su -c 'svc wifi disable'
However, I'm interested in doing it without having to root the phone for an automatic testing I'm doing. Do you guys know if this is possible?
Click to expand...
Click to collapse
Turn WiFi off
Code:
adb shell settings put global airplane_mode_on 1
adb shell settings put global wifi_on 0
adb shell settings put global wifi_scan_always_enabled 0
Afterwards you've to re-boot the device.
Turn WiFi on
Code:
adb shell settings put global airplane_mode 0
adb shell settings put global wifi_on 1
adb shell settings put global wifi_scan_always_enabled 1
jwoegerbauer said:
Turn WiFi off
Code:
adb shell settings put global airplane_mode_on 1
adb shell settings put global wifi_on 0
adb shell settings put global wifi_scan_always_enabled 0
Afterwards you've to re-boot the device.
Turn WiFi on
Code:
adb shell settings put global airplane_mode 0
adb shell settings put global wifi_on 1
adb shell settings put global wifi_scan_always_enabled 1
Click to expand...
Click to collapse
Thank you, but those don't produce any change on my device. Actually, if I put the first two commands without doing "adb kill-server" in between, I get this message:
error: more than one device/emulator
Click to expand...
Click to collapse
But the output when they work is:
adb server is out of date. killing...
* daemon started successfully *
Click to expand...
Click to collapse
and nothing happens.
I've been recently trying:
Code:
C:\adb>adb shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
adb server is out of date. killing...
* daemon started successfully *
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
Warning: Activity not started, its current task has been brought to the front
and
Code:
C:\adb>adb -s serial_number shell am start -a android.intent.action.MAIN -n com.android.settings/.wifi.WifiSettings
Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.wifi.WifiSettings }
Warning: Activity not started, its current task has been brought to the front
This opens the screen where you can turn on and off the WiFi but it doesn't do it...not sure if I'm missing something!
Just to be shure, make shure your using the latest version of ADB offered by google here:
https://developer.android.com/studio/releases/platform-tools
You could use adb wifi
After activating when using usb it and connecting through the same wifi:
svc wifi enable
works without root
I'm a little late to this thread, but if it still helps the OP, non-rooted Android 10 and below allowed wireless adb connections AFTER a USB connection was first established (adb start-server && adb tcpip 5555 && adb connect [IP]:5555), but that changed (for the better) in Android 11 and above with the new new Developer options Wireless debugging random port assignments (adb connect [IP]:[PORT] or adb pair [IP]:[PORT] [PIN]) such that the adb wireless connection never needs USB cable ever again.
Given Android 11 allows Developer options Wireless debugging via a random port, and Android 12 new Developer options Wireless debugging allows that to be accessed even easier with a new Developer options Wireless debugging tile, the only thing missing is a way to turn the non-rooted Android Wi-Fi on or off via adb (which was the OP's original question after all).
Maybe this will work if we can figure out how to tap the buttons?
adb shell "am start -a android.settings.WIFI_SETTINGS"
Click to expand...
Click to collapse
For swiping on the phone from adb this works...
C:\> adb shell input swipe 500 1000 500 100
This will instantly swipe from center to the top of the screen.
You can add a time period, e.g., take 3 seconds to swipe that.
C:\> adb shell input swipe 500 1000 500 100 3000
Click to expand...
Click to collapse
But you want to tap the buttons, right?
If we can figure out the positions, maybe this would work?
C:\> adb shell am start -n com.google.android.gms/.ads.settings.AdsSettingsActivity
That should pop up an Android "Reset Advertising ID" settings page.
C:\> adb shell input tap 500 400
If run after the command above, that will tap the button to
asking to "Opt out of Ads Personalization" in that Activity
if that button is like mine, at the X=500 & Y=400 location.
On my phone, this is the "Reset advertising ID" button location:
adb shell input tap 500 200
On my phone, this is the "OK" button on that GUI above.
adb shell input tap 700 1000
C:\> adb shell am force-stop com.google.android.gms
If run after bringing up the advertising-id reset Activity,
it will close the activity without doing anything else.
Click to expand...
Click to collapse
Here is a somewhat related post...
[adb,scrcpy,vysor] What ports does Android 12 randomly set when Wi-Fi connecting via Wireless debugging adb "pair" or "connect" commands?
Type adb tcpip 5555 in the command line or Terminal and press Enter.
Find your phone's IP address in Settings > About Phone > Status > IP Address.
Back in the command line or Terminal, type adb connect [your Android's IP address].
Finally, press Enter again.
Regards,
J Wick