Thanks for your detailed response, and apologies for my delay in replying.
It seems that there is no control over whether charges are incurred for calculating location on Android, which is both disappointing and a backward step from Java ME.
JSR-179 (
https://jcp.org/aboutJava/communityprocess/mrel/jsr179/index2.html) explicitly allows such control in Java ME, using the Criteria class. On page 22, it states:
However, the cost criteria field is treated differently from others. If the application has set the cost field to indicate that the returned location provider is not allowed to incur financial cost to the end user, the implementation must guarantee that the returned location provider does not incur cost.
As Android uses a carbon-copy of the Criteria class (
http://developer.android.com/reference/android/location/Criteria.html), including an isCostAllowed() method, it is reasonable to assume that it functions in the same way. However, this is clearly not the case.
I'm unsure whether this is intentional or just down to poor implementation. The API is clearly broken as it is possible to construct a test LocationProvider with cost allowed, and when this is checked against a Criteria with
no cost allowed, it somehow meets the criteria. Digging into the source code behind this quickly showed that no cost checks are present, which begs the question: why is the interface there?
// Set up test location provider with cost
String provider = "testLocProv";
boolean hasCost = true;
boolean isAllowed = false;
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
lm.addTestProvider(provider, false, false, false, hasCost, false, false, false, Criteria.NO_REQUIREMENT, Criteria.ACCURACY_FINE); // has cost
lm.setTestProviderEnabled(provider, true); // enabled
// Check provider meets criteria
LocationProvider lp = lm.getProvider(provider);
Criteria c = new Criteria();
c.setCostAllowed(isAllowed); // not allowed
assertFalse("Fails criteria", lp.meetsCriteria(c)); // fail, returns true
I also found an interesting blog entry (
http://mobilesociety.typepad.com/mobile_life/2014/08/supl-reveals-my-identity-and-location-to-google.html) about the contents of SUPL requests from an Android phone, which raises some serious privacy questions if it is true. I have no reason to doubt him, as he describes his investigation method to allow others to reproduce it.