Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorАлександр Зацепин <az@mapswithme.com>2017-07-17 12:42:57 +0300
committerRoman Romanov <rromanov@65apps.com>2017-07-17 12:56:03 +0300
commitcc734fcd4abaf3718a9073624cc4db0808ff91c6 (patch)
tree49b225e29dc4992a54ce6b3433b41a9371de6347
parent66e3f3110fcb4955c64f6ab3a6a33b9499855b81 (diff)
[android] Added lazy initializtion for Crashlytics librarybeta-911
-rw-r--r--android/src/com/mapswithme/maps/MwmApplication.java27
-rw-r--r--android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java4
-rw-r--r--android/src/com/mapswithme/maps/background/UpgradeReceiver.java4
-rw-r--r--android/src/com/mapswithme/maps/background/WorkerService.java3
-rw-r--r--android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java4
-rw-r--r--android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java10
-rw-r--r--android/src/com/mapswithme/util/CrashlyticsUtils.java25
-rw-r--r--android/src/com/mapswithme/util/MultipleTrackerReferrerReceiver.java3
8 files changed, 56 insertions, 24 deletions
diff --git a/android/src/com/mapswithme/maps/MwmApplication.java b/android/src/com/mapswithme/maps/MwmApplication.java
index 3fdbe9169a..29230f9a46 100644
--- a/android/src/com/mapswithme/maps/MwmApplication.java
+++ b/android/src/com/mapswithme/maps/MwmApplication.java
@@ -57,8 +57,9 @@ public class MwmApplication extends Application
private SharedPreferences mPrefs;
private AppBackgroundTracker mBackgroundTracker;
- private boolean mIsFrameworkInitialized;
- private boolean mIsPlatformInitialized;
+ private boolean mFrameworkInitialized;
+ private boolean mPlatformInitialized;
+ private boolean mCrashlyticsInitialized;
private Handler mMainLoopHandler;
private final Object mMainQueueToken = new Object();
@@ -174,7 +175,7 @@ public class MwmApplication extends Application
private void initNativePlatform()
{
- if (mIsPlatformInitialized)
+ if (mPlatformInitialized)
return;
final boolean isInstallationIdFound = setInstallationIdToCrashlytics();
@@ -201,7 +202,7 @@ public class MwmApplication extends Application
mBackgroundTracker.addListener(mBackgroundListener);
TrackRecorder.init();
Editor.init();
- mIsPlatformInitialized = true;
+ mPlatformInitialized = true;
}
private void createPlatformDirectories(@NonNull String settingsPath, @NonNull String tempPath)
@@ -224,7 +225,7 @@ public class MwmApplication extends Application
private void initNativeCore()
{
- if (mIsFrameworkInitialized)
+ if (mFrameworkInitialized)
return;
nativeInitFramework();
@@ -238,7 +239,7 @@ public class MwmApplication extends Application
LocationHelper.INSTANCE.initialize();
RoutingController.get().initialize();
TrafficManager.INSTANCE.initialize();
- mIsFrameworkInitialized = true;
+ mFrameworkInitialized = true;
}
private void initNativeStrings()
@@ -267,14 +268,24 @@ public class MwmApplication extends Application
nativeAddLocalization("place_page_booking_rating", getString(R.string.place_page_booking_rating));
}
- private void initCrashlytics()
+ public void initCrashlytics()
{
if (!isCrashlyticsEnabled())
return;
+ if (isCrashlyticsInitialized())
+ return;
+
Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());
nativeInitCrashlytics();
+
+ mCrashlyticsInitialized = true;
+ }
+
+ public boolean isCrashlyticsInitialized()
+ {
+ return mCrashlyticsInitialized;
}
private static boolean setInstallationIdToCrashlytics()
@@ -294,7 +305,7 @@ public class MwmApplication extends Application
public boolean arePlatformAndCoreInitialized()
{
- return mIsFrameworkInitialized && mIsPlatformInitialized;
+ return mFrameworkInitialized && mPlatformInitialized;
}
public String getApkPath()
diff --git a/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java b/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java
index b0d4a0664a..ea4725a0fb 100644
--- a/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java
+++ b/android/src/com/mapswithme/maps/background/ConnectivityChangedReceiver.java
@@ -5,10 +5,10 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
-import com.crashlytics.android.Crashlytics;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.util.ConnectionState;
+import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.PermissionsUtils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@@ -29,7 +29,7 @@ public class ConnectivityChangedReceiver extends BroadcastReceiver
String msg = "onReceive: " + intent + " app in background = "
+ !backgroundTracker().isForeground();
LOGGER.i(TAG, msg);
- Crashlytics.log(Log.INFO, TAG, msg);
+ CrashlyticsUtils.log(Log.INFO, TAG, msg);
if (!PermissionsUtils.isExternalStorageGranted())
return;
diff --git a/android/src/com/mapswithme/maps/background/UpgradeReceiver.java b/android/src/com/mapswithme/maps/background/UpgradeReceiver.java
index 35e332cf53..57699619b9 100644
--- a/android/src/com/mapswithme/maps/background/UpgradeReceiver.java
+++ b/android/src/com/mapswithme/maps/background/UpgradeReceiver.java
@@ -5,8 +5,8 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
-import com.crashlytics.android.Crashlytics;
import com.mapswithme.maps.MwmApplication;
+import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@@ -22,7 +22,7 @@ public class UpgradeReceiver extends BroadcastReceiver
String msg = "onReceive: " + intent + " app in background = "
+ !backgroundTracker().isForeground();
LOGGER.i(TAG, msg);
- Crashlytics.log(Log.INFO, TAG, msg);
+ CrashlyticsUtils.log(Log.INFO, TAG, msg);
MwmApplication.onUpgrade();
}
}
diff --git a/android/src/com/mapswithme/maps/background/WorkerService.java b/android/src/com/mapswithme/maps/background/WorkerService.java
index 43d6ca4bb0..02cd6128e0 100644
--- a/android/src/com/mapswithme/maps/background/WorkerService.java
+++ b/android/src/com/mapswithme/maps/background/WorkerService.java
@@ -15,6 +15,7 @@ import com.mapswithme.maps.downloader.CountryItem;
import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.editor.Editor;
import com.mapswithme.maps.location.LocationHelper;
+import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.PermissionsUtils;
import com.mapswithme.util.concurrency.UiThread;
import com.mapswithme.util.log.Logger;
@@ -65,7 +66,7 @@ public class WorkerService extends IntentService
String msg = "onHandleIntent: " + intent + " app in background = "
+ !MwmApplication.backgroundTracker().isForeground();
LOGGER.i(TAG, msg);
- Crashlytics.log(Log.INFO, TAG, msg);
+ CrashlyticsUtils.log(Log.INFO, TAG, msg);
final String action = intent.getAction();
switch (action)
{
diff --git a/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java b/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java
index d14907925a..d30fff9fdf 100644
--- a/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java
+++ b/android/src/com/mapswithme/maps/location/TrackRecorderWakeReceiver.java
@@ -5,7 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
-import com.crashlytics.android.Crashlytics;
+import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
@@ -21,7 +21,7 @@ public class TrackRecorderWakeReceiver extends BroadcastReceiver
String msg = "onReceive: " + intent + " app in background = "
+ !backgroundTracker().isForeground();
LOGGER.i(TAG, msg);
- Crashlytics.log(Log.INFO, TAG, msg);
+ CrashlyticsUtils.log(Log.INFO, TAG, msg);
TrackRecorder.onWakeAlarm();
}
}
diff --git a/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java b/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java
index b2db3b56e1..57261eb956 100644
--- a/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java
+++ b/android/src/com/mapswithme/maps/location/TrackRecorderWakeService.java
@@ -5,14 +5,14 @@ import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import com.crashlytics.android.Crashlytics;
import com.mapswithme.maps.MwmApplication;
+import com.mapswithme.util.CrashlyticsUtils;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
public class TrackRecorderWakeService extends IntentService
{
private static final String TAG = TrackRecorderWakeService.class.getSimpleName();
@@ -32,7 +32,7 @@ public class TrackRecorderWakeService extends IntentService
String msg = "onHandleIntent: " + intent + " app in background = "
+ !MwmApplication.backgroundTracker().isForeground();
LOGGER.i(TAG, msg);
- Crashlytics.log(Log.INFO, TAG, msg);
+ CrashlyticsUtils.log(Log.INFO, TAG, msg);
synchronized (sLock)
{
diff --git a/android/src/com/mapswithme/util/CrashlyticsUtils.java b/android/src/com/mapswithme/util/CrashlyticsUtils.java
index 5077a6d750..c5a3cba54e 100644
--- a/android/src/com/mapswithme/util/CrashlyticsUtils.java
+++ b/android/src/com/mapswithme/util/CrashlyticsUtils.java
@@ -9,8 +9,29 @@ public final class CrashlyticsUtils
{
public static void logException(@NonNull Throwable exception)
{
- if (MwmApplication.isCrashlyticsEnabled())
- Crashlytics.logException(exception);
+ if (!checkCrashlytics())
+ return;
+
+ Crashlytics.logException(exception);
+ }
+
+ public static void log(int priority, @NonNull String tag, @NonNull String msg)
+ {
+ if (!checkCrashlytics())
+ return;
+
+ Crashlytics.log(priority, tag, msg);
+ }
+
+ private static boolean checkCrashlytics()
+ {
+ if (!MwmApplication.isCrashlyticsEnabled())
+ return false;
+
+ MwmApplication application = MwmApplication.get();
+ if (!application.isCrashlyticsInitialized())
+ application.initCrashlytics();
+ return true;
}
private CrashlyticsUtils() {}
diff --git a/android/src/com/mapswithme/util/MultipleTrackerReferrerReceiver.java b/android/src/com/mapswithme/util/MultipleTrackerReferrerReceiver.java
index f72af4a876..e7c83c7a83 100644
--- a/android/src/com/mapswithme/util/MultipleTrackerReferrerReceiver.java
+++ b/android/src/com/mapswithme/util/MultipleTrackerReferrerReceiver.java
@@ -5,7 +5,6 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
-import com.crashlytics.android.Crashlytics;
import com.mapswithme.util.log.Logger;
import com.mapswithme.util.log.LoggerFactory;
import com.mapswithme.util.statistics.AlohaHelper;
@@ -26,7 +25,7 @@ public class MultipleTrackerReferrerReceiver extends BroadcastReceiver
String msg = "onReceive: " + intent + " app in background = "
+ !backgroundTracker().isForeground();
LOGGER.i(TAG, msg);
- Crashlytics.log(Log.INFO, TAG, msg);
+ CrashlyticsUtils.log(Log.INFO, TAG, msg);
Counters.initCounters(context);
// parse & send referrer to Aloha
try