views:

255

answers:

3

I would like to replace the default GPS location provider on android phones with my own coordinate source.

Is there any layer/API/library/provider that would allow to be replaced with my signal provider instead of the built-in hardware GPS, or read from an external plugin? It should allow all apps that rely on the GPS service to receive my signal instead of GPS. Ideally, the replacement should still be able to access the GPS signal (for comparison/correction or to toggle between the two providers).

I am thinking for example of implementing my own LocationManager, and registering it in the system (as optional or default), if that is possible. But at this stage, I am still trying to find out what is possible and suitable.

Thank you for any pointers.

+1  A: 

I'm only in the process of reading about the android SDK at the moment. However my understanding is that you would provide an implementation of a GPS_PROVIDER intent.

Any application can then divert to using the user preferred GPS_PROVIDER intent.

See: http://developer.android.com/guide/topics/intents/intents-filters.html

morechilli
does that work?
gregm
+1  A: 

I'm pretty sure the default location providers for fine location are baked into Android.

Given that Google are becoming more conscious about potential misuse and abuse of system resources by applications, i'd say that's a good thing. Otherwise people would be able to trick the user into thinking they're somewhere else, using the trustworthy sounding 'Use GPS satellites' setting.

The only way I can see that you can add a location provider is via [android.location.LocationManager.addTestProvider(......)][1], which requires the permission ACCESS_MOCK_LOCATION. Now, this method and permission are both documented as being for "testing" purposes. I can't find a source that specifically says that that permission is not granted for market release apps, but I strongly suspect that to be the case.

[1]: http://developer.android.com/reference/android/location/LocationManager.html#addTestProvider(java.lang.String, boolean, boolean, boolean, boolean, boolean, boolean, boolean, int, int)

Sam Svenbjorgchristiensensen
I can't really think of a reasonable attack by mock-positioning the user, as opposed to all the other permissions you actually can grant. But I guess you're still right with it not being available for apps in the market.
relet
+2  A: 

Replacing the "default" is not allowed at this time and the only work around is to create a mock provider. First you must set the security permission:

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

Second, set your code to use the mock provider which you will create. There is some excellent information about how to accomplish this here: http://diffract.me/2009/11/android-location-provider-mock/

Mondain
Thanks for the link. If it is not possible to request that permission on the user's phone, it won't help much though. And you still have to modify the target application.
relet