Skip to content

Commit d0381a0

Browse files
committed
refactor startup
1 parent 70bf602 commit d0381a0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/FirebaseCrashlytics.java

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import com.google.firebase.sessions.api.FirebaseSessionsDependencies;
4949
import java.util.List;
5050
import java.util.concurrent.Callable;
51+
import java.util.concurrent.Executor;
5152
import java.util.concurrent.ExecutorService;
5253

5354
/**
@@ -71,7 +72,7 @@ public class FirebaseCrashlytics {
7172
@NonNull Deferred<CrashlyticsNativeComponent> nativeComponent,
7273
@NonNull Deferred<AnalyticsConnector> analyticsConnector,
7374
@NonNull Deferred<FirebaseRemoteConfigInterop> remoteConfigInteropDeferred,
74-
@Background ExecutorService liteExecutorService,
75+
@Background ExecutorService bacgroundExecutorService,
7576
@Blocking ExecutorService blockingExecutorService) {
7677

7778
Context context = app.getApplicationContext();
@@ -151,8 +152,8 @@ public class FirebaseCrashlytics {
151152

152153
Logger.getLogger().v("Installer package name is: " + appData.installerPackageName);
153154

154-
final ExecutorService threadPoolExecutor =
155-
ExecutorUtils.buildSingleThreadExecutorService("com.google.firebase.crashlytics.startup");
155+
final Executor threadPoolExecutor =
156+
ExecutorUtils.buildSequentialExecutor(bacgroundExecutorService);
156157

157158
final SettingsController settingsController =
158159
SettingsController.create(
@@ -182,17 +183,9 @@ public Object then(@NonNull Task<Void> task) throws Exception {
182183

183184
final boolean finishCoreInBackground = core.onPreExecute(appData, settingsController);
184185

185-
Tasks.call(
186-
threadPoolExecutor,
187-
new Callable<Void>() {
188-
@Override
189-
public Void call() throws Exception {
190-
if (finishCoreInBackground) {
191-
core.doBackgroundInitializationAsync(settingsController);
192-
}
193-
return null;
194-
}
195-
});
186+
if (finishCoreInBackground) {
187+
core.doBackgroundInitializationAsync(settingsController);
188+
}
196189

197190
return new FirebaseCrashlytics(core);
198191
}

firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal/common/ExecutorUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
import static java.util.concurrent.TimeUnit.SECONDS;
1818

1919
import android.annotation.SuppressLint;
20+
21+
import com.google.firebase.concurrent.FirebaseExecutors;
2022
import com.google.firebase.crashlytics.internal.Logger;
2123
import java.util.Locale;
24+
import java.util.concurrent.Executor;
2225
import java.util.concurrent.ExecutorService;
2326
import java.util.concurrent.Executors;
2427
import java.util.concurrent.LinkedBlockingQueue;
@@ -34,6 +37,10 @@ public final class ExecutorUtils {
3437

3538
private ExecutorUtils() {}
3639

40+
public static Executor buildSequentialExecutor(Executor commonExecutor) {
41+
return FirebaseExecutors.newSequentialExecutor(commonExecutor);
42+
}
43+
3744
public static ExecutorService buildSingleThreadExecutorService(String name) {
3845
final ThreadFactory threadFactory = ExecutorUtils.getNamedThreadFactory(name);
3946
final ExecutorService executor =

0 commit comments

Comments
 (0)