FORUMS
Remove All Ads from XDA

[Plugin] Remote Adb Shell

1,139 posts
Thanks Meter: 274
 
By Humpie, Senior Member on 23rd February 2017, 05:53 PM
Post Reply Email Thread
4th May 2019, 10:20 PM |#121  
Quote:
Originally Posted by Sedhadi

How does this app handle moving the cursor without any permission granted via adb? It seems to even detect when keyboard is open (not element focus and it's still unknown to me) and then remaps vol +/- buttons to cursor left/right.

It uses an accessibility service. This works without root but can ask s lot of battery.
 
 
4th August 2019, 02:03 PM |#122  
Senior Member
Thanks Meter: 36
 
More
Quote:
Originally Posted by digitalpig82

Prerequisites:
Connect your device via ADB to a PC (google it if you don't know how) and run the command "adb tcpip 5555". That's it, you can disconnect your device now.

Then in Tasker, create an action with this plugin and type in the following:

IP Address: localhost
Port: 5555
ADB Shell Command: input keyevent POWER

Hit the play button to test this action. If you've done everything right, your screen will turn off.
Congrats, you just executed a command on an unrooted device which usually requires root privileges!

Important:
The only downside is, the tcpip setting does not survive a reboot, so you have to set the port 5555 again via PC after rebooting the device.

I hope I explained the important part well enough. If that's not the case, don't hesitate to quote me and I'll answer here.

@Humpie

Hello both of you. I know this is a relatively old thread but I do hope this reaches either of you.

The power button on my Mi A1 recently stopped working and I have been surfing through XDA to figure out a way to simulate the power button using a screen gesture (eg: double tap on a certain area on the homescreen). Almost 3 articles led me to this thread and I tried the steps mentioned in the quoted comment, but to no avail. 'adb devices' recognises the device and I can even successfully execute 'adb tcpip 5555'. The remaining steps seem straight-forward too but yield no output (I have tried different . Surprisingly, typing 'input keyevent POWER' or 'input keyevent 26' both don't yield any result through the adb command prompt on PC too (with USB or WiFi), so I can't say for sure where the problem lies.

This is what the the adb power shell shows:
input : The term 'input' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ input keyevent POWER
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (input:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I'm running on Android Pie (1st July 2019 security patch) with the latest version of both Tasker as well as this plugin. Is this something that has stopped working Pie onwards or something? Is there a different way to emulate the power key to turn off the screen without having to use the pin to unlock the device (I use the fingerprint scanner to unlock)?

I'll be frank, I'm having to do this for the very first time, so if I've made a rookie mistake, do point out

Edit: Rookie mistake found myself 🤦🏻*♂️. 'adb shell input keyevent POWER' does execute the event via the command prompt. However, while 'adb tcpip 5555' does restart in TCP mode:5555, even 'adb devices' won't recognise the device after I have disconnected it from the USB. Isn't it suppose to work over WiFi?
4th August 2019, 04:47 PM |#123  
Quote:
Originally Posted by deepesh_p

@Humpie

Hello both of you. I know this is a relatively old thread but I do hope this reaches either of you.

The power button on my Mi A1 recently stopped working and I have been surfing through XDA to figure out a way to simulate the power button using a screen gesture (eg: double tap on a certain area on the homescreen). Almost 3 articles led me to this thread and I tried the steps mentioned in the quoted comment, but to no avail. 'adb devices' recognises the device and I can even successfully execute 'adb tcpip 5555'. The remaining steps seem straight-forward too but yield no output (I have tried different . Surprisingly, typing 'input keyevent POWER' or 'input keyevent 26' both don't yield any result through the adb command prompt on PC too (with USB or WiFi), so I can't say for sure where the problem lies.

This is what the the adb power shell shows:
input : The term 'input' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1
+ input keyevent POWER
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (input:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I'm running on Android Pie (1st July 2019 security patch) with the latest version of both Tasker as well as this plugin. Is this something that has stopped working Pie onwards or something? Is there a different way to emulate the power key to turn off the screen without having to use the pin to unlock the device (I use the fingerprint scanner to unlock)?

I'll be frank, I'm having to do this for the very first time, so if I've made a rookie mistake, do point out

Edit: Rookie mistake found myself 🤦🏻*♂️. 'adb shell input keyevent POWER' does execute the event via the command prompt. However, while 'adb tcpip 5555' does restart in TCP mode:5555, even 'adb devices' won't recognise the device after I have disconnected it from the USB. Isn't it suppose to work over WiFi?

Good you found out how adb shell works! From a pc normally you type "adb shell" and enter to enter the shell and then you can send commands like "input keyevent POWER". (And you can exit with typing "exit" or pressing Ctrl+C). "adb shell YOUR_COMMAND" is just shorthand to enter shell, send the command and exit it again.
If you turn on adb over wifi with "adb tcpip 5555" and plug out the cable you need to still connect your pc to your device. In this case you type "adb connect THE_IP_OF_YOUR_PHONE:5555" and then you can adb shell however you like.

Adb plug-in does this last thing automatically, so it connects to the device using "adb connect", it enters the shell using "adb shell" and then it sends your command. After your given timeout in ms, it closes the connecting and disconnects from the device over adb.
This means that if you did your tcpip command, adb over wifi should be enabled on your device and you should be able to use adbplugin using "localhost" as IP and "5555" as port.
The Following User Says Thank You to Humpie For This Useful Post: [ View ] Gift Humpie Ad-Free
4th August 2019, 08:22 PM |#124  
Senior Member
Thanks Meter: 36
 
More
Quote:
Originally Posted by Humpie

Good you found out how adb shell works! From a pc normally you type "adb shell" and enter to enter the shell and then you can send commands like "input keyevent POWER". (And you can exit with typing "exit" or pressing Ctrl+C). "adb shell YOUR_COMMAND" is just shorthand to enter shell, send the command and exit it again.
If you turn on adb over wifi with "adb tcpip 5555" and plug out the cable you need to still connect your pc to your device. In this case you type "adb connect THE_IP_OF_YOUR_PHONE:5555" and then you can adb shell however you like.

Adb plug-in does this last thing automatically, so it connects to the device using "adb connect", it enters the shell using "adb shell" and then it sends your command. After your given timeout in ms, it closes the connecting and disconnects from the device over adb.
This means that if you did your tcpip command, adb over wifi should be enabled on your device and you should be able to use adbplugin using "localhost" as IP and "5555" as port.

Thanks for explaining what was happening there. Unfortunately, it still didn't change the fact that I couldn't run the command locally from the phone. But, I just got pointed to the fact that Tasker now has an in-built 'Turn Off' task under Action Category > Display that does exactly what I wanted—lock the screen while still allowing me to unlock using the FPS—albeit using a task shortcut instead of a portion of the screen. It also does so in a single tap, but given that we are so used to expecting a double tap for this, I replaced a 'If/Else/End If' tutorial to make a multi-tap button, to make a single tap output a Flash message to say "Tap again to lock" and a double tap to lock the screen. Ergo, mission accomplished .

I'm weirdly happy that my power button broke. It made me learn something I had absolutely no idea about. It's just another reason to love Android. Even without root, it's crazy what one can do on Android. Thanks for your prompt response and kudos on the plugin
5th August 2019, 12:50 PM |#125  
Quote:
Originally Posted by deepesh_p

Thanks for explaining what was happening there. Unfortunately, it still didn't change the fact that I couldn't run the command locally from the phone. But, I just got pointed to the fact that Tasker now has an in-built 'Turn Off' task under Action Category > Display that does exactly what I wanted—lock the screen while still allowing me to unlock using the FPS—albeit using a task shortcut instead of a portion of the screen. It also does so in a single tap, but given that we are so used to expecting a double tap for this, I replaced a 'If/Else/End If' tutorial to make a multi-tap button, to make a single tap output a Flash message to say "Tap again to lock" and a double tap to lock the screen. Ergo, mission accomplished .

I'm weirdly happy that my power button broke. It made me learn something I had absolutely no idea about. It's just another reason to love Android. Even without root, it's crazy what one can do on Android. Thanks for your prompt response and kudos on the plugin

Oh right, that's a lot easier!
Haha I'm glad you found a solution and learned something on the way too . For the same reason I'll always choose android myself too, it's just great! I'm one of those guys who does root their phone however, so I can do even more
14th August 2019, 08:19 PM |#126  
• 6.2
- Thanks to those who do not understand that this is a Tasker Plugin. Because of you I got the idea you should be able to test the plugin without Tasker, so now you can!
- Let's see if this takes care of the 1 star reviews haha
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes