File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
firebase-crashlytics/src/main/java/com/google/firebase/crashlytics/internal Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,6 @@ private static String formatId(@NonNull String id) {
104
104
@ Override
105
105
@ NonNull
106
106
public synchronized InstallIds getInstallIds () {
107
- CrashlyticsWorkers .checkBackgroundThread ();
108
107
if (!shouldRefresh ()) {
109
108
return installIds ;
110
109
}
@@ -183,7 +182,7 @@ private String readCachedCrashlyticsInstallId(SharedPreferences prefs) {
183
182
*/
184
183
@ NonNull
185
184
public FirebaseInstallationId fetchTrueFid (boolean validate ) {
186
- CrashlyticsWorkers .checkBackgroundThread (); // This fetch blocks, never do it on main.
185
+ CrashlyticsWorkers .checkNotMainThread (); // This fetch blocks, never do it on main.
187
186
String fid = null ;
188
187
String authToken = null ;
189
188
Original file line number Diff line number Diff line change 16
16
17
17
package com.google.firebase.crashlytics.internal.concurrency
18
18
19
+ import android.os.Build
20
+ import android.os.Looper
19
21
import com.google.firebase.crashlytics.internal.Logger
20
22
import java.util.concurrent.ExecutorService
21
23
@@ -59,6 +61,12 @@ class CrashlyticsWorkers(
59
61
/* * When enabled, failed preconditions will cause assertion errors for debugging. */
60
62
@JvmStatic var enforcement: Boolean = false
61
63
64
+ @JvmStatic
65
+ fun checkNotMainThread () =
66
+ checkThread(::isNotMainThread) {
67
+ " Must not be called on a main thread, was called on $threadName ."
68
+ }
69
+
62
70
@JvmStatic
63
71
fun checkBlockingThread () =
64
72
checkThread(::isBlockingThread) {
@@ -71,6 +79,13 @@ class CrashlyticsWorkers(
71
79
" Must be called on a background thread, was called on $threadName ."
72
80
}
73
81
82
+ private fun isNotMainThread () =
83
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
84
+ ! Looper .getMainLooper().isCurrentThread
85
+ } else {
86
+ Looper .getMainLooper() != Looper .myLooper()
87
+ }
88
+
74
89
private fun isBlockingThread () = threadName.contains(" Firebase Blocking Thread #" )
75
90
76
91
private fun isBackgroundThread () = threadName.contains(" Firebase Background Thread #" )
You can’t perform that action at this time.
0 commit comments