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?