Enable ADB Wifi Access on OnePlus Phones 3.0

Enable ADB Wifi without necessity of enabling it with adb command from the computer.

Tags:
  1. autormali
    Normally every time you reboot your device you need to give ADB Wifi Permission via the adb command to have access to ADB Wifi and use of Tasker ADB Wifi action. But if you have OnePlus phone, there is no PC, Mac or other device, or hardware needed to give that permission. You can enable ADB Wifi Access directly from your phone after each reboot.

    To successfully run the profile the requirements are:
    • "Wireless ADB debugging" setting/toggle avialable in Developer Options - see image. Only OnePlus devices (running Oxygen OS and Android 10 and above) have this option for now.
    • Write Secure Settings Permission granted to Tasker.
    • Update: For Oxygen 11.0 and above - a new option "Disable adb authorization timeout" set to on. This will ensure reliable execution of the profile.


    How does it works? After each reboot the profile ADB Wifi Access Enable On Boot is active and run the main task, which is navigating to the Developer Options and do click sequence to enable Wireless ADB.
    Updated in version 3.0: In some cases when the user decided to keep display off and/or locked after reboot, it was observed that above described profile (with reboot context) was not executing the main task due to screen is off and AutoInput action time out. Added the second profile ADB WiFi Access Enable When Display Unlocked, which is activated at the first and only the first unlock of the phone. That profile will make the second attempt to run the main task but only if ADB Wifi has not been enabled on boot.



    Descriptions:
    Code (Text):
     
        Profile: ADB Wifi Access Enable On Boot (549)
        Priority: 50 Restore: no
        Event: Device Boot
        Enter: ADB Wifi Access Enable AI 3.0 (547)
        <‼️ Set this variable to <b>no</b>  if you want to keep "Wireless ADB debugging" option disabled, set it to anything to keep it enabled.<br>
     
        You should set it to <b>no</b> if in your setup you are using "ADB Wifi" actions with "Enable Debugging" option set to on>
        A1: Variable Set [ Name:%wifi_debugging_enabled To:read label for more info Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
        A2: Tasker Function [  Function:CheckADBWifi() ]
        A3: Flash [ Text:ADB Wifi Access already enabled Long:Off ] If [ %has_adb_wifi ~ true ]
        <⚠️ <b>Stop task</b> Sorry...ADB WiFi Access must do not be accessible before proceeding this task otherwise you mess up with AutoInput clicks sequence and task final result.<br>For testing purpose of this task without rebooting your device, go to Developer Options and disable both "USB debugging" and "Wireless ADB debugging" options then run this task.>
        A4: Stop [ With Error:Off Task: ] If [ %has_adb_wifi ~ true ]
        <Disable USB debugging.>
        A5: Custom Setting [ Type:Global Name:adb_enabled Value:0 Use Root:Off Read Setting To: ]
        A6: Status Bar [ Set:Collapsed ]
        <Open Developer Settings>
        A7: Developer Settings
        A8: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        <Scroll to debugging options>
        A9: Anchor
        A10: Variable Set [ Name:%search To:ADB\s|\sADB\s|\sADB Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
        A11: AutoInput UI Query [ Configuration:App Package: com.android.settings Timeout (Seconds):20 ]
        A12: If [ %aitext(#?~R%search) eq 0 ]
        <For OxygenOS 10 (Android 10)>
        A13: Variable Set [ Name:%tid To:< Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ] If [ %SDK = 29 ]
        <For OxygenOS 11 (Android 11) and maybe above>
        A14: Variable Set [ Name:%tid To:%aitext(#)-3 Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ] If [ %SDK = 30 | %SDK > 30 ]
        A15: AutoInput Action [ Configuration:Type: Text
        Value: %aitext(%tid)
        Action : Scroll Forward Timeout (Seconds):20 ]
        A16: Array Clear [ Variable Array:%aitext ]
        A17: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        A18: Goto [ Type:Action Label Number:1 Label:Scroll to debugging options ]
        A19: End If
        A20: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        <Enable Wireless ADB debugging>
        A21: AutoInput Action [ Configuration:Type: Id
        Value: android:id/switch_widget
        Nearby Text: ADB
        Action : Click Timeout (Seconds):25 ]
        <Enable USB debugging>
        A22: Custom Setting [ Type:Global Name:adb_enabled Value:1 Use Root:Off Read Setting To: ]
        A23: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        A24: If [ %wifi_debugging_enabled ~ no ]
        <Disable Wireless ADB debugging>
        A25: AutoInput Action [ Configuration:Type: Id
        Value: android:id/switch_widget
        Nearby Text: ADB
        Action : Click Timeout (Seconds):23 ]
        A26: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        A27: End If
        A28: AutoInput Global Action [ Configuration:Action: Back Timeout (Seconds):20 ]
        A29: Tasker Function [  Function:CheckADBWifi() ]
        A30: Flash [ Text:ADB Wifi Access enabled Long:Off ] If [ %has_adb_wifi ~ true ]
        A31: Flash [ Text:Wireless ADB debugging enabled Long:Off ] If [ %wifi_debugging_enabled !~ no ]
        A32: Flash [ Text:Wireless ADB debugging disabled Long:Off ] If [ %wifi_debugging_enabled ~ no ]
     
        Exit: Anon (538)
        <Time given to run <b>ADB Wifi Access Enable AI</b> task. In the case that display is remaining locked or off after reboot, task with AutoInput actions, triggered by profile <b>ADB Wifi Access Enable On Boot</b> will time out (AutoInput action time out) and not enable ADB Wifi. If this happens then enable (in this task) profile <b>ADB Wifi Access Enable When Display Unlocked</b> - this will make the second attempt to run the task but after display is unlocked. Once ADB Wifi is enabled by <b>ADB Wifi Access Enable When Display Unlocked</b>, that profile status is set to off.>
        A1: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ]
        A2: Tasker Function [  Function:CheckADBWifi() ]
        <Profile Status set to on>
        A3: Profile Status [ Name:ADB Wifi Access Enable When Display Unlocked Set:On ] If [ %has_adb_wifi ~ false ]

    ******************************************************

        Profile: ADB Wifi Access Enable When Display Unlocked (563)
        Restore: no
        Event: Display Unlocked
        Enter: ADB Wifi Access Enable AI 3.0 (547)
        <‼️ Set this variable to <b>no</b>  if you want to keep "Wireless ADB debugging" option disabled, set it to anything to keep it enabled.<br>
     
        You should set it to <b>no</b> if in your setup you are using "ADB Wifi" actions with "Enable Debugging" option set to on>
        A1: Variable Set [ Name:%wifi_debugging_enabled To:read label for more info Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
        A2: Tasker Function [  Function:CheckADBWifi() ]
        A3: Flash [ Text:ADB Wifi Access already enabled Long:Off ] If [ %has_adb_wifi ~ true ]
        <⚠️ <b>Stop task</b> Sorry...ADB WiFi Access must do not be accessible before proceeding this task otherwise you mess up with AutoInput clicks sequence and task final result.<br>For testing purpose of this task without rebooting your device, go to Developer Options and disable both "USB debugging" and "Wireless ADB debugging" options then run this task.>
        A4: Stop [ With Error:Off Task: ] If [ %has_adb_wifi ~ true ]
        <Disable USB debugging.>
        A5: Custom Setting [ Type:Global Name:adb_enabled Value:0 Use Root:Off Read Setting To: ]
        A6: Status Bar [ Set:Collapsed ]
        <Open Developer Settings>
        A7: Developer Settings
        A8: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        <Scroll to debugging options>
        A9: Anchor
        A10: Variable Set [ Name:%search To:ADB\s|\sADB\s|\sADB Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
        A11: AutoInput UI Query [ Configuration:App Package: com.android.settings Timeout (Seconds):20 ]
        A12: If [ %aitext(#?~R%search) eq 0 ]
        <For OxygenOS 10 (Android 10)>
        A13: Variable Set [ Name:%tid To:< Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ] If [ %SDK = 29 ]
        <For OxygenOS 11 (Android 11) and maybe above>
        A14: Variable Set [ Name:%tid To:%aitext(#)-3 Recurse Variables:Off Do Maths:On Append:Off Max Rounding Digits:3 ] If [ %SDK = 30 | %SDK > 30 ]
        A15: AutoInput Action [ Configuration:Type: Text
        Value: %aitext(%tid)
        Action : Scroll Forward Timeout (Seconds):20 ]
        A16: Array Clear [ Variable Array:%aitext ]
        A17: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        A18: Goto [ Type:Action Label Number:1 Label:Scroll to debugging options ]
        A19: End If
        A20: Wait [ MS:250 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        <Enable Wireless ADB debugging>
        A21: AutoInput Action [ Configuration:Type: Id
        Value: android:id/switch_widget
        Nearby Text: ADB
        Action : Click Timeout (Seconds):25 ]
        <Enable USB debugging>
        A22: Custom Setting [ Type:Global Name:adb_enabled Value:1 Use Root:Off Read Setting To: ]
        A23: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        A24: If [ %wifi_debugging_enabled ~ no ]
        <Disable Wireless ADB debugging>
        A25: AutoInput Action [ Configuration:Type: Id
        Value: android:id/switch_widget
        Nearby Text: ADB
        Action : Click Timeout (Seconds):23 ]
        A26: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
        A27: End If
        A28: AutoInput Global Action [ Configuration:Action: Back Timeout (Seconds):20 ]
        A29: Tasker Function [  Function:CheckADBWifi() ]
        A30: Flash [ Text:ADB Wifi Access enabled Long:Off ] If [ %has_adb_wifi ~ true ]
        A31: Flash [ Text:Wireless ADB debugging enabled Long:Off ] If [ %wifi_debugging_enabled !~ no ]
        A32: Flash [ Text:Wireless ADB debugging disabled Long:Off ] If [ %wifi_debugging_enabled ~ no ]
     
        Exit: Anon (163)
        <Profile Status set to off.>
        A1: Profile Status [ Name:ADB Wifi Access Enable When Display Unlocked Set:Off ]