yashsingh1/xdaforums huggingface dataset:
[Tasker Tips & Tricks] finck125:
[MENTION=3372705]Humpie[/MENTION] any update on getting this to work for LineageOS/CM? I have tried to send Ctrl+C, \r, and \n in the code on its own stream.write line, but it still doesn't seem to work. what was the fix you were trying? I would like to test it to see if it works for me.
[Tasker Tips & Tricks] Humpie:
I haven't had time to look at it in a while due to university being started and all. I was looking at sending an enter before sending the command but it didn't work with my plugin and my tablet running CM is being very weird with adb so I can't really trial/error my way through testing... If you have a consistently working method using the other adb app or perhaps with my source code, please let me know
[Tasker Tips & Tricks] finck125:
I understand not having time to mess with this :). The only way I have been able to get the other ADB app to work is to either send a command (which ends up being ignored), or by long pressing the screen and sending a Ctrl+C. It seems like the tasker plugin is coded to only send one command at a time (based on the SendSingleCommand.java class name). I might try removing the code to close the connection and call the plugin from tasker multiple times to see if the second command works.

Edit: Tried commenting out the close connection code, and the second task timed out.
[Tasker Tips & Tricks] Benny Bosser:
Awesome app! Thank you so much

[MENTION=6098695]digitalpig82[/MENTION] thanks for your amazing guide, you saved me a lot of frustration!
[Tasker Tips & Tricks] Humpie:
Sending a ctrl+c from within the other app you mean? You perhaps can try sending (I beleive it's something like) ^C and then a newline before sending the command to the device or by prepending it before the command with ";"?

It's true the plugin can only send a single command in text but if you separate the commands with ";" you can thus send more at a time. (but I named it that way since the command is sent over a single time).

Yup closing the connection isn't something you can remove, it's necessary to allow new instances be connected.

Edit: so indeed the other adb app has ctrl+c implemented, I wonder how... I can't seem to find it in the adb library, will do some digging (and ask the creator). That way I could just simply let the app send a ctrl+c before the command as it shouldn't affect the performance on non-lineage phones
[Tasker Tips & Tricks] digitalpig82:
No problem mate, I'm glad I could help someone by writing this. :)

I still use this plugin every day in my automated tasks. Since my device is still not rooted, many tasks simply would not work without it (or I would be forced to use some hacky workarounds). It's kinda like the most important plugin for my use case!
[Tasker Tips & Tricks] Benny Bosser:
He he, same over here, don't want to root my note 8, but I miss some root goodies. Mind sharing a list of adb shells you use? Your first one was so handy, you might have many more : D
[Tasker Tips & Tricks] Humpie:
I'm actually a bit closer I think. That Ctrl+C part gave me an idea and I found out adb shell has a default escape character "~" which appears to be doing the same thing as Ctrl+C however I wasn't able to send it from within the plugin, please experiment a bit with this character before the command with or without ";" etc. In the meanwhile I'm trying to contact the dev of the adb library
[Tasker Tips & Tricks] Humpie:
I got a response from the original developer and tried to send a CTRL+C before each command. This actually had some response on my ancient Motorola Xoom on Cyanogenmod! But it was very inconsistent, so I'll let you guys with lineage os try. It still works on "normal" android devices albeit a bit slower.

Since sending a CTRL+C also exits the stream, the writing of the command needs to be immediately sent after it and sometimes the stream is even already closed. So I try to send the command until it succeeds (which can take a while sometimes)

But please give it a try and post logcats!

The response output might be a bit messed up on this build tho
[Tasker Tips & Tricks] finck125:
My few attempts to run the new version have just ended in timing out. I'm not sure how to get a logcat or I would include it.
[Tasker Tips & Tricks] Humpie:
Thanks for trying anyway. Do note that it can take up to 10 minutes before the app works after an install
[Tasker Tips & Tricks] Humpie:
I decided to publish the app on XDA Labs too! You can find it here

Enjoy
[Tasker Tips & Tricks] digitalpig82:
Hey mate, sorry for being late. Actually, I use only two commands regularly.

The first one is the one from my example: input keyevent power. I have a task that runs only this action and I've put it on my home screen to execute it. In some situations, it's more useful than pressing the hardware button. In addition to that, I use it for a quick test to check whether my adb connection is still running. (As mentioned above, it breaks down some times, unfortunately.)

The second one is for toggling mobile data on/off, svc data enable and svc data disable. This is the one that runs countless times a day on my device (okay, not countless, but several times ;) ). I use it to turn it on in the morning, switch from wifi to mobile data automatically and finally turn it off in the evening. This is the one that is REALLY handy. :cool:

What are your adb shells you use? Maybe we could give each other some inspiration! :cowboy:
[Tasker Tips & Tricks] vaderag:
This was working great but just received an update and now fails with the following error... Any thoughts? Thanks

I re ran the ADB command on computer to open port...

11.22.58/E FIRE PLUGIN: ADB Shell Command / com.twofortyfouram.locale.intent.action.FIRE_SETTING: 4 bundle keys

11.22.58/E ADB Shell Command: plugin comp: com.ADBPlugin/com.ADBPlugin.receiver.FireReceiver

11.22.58/E add wait type Plugin1 time 5

11.22.58/E add wait type Plugin1 done

11.22.58/E add wait task

11.23.03/E Error: null
[Tasker Tips & Tricks] digitalpig82:
Sorry, I have no idea. [MENTION=3372705]Humpie[/MENTION] maybe?
[Tasker Tips & Tricks] Humpie:
An update? What app got updated? Or was it your phone perhaps?

It looks like an out of time kind of error, does it fail every time?
[Tasker Tips & Tricks] vaderag:
Update was the phone update (October or November security update)

It still doesn't appear to be working, but haven't tried since the latest update as I gave up. Would love to get it working again!
[Tasker Tips & Tricks] cablegoon:
cant seem to get it working on my fire tv correctly - after I launch an app adb gets turned off and I cant do any other commands after that - let me know if this is a bug or if there is a workaround.

I have to turn adb debugging on/off each time I want to use the plugin

TY
[Tasker Tips & Tricks] Benny Bosser:
Wow totally missed your answer! Thanks for replying! I don't use any other commands than this one unfortunately :( as for phone updates breaking the functionality,I've just updated my Note 8 and everything is still working fine over here
[Tasker Tips & Tricks] lauralbaby:
I had trouble getting this to work at first, it appears you can only have one debugger attached at once, heh. So I do wonder if it would be at all possible to get the output of an adb command? For example, when I run dumpsys over adb it works fine, but not through a terminal or Run Shell in Tasker.
[Tasker Tips & Tricks] capstan12:
Also ran into an issue.

I want to turn on/off my fireTV-Stick, so my configuration is:

192.168.0.100

5555

input keyevent 26

This kinda works for the first time. It is turning on/off the TV. However, the ADB Shell command inside Tasker keeps running for a very long time (the play icon is next to the action) and only proceeds after 1 min (I guess that's the timeout hitting in).

If I try to run it another time afterwards, its proceeding through the task very fast and nothing happens. Outputs are empty, too.

If I then try to connect from another device, I can't connect to the firetv stick.

So I think it is not able to exit from adb, then timeout cuts off the task and the Stick is "blocked". I have to cut the power and let it reboot. Then its working once, again.

Any ideas?
[Tasker Tips & Tricks] Humpie:
This appears to be a bug but not something I can easily solve as adb works different on each device :/. My Plugin tries to connect, send the command and disconnect, but if at any of these points the device refuses the connection might not be closed, so I think that's what's happening.
[Tasker Tips & Tricks] Humpie:
Is dumpsys available through adb shell? Then yes, you can get the output in tasker. But only then. That's for instance also why adb push doesn't work. It's a different protocol than adb shell.
[Tasker Tips & Tricks] Humpie:
Yep I've heard this one before. The firestick doesn't allow to close the connection properly afterwards :/. What you can try tho, is adding "; exit" to the end of your command. Let me know if it works
[Tasker Tips & Tricks] capstan12:
Forgot to mention that I already tried that. Doesn't help.

Whats strange is, that I can close the connection from my laptop or using this app: https://play.google.com/store/apps/details?id=com.cgutman.androidremotedebugger

(adb disconnect)

So there should be a possible way...

Edit: edited this message, got the text wrong, so you might understood somethin different at first
[Tasker Tips & Tricks] capstan12:
Tried around with it, still no luck.

Found somewhere that you based your work on remote adb shell. As it's working there, is there still a chance to fix it in your app?

Best
[Tasker Tips & Tricks] Blue858:
Thanks for sharing！
[Tasker Tips & Tricks] Humpie:
Well, the difference is that in the other app you can take some time after you sent the command to close the connection while the plug-in tries to handle everything as fast as possible. If I slow it down it will be slowed down for all devices soo... yeah
[Tasker Tips & Tricks] capstan12:
Understand: one idea: a option inside the plugin preferences/the action called "use for firetv stick" which slows it down? So others would stay with the fast acting and firetv's (and possible other devices having this issue) would be working.

Really would be awesome, as this gives the possibility of controling the firetv with google home!

Thanks again for this great add-on!
[Tasker Tips & Tricks] ashjas:
[MENTION=3372705]Humpie[/MENTION]

I tried to use your plugin to execute the following command:

appops query-op --user 0 READ_CLIPBOARD allow

Which doesent work.

obviously i have setup wifi adb and commands like "input keycode" work.

on a shell prompt, the above command results in the following error:

Failure calling service appops: Failed transaction (234235235)

Is the above command possible using wifi adb setup and your plugin?
[Tasker Tips & Tricks] capstan12:
Sorry, that I'm so impatient, but: no love for this idea?
[Tasker Tips & Tricks] geigervibe:
I vote also for a re-edit of this plugin, but I would not call this option as "use for firetv stick", I would name the toggle rater fast/safe mode. I do not have a firetv but have the same problem. My task / the adb-action is always running in a time out, no matter what I do.

I have no problems to connect and running an adb-shell from my notebook via wifi nor via the app "Remote ADB Shell", if I disconnect the last session correctly or if I set USB-Debug off/on in the dev-settings. I own a none-rooted Sony tablet SGP621 with stock firmware android 6.0.1.

If it is only a timing problem as expected, then a fast/safe(slow) switch inside of an adb-action would be very much appreciated.
[Tasker Tips & Tricks] Humpie:
I just tried it on my Pixel 2XL and the command worked, so I guess it's just your device. Does the command work from a pc?
[Tasker Tips & Tricks] Humpie:
It's been a long time since I worked on this plugin, been busy with my other Tasker plugin and a widget app. However I've learned a lot in the mean time, so perhaps I am able to solve this problem now whereas I couldn't before. I'll definitely try this week or the next, as well as update the plugin to the newest sources and the Tasker service for improved performance on the device running Tasker. It might be a bit hard to test though as most of the time it doesn't time out on my android devices (and I don't have a fire tv), but I've got plenty of android devices in house, so there must be one that has the problem as well.
[Tasker Tips & Tricks] Humpie:
Alright, today I basically rewrote the plugin, converted it to Kotlin, updated the sources, corrected the code of my past self numerous times, added variable drop down menus, etc. I also improved the error reporting. Now is my question whether you could test this version of the app to see if the problems are gone (as I changed a lot) and if the problems are still there to give me the logs :).

Thanks for using the app and being patient with me!

Enjoy

Edit: ooops, found a crash, one moment...

Edit2: There, fixed
[Tasker Tips & Tricks] geigervibe:
You have been fast to re-edit your plugin, thank you for that. Overall the new version feels better, but the problem still exist, with or without the ctrl+c option.

First I force-quit the old version, deleted the app-data and then did an uninstall. Sideloaded and installed the new version. Between each test I switched the usb-debug off-and-on. That works for me, when I use "Remote ADB Shell" and I forgot to exit.

I have no logs yet for you, but some screenshots, because I'm not allowed to link to these screenshots because I'm a new member here, and I did not find any possibility to upload them here too.

... sorry for my bad english...

edit: I was able to sent your the link to the screenshots via pm, maybe this helps to start with...
[Tasker Tips & Tricks] capstan12:
Great to hear, you're back on the track! Thanks for the update!

Sadly it did not change, here are my results:

that happens when I first run the command (which does what it should do)

tahts what appearing if I use it for the second time:

without new option

and thats with "control+c" enabled

Am I supposed to change anything in the dropdown menus?
[Tasker Tips & Tricks] geigervibe:
I have to disable usb-debug off-and-on between each test, because the session gets not closed after a failed attempt. You can test it with using the app "Remote ADB Shell".

I had a private conversation with Humpie after my last post here yesterday. I sent him a detailed logcat output of the errors and he could identify a possible cause. The problem he has is, that he has no problematic device to test with.

I offered him to test his builds...
[Tasker Tips & Tricks] Humpie:
Thanks to the logs of [MENTION=9491380]geigervibe[/MENTION] I found out where the problem was. It was in detecting the end of the stream while waiting for a response. So, I now created a manual timeout for this. If you set the timeout too fast however, the command won't execute because it wont have had the chance to. However, most of the times 50 ms is enough, so it's still quite fast.

I'll share the newest version below, a sort of second beta if you will. Let me know if you have issues!

Oh yeah, I added (as suggested) %errors as response variable which contains all the logs I need when an error occurs :) makes it easier for everyone.
[Tasker Tips & Tricks] geigervibe:
:good:

Looks good so far, now you have an error reporting, we do not need this anymore! THANKS.

I will take a deeper look at some later point. Now I'm trying your hotword-plug, which I have minor problems with. BTW is there a limit of hotwords in the free-edition?

Edit: tested it with 100ms
[Tasker Tips & Tricks] Humpie:
Haha, Nice you're also looking at my other plugins ;p for that I created a beta as well, but only for the pro version as it's less work refactoring, however not many people seem to be testing it... it shouldn't have any limits, just a single ad.
[Tasker Tips & Tricks] Humpie:
I forgot that I didn't actually put the latest version in the Play Store and XDA Labs yet due to being busy with Hotword Plugin. Oops.

Well I released it now!

• 6.0 Biggest update yet!

- Added timeout mechanism so that it should work on all devices including the Fire TV

- Rewrote code to Kotlin, upgraded sources to Pie and fixed my ignorant code errors

- Better error reporting (in %errors), so if you find any, please send me %errors

- You can now choose variables from a drop-down list for convenience

Check it out if you haven't already, the links are in my signature. Thanks to you all for your help!

Edit: for the latest version, check XDA-Labs. The incompetent app-check system of the Google Play Store rejected my update due to a "Violation of Payments policy".

As you all know this app is completely free and open source... :rolleyes: Hopefully they'll resolve it quickly.

Edit2: seems to be rolled out! Guess they didn't like the PayPal donation link anymore. Odd, it's been there since the beginning. Oh well.
[Tasker Tips & Tricks] gautamajay52:
How can i give adb commands to my phone itself???
[Tasker Tips & Tricks] ktmom:
Not relevant to this thread, but please read adb shell and terminal emulator

"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini
[Tasker Tips & Tricks] fire1951:
I am trying to use the adb shell plugin on a fire stick 4k to send a keyevent...when I execute it I get Error 10"the socket fails while connecting " error. Can you explain how/if I can remedy this? Thanks.
[Tasker Tips & Tricks] Arka Bhattacharya:
could you educate me to use adb with dead phone?
[Tasker Tips & Tricks] Humpie:
Adb only works if the phone is booted up and the phone is connected via USB or wifi (if adb over WiFi is enabled) to computer (which you previously had to grant access). So if your phone is dead your only way if using adb is if you're able to get to TWRP recovery and then using a USB cable attach it to the computer.
[Tasker Tips & Tricks] fire1951:
Could you explain the meaning of "Error 10"....."the socket fails while connecting", please? Refer to above post 107. Thank you. (And tell me if there is something I can do to make it work for me....I am unrooted, if that makes a difference). P.S. The remote adb shell app your plugin is based on works remotely with the fire stick but not locally. I am using Tasker version 5.2.bf1 .
[Tasker Tips & Tricks] Humpie:
The socket connection is the first thing that happens when the Plugin starts. So when the socket fails to connect it can't find the device or connect to the IP address.

If it works remotely it should also work locally. For the IP try "localhost" or "0.0.0.0" or "127.0.0.1", maybe those will work.
[Tasker Tips & Tricks] fire1951:
Thanks for the response. Evidently the "adb over network" setting on thefire stick was casing the problem (it was turned on but needed to be turned off then back on to work (???) ) . Now I don't get the error (the little indicator in front of the task turns green instead of red and the error does not come up), but nothing happens ....I have been trying " input keyevent 223 " and 276, and others , but nothing happens. When I try thisfrom a remote device over adb over network, it works. Is there something else I can try? Thanks.
[Tasker Tips & Tricks] fire1951:
I thought you wanted to know if anyone had issues using your plugin ( as per your post#101). I posted the problem I was having, but so far no suggestions. In the absence of any alternative ways to do this with your plugin, I found another way to accomplish my task without the use of your plugin. Thanks for the initial suggestion ( didn't cure the problem ,though). Good luck.
[Tasker Tips & Tricks] Humpie:
Really strange... I don't have a fire tv stick to test it for myself, otherwise I would. ADB over network definitely should be turned on on the fire stick, otherwise it cannot connect to it at all (Maybe you'll get a different error or none). Something else you can try is increasing the timeout from the plugin, set it to 1000 to give it a second to execute the command. Aside from this I also don't know how to make it work. Some devices need different ADB versions or work completely differently (like Cyanogenmod/Lineage os devices), and maybe the Fire tv is also an odd device like that, not really developer friendly.
[Tasker Tips & Tricks] fire1951:
Thanks very much for the response. I tried the longer timeout and that seems to have done the trick .It is working now. Thanks again!
[Tasker Tips & Tricks] Sedhadi:
Sorry if it's off-topic, but I think it's kinda related. Using this plugin, is it possible to distinguish whether the screen was turned off by power button or screen timeout?

BTW, what other cool root actions can be done using this plugin on a non-root phone? Is toggling airplane mode and toggling Mobile Data off possible?
[Tasker Tips & Tricks] 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.
[Tasker Tips & Tricks] tyler78:
Unfortunately this didn't work for me. I've tried 127.0.0.1, 0.0.0.0, localhost, ctrl+c, longer time outs. It doesn't give error either. I have an lg g6 with android 8.0.

Also input keyevent power works from pc. It doesn't work with this plugin.
[Tasker Tips & Tricks] tyler78:
I've found one of the early versions in one of your posta. 6.0b1 to be exact. That worked for me. Thank you so much
[Tasker Tips & Tricks] Humpie:
Strange the newest version doesn't work for you... But I'm glad an older version does!
[Tasker Tips & Tricks] Humpie:
It uses an accessibility service. This works without root but can ask s lot of battery.
[Tasker Tips & Tricks] deepesh_p:
[MENTION=3372705]Humpie[/MENTION]

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?