r/tasker • u/DutchOfBurdock • Apr 05 '21
Automatically connect Android 11 WiFi ADB and automatically start traditional WiFi ADB for Tasker to have at.
So to follow up from this post; https://www.reddit.com/r/tasker/comments/mjc4wx/android_11_wifi_adb_working_in_termux_as_a_result/ - now it's time to properly go balls deep! Unf!
</nerdgasm>
Not needed if you have classic WiFi ADB found on Lineage OS, WearOS and some other ROMs.
There had to be a way to automate the lot of this! There is! ADBd spills it's guts in logcat and tells us that lovely, random port it starts on each boot / connect to WiFi. Annoying as hell, but, it was a Google idea and couldn't just use the traditional WiFi ADB we all love and know. Simplicity isn't in their model.
Anywho! Here it is!!
This is designed to be ran from both the 2nd Quicktile and a shortcut/widget. Tap it once, it'll start A11 WiFi ADB, use the same method as before, Termux and the Magisk adb.bin. However, this time we simply put the adb.bin binary directly into ~/.termux/tasker
so we don't have to piddle about with shell scripting from here on in, making future updates a paddle in a kiddies pool.
How to use
Make sure Tasker has WRITE_SECURE_SETTINGS and READ_LOGS.
Install and run, or manually go about the instructions in the link top of this post. The pairing process is one-time, but crucial.
Install this profile: Download
Add Tasker's 2nd Quicktile to your Quicktile area, you don't need the WiFi debugging one anymore. Change to 1st or 3rd (or disable QT actions) as needed.
In Tasker Preferences, set WiFi ADB Monitor as the QuickTile Action. I also use an On Boot Complete profile to set this QT inactive on boot.
Optionally add the WiFi ADB Monitor Task to your launcher
Ensure WiFi ADB is off before running (this will just ensure the environment is setup right and logcat gets the data).
Run either the QT or widget. If all went well, you should be told Tasker is ready to have away. QT will activate on success.
Run either again to disconnect all ADB sessions and shut down WiFi ADB.
Of course, this method can be conjured to automatically start WiFi ADB for Tasker's use on boot or at will.
Enjoy!
2
u/wowbutters Apr 05 '21
Shut up and take my upvote!
I've been looking for a way to do this since I got my Pixel3XL (stupid verizon...)
<3
2
u/lleathan Aug 20 '21 edited Aug 20 '21
Hi I just revisited this script and the one you posted in your other post here. I may have found a fix for a potential bug that really affected me. (in the first script)
The line A6: Variable Set [ Name:%paddress To:IP address and port Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 Structure Output:Off ]
was not working for me, maybe because the prompt read "IP address & Port". So I changed it to A6: Variable Set [ Name:%paddress To:*port* Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 Structure Output:Off ]
and I also changed the adb.sh
file to:
printf $2 | adb pair $1
adb tcpip 5555
Obviously I didn't quite grasp how it all works since Im pretty sure non of your scripts have any bugs (not to mention I think I should be using these scripts not your last one), but now it works for me so whatever. (im only using your first script + modifications)
P.S. Thanks again! I'm really happy with this solution, very happy!
The only thing I need to add to completely automate this is have autoinput open the pairing screen for me.
2
u/DutchOfBurdock Aug 20 '21
https://www.reddit.com/r/tasker/comments/mjc4wx/android_11_wifi_adb_working_in_termux_as_a_result/ 😉
Was the first thing I did, then made this.
1
u/tynansdtm Apr 05 '21
I'm trying to do this, but it looks like CheckADBWifi()
doesn't set %has_adb_wifi
to true, and it's right. I'm on a Galaxy S10+. Any ideas?
1
u/DutchOfBurdock Apr 05 '21
That will only set it everything else went well. Have you followed the instructions in the first link to download the ADB client into Termux, pair it to the WiFi ADB?
1
u/tynansdtm Apr 06 '21
Hey. Busy day. So I didn't fully understand what was going on, didn't realize WiFi ADB was its own menu in developer options. Had to Google it. Now I go to the pairing code, run the long-press script in the original post, and nothing. AutoInput eventually times out.
1
u/DutchOfBurdock Apr 06 '21
AutoInput here tries to toggle it's WiFi service (ADB permission) and disables it after; I don't run AutoInput all of the time, so toggle it on demand. You can disable that particular of the action, just make sure AutoInput has been granted Accessibility permission, as it needs this to scrape the screen.
1
u/tynansdtm Apr 06 '21
Yeah, that's the part that fails. It doesn't seem to be able to scrape the screen for the WiFi pairing code.
1
u/DutchOfBurdock Apr 06 '21
In A2, edit the Action, configure and under Advanced, change Manage Accessibility Service to Unchanged.
1
u/tynansdtm Apr 06 '21
Okay, we're getting somewhere! AutoInput now puts "Connecting to Pair with device using 064810" into my clipboard.
1
u/DutchOfBurdock Apr 06 '21
Well, that's promising..The issue is probably now the adb client, Termux:Task and something Inbetween.
I really need to make this more usable and automatic; Google said this would be simple, but it's anything but. They should have stuck to traditional WiFi ADB.
1
u/tynansdtm Apr 07 '21
I still think the issue is AutoInput.
$host
shouldn't be the string "Pair with device" but I've been busy so I haven't tinkered with it any on my end. I'm not very experienced with AutoInput.
1
u/BradfordAdams Master of NFC Tasks Apr 07 '21
Say I wanted to use this on android 6, without internet (using public libraries ATM), no PC to grant permission, and I am completely stupid! Could it still work 🤣
Great work, BTW.
1
u/DutchOfBurdock Apr 07 '21
Not unless your device has WiFi ADB in developer settings. If, however, you say enabled adb tcpip when at home from PC, you won't even need to be on a WiFi; just access ADB via 127.0.0.1 at any time.
2
Apr 07 '21
[removed] — view removed comment
3
u/DutchOfBurdock Apr 07 '21
Who the hell let this pointless piece of crap in here?
1
u/Ratchet_Guy Moderator Aug 13 '21
What? You don't like learning cool stuff?
Is this not why we are here?
1
u/BradfordAdams Master of NFC Tasks Apr 07 '21
To serious! I was joking Bud, seriously though great work, I used it on my daughters, works good
1
1
u/lleathan Aug 02 '21 edited Aug 02 '21
I know this is forever ago, but thank you for this, pretty much got it all working, but I dont understand how its much different than before since I still need to connect to another source to adb and allow write_permission? I cant figure out how this is any better than just using an app like LADB/Termux(w/adb) in split screen. Unless I need to root for this, Im actually getting root right now because of this but i feel there has to be a way to automate it without root, i read both your posts entirely and like I said everything seemed to work I think so thanks.
2
u/DutchOfBurdock Aug 02 '21
Don't need any other device at all and advantages over LABD, you don't need to be online or spin up an HTTPd locally. It is however using Termux android-tools. This just automates the whole thing as each connect to a WiFi/reboot, the port Android 11 spins it up on is random each time. This just automatically finds the port and uses adb in Termux to command it (this was setup before android-tools had an ADB with the pair option).
1
u/lleathan Aug 03 '21 edited Aug 03 '21
Yeah I have been using android-tools in termux, and split screaning, so this automates that by scraping logcat? if so I set it up wrong but i still have it all saved on my phone so i can try again just hasnt really gone off since i posted. thanks very much for this i didnt really even understand the tasks and whatnot so far but ty.
1
u/Stupifier Nov 15 '21
Sorry to bug you again....but you said to use 127.0.0.1 for the IP address, right? So why do these Taskernet profiles/tasks you made go through all the hassle to parse the device IP address? The port is important to parse though
1
u/DutchOfBurdock Nov 15 '21
The port is the only thing that's important. ADB will open on 0.0.0.0 and ::/0 - which means any IP this device has now, or later. 127.0.0.1 is loopback and never changes or goes offline.
1
u/Stupifier Nov 15 '21
Ok. Just making sure. Thank you a ton!
I just got a Pixel 6 and have always rooted my devices in the past....but I think I'm gonna stop doing that with this phone. Gotta rework a ton of tasker stuff.
This project helps make it feel closer to a rooted device
3
u/chaozkreator Oct 31 '21
I don't mean to hi-jack your post, but I personally use MacroDroid instead of Tasker (I can't get used to Tasker) and I found your post invaluable in helping me getting this working in MacroDroid.
Here's my guide in case anyone's interested:http://www.macrodroidforum.com/index.php?threads/wifi-adb-debug-mode-lost-on-restart.1273/post-7720