0

I work on Android Studio while using actual device for ADB using ADB over tcp/ip through command prompt (no additional software). But, this new device gets offline the moment screen turns off. I've tried turning off everything related to Battery Optimization or Wifi. Although, there's no such specific setting to let the Wifi awake after device sleeps like my old phone Huawei.

I'd also posted this over the official forum of Realme about a week ago but no one has replied so far. Link - Wifi gets turned off after screen lock - ADB issues.

So, Device's status in ADB devices goes to offline the very moment screen locks and then I've to do the process of ADB Wifi all over again and I don't want to use cable all the time because it affects battery through that 0.5/0.9 mA slow charging through motherboard. It is already slow enough that battery gets discharged even after continuous charging. I use ADB Wifi for more than 14 hours per day hence I need a stable solution.

So, my question is how to keep the device's Wifi on even after screen lock? I know it's device specific because of the custom changes to the ROM but I really need something.

1
  • adb disconnection might be related to a lock screen (adb disabled for security reasons). Alternatively is your device rooted? If yes you can disable charging on most devices so you could connect your device via USB without charging.
    – Robert
    Sep 26, 2020 at 11:03

2 Answers 2

1

I run the device farm in our company based on ADB wifi and I had similar problem. I ended up with creating an app to keep wake-lock all the time to prevent device sleep (it has to have foreground service, otherwise it gets killed too, and it has to have turned off battery optimization for the same reason). Now I am online nearly all the time.

2
  • Have you published your app or its source code? Jun 11, 2021 at 0:08
  • Sorry, I cannot do this, as it was made during my work hours and hence it's property of the company I am employed in. But the app is pretty simple and shouldn't be hard for android developer to make his own. Jun 13, 2021 at 19:15
1

It's a bug in the rom in some kinds of android devices, apparently. This fixed it for me:

Link: https://github.com/Genymobile/scrcpy/issues/1382

Here's what you have to do:
Go to Usb preferences in developer options, and change it from "data transfer" or anything else to "no data transfer". Tell me if this fixed it for you! Sending this here for any onlooker.

You must log in to answer this question.

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