microg / NetworkLocation

Deprecated! Use UnifiedNlp --- Geolocation using wlan and gsm cells. Data provided by Apple and opencellid.org
102 stars 27 forks source link

Add support for KitKat (yep, this really is all it takes). #1

Closed notriddle closed 10 years ago

notriddle commented 10 years ago

Adds the v3 API introduced in Android 4.4.

mar-v-in commented 10 years ago

Actually this is not working on official KitKat builds. This requires an build that is incompatible with official NetworkLocation, because Google changed the package name of the location provider (compare https://github.com/CyanogenMod/android_vendor_cm/blob/cm-11.0/overlay/common/frameworks/base/core/res/res/values/config.xml and https://github.com/CyanogenMod/android_vendor_cm/blob/cm-10.2/overlay/common/frameworks/base/core/res/res/values/config.xml )

If you run an inofficial build that did not react on the recent config changes (means it uses the old config, being incompatible with new version) your fix should work as the api did not change (no idea why they changed the version number).

I'll merge this anyway, because it's the minimum needed for KitKat support.

notriddle commented 10 years ago

I'm running a CyanogenMod built on 10 November 2013. According to that log, they change the location service name on 5 November.

I think it still works because of this commit: https://android.googlesource.com/platform/frameworks/base/+1/c5fc9988f11acc58229fb6ae80d346277318ada4

mar-v-in commented 10 years ago

I don't see any official builds of cm11 yet, so could you please provide me a download link to the version you use?

The mentioned commit should not apply here. This config option allows packages with the same signature as the specified package (= same signature as "com.google.android.gms") to act as an location provider. If there is no package "com.google.android.gms" (or it is google's original one) the signature does not match and it should not work.

notriddle commented 10 years ago

http://forum.xda-developers.com/showpost.php?p=47307797&postcount=665

com.google.android.gms isn't the only item in that list, though.

mar-v-in commented 10 years ago

That's interesting... could you please do a logcat during startup and grep for "LocationProviderProxy"?

If you meant the fused location provider: it's singed with the platform key. For good reasons (namely security), the platform key is not published with most roms.

notriddle commented 10 years ago

LocationProviderProxy never shows up in the logs at all. If I just search for location, however...

$ adb logcat | grep -i location
W/linker  (  234): libmmjpeg.so has text relocations. This is wasting memory and is a security risk. Please fix.
W/PackageManager(  664): Unknown permission android.permission.ACCESS_COARSE_UPDATES in package com.google.android.location
W/PackageManager(  664): Unknown permission android.permission.ACCESS_COARSE_UPDATES in package com.google.android.location
I/SystemServer(  664): Location Manager
I/ActivityManager(  664): Start proc com.google.android.location for service com.google.android.location/.NetworkLocationService: pid=926 uid=10067 gids={50067, 1028, 3003, 1015}
E/LocationManagerService(  664): No FusedProvider found.
E/LocationManagerService(  664): no geofence provider found
D/NetworkLocationService(  926): new Service-Object constructed
D/NetworkLocationService(  926): Creating Service
D/NetworkLocationService(  926): airplane:false | wifi:false
D/NetworkLocationService(  926): AirplaneMode or wifi is enabled. make sure we're active!
D/NetworkLocationService(  926): Incoming Bind Intent: Intent { act=com.android.location.service.GeocodeProvider pkg=com.google.android.location }
D/NetworkLocationService(  926): Incoming Bind Intent: Intent { act=com.android.location.service.v3.NetworkLocationProvider pkg=com.google.android.location }
D/NetworkLocationThread(  926): We did not wait, lastTime: 0 autoTime: 9223372036854775807 currentTime: 18385
W/NetworkLocationThread(  926): waiting 5s to prevent mass update...
D/NetworkLocationThread(  926): Update forced because of new incoming request
D/NetworkLocationThread(  926): Now requesting \o/
I/FusedLocation(  664): engine stopped (com.android.location.fused)
I/FusedLocation(  664): engine started (com.android.location.fused)
D/NetworkLocationThread(  926): We did not wait, lastTime: 18461 autoTime: 9223372036854775807 currentTime: 18475
W/NetworkLocationThread(  926): waiting 5s to prevent mass update...
I/FusedLocation(  664): engine started (com.android.location.fused)
D/NetworkLocationThread(  926): We did not wait, lastTime: 18461 autoTime: 9223372036854775807 currentTime: 18502
W/NetworkLocationThread(  926): waiting 5s to prevent mass update...
D/NetworkLocationThread(  926): we're not active (or not initialized yet) = do not track!
D/NetworkLocationThread(  926): Update forced because of new incoming request
D/NetworkLocationThread(  926): Now requesting \o/
D/WlanLocationData(  926): could not get location via wlan
D/CellLocationData(  926): could not get location via gsm calculateLocation is null
D/WlanLocationData(  926): could not get location via wlan
D/CellLocationData(  926): could not get location via gsm calculateLocation is null
D/NetworkLocationThread(  926): lastTime: 18503 autoTime: 86400000 currentTime: 18518
D/NetworkLocationThread(  926): waiting 86399.984s to update...
D/GpsLocationProvider(  664): NTP server returned: 1384658862980 (Sat Nov 16 20:27:42 MST 2013) reference: 30194 certainty: 23 system time offset: 766
dicer commented 10 years ago

I'm trying to build NetworkLocation for currently nightlies of CM11. So I need com.google.android.gms right? I rename the package of the files already in com.google.android.location? What else do I need to change? From your gms.apk I see that the AndroidManifest has references to both gms and location packages? Why?

mar-v-in commented 10 years ago

@dicer you just need to change the packageName in AndroidManifest.xml, don't touch any other files, they're still the same for kitkat

dalb8 commented 10 years ago

So, as of today, the change needed is sed -i 's/package="com.google.android.location"/package="com.google.android.gms"/g' NetworkLocation/AndroidManifest.xml and install to system/priv-app/NetworkLocation.apk.