Search in sources :

Example 1 with CrashlyticsNativeComponent

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

the class CrashlyticsRegistrar method buildCrashlytics.

/* JADX INFO: Access modifiers changed from: private */
public FirebaseCrashlytics buildCrashlytics(ComponentContainer container) {
    FirebaseApp app = (FirebaseApp) container.get(FirebaseApp.class);
    CrashlyticsNativeComponent nativeComponent = (CrashlyticsNativeComponent) container.get(CrashlyticsNativeComponent.class);
    AnalyticsConnector analyticsConnector = (AnalyticsConnector) container.get(AnalyticsConnector.class);
    FirebaseInstanceIdInternal instanceId = (FirebaseInstanceIdInternal) container.getProvider(FirebaseInstanceIdInternal.class).get();
    return FirebaseCrashlytics.init(app, instanceId, nativeComponent, analyticsConnector);
}
Also used : FirebaseInstanceIdInternal(com.google.firebase.iid.internal.FirebaseInstanceIdInternal) FirebaseApp(com.google.firebase.FirebaseApp) CrashlyticsNativeComponent(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent) AnalyticsConnector(com.google.firebase.analytics.connector.AnalyticsConnector)

Example 2 with CrashlyticsNativeComponent

use of com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent 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 3 with CrashlyticsNativeComponent

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

the class CrashlyticsCoreTest method testOnPreExecute_nativeDidCrashOnPreviousExecution.

public void testOnPreExecute_nativeDidCrashOnPreviousExecution() throws Exception {
    // Create a previous execution
    appRestart();
    final CrashlyticsNativeComponent mockNativeComponent = mock(CrashlyticsNativeComponent.class);
    when(mockNativeComponent.hasCrashDataForSession(anyString())).thenReturn(true);
    final CrashlyticsCore crashlyticsCore = appRestart(mockNativeComponent);
    assertTrue(crashlyticsCore.didCrashOnPreviousExecution());
}
Also used : CrashlyticsNativeComponent(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent)

Example 4 with CrashlyticsNativeComponent

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

the class CrashlyticsControllerTest method testNativeCrashDataCausesNativeReport.

public void testNativeCrashDataCausesNativeReport() throws Exception {
    final String sessionId = "sessionId_1_new";
    final String previousSessionId = "sessionId_0_previous";
    final File testDir = testFileStore.getNativeSessionDir(previousSessionId);
    final File minidump = new File(testDir, "crash.dmp");
    final File metadata = new File(testDir, "crash.device_info");
    final File session = new File(testDir, "session.json");
    final File app = new File(testDir, "app.json");
    final File device = new File(testDir, "device.json");
    final File os = new File(testDir, "os.json");
    TestUtils.writeStringToFile("minidump", minidump);
    TestUtils.writeStringToFile("metadata", metadata);
    TestUtils.writeStringToFile("session", session);
    TestUtils.writeStringToFile("app", app);
    TestUtils.writeStringToFile("device", device);
    TestUtils.writeStringToFile("os", os);
    final CrashlyticsNativeComponent mockNativeComponent = mock(CrashlyticsNativeComponent.class);
    when(mockNativeComponent.hasCrashDataForSession(anyString())).thenReturn(true);
    when(mockNativeComponent.getSessionFileProvider(anyString())).thenReturn(new NativeSessionFileProvider() {

        @Override
        public File getMinidumpFile() {
            return minidump;
        }

        @Override
        public File getBinaryImagesFile() {
            return null;
        }

        @Override
        public File getMetadataFile() {
            return metadata;
        }

        @Override
        public File getSessionFile() {
            return session;
        }

        @Override
        public File getAppFile() {
            return app;
        }

        @Override
        public File getDeviceFile() {
            return device;
        }

        @Override
        public File getOsFile() {
            return os;
        }
    });
    when(mockSessionReportingCoordinator.listSortedOpenSessionIds()).thenReturn(new TreeSet<>(Arrays.asList(sessionId, previousSessionId)).descendingSet());
    final LogFileManager logFileManager = new LogFileManager(testFileStore, sessionId);
    final CrashlyticsController controller = builder().setNativeComponent(mockNativeComponent).setLogFileManager(logFileManager).build();
    controller.finalizeSessions(testSettingsProvider);
    verify(mockSessionReportingCoordinator).finalizeSessionWithNativeEvent(eq(previousSessionId), any());
    verify(mockSessionReportingCoordinator, never()).finalizeSessionWithNativeEvent(eq(sessionId), any());
}
Also used : NativeSessionFileProvider(com.google.firebase.crashlytics.internal.NativeSessionFileProvider) TreeSet(java.util.TreeSet) Mockito.anyString(org.mockito.Mockito.anyString) File(java.io.File) LogFileManager(com.google.firebase.crashlytics.internal.metadata.LogFileManager) CrashlyticsNativeComponent(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent)

Example 5 with CrashlyticsNativeComponent

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

the class CrashlyticsCoreTest method testOnPreExecute_nativeDidNotCrashOnPreviousExecution.

public void testOnPreExecute_nativeDidNotCrashOnPreviousExecution() throws Exception {
    // Create a previous execution
    appRestart();
    final CrashlyticsNativeComponent mockNativeComponent = mock(CrashlyticsNativeComponent.class);
    when(mockNativeComponent.hasCrashDataForSession(anyString())).thenReturn(false);
    final CrashlyticsCore crashlyticsCore = appRestart(mockNativeComponent);
    assertFalse(crashlyticsCore.didCrashOnPreviousExecution());
}
Also used : CrashlyticsNativeComponent(com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent)

Aggregations

CrashlyticsNativeComponent (com.google.firebase.crashlytics.internal.CrashlyticsNativeComponent)6 FirebaseApp (com.google.firebase.FirebaseApp)2 AnalyticsConnector (com.google.firebase.analytics.connector.AnalyticsConnector)2 Context (android.content.Context)1 MissingNativeComponent (com.google.firebase.crashlytics.internal.MissingNativeComponent)1 NativeSessionFileProvider (com.google.firebase.crashlytics.internal.NativeSessionFileProvider)1 Onboarding (com.google.firebase.crashlytics.internal.Onboarding)1 CrashlyticsCore (com.google.firebase.crashlytics.internal.common.CrashlyticsCore)1 DataCollectionArbiter (com.google.firebase.crashlytics.internal.common.DataCollectionArbiter)1 IdManager (com.google.firebase.crashlytics.internal.common.IdManager)1 LogFileManager (com.google.firebase.crashlytics.internal.metadata.LogFileManager)1 SettingsController (com.google.firebase.crashlytics.internal.settings.SettingsController)1 FirebaseInstanceIdInternal (com.google.firebase.iid.internal.FirebaseInstanceIdInternal)1 FirebaseInstallationsApi (com.google.firebase.installations.FirebaseInstallationsApi)1 File (java.io.File)1 TreeSet (java.util.TreeSet)1 ExecutorService (java.util.concurrent.ExecutorService)1 Mockito.anyString (org.mockito.Mockito.anyString)1