I'm trying to set some protection against people using mock locations to manipulate my app. I realise that it's impossible to prevent 100%... I'm just trying to do what I can.
The app uses Google location services (part of play services) in its main activity.
The onLocationChanged() method is:
public void onLocationChanged(Location location) {
    this.mCurrentLocation = location;
    if (Build.VERSION.SDK_INT > 17 && mCurrentLocation.isFromMockProvider()) {
        Log.i(TAG, "QQ Location is MOCK");
        // TODO: add code to stop app
        // otherwise, currently, location will never be updated and app will never start
    } else {
        Double LAT = mCurrentLocation.getLatitude();
        Double LON = mCurrentLocation.getLongitude();
        if ((LAT.doubleValue() > 33.309171) || (LAT.doubleValue() < 33.226442) || (LON.doubleValue() < -90.790165) || (LON.doubleValue() > -90.707081)) {
            buildAlertMessageOutOfBounds();
        } else if (waiting4FirstLocationUpdate) {
            Log.i(TAG, "YYY onLocationChanged() determines this is the FIRST update.");
            waiting4FirstLocationUpdate = false;
            setContentView(R.layout.activity_main);
            startDisplayingLists();
        }
    }
}
The location services work perfectly and all is well with the app in general, but when I run the app in an emulator with Android Studio (Nexus One API 23), and I set the location using extended controls (mock), the app just continues to work as normal, and so it seems that the condition:
if (Build.VERSION.SDK_INT > 17 && mCurrentLocation.isFromMockProvider())
Is returning false.
This doesn't make any sense to me. Does anyone know why this would happen?
Thanks!