[android] - validate intent and contents before handling (#6938)

This commit is contained in:
Tobrun
2016-11-07 14:38:04 +01:00
committed by GitHub
parent 505bf7db7a
commit 5412191ab4

View File

@@ -6,15 +6,12 @@ import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
import android.os.Handler;
import android.util.Log;
/**
* Listener for Location updates generated by implementing app.
*/
public class TelemetryLocationReceiver extends BroadcastReceiver {
private static final String TAG = "TelemLocationReceiver";
public static final String INTENT_STRING = "com.mapbox.mapboxsdk.telemetry.TelemetryLocationReceiver";
/**
@@ -61,12 +58,14 @@ public class TelemetryLocationReceiver extends BroadcastReceiver {
*/
@Override
public void onReceive(Context context, Intent intent) {
Location location = (Location)intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED);
if (intent == null || intent.getExtras() == null) {
// see https://github.com/mapbox/mapbox-gl-native/issues/6934
return;
}
Location location = (Location) intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED);
if (location != null) {
// Log.d(TAG, "location received = " + location);
MapboxEventManager.getMapboxEventManager().addLocationEvent(location);
} else {
Log.d(TAG, "location NOT received");
}
}
}