2

I've noticed my phone now and then to stop using GPS right in the moment when I switch on the display. This is noticeable because there is the "going away" animation of the notification which tells that GPS is in use. I can find no reason why my phone is trying to locate itself in such a moment.

At least one other user has reported this behavior, here in a comment to How to check which app uses GPS on Galaxy Nexus?:

[...] it's just that when I unlock the phone I can see the GPS icon in the notifications bar for a split second, then it disappears. [...] – Dario Solera Jun 22 '12 at 7:01

I've then used logcat to save the log to a file on the phone in order to later examine what's going on:

username@desktop:~$ adb shell
shell@jflte:/ $ logcat -r 1048576 -n 10 -f /mnt/extSdCard/logging/main.txt &

At 01:52 when switching on my phone, I observed the mentioned behavior again (GPS notification going away the moment I switch on my phone's display). I've later copied main.txt to my desktop computer and filtered with cat main.txt | grep -a -i location. The log of the time in question is as follows:

06-12 01:34:46.293 D/GpsLocationProvider(  908): receive broadcast intent, action: android.intent.action.SCREEN_OFF
06-12 01:38:36.815 W/ResourcesManager( 9551): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
06-12 01:52:50.265 I/LocationManagerService(  908): remove 2bd78731 by com.google.android.gms
06-12 01:52:50.265 D/LocationManagerService(  908): provider request: passive ProviderRequest[ON interval=0]
06-12 01:52:50.265 D/LocationManagerService(  908): request 325c2a7a gps Request[ACCURACY_FINE gps requested=0 fastest=0] from com.google.android.gms(10055)
06-12 01:52:50.265 D/LocationManagerService(  908): provider request: gps ProviderRequest[ON interval=0]
06-12 01:52:50.275 D/GpsLocationProvider(  908): setRequest ProviderRequest[ON interval=0]
06-12 01:52:50.275 D/GpsLocationProvider(  908): startNavigating, singleShot is false
06-12 01:52:50.275 D/GpsLocationProvider_ex(  908): Data state true
06-12 01:52:50.275 D/GpsLocationProvider_ex(  908): getSKAFEnable : false
06-12 01:52:50.285 D/GpsLocationProvider(  908): setting position_mode to MS_BASED
06-12 01:52:50.505 E/LocSvc_ApiV02(  908): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 99 QMI_LOC_EVENT_LOCATION_SERVER_CONNECTION_REQ_IND_V02
06-12 01:52:50.505 V/GpsLocationProvider(  908): AGpsStatus is V2+: 96
06-12 01:52:50.505 V/GpsLocationProvider(  908): AGPS IP is v4: ffffffff
06-12 01:52:50.505 V/GpsLocationProvider(  908): Passing AGPS IP addr: size 0
06-12 01:52:50.505 D/GpsLocationProvider(  908): GPS_REQUEST_AGPS_DATA_CONN
06-12 01:52:50.505 V/GpsLocationProvider(  908): Received SUPL IP addr[]: null
06-12 01:52:50.545 D/GpsLocationProvider(  908): PhoneConstants.APN_ALREADY_ACTIVE
06-12 01:52:50.585 E/LocSvc_ApiV02(  908): I/<--- void globalRespCb(locClientHandleType, uint32_t, locClientRespIndUnionType, void*) line 125 QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_REQ_V02
06-12 01:52:50.905 V/GpsLocationProvider(  908): reportStatus status: 3
06-12 01:52:50.905 V/GpsLocationProvider(  908): reportStatus status: 1
06-12 01:52:50.905 D/GpsLocationProvider(  908): send an intent to notify GPS has been enabled or disabled mNavigating = true
06-12 01:52:51.055 D/GpsLocationProvider(  908): receive broadcast intent, action: android.net.conn.CONNECTIVITY_CHANGE
06-12 01:52:51.766 D/GpsLocationProvider(  908): receive broadcast intent, action: android.intent.action.SCREEN_ON
06-12 01:52:51.856 I/LocationManagerService(  908): remove 325c2a7a by com.google.android.gms
06-12 01:52:51.856 D/LocationManagerService(  908): provider request: gps ProviderRequest[OFF]
06-12 01:52:51.856 D/GpsLocationProvider(  908): setRequest ProviderRequest[OFF]
06-12 01:52:51.856 D/GpsLocationProvider(  908): stopNavigating
06-12 01:52:51.866 D/LocationManagerService(  908): request 3ec60783 passive Request[POWER_NONE passive fastest=0] from com.google.android.gms(10055)
06-12 01:52:51.866 D/LocationManagerService(  908): provider request: passive ProviderRequest[ON interval=0]
06-12 01:52:51.916 V/GpsLocationProvider(  908): reportStatus status: 2
06-12 01:52:51.916 D/GpsLocationProvider(  908): send an intent to notify GPS has been enabled or disabled mNavigating = false
06-12 01:52:51.916 V/GpsLocationProvider(  908): reportStatus status: 4
06-12 01:52:52.677 E/LocSvc_ApiV02(  908): I/<--- void globalEventCb(locClientHandleType, uint32_t, locClientEventIndUnionType, void*) line 99 QMI_LOC_EVENT_LOCATION_SERVER_CONNECTION_REQ_IND_V02
06-12 01:52:52.697 E/LocSvc_ApiV02(  908): I/<--- void globalRespCb(locClientHandleType, uint32_t, locClientRespIndUnionType, void*) line 125 QMI_LOC_INFORM_LOCATION_SERVER_CONN_STATUS_REQ_V02
06-12 01:52:52.697 V/GpsLocationProvider(  908): AGpsStatus is V2+: 96
06-12 01:52:52.697 V/GpsLocationProvider(  908): AGPS IP is v4: ffffffff
06-12 01:52:52.697 V/GpsLocationProvider(  908): Passing AGPS IP addr: size 0
06-12 01:52:52.697 D/GpsLocationProvider(  908): GPS_RELEASE_AGPS_DATA_CONN
06-12 01:52:53.398 D/GpsLocationProvider(  908): receive broadcast intent, action: android.net.conn.CONNECTIVITY_CHANGE
06-12 01:52:53.398 D/GpsLocationProvider(  908): receive broadcast intent, action: android.net.conn.CONNECTIVITY_CHANGE
06-12 01:52:54.098 D/LocationManagerService(  908): getLastLocation: Request[POWER_NONE passive fastest=0 num=1]
06-12 01:52:54.349 W/ResourcesManager(10089): Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
06-12 01:52:54.729 D/LocationManagerService(  908): getLastLocation: Request[POWER_NONE passive fastest=0 num=1]
06-12 01:52:54.859 D/LocationManagerService(  908): getLastLocation: Request[POWER_NONE passive fastest=0 num=1]
06-12 01:52:56.601 I/dex2oat (10211): /system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --instruction-set=arm --instruction-set-features=div --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/com.google.android.gms/app_fb/f.apk --oat-fd=46 --art-fd=-1 --oat-location=/data/data/com.google.android.gms/app_fb/f.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m
06-12 01:53:05.780 D/LocationProviderProxy(  908): applying state to connected service
06-12 01:53:05.800 D/LocationProviderProxy(  908): applying state to connected service
06-12 01:54:49.651 D/GpsLocationProvider(  908): receive broadcast intent, action: android.intent.action.SCREEN_OFF

As you can see, the GPS request is canceled 90ms after the SCREEN_ON intent was broadcast. I'm sure this is a direct reaction to the broadcast, because I've seen this behavior so many times now.

Is there a reason for hiding the fact that GPS is getting used? Maybe is it better to use GPS while the display is off for lowering peak battery usage? What is actually triggering the GPS request? Is com.google.android.gms the Google Maps App? Why would it request a location update 18 minutes after I switch off the display?

2
  • com.google.android.gms corresponds to Google Play Services.
    – Grimoire
    Jun 14, 2016 at 13:20
  • 1
    Play Services typically checks your location when the screen is unlocked, to update any location based applications and GN cards. This behaviour is normal, it's not hiding it, it just gets a quick location then stops.
    – acejavelin
    Jun 14, 2016 at 13:29

1 Answer 1

2

Several features in Google Play Services need to check your location in the background, maybe even when you're not using the phone otherwise. These features include geofences, which let apps react to you moving in or out of a particular region (e.g. when you're at home); Location History if you have turned on; Google Now's "current location" weather reports and suggested nearby places; activity or fitness tracking; amongst others.

It would be really bad for your battery life if the phone had to keep waking up to satisfy these requests. When you're not using the phone, normally it goes into a "low-power" state, where no apps run (not even Google Play Services), the main processor is underclocked or turned off completely, and radios (the cell radio, the Wi-Fi radio, the Bluetooth radio, and the GPS) can also be turned off or put into sleep modes. Coming out of that sleep mode costs quite a bit of energy, so Android tries to minimise unnecessary wake-ups, to extend battery life.

For this reason, Android's scheduler for recurring background tasks often delays a background task (such as a location update) while the phone is asleep, or it batches multiple tasks together (such as a location update and a check for new emails). But if the phone has to wake up anyway, because you've just turned the screen on, then any tasks which were delayed will run immediately.

Google Play Services' location update only takes a fraction of a second, especially if your location hasn't changed much, so it looks like it's just stopping when you turn the screen on, when in fact the whole update took less time than it took you to unlock the phone. Stopping the request isn't "a direct reaction to the [SCREEN_ON] broadcast": rather, starting the request is a reaction to you bringing the phone out of sleep.

3
  • Do you feel like adding a little bit of info concerning the phone's behaviour when Doze is present?
    – Grimoire
    Jun 14, 2016 at 16:29
  • @DeathMaskSalesman I feel like that's too much detail for this question. Even before "doze", rescheduling and batching scheduled tasks and network activity to avoid waking the phone from sleep unnecessarily was a thing. Doze just changes what kind of sleep states there are and how apps interact with it. If you want to ask a more specific question about doze, I'll try to give a helpful answer.
    – Dan Hulme
    Jun 14, 2016 at 19:58
  • I see. Nothing to object, then. ;)
    – Grimoire
    Jun 14, 2016 at 19:59

You must log in to answer this question.

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