Search in sources :

Example 1 with SettingsController

use of com.google.firebase.crashlytics.internal.settings.SettingsController in project GreenHouse by utsanjan.

the class FirebaseCrashlytics method init.

/* JADX INFO: Access modifiers changed from: package-private */
public static FirebaseCrashlytics init(FirebaseApp app, FirebaseInstanceIdInternal instanceId, CrashlyticsNativeComponent nativeComponent, AnalyticsConnector analyticsConnector) {
    CrashlyticsNativeComponent nativeComponent2;
    Context context = app.getApplicationContext();
    String appIdentifier = context.getPackageName();
    IdManager idManager = new IdManager(context, appIdentifier, instanceId);
    DataCollectionArbiter arbiter = new DataCollectionArbiter(app);
    if (nativeComponent == null) {
        nativeComponent2 = new MissingNativeComponent();
    } else {
        nativeComponent2 = nativeComponent;
    }
    final Onboarding onboarding = new Onboarding(app, context, idManager, arbiter);
    final CrashlyticsCore core = new CrashlyticsCore(app, idManager, nativeComponent2, arbiter, analyticsConnector);
    if (!onboarding.onPreExecute()) {
        Logger.getLogger().e("Unable to start Crashlytics.");
        return null;
    }
    final ExecutorService threadPoolExecutor = ExecutorUtils.buildSingleThreadExecutorService("com.google.firebase.crashlytics.startup");
    final SettingsController settingsController = onboarding.retrieveSettingsData(context, app, threadPoolExecutor);
    final boolean finishCoreInBackground = core.onPreExecute(settingsController);
    Tasks.call(threadPoolExecutor, new // from class: com.google.firebase.crashlytics.FirebaseCrashlytics.1
    Callable<Void>() {

        // java.util.concurrent.Callable
        @Override
        public Void call() throws Exception {
            Onboarding.this.doOnboarding(threadPoolExecutor, settingsController);
            if (!finishCoreInBackground) {
                return null;
            }
            core.doBackgroundInitializationAsync(settingsController);
            return null;
        }
    });
    return new FirebaseCrashlytics(core);
}
Also used : Context(android.content.Context) CrashlyticsCore(com.google.firebase.crashlytics.internal.common.CrashlyticsCore) IdManager(com.google.firebase.crashlytics.internal.common.IdManager) DataCollectionArbiter(com.google.firebase.crashlytics.internal.common.DataCollectionArbiter) CrashlyticsNativeComponent(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent) Onboarding(com.google.firebase.crashlytics.internal.Onboarding) ExecutorService(java.util.concurrent.ExecutorService) MissingNativeComponent(com.google.firebase.crashlytics.internal.MissingNativeComponent) SettingsController(com.google.firebase.crashlytics.internal.settings.SettingsController)

Example 2 with SettingsController

use of com.google.firebase.crashlytics.internal.settings.SettingsController in project firebase-android-sdk by firebase.

the class FirebaseCrashlytics method init.

@Nullable
static FirebaseCrashlytics init(@NonNull FirebaseApp app, @NonNull FirebaseInstallationsApi firebaseInstallationsApi, @NonNull Deferred<CrashlyticsNativeComponent> nativeComponent, @NonNull Deferred<AnalyticsConnector> analyticsConnector) {
    Context context = app.getApplicationContext();
    final String appIdentifier = context.getPackageName();
    Logger.getLogger().i("Initializing Firebase Crashlytics " + CrashlyticsCore.getVersion() + " for " + appIdentifier);
    FileStore fileStore = new FileStore(context);
    final DataCollectionArbiter arbiter = new DataCollectionArbiter(app);
    final IdManager idManager = new IdManager(context, appIdentifier, firebaseInstallationsApi, arbiter);
    final CrashlyticsNativeComponentDeferredProxy deferredNativeComponent = new CrashlyticsNativeComponentDeferredProxy(nativeComponent);
    // Integration with Firebase Analytics
    final AnalyticsDeferredProxy analyticsDeferredProxy = new AnalyticsDeferredProxy(analyticsConnector);
    final ExecutorService crashHandlerExecutor = ExecutorUtils.buildSingleThreadExecutorService("Crashlytics Exception Handler");
    final CrashlyticsCore core = new CrashlyticsCore(app, idManager, deferredNativeComponent, arbiter, analyticsDeferredProxy.getDeferredBreadcrumbSource(), analyticsDeferredProxy.getAnalyticsEventLogger(), fileStore, crashHandlerExecutor);
    final String googleAppId = app.getOptions().getApplicationId();
    final String mappingFileId = CommonUtils.getMappingFileId(context);
    Logger.getLogger().d("Mapping file ID is: " + mappingFileId);
    final DevelopmentPlatformProvider developmentPlatformProvider = new DevelopmentPlatformProvider(context);
    AppData appData;
    try {
        appData = AppData.create(context, idManager, googleAppId, mappingFileId, developmentPlatformProvider);
    } catch (PackageManager.NameNotFoundException e) {
        Logger.getLogger().e("Error retrieving app package info.", e);
        return null;
    }
    Logger.getLogger().v("Installer package name is: " + appData.installerPackageName);
    final ExecutorService threadPoolExecutor = ExecutorUtils.buildSingleThreadExecutorService("com.google.firebase.crashlytics.startup");
    final SettingsController settingsController = SettingsController.create(context, googleAppId, idManager, new HttpRequestFactory(), appData.versionCode, appData.versionName, fileStore, arbiter);
    // Kick off actually fetching the settings.
    settingsController.loadSettingsData(threadPoolExecutor).continueWith(threadPoolExecutor, new Continuation<Void, Object>() {

        @Override
        public Object then(@NonNull Task<Void> task) throws Exception {
            if (!task.isSuccessful()) {
                Logger.getLogger().e("Error fetching settings.", task.getException());
            }
            return null;
        }
    });
    final boolean finishCoreInBackground = core.onPreExecute(appData, settingsController);
    Tasks.call(threadPoolExecutor, new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            if (finishCoreInBackground) {
                core.doBackgroundInitializationAsync(settingsController);
            }
            return null;
        }
    });
    return new FirebaseCrashlytics(core);
}
Also used : Context(android.content.Context) CrashlyticsCore(com.google.firebase.crashlytics.internal.common.CrashlyticsCore) HttpRequestFactory(com.google.firebase.crashlytics.internal.network.HttpRequestFactory) DevelopmentPlatformProvider(com.google.firebase.crashlytics.internal.DevelopmentPlatformProvider) IdManager(com.google.firebase.crashlytics.internal.common.IdManager) DataCollectionArbiter(com.google.firebase.crashlytics.internal.common.DataCollectionArbiter) FileStore(com.google.firebase.crashlytics.internal.persistence.FileStore) PackageManager(android.content.pm.PackageManager) AppData(com.google.firebase.crashlytics.internal.common.AppData) CrashlyticsNativeComponentDeferredProxy(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponentDeferredProxy) ExecutorService(java.util.concurrent.ExecutorService) SettingsController(com.google.firebase.crashlytics.internal.settings.SettingsController) Nullable(androidx.annotation.Nullable)

Example 3 with SettingsController

use of com.google.firebase.crashlytics.internal.settings.SettingsController in project firebase-android-sdk by firebase.

the class CrashlyticsCoreTest method startCoreAsync.

// Starts the given CrashlyticsCore.
private Task<CrashlyticsCore> startCoreAsync(CrashlyticsCore crashlyticsCore) {
    // Swallow exceptions so tests don't crash.
    Thread.setDefaultUncaughtExceptionHandler(NOOP_HANDLER);
    SettingsController mockSettingsController = mock(SettingsController.class);
    final Settings settings = new TestSettings(3);
    when(mockSettingsController.getSettingsSync()).thenReturn(settings);
    when(mockSettingsController.getSettingsAsync()).thenReturn(Tasks.forResult(settings));
    AppData appData = new AppData(GOOGLE_APP_ID, "buildId", "installerPackageName", "packageName", "versionCode", "versionName", mock(DevelopmentPlatformProvider.class));
    crashlyticsCore.onPreExecute(appData, mockSettingsController);
    return crashlyticsCore.doBackgroundInitializationAsync(mockSettingsController).onSuccessTask(new SuccessContinuation<Void, CrashlyticsCore>() {

        @NonNull
        @Override
        public Task<CrashlyticsCore> then(@Nullable Void aVoid) throws Exception {
            return Tasks.forResult(crashlyticsCore);
        }
    });
}
Also used : Task(com.google.android.gms.tasks.Task) DevelopmentPlatformProvider(com.google.firebase.crashlytics.internal.DevelopmentPlatformProvider) TestSettings(com.google.firebase.crashlytics.internal.settings.TestSettings) NonNull(androidx.annotation.NonNull) TestSettings(com.google.firebase.crashlytics.internal.settings.TestSettings) Settings(com.google.firebase.crashlytics.internal.settings.Settings) SettingsController(com.google.firebase.crashlytics.internal.settings.SettingsController)

Example 4 with SettingsController

use of com.google.firebase.crashlytics.internal.settings.SettingsController in project GreenHouse by utsanjan.

the class Onboarding method retrieveSettingsData.

public SettingsController retrieveSettingsData(Context context, FirebaseApp app, Executor backgroundExecutor) {
    String googleAppId = app.getOptions().getApplicationId();
    SettingsController controller = SettingsController.create(context, googleAppId, this.idManager, this.requestFactory, this.versionCode, this.versionName, getOverridenSpiEndpoint(), this.dataCollectionArbiter);
    controller.loadSettingsData(backgroundExecutor).continueWith(backgroundExecutor, new // from class: com.google.firebase.crashlytics.internal.Onboarding.3
    Continuation<Void, Object>() {

        // com.google.android.gms.tasks.Continuation
        @Override
        public Object then(Task<Void> task) throws Exception {
            if (task.isSuccessful()) {
                return null;
            }
            Logger.getLogger().e("Error fetching settings.", task.getException());
            return null;
        }
    });
    return controller;
}
Also used : SettingsController(com.google.firebase.crashlytics.internal.settings.SettingsController)

Aggregations

SettingsController (com.google.firebase.crashlytics.internal.settings.SettingsController)4 Context (android.content.Context)2 DevelopmentPlatformProvider (com.google.firebase.crashlytics.internal.DevelopmentPlatformProvider)2 CrashlyticsCore (com.google.firebase.crashlytics.internal.common.CrashlyticsCore)2 DataCollectionArbiter (com.google.firebase.crashlytics.internal.common.DataCollectionArbiter)2 IdManager (com.google.firebase.crashlytics.internal.common.IdManager)2 ExecutorService (java.util.concurrent.ExecutorService)2 PackageManager (android.content.pm.PackageManager)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 Task (com.google.android.gms.tasks.Task)1 CrashlyticsNativeComponent (com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent)1 CrashlyticsNativeComponentDeferredProxy (com.google.firebase.crashlytics.internal.CrashlyticsNativeComponentDeferredProxy)1 MissingNativeComponent (com.google.firebase.crashlytics.internal.MissingNativeComponent)1 Onboarding (com.google.firebase.crashlytics.internal.Onboarding)1 AppData (com.google.firebase.crashlytics.internal.common.AppData)1 HttpRequestFactory (com.google.firebase.crashlytics.internal.network.HttpRequestFactory)1 FileStore (com.google.firebase.crashlytics.internal.persistence.FileStore)1 Settings (com.google.firebase.crashlytics.internal.settings.Settings)1 TestSettings (com.google.firebase.crashlytics.internal.settings.TestSettings)1