@@ -5,7 +5,7 @@ import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.BuildConfig;
|
||||
import com.mapbox.mapboxsdk.MapboxAccountManager;
|
||||
@@ -32,7 +32,6 @@ import okhttp3.internal.Util;
|
||||
class HTTPRequest implements Callback {
|
||||
|
||||
private static OkHttpClient mClient = new OkHttpClient();
|
||||
private static final String LOG_TAG = HTTPRequest.class.getName();
|
||||
private String USER_AGENT_STRING = null;
|
||||
|
||||
private static final int CONNECTION_ERROR = 0;
|
||||
@@ -108,11 +107,11 @@ class HTTPRequest implements Callback {
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
Log.v(LOG_TAG, String.format("[HTTP] Request was successful (code = %d).", response.code()));
|
||||
Timber.v(String.format("[HTTP] Request was successful (code = %d).", response.code()));
|
||||
} else {
|
||||
// We don't want to call this unsuccessful because a 304 isn't really an error
|
||||
String message = !TextUtils.isEmpty(response.message()) ? response.message() : "No additional information";
|
||||
Log.d(LOG_TAG, String.format(
|
||||
Timber.d(String.format(
|
||||
"[HTTP] Request with response code = %d: %s",
|
||||
response.code(), message));
|
||||
}
|
||||
@@ -158,14 +157,14 @@ class HTTPRequest implements Callback {
|
||||
String errorMessage = e.getMessage() != null ? e.getMessage() : "Error processing the request";
|
||||
|
||||
if (type == TEMPORARY_ERROR) {
|
||||
Log.d(LOG_TAG, String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
Timber.d(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
"Request failed due to a temporary error: %s", errorMessage));
|
||||
} else if (type == CONNECTION_ERROR) {
|
||||
Log.i(LOG_TAG, String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
Timber.i(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
"Request failed due to a connection error: %s", errorMessage));
|
||||
} else {
|
||||
// PERMANENT_ERROR
|
||||
Log.w(LOG_TAG, String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
Timber.w(String.format(MapboxConstants.MAPBOX_LOCALE,
|
||||
"Request failed due to a permanent error: %s", errorMessage));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.telemetry.TelemetryLocationReceiver;
|
||||
import com.mapzen.android.lost.api.LocationRequest;
|
||||
@@ -30,8 +30,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
*/
|
||||
public class LocationServices implements com.mapzen.android.lost.api.LocationListener {
|
||||
|
||||
private static final String TAG = "LocationServices";
|
||||
|
||||
private static LocationServices instance;
|
||||
|
||||
private Context context;
|
||||
@@ -73,7 +71,7 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
|
||||
*/
|
||||
public void toggleGPS(boolean enableGPS) {
|
||||
if (!areLocationPermissionsGranted()) {
|
||||
Log.w(TAG, "Location Permissions Not Granted Yet. Try again after requesting.");
|
||||
Timber.w("Location Permissions Not Granted Yet. Try again after requesting.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -130,7 +128,7 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// Log.d(TAG, "onLocationChanged()..." + location);
|
||||
// Timber.d("onLocationChanged()..." + location);
|
||||
this.lastLocation = location;
|
||||
|
||||
// Update Listeners
|
||||
@@ -181,7 +179,7 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis
|
||||
public boolean areLocationPermissionsGranted() {
|
||||
if ((ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) &&
|
||||
(ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
|
||||
Log.w(TAG, "Location Permissions Not Granted Yet. Try again after requesting.");
|
||||
Timber.w("Location Permissions Not Granted Yet. Try again after requesting.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -36,7 +36,7 @@ import android.support.v4.view.ScaleGestureDetectorCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
@@ -449,7 +449,7 @@ public class MapView extends FrameLayout {
|
||||
savedInstanceState.getBoolean(MapboxConstants.STATE_MY_BEARING_TRACKING_DISMISS, true));
|
||||
} else if (savedInstanceState == null) {
|
||||
// Start Telemetry (authorization determined in initial MapboxEventManager constructor)
|
||||
Log.i(MapView.class.getCanonicalName(), "MapView start Telemetry...");
|
||||
Timber.i("MapView start Telemetry...");
|
||||
MapboxEventManager eventManager = MapboxEventManager.getMapboxEventManager();
|
||||
eventManager.initialize(getContext(), getAccessToken());
|
||||
}
|
||||
@@ -1295,12 +1295,12 @@ public class MapView extends FrameLayout {
|
||||
|
||||
// NaN and Infinite checks to prevent JSON errors at send to server time
|
||||
if (Double.isNaN(tapLatLng.getLatitude()) || Double.isNaN(tapLatLng.getLongitude())) {
|
||||
Log.d(MapView.class.getSimpleName(), "trackGestureEvent() has a NaN lat or lon. Returning.");
|
||||
Timber.d("trackGestureEvent() has a NaN lat or lon. Returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Double.isInfinite(tapLatLng.getLatitude()) || Double.isInfinite(tapLatLng.getLongitude())) {
|
||||
Log.d(MapView.class.getSimpleName(), "trackGestureEvent() has an Infinite lat or lon. Returning.");
|
||||
Timber.d("trackGestureEvent() has an Infinite lat or lon. Returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1327,12 +1327,12 @@ public class MapView extends FrameLayout {
|
||||
|
||||
// NaN and Infinite checks to prevent JSON errors at send to server time
|
||||
if (Double.isNaN(tapLatLng.getLatitude()) || Double.isNaN(tapLatLng.getLongitude())) {
|
||||
Log.d(MapView.class.getSimpleName(), "trackGestureDragEndEvent() has a NaN lat or lon. Returning.");
|
||||
Timber.d("trackGestureDragEndEvent() has a NaN lat or lon. Returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Double.isInfinite(tapLatLng.getLatitude()) || Double.isInfinite(tapLatLng.getLongitude())) {
|
||||
Log.d(MapView.class.getSimpleName(), "trackGestureDragEndEvent() has an Infinite lat or lon. Returning.");
|
||||
Timber.d("trackGestureDragEndEvent() has an Infinite lat or lon. Returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.v4.util.Pools;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@@ -55,7 +55,6 @@ import java.util.List;
|
||||
* </p>
|
||||
*/
|
||||
public class MapboxMap {
|
||||
private static final String TAG = MapboxMap.class.getSimpleName();
|
||||
|
||||
private MapView mapView;
|
||||
private UiSettings uiSettings;
|
||||
@@ -119,7 +118,7 @@ public class MapboxMap {
|
||||
//noinspection unchecked
|
||||
return (T) getMapView().getNativeMapView().getLayer(layerId);
|
||||
} catch (ClassCastException e) {
|
||||
Log.e(TAG, String.format("Layer: %s is a different type: %s", layerId, e.getMessage()));
|
||||
Timber.e(String.format("Layer: %s is a different type: %s", layerId, e.getMessage()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -187,7 +186,7 @@ public class MapboxMap {
|
||||
//noinspection unchecked
|
||||
return (T) getMapView().getNativeMapView().getSource(sourceId);
|
||||
} catch (ClassCastException e) {
|
||||
Log.e(TAG, String.format("Source: %s is a different type: %s", sourceId, e.getMessage()));
|
||||
Timber.e(String.format("Source: %s is a different type: %s", sourceId, e.getMessage()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -260,7 +259,7 @@ public class MapboxMap {
|
||||
public void setMinZoom(
|
||||
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double minZoom) {
|
||||
if ((minZoom < MapboxConstants.MINIMUM_ZOOM) || (minZoom > MapboxConstants.MAXIMUM_ZOOM)) {
|
||||
Log.e(MapboxConstants.TAG, "Not setting minZoom, value is in unsupported range: " + minZoom);
|
||||
Timber.e("Not setting minZoom, value is in unsupported range: " + minZoom);
|
||||
return;
|
||||
}
|
||||
minZoomLevel = minZoom;
|
||||
@@ -297,7 +296,7 @@ public class MapboxMap {
|
||||
public void setMaxZoom(
|
||||
@FloatRange(from = MapboxConstants.MINIMUM_ZOOM, to = MapboxConstants.MAXIMUM_ZOOM) double maxZoom) {
|
||||
if ((maxZoom < MapboxConstants.MINIMUM_ZOOM) || (maxZoom > MapboxConstants.MAXIMUM_ZOOM)) {
|
||||
Log.e(MapboxConstants.TAG, "Not setting maxZoom, value is in unsupported range: " + maxZoom);
|
||||
Timber.e("Not setting maxZoom, value is in unsupported range: " + maxZoom);
|
||||
return;
|
||||
}
|
||||
maxZoomLevel = maxZoom;
|
||||
@@ -1150,7 +1149,7 @@ public class MapboxMap {
|
||||
@UiThread
|
||||
public void selectMarker(@NonNull Marker marker) {
|
||||
if (marker == null) {
|
||||
Log.w(MapboxConstants.TAG, "marker was null, so just returning");
|
||||
Timber.w("marker was null, so just returning");
|
||||
return;
|
||||
}
|
||||
annotationManager.selectMarker(marker, this);
|
||||
@@ -1476,7 +1475,7 @@ public class MapboxMap {
|
||||
@UiThread
|
||||
public void setMyLocationEnabled(boolean enabled) {
|
||||
if (!mapView.isPermissionsAccepted()) {
|
||||
Log.e(MapboxConstants.TAG, "Could not activate user location tracking: "
|
||||
Timber.e("Could not activate user location tracking: "
|
||||
+ "user did not accept the permission or permissions were not requested.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
import android.view.Surface;
|
||||
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
@@ -149,14 +149,14 @@ final class NativeMapView {
|
||||
|
||||
if (width > 65535) {
|
||||
// we have seen edge cases where devices return incorrect values #6111
|
||||
Log.e(MapboxConstants.TAG, "Device returned an out of range width size, " +
|
||||
Timber.e("Device returned an out of range width size, " +
|
||||
"capping value at 65535 instead of " + width);
|
||||
width = 65535;
|
||||
}
|
||||
|
||||
if (height > 65535) {
|
||||
// we have seen edge cases where devices return incorrect values #6111
|
||||
Log.e(MapboxConstants.TAG, "Device returned an out of range height size, " +
|
||||
Timber.e("Device returned an out of range height size, " +
|
||||
"capping value at 65535 instead of " + height);
|
||||
height = 65535;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.MapboxAccountManager;
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
* Not public api.
|
||||
*/
|
||||
public class ConnectivityReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = ConnectivityReceiver.class.getSimpleName();
|
||||
private static ConnectivityReceiver INSTANCE;
|
||||
|
||||
/**
|
||||
@@ -49,7 +48,7 @@ public class ConnectivityReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
boolean connected = isConnected(context);
|
||||
Log.v(TAG, "Connected: " + connected);
|
||||
Timber.v("Connected: " + connected);
|
||||
|
||||
//Loop over listeners
|
||||
for (ConnectivityListener listener : listeners) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.MapboxAccountManager;
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
@@ -20,8 +20,6 @@ import java.io.File;
|
||||
*/
|
||||
public class OfflineManager {
|
||||
|
||||
private final static String LOG_TAG = "OfflineManager";
|
||||
|
||||
//
|
||||
// Static methods
|
||||
//
|
||||
@@ -119,9 +117,9 @@ public class OfflineManager {
|
||||
MapboxConstants.KEY_META_DATA_SET_STORAGE_EXTERNAL,
|
||||
MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(LOG_TAG, "Failed to read the package metadata: " + e.getMessage());
|
||||
Timber.e("Failed to read the package metadata: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Failed to read the storage key: " + e.getMessage());
|
||||
Timber.e("Failed to read the storage key: " + e.getMessage());
|
||||
}
|
||||
|
||||
String databasePath = null;
|
||||
@@ -130,7 +128,7 @@ public class OfflineManager {
|
||||
// Try getting the external storage path
|
||||
databasePath = context.getExternalFilesDir(null).getAbsolutePath();
|
||||
} catch (NullPointerException e) {
|
||||
Log.e(LOG_TAG, "Failed to obtain the external storage path: " + e.getMessage());
|
||||
Timber.e("Failed to obtain the external storage path: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +156,7 @@ public class OfflineManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
Log.w(LOG_TAG, "External storage was requested but it isn't readable. For API level < 18"
|
||||
Timber.w("External storage was requested but it isn't readable. For API level < 18"
|
||||
+ " make sure you've requested READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE"
|
||||
+ " permissions in your app Manifest (defaulting to internal storage).");
|
||||
|
||||
@@ -175,10 +173,10 @@ public class OfflineManager {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
Log.d(LOG_TAG, "Old ambient cache database deleted to save space: " + path);
|
||||
Timber.d("Old ambient cache database deleted to save space: " + path);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOG_TAG, "Failed to delete old ambient cache database: " + e.getMessage());
|
||||
Timber.e("Failed to delete old ambient cache database: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -16,8 +16,6 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
public class OfflineRegion {
|
||||
|
||||
private final static String LOG_TAG = "OfflineRegion";
|
||||
|
||||
//
|
||||
// Static methods
|
||||
//
|
||||
@@ -404,7 +402,7 @@ public class OfflineRegion {
|
||||
super.finalize();
|
||||
destroyOfflineRegion();
|
||||
} catch (Throwable throwable) {
|
||||
Log.e(LOG_TAG, "Failed to finalize OfflineRegion: " + throwable.getMessage());
|
||||
Timber.e("Failed to finalize OfflineRegion: " + throwable.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Properties for Layer
|
||||
*/
|
||||
public class PropertyValue<T> {
|
||||
private static final String TAG = PropertyValue.class.getSimpleName();
|
||||
|
||||
private final Object value;
|
||||
|
||||
@@ -33,7 +32,7 @@ public class PropertyValue<T> {
|
||||
//noinspection unchecked
|
||||
return (Function<T>) value;
|
||||
} else {
|
||||
Log.w(TAG, "not a function, try value");
|
||||
Timber.w("not a function, try value");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +43,7 @@ public class PropertyValue<T> {
|
||||
//noinspection unchecked
|
||||
return (T) value;
|
||||
} else {
|
||||
Log.w(TAG, "not a value, try function");
|
||||
Timber.w("not a value, try function");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.telemetry;
|
||||
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
import java.io.IOException;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
@@ -17,16 +17,14 @@ import okio.Okio;
|
||||
*/
|
||||
public final class GzipRequestInterceptor implements Interceptor {
|
||||
|
||||
private static final String TAG = "GzipRequestInterceptor";
|
||||
|
||||
@Override public Response intercept(Interceptor.Chain chain) throws IOException {
|
||||
Request originalRequest = chain.request();
|
||||
if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
|
||||
Log.d(TAG, "Not compressing");
|
||||
Timber.d("Not compressing");
|
||||
return chain.proceed(originalRequest);
|
||||
}
|
||||
|
||||
Log.d(TAG, "Compressing");
|
||||
Timber.d("Compressing");
|
||||
Request compressedRequest = originalRequest.newBuilder()
|
||||
.header("Content-Encoding", "gzip")
|
||||
.method(originalRequest.method(), gzip(originalRequest.body()))
|
||||
|
||||
@@ -21,7 +21,7 @@ import android.support.annotation.NonNull;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.mapbox.mapboxsdk.BuildConfig;
|
||||
@@ -60,8 +60,6 @@ import okhttp3.internal.Util;
|
||||
*/
|
||||
public class MapboxEventManager {
|
||||
|
||||
private static final String TAG = "MapboxEventManager";
|
||||
|
||||
private static MapboxEventManager mapboxEventManager = null;
|
||||
|
||||
private boolean initialized = false;
|
||||
@@ -117,10 +115,10 @@ public class MapboxEventManager {
|
||||
*/
|
||||
public void initialize(@NonNull Context context, @NonNull String accessToken) {
|
||||
|
||||
Log.i(TAG, "Telemetry initialize() called...");
|
||||
Timber.i("Telemetry initialize() called...");
|
||||
|
||||
if (initialized) {
|
||||
Log.i(TAG, "Mapbox Telemetry has already been initialized.");
|
||||
Timber.i("Mapbox Telemetry has already been initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +131,7 @@ public class MapboxEventManager {
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA-1");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
Log.w(TAG, "Error getting Encryption Algorithm: " + e);
|
||||
Timber.w("Error getting Encryption Algorithm: " + e);
|
||||
}
|
||||
|
||||
// Create Initial Session Id
|
||||
@@ -142,7 +140,7 @@ public class MapboxEventManager {
|
||||
SharedPreferences prefs = context.getSharedPreferences(MapboxConstants.MAPBOX_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
|
||||
|
||||
// Determine if Telemetry Should Be Enabled
|
||||
Log.i(TAG, "Right before Telemetry set enabled in initialized()");
|
||||
Timber.i("Right before Telemetry set enabled in initialized()");
|
||||
setTelemetryEnabled(prefs.getBoolean(MapboxConstants.MAPBOX_SHARED_PREFERENCE_KEY_TELEMETRY_ENABLED, true));
|
||||
|
||||
// Load / Create Vendor Id
|
||||
@@ -169,7 +167,7 @@ public class MapboxEventManager {
|
||||
String stagingAccessToken = appInfo.metaData.getString(MapboxConstants.KEY_META_DATA_STAGING_ACCESS_TOKEN);
|
||||
|
||||
if (TextUtils.isEmpty(stagingURL) || TextUtils.isEmpty(stagingAccessToken)) {
|
||||
Log.d(TAG, "Looking in SharedPreferences for Staging Credentials");
|
||||
Timber.d("Looking in SharedPreferences for Staging Credentials");
|
||||
stagingURL = prefs.getString(MapboxConstants.MAPBOX_SHARED_PREFERENCE_KEY_TELEMETRY_STAGING_URL, null);
|
||||
stagingAccessToken = prefs.getString(MapboxConstants.MAPBOX_SHARED_PREFERENCE_KEY_TELEMETRY_STAGING_ACCESS_TOKEN, null);
|
||||
}
|
||||
@@ -187,7 +185,7 @@ public class MapboxEventManager {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error Trying to load Staging Credentials: " + e.toString());
|
||||
Timber.e("Error Trying to load Staging Credentials: " + e.toString());
|
||||
}
|
||||
|
||||
// Register for battery updates
|
||||
@@ -222,7 +220,7 @@ public class MapboxEventManager {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(MapboxConstants.TAG, "Error checking for Telemetry Service Config: " + e);
|
||||
Timber.w("Error checking for Telemetry Service Config: " + e);
|
||||
}
|
||||
throw new TelemetryServiceNotConfiguredException();
|
||||
}
|
||||
@@ -240,40 +238,40 @@ public class MapboxEventManager {
|
||||
* @param telemetryEnabled True to start telemetry, false to stop it
|
||||
*/
|
||||
public void setTelemetryEnabled(boolean telemetryEnabled) {
|
||||
Log.i(TAG, "setTelemetryEnabled(); this.telemetryEnabled = " + this.telemetryEnabled + "; telemetryEnabled = " + telemetryEnabled);
|
||||
Timber.i("setTelemetryEnabled(); this.telemetryEnabled = " + this.telemetryEnabled + "; telemetryEnabled = " + telemetryEnabled);
|
||||
if (this.telemetryEnabled == telemetryEnabled) {
|
||||
Log.d(TAG, "No need to start / stop telemetry as it's already in that state.");
|
||||
Timber.d("No need to start / stop telemetry as it's already in that state.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (telemetryEnabled) {
|
||||
Log.d(TAG, "Starting Telemetry Up!");
|
||||
Timber.d("Starting Telemetry Up!");
|
||||
// Start It Up
|
||||
context.startService(new Intent(context, TelemetryService.class));
|
||||
|
||||
// Make sure Ambient Mode is started at a minimum
|
||||
if (LocationServices.getLocationServices(context).areLocationPermissionsGranted()) {
|
||||
Log.i(TAG, "Permissions are good, see if GPS is enabled and if not then setup Ambient.");
|
||||
Timber.i("Permissions are good, see if GPS is enabled and if not then setup Ambient.");
|
||||
if (LocationServices.getLocationServices(context).isGPSEnabled()) {
|
||||
LocationServices.getLocationServices(context).toggleGPS(false);
|
||||
}
|
||||
} else {
|
||||
// Start timer that checks for Permissions
|
||||
Log.i(TAG, "Permissions are not good. Need to do some looping to check on stuff.");
|
||||
Timber.i("Permissions are not good. Need to do some looping to check on stuff.");
|
||||
|
||||
final Handler permsHandler = new Handler();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (LocationServices.getLocationServices(context).areLocationPermissionsGranted()) {
|
||||
Log.i(TAG, "Permissions finally granted, so starting Ambient if GPS isn't already enabled");
|
||||
Timber.i("Permissions finally granted, so starting Ambient if GPS isn't already enabled");
|
||||
// Start Ambient
|
||||
if (LocationServices.getLocationServices(context).isGPSEnabled()) {
|
||||
LocationServices.getLocationServices(context).toggleGPS(false);
|
||||
}
|
||||
} else {
|
||||
// Restart Handler
|
||||
Log.i(TAG, "Permissions not granted yet... let's try again in 30 seconds");
|
||||
Timber.i("Permissions not granted yet... let's try again in 30 seconds");
|
||||
permsHandler.postDelayed(this, 1000 * 30);
|
||||
}
|
||||
}
|
||||
@@ -285,7 +283,7 @@ public class MapboxEventManager {
|
||||
timer = new Timer();
|
||||
timer.schedule(new FlushEventsTimerTask(), flushDelayInitialInMillis, flushDelayInMillis);
|
||||
} else {
|
||||
Log.d(TAG, "Shutting Telemetry Down");
|
||||
Timber.d("Shutting Telemetry Down");
|
||||
// Shut It Down
|
||||
events.removeAllElements();
|
||||
context.stopService(new Intent(context, TelemetryService.class));
|
||||
@@ -311,7 +309,7 @@ public class MapboxEventManager {
|
||||
* NOTE: Permission set to package private to enable only telemetry code to use this.
|
||||
*/
|
||||
void flushEventsQueueImmediately() {
|
||||
Log.i(TAG, "flushEventsQueueImmediately() called...");
|
||||
Timber.i("flushEventsQueueImmediately() called...");
|
||||
new FlushTheEventsTask().execute();
|
||||
}
|
||||
|
||||
@@ -325,7 +323,7 @@ public class MapboxEventManager {
|
||||
}
|
||||
events.add(event);
|
||||
if (events.size() == FLUSH_EVENTS_CAP) {
|
||||
Log.d(TAG, "eventsSize == flushCap so send data.");
|
||||
Timber.d("eventsSize == flushCap so send data.");
|
||||
flushEventsQueueImmediately();
|
||||
}
|
||||
}
|
||||
@@ -419,7 +417,7 @@ public class MapboxEventManager {
|
||||
eventWithAttributes.put(MapboxEvent.ATTRIBUTE_CELLULAR_NETWORK_TYPE, getCellularNetworkType());
|
||||
eventWithAttributes.put(MapboxEvent.ATTRIBUTE_WIFI, getConnectedToWifi());
|
||||
} else {
|
||||
Log.w(TAG, "This is not an event type in the Events Data Model.");
|
||||
Timber.w("This is not an event type in the Events Data Model.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,7 +439,7 @@ public class MapboxEventManager {
|
||||
|
||||
// Send to Server Immediately
|
||||
flushEventsQueueImmediately();
|
||||
Log.d(TAG, "turnstile event pushed.");
|
||||
Timber.d("turnstile event pushed.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -466,7 +464,7 @@ public class MapboxEventManager {
|
||||
return hex;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error encoding string, will return in original form." + e);
|
||||
Timber.w("Error encoding string, will return in original form." + e);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
@@ -602,7 +600,7 @@ public class MapboxEventManager {
|
||||
status = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "Error getting Wifi Connection Status: " + e);
|
||||
Timber.w("Error getting Wifi Connection Status: " + e);
|
||||
status = false;
|
||||
}
|
||||
}
|
||||
@@ -620,13 +618,13 @@ public class MapboxEventManager {
|
||||
protected Void doInBackground(Void... voids) {
|
||||
|
||||
if (events.isEmpty()) {
|
||||
Log.d(TAG, "No events in the queue to send so returning.");
|
||||
Timber.d("No events in the queue to send so returning.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check for NetworkConnectivity
|
||||
if (!MapboxAccountManager.getInstance().isConnected()) {
|
||||
Log.w(TAG, "Not connected to network, so empty events cache and return without attempting to send events");
|
||||
Timber.w("Not connected to network, so empty events cache and return without attempting to send events");
|
||||
// Make sure that events don't pile up when Offline
|
||||
// and thus impact available memory over time.
|
||||
events.removeAllElements();
|
||||
@@ -747,10 +745,10 @@ public class MapboxEventManager {
|
||||
.post(body)
|
||||
.build();
|
||||
response = client.newCall(request).execute();
|
||||
Log.d(TAG, "response code = " + response.code() + " for events " + events.size());
|
||||
Timber.d("response code = " + response.code() + " for events " + events.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "FlushTheEventsTask borked: " + e);
|
||||
Timber.e("FlushTheEventsTask borked: " + e);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (response != null && response.body() != null) {
|
||||
|
||||
@@ -8,15 +8,13 @@ import android.content.pm.ServiceInfo;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Manages Startup and Shutdown of Telemetry resources
|
||||
*/
|
||||
public class TelemetryService extends Service {
|
||||
|
||||
private static final String TAG = "TelemetryService";
|
||||
|
||||
private TelemetryLocationReceiver telemetryLocationReceiver = null;
|
||||
|
||||
/**
|
||||
@@ -53,7 +51,7 @@ public class TelemetryService extends Service {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
Log.i(TAG, "onCreate() called");
|
||||
Timber.i("onCreate() called");
|
||||
|
||||
// Enable Location Listening for lifecycle of app
|
||||
IntentFilter filter = new IntentFilter(TelemetryLocationReceiver.INTENT_STRING);
|
||||
@@ -128,7 +126,7 @@ public class TelemetryService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
Log.i(TAG, "onStartCommand() called");
|
||||
Timber.i("onStartCommand() called");
|
||||
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
@@ -142,13 +140,13 @@ public class TelemetryService extends Service {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error while trying to sleep for 1 second: " + e);
|
||||
Timber.e("Error while trying to sleep for 1 second: " + e);
|
||||
}
|
||||
|
||||
try {
|
||||
unregisterReceiver(telemetryLocationReceiver);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(TAG, "Error when unregisterReceiver: " + e);
|
||||
Timber.e("Error when unregisterReceiver: " + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user