GPSLogger icon indicating copy to clipboard operation
GPSLogger copied to clipboard

Huawei P10 Lite - Android 8.0.0 - Record stops after some time

Open gion86 opened this issue 6 years ago • 24 comments

Hardware/Probe/Firmware description

Huawei P10 LIte, Android 8.0.0, Stock Firmware

Unexpected Behavior

I'm having many problems with "always on" applications in general. They don't stay "active". GPSLogger seems to just stop logging after an amount of time. The message on the main screen is

GPS temporary unavailable

How to reproduce the issue

Simply start a track record and wait 2-3 minutes. Leaving the phone on charge seems to mitigate the issue: I haven't seen the application stop, but maybe it's just matter of time...

gion86 avatar Aug 06 '18 17:08 gion86

Starting from Android 6.0 (API level 23), Android introduces two power-saving features that extend battery life for users by managing how apps behave when a device is not connected to a power source.

The unexpected behaviour could be caused by the new battery optimization features.

On the first step, with your help, we'll try to identify the cause of the issue.

The following (manual) procedure will disable the battery optimization for GPSLogger. Please install GPSLogger, go on Android settings and try it:

whitelisting an app

Then start GPS Logger and check whether the problem is solved. We wait a feedback in order to proceed with the next step. Thanks in advance.

GrazianoCapelli avatar Aug 07 '18 20:08 GrazianoCapelli

OK, I disabled the battery optimization. Then I tried GPSLogger but after few minutes I got the message "GPS temporarily unavailable".

Today I went out by bike, using Strava AND GPSLogger together. This way GPSLogger seems to work and record everything. So, in the end, I don't if this was of any help...

gion86 avatar Aug 08 '18 20:08 gion86

@gion86 thanks for your try, your feedback (also in parallel with Strava) is very helpful. In the next days we'll try to implement a PARTIAL_WAKELOCK in order to prevent the system to go in standby.

GrazianoCapelli avatar Aug 09 '18 19:08 GrazianoCapelli

OK thank you. I might have time to test you changes in the next few days. Please let me know on this thread when it's ready!

gion86 avatar Aug 11 '18 14:08 gion86

Implemented a PARTIAL_WAKELOCK on GPSService (commit bb22365 and eac0c42). Now we start the test phase.

BEFORE TESTING: In Android 8, if you want to run an app in background without be stopped, you have to go on Android settings and disable (for this app) both battery monitoring AND optimization; please disable them for GPSLogger, and then test it.

GrazianoCapelli avatar Sep 02 '18 09:09 GrazianoCapelli

Works great on LineageOS 15.1 / Android 8.1.0!

Thank you very much!

sanch3z avatar Sep 07 '18 09:09 sanch3z

I have tested it on my Huawei P10 LIte, Android 8.0.0, Stock Firmware. I have disabled battery optimization, but it's not working.. same behavior as before. The only settings I changed is "keep screen on" (to off) and after a few minutes the screen is off I get GPS temporary unavailable.

I have also tested it on an old Nexus 4 with Android 5.1.1, but I cound't even get a GPS fix... maybe this is another story....

gion86 avatar Sep 10 '18 21:09 gion86

Removed every optimization of the operating system and by third-party software (not only battery) Tested on Oreo 8.0, LG G6 phone. Work flawlessly. Even airborne. Thank you very much!

JLJu avatar Sep 11 '18 09:09 JLJu

@gion86 - Sadly every smartphone brand implements different optimization utilities (some very aggressive with background apps), thus it is impossible to make an universal guide. The user has to search the way his phone vendor choose to manage and optimize the background apps.

In your case I think this video could resolve your problem with background apps: https://www.youtube.com/watch?v=0eyksACxNPA

GrazianoCapelli avatar Sep 11 '18 16:09 GrazianoCapelli

Works great on my old S3 mini with SlimKat / Android 4.4.4 as well.

@gion86 Maybe you are still running the PlayStore version or the .apk from the releases page? None of these come with the recent changes in this repository. In order to test these you have to build the app from the source code yourself.

sanch3z avatar Sep 11 '18 17:09 sanch3z

@GrazianoCapelli: the menu in the video is not present in my version battery menu. I have searched for it but the only thing I could find was "manual battery management" which is already on for autorun, keep app on and everything.

@sanch3z: ok.......... I'm not an expert Android developer but... I can download the latest sources and build the apk myself! :) The PARTIAL_WAKELOCK code is present, and the application info page shows version 2.1.11b_20180902.

In my opinion the battery optimization done by Huawei are too aggressive: even though Strava is working perfectly, I have had problems with other apps too (KinScreen).

gion86 avatar Sep 11 '18 20:09 gion86

@gion86 right, in the new Huawei update I think you can find the setting under: Settings -> Advanced settings -> Battery manager -> Protected apps

Maybe a better link is here: https://www.youtube.com/watch?v=WUmVhp6oPlE

Please try to add GPS Logger to protected apps, and then repeat the test. And, by the way, I'd be curious to know whether Strava is Protected or not in your list ...

GrazianoCapelli avatar Sep 11 '18 20:09 GrazianoCapelli

I'm sorry but I can't find the menu... my build must be newer.... I suspect (after some google) that the list of protected app is not locked by Huawei AND Strava might be on the list!!!!!!!!

gion86 avatar Sep 11 '18 21:09 gion86

Ops.. I meant:

I suspect (after some google) that the list of protected app is not locked by Huawei I suspect (after some google) that the list of protected app is NOW locked by Huawei

gion86 avatar Sep 11 '18 21:09 gion86

Maybe this thread is useful...

Yes, very informative, thanks. Sadly this is a patch, not a solution. In effect it seems that some popular apps are set as protected by default by Huawei. BUT, if there is no way to add another app to the protected list, the suggested code on the link should not drive the user to any useful settings page. It needs more digging.

From the user's point of view I found this good repo: https://github.com/dirkam/backgroundable-android Please, check if there is something useful on Huawei chapters.

Leaving the phone on charge seems to mitigate the issue: I haven't seen the application stop, but maybe it's just matter of time...

A comment regarding the first message: With the power adapter attached (or a power bank) the optimizations should be turned off, and the background apps should works flawlessly.

GrazianoCapelli avatar Sep 12 '18 17:09 GrazianoCapelli

OK, the repo at the link just tells what I did already. A powerbank may be a solution.. but I think the only true solution for me is......a custom ROM.....

gion86 avatar Sep 12 '18 17:09 gion86

OK, the repo at the link just tells what I did already

I tried, but I strongly suspected that :disappointed:

For now no solutions found for your problem, it seems that there is no way to override the manufacturer settings. I leave open this issue, hoping sooner or later anyone will find a solution

  • a combination of settings
  • a third-party app that manages and overrides the default settings
  • a piece of Java code
  • an Android update by Huawei

I'll try to deep the argument as soon as I will have a Huawei to test, in order to dig into the system and the app with adb commands.

From the user's point of view I found this good repo:

It would be interesting, for a complete information, to know which setting page your device would open by launching each of these 2 intents:

new Intent().setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"))

getPackageManager().getLaunchIntentForPackage("com.huawei.systemmanager")

However I suspect that you'll see again the settings pages that you already know well...

For now @gion86 @sanch3z @JLJu thanks for your time! Any update is welcome!

GrazianoCapelli avatar Sep 12 '18 20:09 GrazianoCapelli

@gion86 I've found this Huawei web Support page that explains a way to "protect a running app", preventing to be closed when runs in background.

Lock an app: If you want an app to continue running in the background and not be closed, you can lock the app. After an app is locked, it cannot be closed. Touch...

Here below a screenshot of the "Lock" icon, that should be present (for each running app) on the recent apps screen:

p10_lock

In case you haven't yet tried this, please check whether this can solve the problem!

GrazianoCapelli avatar Sep 24 '18 08:09 GrazianoCapelli

I tried.. but no way.. the application closes completely after a few minutes.. Maybe have I done something wrong?? The battery optimization are still present.

gion86 avatar Sep 25 '18 17:09 gion86

Same problem with Huawei P20 Pro. Unable to keep background apps running. Battery optimization is turned off for app.

sookoll avatar Mar 08 '19 13:03 sookoll

@sookoll Please start listing all the settings you changed in order to try to run the app in background.

GrazianoCapelli avatar Mar 19 '19 07:03 GrazianoCapelli

I experienced a similar behaviour. Setting location permissions to "allow all the time" solved the problem for me

Michael-101 avatar Apr 03 '20 17:04 Michael-101

Thanks to @Michael-101 for choosing to share his experience with other users. The solution proposed can be useful, but unfortunately only starting from Android 10.

Users can set the location permission to "allow all the time" only in Android 10+, that supports the tristate permissions. For Android 9 and lower you can only Deny or Allow.

In Android 9 and lower, users made persistent choices when granting location access to apps. They could either Deny or Allow, the latter of which gave apps access "all the time" (foreground and background). Tristate location permissions in Android 10 give users three options for allowing an app access to a device’s location.

GrazianoCapelli avatar Apr 04 '20 14:04 GrazianoCapelli