[Android General] laurens1975:
For those who encounter this problem:

Thanks to do1fmd's help I managed to find the cause and to "fix" the problem.

After analyzing the logs it turned out to be the Android Doze function that killed the GPS service after ~ 1-1.5 hours of screen-off.

08-19 16:40:02.507 1154 1169 D GnssLocationProvider: updateLowPowerMode triggered gps status update mDisableGpsForPowerManager=true

I searched the web extensively and couldn't find a solution to prevent the GPS service to be killed. Doze can't be disabled from within Android and whitelisting the GPS logging app didn't help either. See here, here and here for more info.

Only thing that worked was to completely disable Doze. This can be done from an ADB shell (no root required) or from a local script (root required). Problem is that the ADB method only lasts until next boot, so it has to be re-applied after each system (re-)start.

adb shell
dumpsys deviceidle disable

So I decided to use this rather old method (still works perfectly fine on my Android 10) to disable Doze with SManager. To use this the device has to be rooted, so I followed do1fmd's guide from the OP and it worked like a charm. After rooting disabling Doze can be done on the device:

View attachment 5397357

With

dumpsys deviceidle enable

Doze can be re-enabled.

For a bit more automation an app like Tasker could also be used to run the command from a local shell.

If root cannot be obtained there might be a workaround using MacroDroid.

For completeness: To avoid rooting the device I tried granting DUMP-permission to SManager using ADB shell, but that failed:

BV9900Pro:/ $ pm grant os.tools.scriptmanagerpro android.permission.DUMP
Security exception: Package os.tools.scriptmanagerpro has not requested permission android.permission.DUMP

java.lang.SecurityException: Package os.tools.scriptmanagerpro has not requested permission android.permission.DUMP
at com.android.server.pm.permission.BasePermission.enforceDeclaredUsedAndRuntimeOrDevelopment(BasePermission.java:425)
at com.android.server.pm.permission.PermissionManagerService.grantRuntimePermission(PermissionManagerService.java:2195)
at com.android.server.pm.permission.PermissionManagerService.access$900(PermissionManagerService.java:125)
at com.android.server.pm.permission.PermissionManagerService$PermissionManagerServiceInternalImpl.grantRuntimePermission(PermissionManagerService.java:3193)
at com.android.server.pm.PackageManagerService.grantRuntimePermission(PackageManagerService.java:5844)
at com.android.server.pm.PackageManagerShellCommand.runGrantRevokePermission(PackageManagerShellCommand.java:1955)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:230)
at android.os.ShellCommand.exec(ShellCommand.java:104)
at com.android.server.pm.PackageManagerService.onShellCommand(PackageManagerService.java:22207)
at android.os.Binder.shellCommand(Binder.java:881)
at android.os.Binder.onTransact(Binder.java:765)
at android.content.pm.IPackageManager$Stub.onTransact(IPackageManager.java:4860)
at com.android.server.pm.PackageManagerService.onTransact(PackageManagerService.java:4116)
at android.os.Binder.execTransactInternal(Binder.java:1021)
at android.os.Binder.execTransact(Binder.java:994)
255|BV9900Pro:/ $

I googled that error and found many answers instructing to enable developers options "Disable permission monitoring" and/or "USB debugging (Security setting)", but I have neither of those in my developer settings. Also, one answer clearly stated it's impossible: https://stackoverflow.com/questions...plication-which-is-downloaded-from-play-store.