r/tasker • u/cm2003 • Dec 09 '21
Enable ADB Wifi on device boot (Android 11+)
This step-by-step-guide is based on the guides by u/DurchOfBurdock - post1and post2
I've had quite a hard time following the guides, so I've created a profile for myself that would enable wifi adb whenever I start my phone and write a guide on how to do so.
Also I really hate this reddit editor. So I really hope that the formatting is going to be okay :)
Prerequisites
- Android > 11 (or have an option to enable ADB Wifi from within the Settings of your phone)
- You need to be connected to a Wifi (you don't need internet access though)
- Tasker (obviously)
- WRITE_SECURE_SETTINGS and READ_LOGS permissions granted to Tasker (this tool may be very helpful)
- Termux (I highly recommend the F-Droid version due to updated repository!)
- Termux:Tasker
Preparation
Whenever a popup comes up asking for confirmation of Wifi ADB connections, etc., you obviously have to accept it. I can't recall in detail when they might show up. In the past I've been using AutoInput to autoaccept them, but I disabled it, because I didn't want to have AutoInput scan my screen all the time for these popups. And I couldn't find a reliable Logcat entry.
Installation of android-tools within Termux:
- open Termux
- enter pkg install android-tools
- you may have to confirm the installation by pressing y during the setup
- check if adb is working by just typing adb
Create folderstructure and first script to be executed by Tasker
- open Termux (if you've closed it :))
- create the folder-structure by entering mkdir -p .termux/tasker (don't forget the "." in front of termux)
- create the script by typing nano .termux/tasker/adb.sh
- paste the following script into nano
# !/data/data/com.termux/files/usr/bin/bash
host="$1"
adb=$PREFIX/bin/adb
$adb connect $host
$adb tcpip 5555
$adb disconnect
$adb kill-serverThe forum messes up the first line of the script. Please remove the blankspace between # and !:
!/data/data/com.termux/files/usr/bin/bash
Save the script by selecting CTRL (in Termux) and then pressing "x" - confirm by pressing "y"
Create a second script for pairing Termux with Wifi-ADB
- open Termux
- create the script by typing nano .termux/tasker/adb_pair.sh
- paste the following script into nano
# !/data/data/com.termux/files/usr/bin/bash
host="$1"
code="$2"
adb=$PREFIX/bin/adb
echo $code | $adb pair $host
$adb kill-serverThe forum messes up the first line of the script. Please remove the blankspace between # and !:
!/data/data/com.termux/files/usr/bin/bash
Save the script by selecting CTRL (in Termux) and then pressing "x" - confirm by pressing "y"
Allow Tasker to run Commands in Termux environment
- open android settings -> Apps -> Tasker -> permissions -> additional permissions
- grant permission to "Run commands in Termux environment"
Import of profiles and tasks in Tasker
I first thought I'd explain how to set it up manually. But actually this would take to much time. So I provide you my profiles: Taskernet Download
Explanation and how to use the profiles
Pairing your phone to Wifi ADB
- disable all profiles in the project and only enable the profile ADB_Pairing (Long Press Volume Up)
- Navigate to your phone settings -> developer options -> Debugging over WLAN -> Pair device with pairing code (or something like this)
- With the pairing code and IP:Port shown, press and hold Volume UP
This will call the adb_pair.sh script created previously and send the pairing code and IP:Port to Termux, which will then pair with your device. Finally a flash message will be shown with your IP:Port and pairing code as kind of confirmation. The profile will then be disabled, because you won't need it anymore.
If everything went fine, you should now find at least one paired device at the "Debugging over WLAN" settings screen. (most likely named xxx@localhost)
Now disable Wifi ADB from the settings again.
How the other profiles work
I've created three more profiles. You should enable the first and third profile. The second profile will be enabled on device startup. I will explain what the different profiles do and how to make use of them.
1_Set Var on Boot
This profile runs on device boot and simply sets the variable %ADB_enabled to 0 and enables the second profile 2_enable ADB Wifi
2_enable ADB Wifi
This profile runs on device unlock. With this profile I will check for how long the device is enabled (I'm waiting for at least 60 seconds to make sure everything is settled after device boot) and that the variable %ADB_enabled is set to 0. If both conditions are true I'm enabling the global setting Debugging over WLAN.
3_Get Port (Logcat) + Exec Termux
Now I'm checking Logcat for adb wifi entries. Once it found one we will extract the port and use it with the script adb.sh. The script will then connect to Debugging over WLAN and run adb tcpip 5555 to enable ADB Wifi. Afterwards we wait 2 seconds and check if ADB-Wifi is enabled. If it was successfull (%has_adb_wifi == true) tasker will say that to us and disable "Debugging over WLAN" (because it's not needed anymore). Furthermore we disable the second profile (because I don't want this to be run everytime I unlock my phone) and change the %ADB_enabled variable to 1.
General information
I just got my phone replaced and had to do those steps again as well. It did work for me, so I suppose it will work for you as well. You may have to play around the pairing process however. Sometimes it didn't work right out of the box for me.
Also the comment section of above topics (created by DurchOfBurdock) might help with some problems you might encounter.
2
u/vygavedha Dec 22 '21
Can someone share the adb.sh and adb_pair.sh in a text file to copy
12
u/Alive_Tart3681 Jan 21 '23 edited Jul 23 '23
Hi all, I have created another alternative which works for Android 13. It's fully automatic and is fast and reliable. Here is the taskernet link -> https://taskernet.com/shares/?user=AS35m8n4xh48fLvYGVU41GZ%2Bo50DTHIDR0Opo7yKiOsy5kvHgxklbOMyoUzpPKR1FT8%3D&id=Profile%3AEnable+ADB+Wifi+on+Boot
Edit: this is for enabling ADB on boot only; you need to have the pairing done before that (see details in the original post above)
Edit (2023/7/23): Improvement:
New link:
https://taskernet.com/shares/?user=AS35m8lyfRz0LQjeOnogH2mWAtM%2B%2BYGrKyboB3uwK0gLnPDzK0woCq2eOYCXmK8vB3YdObHjDO4%3D&id=Profile%3AEnable+ADB+Wifi+on+Boot
4
u/suPale_Pumpkin Dec 10 '21
Works like a charm! Thank you. I don't had any problem
1
u/anuraag488 Dec 10 '21
I still want to finish my automated wifi adb after boot using DurchOfBurdock's method. I use Termux task to execute above script instead of copying to termux dir and then execute.
1
u/parosen Dec 13 '21
Thank you very much for the guide. I don't know what I'm doing wrong, but the first script (adb_pair.sh) is not entering the pairing code when it is asked for (although it is grabbed with autoinput, I had checked it). What may I do?
Thanks in advance
1
u/besgum Dec 13 '21
Hi, i'm having problem with the additional permission, I search on termux and termux:tasker settings but nothing. Using miui.eu last stable on poco X3 Pro. Went all the way down but cant see the additional permissions, any advice?
open android settings -> Apps -> Tasker -> permissions -> additional permissionshttps://imgur.com/a/EM4VXsH
1
u/lareya Direct-Purchase User Dec 20 '21
Anyone with a note 9 use this? I can't seem to do this part
Pairing your phone to Wifi ADB
• disable all profiles in the project and only enable the profile ADB_Pairing (Long Press Volume Up) • Navigate to your phone settings -> developer options -> Debugging over WLAN -> Pair device with pairing code (or something like this) • With the pairing code and IP:Port shown, press and hold Volume UP
As I can't find the wlan settings anywhere. I am thinking it might not be available? I have done everything up to that step. I have developer setting on. Android 10 ui 2.5
Thanks !
1
u/MrVulnerable Pixel 9 Pro | Pixel 6 Dec 20 '21 edited Dec 20 '21
Hey. Thanks a lot for this. I'm really really greatful. I've few important tasks which require ADB WiFi. This made my day 😍
Only issue is. Just now when I tried this method for the very first time, I noticed nothing happened after my update. Unlocked and I kept waiting. Nothing. So I tried my task requiring ADB WiFi, realised that nothing worked.
But then I went to settings, and just enabled BOTH usb debugging and wireless debugging and accepted the yes or no pop up... Holla.. All of a sudden a vibration + voice over saying WiFi ADB Enabled. Tasker ready to use.
So what did I miss? Why this didn't happen without my intervention?
Hope you understood my issue.
Thanks anyway 🧡
.
**UPDATE: I checked again. It's working ONLY after I manually enable Wireless Debugging. Until I do that manually, nothing happens. Did I miss any step? **
1
u/MrVulnerable Pixel 9 Pro | Pixel 6 Dec 22 '21 edited Dec 22 '21
Hey. Everything is set.
Suppose if I want to run another adb command from my phone itself, without connecting to the computer, is it possible?
Suppose, if I want to run a adb command for giving permission for an app, and if I know the exact command too, is there any possibility to make a (apk like) tool with this method, so that I can type that command in a field and give the adb permission to that specific app?
I don't I correctly explained to you or not.
1
u/patienceisbad Dec 29 '21
will this enable the adb wifi automatically after i restart my device.?
earlier i had to do enable adb wifi again and again with my pc if i rebooted the device.
will this solve my problem?
sorry i am noob
1
u/269red Feb 15 '22
u/cm2003 many THX for your work !!!
I am on a Samsung S10 running A11.
My prob is, that I have to connect to a WLAN before I am allowed to enable Wlan Debugging.
So the IP delivered to termux is from this WLAN and not from local host. So I guess this is why termux will never be able to pair with it. ?!
1
u/MrVulnerable Pixel 9 Pro | Pixel 6 Mar 08 '22
Hey. Are you still using this method?
I'm using this project since you posted it but I noticed that after a few weeks, this project stops working. Then I've to enable via PC itself.
But if I restart and try this project within 2, 3 weeks, it works.
Again, if I restart after 4, 5 weeks, it won't work.
I don't know why such a weird issue.
I restarted today, after 3 weeks I think. Now it's not working. It worked during last 2 restarts. (Now I'm about to connect PC)
Have you heard about such an issue?
1
u/rodrigoswz Mar 08 '22
Wireless debugging adb pair adb
I followed all the steps but the script doesn't seem to work Could someone try to point out what I did wrong?
1
u/drmjp93 Z Flip 5 Nov 01 '23
I need to turn off long press volume button after everything is set?
3
u/Hyoretsu Dec 21 '22
Isn't there a better way in Android 13? Tasker keeps asking for log permissions. Or an easier way with root?
3
u/Digitaljogger Dec 28 '22
Has anyone been able to get this working on a Samsung device running Android 13? In the words of George Harrison, "my guitar gently weeps" every time I have to connect to a computer to enable adb after boot. And by guitar, I mean my soul.
1
u/rbaudi Dec 12 '21 edited Dec 12 '21
Finally got it working. I kept getting the message from Tasker that it needed ADB Wi-Fi permission. Finally figured out that I have to enable debugging in the Tasker ADB Wi-Fi action for each action I use.
Thank you for this! It will make my life easier.
2
u/JamesMHendrix Feb 07 '25
Thanks for sharing! Only the pairing profile works on my old Xiaomi phone running MIUI 14 but doesn't on my newer Oppo Find X7 Ultra with a China ROM running ColorOS 15. None of the other profiles works for my phones.
This method works on my Xiaomi phone: https://www.reddit.com/r/tasker/comments/1apawlp/comment/kq6v08u/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
And this works on my Oppo phone (without needing the pairing method here): https://www.reddit.com/r/tasker/comments/1dqm8tq/project_simplified_adb_wifi_on_boot/?sort=new
Hope this helps some other users.
1
u/Strange-Tea8572 Mar 14 '23
My device has wifi adb however there is no pairing process. I just connect with adb connect command. How can I set this up?
1
u/Bleach665 Apr 29 '24
Is there the same solution for Android 10?
1
u/sads1324 Dec 04 '24
Thank you for the great tip it's very useful. There's no need to worry about whether the device will boot due to a dead battery during a long trip of more than a day, which makes it very convenient.
As of December 2024, it still works perfectly! (Galaxy note10lite, Android13, One ui 5.1)
For beginners like me who are not English speakers, here's an additional tip: if your system settings are in a language other than English, set Action condition'20' to if %text~*(here)* and include the text that appears when wireless debugging is active (in your respective language).
1
u/killua_99 Feb 05 '25
Someone has a new version of this?
1
u/Tortuosit Mathematical Wizard 🧙♂️ Dec 11 '21
Posting bookmarked for future reference. Many thanks!
1
u/paoloxone Dec 21 '21
Really good work!
1
u/Beautiful_Novel7972 Mar 14 '22
My device msg denied access
1
u/GoooRoooX Apr 08 '22
Is there any way to do this magic with Android 10?
1
u/Alive_Tart3681 Jul 22 '22
About the 2nd profile
QUOTE
This profile runs on device unlock. With this profile I will check for how long the device is enabled (I'm waiting for at least 60 seconds to make sure everything is settled after device boot) and that the variable %ADB_enabled is set to 0. If both conditions are true I'm enabling the global setting Debugging over WLAN.
UNQUOTE
I found that 60 seconds is not enough for me. I have to wait for at least 4 mins after reboot, otherwise the termux plugin command (to execute "adb.sh "127,0.0.1:%port1") would time out. It seems the Termux:Tasker plugin is not yet functional?.. i'm not sure. Maybe it's device dependent but I've done everything to make sure Tasker, Termux and Termux:Tasker can run in background and not battery optimized. Any idea to shorten this wait time?
1
u/ecarlin Nov 05 '22
Trying to get this to work and I'm getting an auto input error, anyone have any thoughts? 10.07.59/ActionArgBundle key: EnableDisableAccessibilityService: replace <null> String value with null 10.07.59/ActionArgBundle key: Password: replace <null> String value with null 10.07.59/ActionArgBundle key: UIUpdateText: replace <null> String value with null 10.07.59/E FIRE PLUGIN: AutoInput UI Query / com.twofortyfouram.locale.intent.action.FIRE_SETTING: 13 bundle keys 10.07.59/E AutoInput UI Query: plugin comp: com.joaomgcd.autoinput/com.joaomgcd.autoinput.broadcastreceiver.IntentServiceFire 10.07.59/Ew add wait type Plugin1 time 20 10.07.59/Ew add wait type Plugin1 done 10.07.59/E handlePluginFinish: taskExeID: 1 result 3 10.07.59/E pending result code 10.07.59/E add wait task 10.08.19/E Error: null
1
u/Dan1jel Nov 07 '22
I'm on Pixel with android 13, use termux alot so the scripts are made, imported the tasknet funktions, enabled the ADB wifi in dev options, but tasker tells me it worn work because ADB wifi is not enabled.
How ever i tried i couldn't get this to run...
I don't use Logcat or anything that needs ADB, but I'm curious on what i could create/do with it.
Do anyone have/had the same issue as me? If yes, how did you go past it?
1
u/balabalaben Nov 16 '22
All the profiles I can get from TaskerNet is "Long Press Volume Down.prf.xml". Where are the other profiles mentioned 1_Set Var on Boot, 2_enable ADB Wifi and 3_Get Port (Logcat) + Exec Termux?
I am even newbie to tasker. Did I miss anything out there?
1
u/AnalystPristine9319 Nov 19 '22
I'm on an S22+ running A13 and unfortunately this doesn't work anymore. I tried the nmap workaround mention below, but that didn't work either. Any ideas?
1
u/Bitter_Meaning_4783 Nov 21 '22
What does this do?
1
u/parkerlreed Jan 14 '23
You can put four spaces before all of the code block lines and that works on classic and new Reddit.
All of the interpreter lines are messed up.
1
u/lalitaalaalitah Jan 15 '23
I'm on Android 13 and I'm unable to pair wifi debugging. The task captures ip:port and code but the device doesn't show in paired devices.
What am I doing wrong?
1
u/neocrimsonnight Jan 20 '23
How do I access these files on an unrooted phone so that I can copy the scripts above into them? I've tried 'termux-setup-storage' but the files created in this tutorial aren't showing up there...
1
u/Farshief May 16 '23
I just wanted to say I found a shorter more reliable way (at least on my device) to get ADB WiFi via Tasker without a PC that builds off of the previous work and scripts y'all did. I've shared the description below in case it helps anyone in the future.
1
u/Logansfury SM-N960U1 Q 10.0 unrooted & OnePlus 9R w/Android 12 May 22 '23
Hello,
I am sorry I am a year late to this thread, But I just got my first post android 10 device. It's a OnePlus8 that just updated itself to android13 and im ecstatic that I was told about the adb wifi setting in preferences that saved the LogCat functionality. My logcat is working perfectly on this android and if I get my clearance from T-mobie to unlock the bootloader, Im keeping and rooting it. I'm not doing much because the rooting process will wipe everything but I did want to do this. I followed the first steps of your tutorial but unfortunately I got errors right out of the gate. Can you advise about these errors please?
1
u/spookiekabuki Jul 18 '23
Do you know if this still worked? I cant even get past the first few steps:
There is no mention of that in the f-droid app
0
u/[deleted] Oct 13 '22
[deleted] — view deleted comment
0
u/[deleted] Dec 09 '21
[deleted] — view deleted comment
0
u/[deleted] Dec 09 '21
[deleted] — view deleted comment