I just broke the screen on my OnePlus 6, which doesn't allow adb debugging until you change the USB Connection Type to 'MTP' (via the screen), and their repair service states they will wipe any device they are sent, no exceptions. I didn't unlock the bootloader, and so unlocking it to flash a different recovery will also wipe the device. It also removed adb over wifi, so it appears it is completely locked down.

On my next phone (Razer Phone 2), I want to ensure this never happens again. I am concerned that potential Android updates may also require screen interaction before it will allow adb over USB, or that adb over wifi may be removed.

What is the best way to ensure that I can maintain adb access without screen interaction in the case of a future breakage?

I plan on:

  • Unlocking the bootloader right away, so that worst case I could flash a custom recovery like twrp that would allow adb access
  • Enabling adb
  • Authorizing at least two computers
  • Setting the default USB mode to MTP (if possible)
  • Enabling adb over wifi, but ONLY if I can lock it down

Regarding adb over WiFi, I don't want this fully enabled on every network I join. Is there a way to whitelist only my home WiFi, or to only allow it from authorized computers?

I'm looking for ways to not lose access like this in the future - I have to order a replacement screen and repair it myself in order to try and retrieve the data. It's also important to me that I don't lose access via any system updates in the future, though this is difficult to ensure. Perhaps a nandroid backup of a system with everything ready that could be restored through the recovery?

In devices like the OnePlus 6, that have removed adb over WiFi and require touch input to adb over USB, what are the viable options?

  • Authorizing one computer is enough, but you should backup the adb key (~/.android/adbkey and adbkey.pub).
    – Robert
    Feb 14, 2019 at 20:20

1 Answer 1


This could be a problem with the installed drivers if you need to switch to a data transfer mode such as MTP to use adb. I use adb on charging only in data transfer mode, which is status-by-design, in OnePlus 6.

For the broken screen issue, I don't know if this would help. You could try with an OTG cable and a mouse to see if it works automatically. There is an OTG toggle in Settings app so it might be the cause if this approach doesn't work as plug-n-play.

As for your approach on your new phone, understand that adb over wifi is safe. Whether on wifi or on USB, your phone would show an authorisation approval dialog to approve a machine (PC) for USB Debugging, be it on USB or Wifi. So you need to careful more on what machine to allow for, instead of restricting the access over a specific Wifi.

However, it is possible to mistakenly authorize adb over wifi when unsuspecting that the dialog would show up suddenly, say when you were playing a game and so deeply engaged that you just nearly click anything as ok that shows up on screen, so for that you would want to restrict access to adb only on your personal wifi with trusted machines.

Now for that, you can use automation. I use Tasker app to automatically enable adb over wifi on boot. For your case, here are the instructions (tested with a rooted OnePlus running Android 8.1):

  1. Profile: State → Net → Wifi Connected (requires Location permission and Location enabled at all times):

    • SSID: select your SSID/WiFi's name
    • Active: Yes
    • leave the rest untouched
  2. Task: Code → Run Shell:

    • Command:

      setprop service.adb.tcp.port 9999
      stop adbd && start adbd
    • Tick Use Root

  3. Long press the task next to profile and select Add Exit Task.

  4. Exit Task: Code → Run Shell:

    • Command:

      setprop service.adb.tcp.port ''
      stop adbd && start adbd
    • Tick Use Root

Now, as long as location service remains enabled, Tasker would detect when the phone gets connected and disconnected to your SSID. When connected, adb would be listening over your WiFI on port 9999 (choose any port of your choice but above 1024). When the WiFi disconnects from that SSID, adb would not listen on a port.

If you plan to use TWRP than even if a system update messes up with your USB Debugging settings TWRP would always grant you access to debugging automatically as it works independently of Android system installed in the device. You don't need to change data transfer mode there either. If you need to do it, something is definitely not right. Furthermore, if you have TWRP installed than you have deeper access to your data that which adb can never have so you need not to worry about debugging in Android if TWRP is available and kicking.

  • On the OP6: Something must be off then, maybe the adb or authorizations got reset on a system update I took without realizing it, and that's why it's not showing up. Other phones adb just fine with the same computer (a OP1 and HTC m7vzw). As I recall, the OTG could only be enabled for a limited time, and then it turned off automatically and boots in the off state.
    – Ehryk
    Feb 14, 2019 at 7:17
  • On the new phone, I plan on unlocking the bootloader and installing TWRP as soon as it's ported to the device, which it hasn't been yet. Even with the authorization dialogs, I'm not happy with open :5555 over all my connections, is there a way to lock it down to only whitelisted SSIDs?
    – Ehryk
    Feb 14, 2019 at 7:18
  • @Ehryk I have edited my answer and added a way to enable adb over wifi only for a specific wifi.
    – Firelord
    Feb 14, 2019 at 17:26
  • Thank you. I think between TWRP and adb over WiFi on my home network, I should be covered on my next device.
    – Ehryk
    Feb 14, 2019 at 20:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .