lostzen / lost

A drop-in replacement for Google Play services location APIs for Android
http://mapzen.github.io/lost/
Other
351 stars 70 forks source link

AOSP Integration #179

Closed mikalackis closed 7 years ago

mikalackis commented 7 years ago

I am working on a system application that is integrated as a part of my AOSP ROM. This applications runs on first boot and it should collect users location and ship it to a server. As soon as my application starts, I encounter a following crash:

03-06 23:06:03.704 966 4160 I GnssLocationProvider: WakeLock acquired by sendMessage(3, 0, com.android.server.location.GnssLocationProvider$GpsRequest@d1b15e6) 03-06 23:06:03.706 966 979 I GnssLocationProvider: WakeLock released by handleMessage(3, 0, com.android.server.location.GnssLocationProvider$GpsRequest@d1b15e6) 03-06 23:06:03.709 4149 4149 E FusionEngine: Unable to register for network updates. 03-06 23:06:03.709 4149 4149 E FusionEngine: java.lang.IllegalArgumentException: provider doesn't exist: network 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.os.Parcel.readException(Parcel.java:1688) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.os.Parcel.readException(Parcel.java:1637) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:614) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:887) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.location.LocationManager.requestLocationUpdates(LocationManager.java:471) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusionEngine.enableNetwork(FusionEngine.java:154) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusionEngine.enable(FusionEngine.java:112) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.LocationEngine.setRequest(LocationEngine.java:45) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusedLocationProviderServiceImpl.requestLocationUpdates(FusedLocationProviderServiceImpl.java:60) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusedLocationProviderService.requestLocationUpdates(FusedLocationProviderService.java:69) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.requestLocationUpdates(FusedLocationProviderApiImpl.java:109) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.ariel.guardian.location.LostLocationManager.restartLocationUpdates(Unknown Source) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.ariel.guardian.location.LostLocationManager.onConnected(Unknown Source) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusedLocationServiceConnectionManager.onServiceConnected(FusedLocationServiceConnectionManager.java:84) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.mapzen.android.lost.internal.FusedLocationProviderApiImpl.onServiceConnected(FusedLocationProviderApiImpl.java:65) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1453) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1481) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.os.Handler.handleCallback(Handler.java:751) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.os.Handler.dispatchMessage(Handler.java:95) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.os.Looper.loop(Looper.java:154) 03-06 23:06:03.709 4149 4149 E FusionEngine: at android.app.ActivityThread.main(ActivityThread.java:6119) 03-06 23:06:03.709 4149 4149 E FusionEngine: at java.lang.reflect.Method.invoke(Native Method) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 03-06 23:06:03.709 4149 4149 E FusionEngine: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 03-06 23:06:03.759 966 3903 D SntpClient: round trip: 59ms, clock offset: 1092ms 03-06 23:06:03.759 966 3439 D SntpClient: round trip: 62ms, clock offset: 1093ms

The main part of the crash is probably this line: FusionEngine: java.lang.IllegalArgumentException: provider doesn't exist: network

I am running the app on Nexus 5X, ROM version is 7.1.1. If I set my location setting to GPS and get out, I do get a fix and after I revert it back to battery saving it works, but the very first boot of the device fails with that exception. I am using lost version 2.1.2. Could you please help me out with this? Thanks!

ecgreb commented 7 years ago

This exception is logged when the FusionEngine attempts to register for network location updates but the LocationManager reports no network provider is available. Does the ROM and/or device you are using have a network location provider?

However there is nothing in this stack trace that indicates a crash. The FusionEngine specifically catches the IllegalArgumentException to prevent a crash on devices and emulators that do not support network location updates.

https://github.com/mapzen/lost/blob/98aae3593fa6a73c2cfa458d43940fe684a2bc25/lost/src/main/java/com/mapzen/android/lost/internal/FusionEngine.java#L152-L158

mikalackis commented 7 years ago

Thanks for your reply. Im running a stock AOSP ROM without google apps, so I figured lost should work. On the other hand, yes, my app doesnt crash in death but I'm unable to receive location updates unless I turn on high accuracy.

ecgreb commented 7 years ago

As long as the LocationManager (AOSP component) reports there is no network provider it is true you will only receive updates if you request PRIORITY_HIGH_ACCURACY since this is the only time GPS is enabled.

I don't have much experience with system applications but if it is running on first boot perhaps the network provider has not yet been initialized by the OS? Maybe @sarahlensing can shed some more light on this since she has more experience writing system apps.

mikalackis commented 7 years ago

Sorry for the delay in reply, got a bit busy. You are completely right, since I ran my system app on a device that at first boot doesnt have Google Play Services installed, the only way to fetch location was via GPS. I thought that network location provider is part of the AOSP but it seems that it was removed and is integrated into google play services. Thanks for your explanation, will close the question now.