nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.28k stars 1.77k forks source link

NextCloud remains in "powersave" mode while being whitelisted with Power Manager on Samsung S7 #2889

Closed sgurder closed 11 months ago

sgurder commented 6 years ago

Actual behaviour

Nextcloud app was added to "Unmonitored Apps" and in "Optimise Battery Usage" the app is listed with a gray button (=should be ignored). Power saving mode is on (permanently).

New files do not seem to be detected, "force rescan" needed to detect new file. Upload queue items (created through a forced rescan) remain in "Waiting to exit power save mode" even when (creating a new file while) charging.

This might be due to PowerUtils.java only containing a check for PowerManager.isPowerSaveMode without checking if PowerManager.isIgnoringBatteryOptimizations is true. I'm not an Android developer, I only googled around a bit.

Expected behaviour

If the Nextcloud app is whitelisted it should upload while power saving mode is on.

Steps to reproduce

  1. Get a Samsung S7 (only have this device, sorry !)
  2. Enable Power Saving mode: go to "Battery" -> Set "Power Saving Mode" to MID (customised; ensure at least "Background network usage" is enabled, rest can all be off)
  3. Whitelist attempt 1: go to "Battery" -> "Unmonitored apps", add "Nextcloud"
  4. Whitelist attempt 2: go to "Battery" -> "Battery Usage" -> 3 dots -> "Optimise Battery Usage"; ensure "All Apps" are shown; Disable button next to "Nextcloud"
  5. Open Nextcloud (with expert mode on and Screenshot folder autoupload enabled) -> "Uploads", Take screenshot => nothing happens
  6. "Force Rescan" => screenshot will appear in queue with "Waiting to exit power save mode"
  7. Put phone in charger, new screenshot, Force Rescan => same result as 6.
  8. Disable Power Saving mode => Uploads are processed and finish successfully

Environment data

Android version: 8.0.0 (Samsung Experience 9.0)

Device model: SM-G935F

Stock or customized system: Stock

Nextcloud app version: 3.2.1

Nextcloud server version: 13.0.5

Logs

Web server error log

I didn't attach this as I believe it's purely on the Android side.

Nextcloud log (data/nextcloud.log)

I didn't attach this as I believe it's purely on the Android side.
AndyScherzinger commented 6 years ago

@tobiasKaminsky do you have any Samsung Galaxy S device at hand to reproduce this scenario?

sgurder commented 6 years ago

I've installed Android Studio and imported this project (went smooth thanks to the great SETUP.MD) and adding powerManager.isIgnoringBatteryOptimizations in PowerUtils.java seems to do the trick (tested on my device): A. Without app in Battery Optimisation list: 1/ Remove "Nextcloud dev" app from Battery Optimisation list 2/ Nextcloud dev -> Uploads: Take screenshot => nothing 3/ "Force Rescan" -> file appears but "waiting to exit power save mode" as expected B. Whitelisted 1/ Add "Nextcloud dev" app to Battery Optimisation list 2/ Nextcloud dev -> Uploads: Take screenshot => file gets added to upload queue and upload starts (this also triggers any previously "waiting to exit power save" uploads to also start)

I've pushed the code to my cloned repo: https://github.com/sgurder/android/commit/c6ab7c30255e6257c42b4800e15b4b65e1cdf41a

Obviously this will cause more battery drain but right now the app is not really functional when running in Power Saving mode (on at least a Samsung S7).

AndyScherzinger commented 6 years ago

@tobiasKaminsky @mario see https://github.com/nextcloud/android/issues/2889#issuecomment-413177555 I think this is a valid solution via https://github.com/sgurder/android/commit/c6ab7c30255e6257c42b4800e15b4b65e1cdf41a and I'd support to have this as a PR by @sgurder :smiley:

What do you think?

tobiasKaminsky commented 6 years ago

Ah, damn me. I should have refreshed this issue before testing it on "my" S9.

@sgurder this looks like a valid approach. Can you make a PR for this? :tada: :+1:

mario commented 6 years ago

Ergh, wait - why do you mix isIgnoringBatteryOptimizations with PowerSave mode?

Ignoring power save mode means the app might kill your battery and in turn turning off your phone. While newer phones do have protections against this and of course the battery doesn't suffer as much as it did in the past, this is STILL a bad user experience.

Ignoring battery optimizations is usually done to allow say notifications when app is in background, to allow waking up a device under certain occasions and to be able to detect new files on certain devices. But to ignore power save if ignoring battery optimizations just to upload a file RIGHT AWAY? I don't think this is a good idea.

mario commented 6 years ago

cc @tobiasKaminsky @AndyScherzinger

mario commented 6 years ago

My thoughts as a user: if an app did this, it would be deleted from my phone right away.

tobiasKaminsky commented 6 years ago

It is tricky as there seems to be only one check for power safe mode, even Samsung is having multiple ones (medium/high/<15% power).

One could argue that if an user adds our app to whitelist, he/she has to deal with more power consumption…But this is of course not that great.

Ignoring battery optimizations is usually done to allow say notifications when app is in background, to allow waking up a device under certain occasions and to be able to detect new files on certain devices.

This affects only a few devices, or? How big are the chances that one has to enable it for above reasons and have a Samsung device with set powersave to medium?

I can imagine two possible solutions on longer term:

mario commented 6 years ago

You cannot get rid of the need to enable "ignore battery optimization" unless you can get the vendors to whitelist your app when they ship the phone :)

In addition, power save mode is defined differently by various vendors and some even allow you to define your own percentage % when power saving kicks in.

mario commented 6 years ago

What I'm saying is ... despite Samsung being weird, this is not a Samsung-only issue.

rwat1 commented 6 years ago

@sgurder

Does this problem occur even after reinstalling NC app? I fixed my "auto-upload" detection issue on my Samsung S9+ by clearing data, deleting NC app, and reinstalling. Then putting it in "Unmonitored apps for sleep", then my Autoupload works now. It helped 2 other users, who we all speculate it an configuration data issue that clearing data/reinstalling help resolve.

I posted instructions here: https://github.com/nextcloud/android/issues/2889#issuecomment-414090362

kemsar commented 6 years ago

Same issue on Samsung S9+ and v. 3.3.2. Detects new photos but then says "waiting to exit power save mode" even though I've excluded it from all power save settings/monitoring. Tried clearing data and reinstalling but problem persists.

tobiasKaminsky commented 6 years ago

@kevinsarsen my wife has a S9+ and there it is working without problems. As far as I remember there were two settings

rwat1 commented 6 years ago

@kevinsarsen I also have an Samsung S9+, all I do is just temporarily turn off Power saver mode, allow it to upload, then turn it back on :) lol.

kemsar commented 5 years ago

@tobiasKaminsky, just updated from fdroid and still have this issue. I only have to be in Medium power save and it will stop uploading.

tobiasKaminsky commented 5 years ago

This might be fixed via https://github.com/nextcloud/android/pull/3589

snowboarder04 commented 5 years ago

I am using the latest version from the Play store and still experiencing this behaviour which is really rather frustrating. Android Pie (9) running on a Samsung Note 8.

Ergh, wait - why do you mix isIgnoringBatteryOptimizations with PowerSave mode?

Ignoring power save mode means the app might kill your battery and in turn turning off your phone. While newer phones do have protections against this and of course the battery doesn't suffer as much as it did in the past, this is STILL a bad user experience.

Ignoring battery optimizations is usually done to allow say notifications when app is in background, to allow waking up a device under certain occasions and to be able to detect new files on certain devices. But to ignore power save if ignoring battery optimizations just to upload a file RIGHT AWAY? I don't think this is a good idea.

I think there may be some things @mario may be overlooking here ...

Firstly, I've gone to the trouble of manually excepting the app from battery optimisations. Any excess battery usage is a deliberate choice. The feature is called 'auto-upload' and users should reasonably expect it to behave as such when going to such lengths. Keep in mind also that each folder set to be auto-uploaded has an individual option for which circumstances must be true/false for it to happen e.g. wifi connected, is charging etc

After excepting, to have to turn battery saving mode off each time I want to sync and to go through the Samsung implementation of changing screen resolutions is a terrible UX.

caffeinatedgoat commented 5 years ago

I am also experiencing this issue, and am forced to keep my phone out of powef saving mode as a result. If I have explicitly whitelisted this app to ignore power saving mode why the hell does it refuse to upload in powersaving mode. This app is USELESS when the device is in power saving mode.

rodion-k commented 5 years ago

@caffeinatedgoat Try to "Disable power save check" in Auto upload in the top right

caffeinatedgoat commented 5 years ago

@rodion-k Thanks! It's working for me now with that option enabled (after updating to 3.7.0)

EpochalEngineer commented 4 years ago

@caffeinatedgoat Try to "Disable power save check" in Auto upload in the top right

This option is no longer in 3.13.0. On Android 10 with an LG G7.

3589 Did not fix this issue

On this phone, when charging, power save can still be enabled, so it won't even upload when it's charging, regardless of settings.

tobiasKaminsky commented 4 years ago

This option is no longer in 3.13.0. On Android 10 with an LG G7.

We now directly check this, when enabling an auto-upload folder. So if you already have one folder configured, and experience problems, please turn this folder off, save, turn it on. Then you should get the option to disable power save.

tobiasKaminsky commented 3 years ago

No feedback, if this is still valid, please re-open.

fromage9747 commented 3 years ago

How can I reopen this? I've just started making use of power saving on my note8 and discovered that my auto-upload was not working even though next cloud has been whitelisted. Running Android 9 with nextcloud app 3.14.1

EpochalEngineer commented 3 years ago

@fromage9747 @sgurder I reopened it as #8304

EDIT: this has been re-opened instead, here are the relevant updates with Nextcloud 3.13.0 and re-tested on 3.15.1 on an LG G7 and Samsung Galaxy Tab A7:

Try to "Disable power save check" in Auto upload in the top right

This option is no longer in 3.13.0. On Android 10 with an LG G7.

On this phone, when charging, power save can still be enabled, so it won't even upload when it's charging, regardless of settings.

We now directly check this, when enabling an auto-upload folder. So if you already have one folder configured, and experience problems, please turn this folder off, save, turn it on. Then you should get the option to disable power save.

I do get the option to disable power save and a second one for battery optimizations, and this does turn on the system setting "Allow background activity" for the Nextcloud app. But it still will not upload when the device itself is in "Medium power saving mode" (regardless of whether the charger is plugged in).

The above is on the LG G7 mentioned. On a Galaxy Tab A7, I only get 1 of the 2 popups, which only changes the running in background option, not the "Optimize battery usage". Setting this to "Not optimized" does not change anything either. Note that turning auto-upload on and off on that folder does give me the "disable power save / optimization" popup again only on the Tab A7, even though those settings are already turned on at this point.

With both devices, with both power settings set correctly, on nextcloud's uploads view, it still says "Waiting to exit power save mode". As described in #7019, when clicking on a file, it does attempt to try and upload (displaying a progress bar and "uploading", but then immediately goes back to saying "Waiting to exit power save mode".

tobiasKaminsky commented 3 years ago

"Medium power saving mode" (regardless of whether the charger is plugged in).

This is then something vendor specific and hard to handle…

EpochalEngineer commented 3 years ago

"Medium power saving mode" (regardless of whether the charger is plugged in).

This is then something vendor specific and hard to handle…

Perhaps, but as mentioned in #8304, this non-uploading issue even while charging occurs on both devices I have access to: an LG G7 and Samsung Galaxy Tab A7 in any sort of power saving mode, which I keep on at all times to preserve battery.

Zanathoz commented 1 year ago

@caffeinatedgoat Try to "Disable power save check" in Auto upload in the top right

This did the trick for me - Thank you! I still wanted to chime in to +1 this issue on my S22. I had the following settings set and the issue still presented itself.

Settings > Apps > Nextcloud > Mobile Data > Allow background data usage > Enabled Settings > Apps > Nextcloud > Mobile Data > Allow data usage while Data saver is on > Enabled Settings > Apps > Nextcloud > Battery > Unrestricted

After disabling power save check on the Instant Upload section as mentioned above, the items started uploading without issue.

EpochalEngineer commented 1 year ago

After disabling power save check on the Instant Upload section as mentioned above, the items started uploading without issue.

I still don't have a "Disable power save check" or an "Instant Upload" on Nextcloud 3.24.1, Android 10 for a LG G7.

In settings I have an "Auto upload" section where individual folders are identified, and by default the Remote folder is set to "/InstantUpload/" if that is what you are referring to. But the 3 dot menu on the top right only has "Set up a custom folder" while the 3 dots for a folder has options like "Only upload on unmetered Wi-Fi" and "Only upload when charging"

Settings > Apps > Nextcloud > Mobile Data > Allow background data usage > Enabled Settings > Apps > Nextcloud > Mobile Data > Allow data usage while Data saver is on > Enabled Settings > Apps > Nextcloud > Battery > Unrestricted

I do have these but they do not fix the "Waiting to exit power save mode" - the only way I've gotten this to work is just disabling power saver.

joshtrichards commented 11 months ago

@EpochalEngineer:

I still don't have a "Disable power save check" or an "Instant Upload" on Nextcloud 3.24.1, Android 10 for a LG G7.

To see the option you have to toggle the applicable auto-upload folder off then back in again (see https://github.com/nextcloud/android/issues/2889#issuecomment-677442766).

Though looks like the power save override only is available for these devices:

https://github.com/nextcloud/android/blob/91c8c38e5add534aa785525fd6164aee6aa2d9ae/app/src/main/java/com/nextcloud/client/device/PowerManagementServiceImpl.kt#L44

So it may be worth creating an enhancement request specifically to get your device added if it doesn't appear after toggling.

As the original issue has been addressed I'll close this Issue.