[android] - validate intent and contents before handling (#6938)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user