find3-android-scanner icon indicating copy to clipboard operation
find3-android-scanner copied to clipboard

Screen randomly wakes

Open nielsole opened this issue 6 years ago • 17 comments

I just tried this app out yesterday (we already talked: https://news.ycombinator.com/item?id=16674745) :) and liked it a lot. What bothered me in the night was that the screen was randomly waking (maybe every 20 minutes?) I uninstalled the app and my phone stopped waking me up again, so I guess it was this app (otherwise hard to attribute)

I'm on Android v7.1.2 with lineageOS

nielsole avatar Mar 26 '18 20:03 nielsole

I guess it is this here: https://github.com/schollz/find3-android-scanner/blob/7cdf6aa1823f8eeff94d887df82e79dbd0d8c71f/app/src/main/java/com/internalpositioning/find3/find3app/AlarmReceiverLife.java#L33 And I guess these are my 20 minutes (1000/60=16m40s): https://github.com/schollz/find3-android-scanner/blob/7cdf6aa1823f8eeff94d887df82e79dbd0d8c71f/app/src/main/java/com/internalpositioning/find3/find3app/MainActivity.java#L219

nielsole avatar Mar 26 '18 20:03 nielsole

@nielsole Yes, the phone randomly wakes - this was the only way I was able to get the scanning to work in the background. It seems that if you just run a typical service in the background it will idle and not be allowed to scan until it wakes again. To make sure the phone continually scans, then, I implemented this wake.

Its not an ideal solution, but it works and its not bad on battery (it uses ~1%/hour on my pixel). I'd love to have a different solution if there is one though!

schollz avatar Mar 26 '18 22:03 schollz

I second the issue, but also want to thank you for an amazing bundle of software. I'm not familiar enough with Android development to be of any help, but would love for a workaround that didn't involve turning on the screen (my Essential PH-1 running Android Oreo is flashing the screen almost every 30 seconds, and it stays on for at least a minute, which will play hell with my battery life).

I'm sure there's a workaround, because loads of apps run continuously without waking the screen (Fit & Tasker, to name a couple off the top of my head). This link is slightly outdated, but may be of use?

gooselord-0 avatar Apr 06 '18 02:04 gooselord-0

So I've been looking into this. I forked the repo and have been reading up on Doze, JobScheduler, etc. And I wanted to run some thoughts by you:

Instead of continuously scanning, why not make some assumptions?

  1. If the phone is stationary, its location will not change, unless teleportation.
  2. If the phone's location won't change, we don't have any need of updating or querying its location (except in Learning Mode)
  3. Since we have access to whether or not the phone is stationary (via the accelerometer and other means), why not feature two distinct means of running the app: (1) Learning Mode can work as-is, because who cares about the screen turning on during app setup/maintenace? (2) Once Tracking Mode is enabled, why not switch to a different means of scanning?

We could enter into an aggressive scanning mode when we learn the user is moving (possibly even querying network status more frequently for more frequently updated information, if the OS allows), which I don't think Doze would interfere with (unless Doze >= Nougat messes with it; still not clear on that),

Once we've detected the phone is stationary for some period (long enough for your back-end to settle on a good guess), enter into passive mode, where we just work with the constraints imposed by Doze.

From what I've read, the period before which a phone enters Doze is set by the OEM (one post recorded it at one hour), and the periods between maintenance windows once in Doze go something like 1h, 2h, 4h, 6h, 12h, etc. But I'm guessing the period before Doze would be sufficient for a good guess, if that's something that can be defined. (I've seldom gotten wrong guesses with 70% probability, and it seems that the longer my phone is stationary, the more accurate the guesses; they don't seem to "drift" after a certain period.)

What do you think? I'm still reading up on all this, but I'll be giving this a shot once I'm satisfied I understand everything well enough. Would this be a feature you'd be interested in merging into master?

gooselord-0 avatar Apr 08 '18 19:04 gooselord-0

@mscott5861 I think that's a great idea. "Wake-on'shake" is a very common mechanism for this type of thing.

I'd be really happy if you could lend a hand for this, as I'm not adept at Android and don't know when I could implement something like that.

schollz avatar Apr 09 '18 08:04 schollz

@schollz Cool. I'd be happy to help.

I'm not very adept at Android either, and I'm still bringing myself up to speed on everything. I expect the coding to take a lot less time than the learning. I'll let you know once I've got something testable.

gooselord-0 avatar Apr 09 '18 10:04 gooselord-0

Hi there!

Is there any new about this issue?

Regards!

orxaz avatar Jun 13 '18 12:06 orxaz

@orxaz Still hasn't changed. I'm leaving it open because its not a problem for me for the phone to wake randomly (it still uses very very little battery on my Pixel 2). However, if someone wants to make a PR, I'd be happy to merge it!

schollz avatar Jun 13 '18 16:06 schollz

@schollz , ok, the whole system is nice anyway, will keep using it, but if some day this little issue is fixed will be even better!

Many thanks for your work!

orxaz avatar Jun 15 '18 06:06 orxaz

I know nothing about Android app development, but would a persistent notification while tracking is enabled allow the app to search while the screen is off?

kmlucy avatar Jan 08 '19 11:01 kmlucy

I'm very new to Android development and this might be completely not the right thing to do but wouldn't be posible to just change the FULL_WAKE_LOCK to a PARTIAL_WAKE_LOCK?

https://github.com/schollz/find3-android-scanner/blob/7cdf6aa1823f8eeff94d887df82e79dbd0d8c71f/app/src/main/java/com/internalpositioning/find3/find3app/AlarmReceiverLife.java#L33

Docs: https://developer.android.com/reference/android/os/PowerManager.html#summary

Rayz224 avatar Apr 27 '19 03:04 Rayz224

I'd love to be able to use this app, but the screen constantly turning on is going to be a non-starter for me. Not an Android development expert either, but it does sound like switching to a partial wake lock could be a good option.

apop880 avatar Aug 11 '19 19:08 apop880

I'm very new to Android development and this might be completely not the right thing to do but wouldn't be posible to just change the FULL_WAKE_LOCK to a PARTIAL_WAKE_LOCK?

https://github.com/schollz/find3-android-scanner/blob/7cdf6aa1823f8eeff94d887df82e79dbd0d8c71f/app/src/main/java/com/internalpositioning/find3/find3app/AlarmReceiverLife.java#L33

Docs: https://developer.android.com/reference/android/os/PowerManager.html#summary

I have very limited experience programming and zero experience with any development, but I downloaded android studio and changed to from FULL_WAKE_LOCK to PARTIAL_WAKE_LOCK. After 20min of testing the app, my position updates while phone is locked and the screen does not wake up.

MarcusNi96 avatar Oct 01 '19 21:10 MarcusNi96

After 20min of testing the app, my position updates while phone is locked and the screen does not wake up.

Can you please share your apk?

Or better than this... @schollz , do you plan to update the app and upload it to the Play Store?

I've tried to compile it myself but several hours wasted with no success :(

Thanks!

orxaz avatar Oct 02 '19 13:10 orxaz

Hi all.

Excuse me, the apk I compiled is valid, the problem was that I've tried to install it without uninstall the original one.

Thanks!

orxaz avatar Oct 07 '19 13:10 orxaz

Update: Took the liberty of preparing a PR (https://github.com/schollz/find3-android-scanner/pull/22)

dermotduffy avatar Nov 22 '19 20:11 dermotduffy

No news since 2019 ? Why the two proposed PR have been closed but not merged ? They seemed to solves this issue.

Any plan to solve this issue ? Having the screen turn on shouldn't have to be. Tons of app do a lot of things in the background without turning on the screen. And it's just super annoying to see your phone screen turn on every few minutes when you're working.

Hexalyse avatar Oct 23 '21 17:10 Hexalyse