335 lines
12 KiB
Java
335 lines
12 KiB
Java
package com.google.firebase;
|
|
|
|
import android.annotation.TargetApi;
|
|
import android.app.Application;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import android.content.SharedPreferences;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.os.Handler;
|
|
import android.os.Looper;
|
|
import android.util.Log;
|
|
import androidx.collection.ArrayMap;
|
|
import androidx.core.content.ContextCompat;
|
|
import com.google.android.gms.common.api.internal.BackgroundDetector;
|
|
import com.google.android.gms.common.internal.Objects;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.util.PlatformVersion;
|
|
import com.google.android.gms.common.util.ProcessUtils;
|
|
import com.google.firebase.components.Component;
|
|
import com.google.firebase.components.zzf;
|
|
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
|
import com.unity3d.ads.metadata.MediationMetaData;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Modifier;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Collections;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.concurrent.CopyOnWriteArrayList;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* compiled from: com.google.firebase:firebase-common@@16.0.2 */
|
|
/* loaded from: classes.dex */
|
|
public class FirebaseApp {
|
|
private static final List<String> j = Arrays.asList("com.google.firebase.auth.FirebaseAuth", "com.google.firebase.iid.FirebaseInstanceId");
|
|
private static final List<String> k = Collections.singletonList("com.google.firebase.crash.FirebaseCrash");
|
|
private static final List<String> l = Arrays.asList("com.google.android.gms.measurement.AppMeasurement");
|
|
private static final List<String> m = Arrays.asList(new String[0]);
|
|
private static final Set<String> n = Collections.emptySet();
|
|
private static final Object o = new Object();
|
|
private static final Executor p = new zzb(0);
|
|
static final Map<String, FirebaseApp> q = new ArrayMap();
|
|
private final Context a;
|
|
private final String b;
|
|
private final FirebaseOptions c;
|
|
private final zzf d;
|
|
private final SharedPreferences e;
|
|
private final AtomicBoolean f = new AtomicBoolean(false);
|
|
private final AtomicBoolean g = new AtomicBoolean();
|
|
private final AtomicBoolean h;
|
|
private final List<BackgroundStateChangeListener> i;
|
|
|
|
/* compiled from: com.google.firebase:firebase-common@@16.0.2 */
|
|
public interface BackgroundStateChangeListener {
|
|
void a(boolean z);
|
|
}
|
|
|
|
/* compiled from: com.google.firebase:firebase-common@@16.0.2 */
|
|
@Deprecated
|
|
public interface IdTokenListenersCountChangedListener {
|
|
}
|
|
|
|
/* compiled from: com.google.firebase:firebase-common@@16.0.2 */
|
|
static class zzb implements Executor {
|
|
private static final Handler a = new Handler(Looper.getMainLooper());
|
|
|
|
private zzb() {
|
|
}
|
|
|
|
@Override // java.util.concurrent.Executor
|
|
public final void execute(Runnable runnable) {
|
|
a.post(runnable);
|
|
}
|
|
|
|
/* synthetic */ zzb(byte b) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: com.google.firebase:firebase-common@@16.0.2 */
|
|
@TargetApi(24)
|
|
static class zzc extends BroadcastReceiver {
|
|
private static AtomicReference<zzc> b = new AtomicReference<>();
|
|
private final Context a;
|
|
|
|
private zzc(Context context) {
|
|
this.a = context;
|
|
}
|
|
|
|
static /* synthetic */ void a(Context context) {
|
|
if (b.get() == null) {
|
|
zzc zzcVar = new zzc(context);
|
|
if (b.compareAndSet(null, zzcVar)) {
|
|
context.registerReceiver(zzcVar, new IntentFilter("android.intent.action.USER_UNLOCKED"));
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.content.BroadcastReceiver
|
|
public final void onReceive(Context context, Intent intent) {
|
|
synchronized (FirebaseApp.o) {
|
|
Iterator<FirebaseApp> it = FirebaseApp.q.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().j();
|
|
}
|
|
}
|
|
this.a.unregisterReceiver(this);
|
|
}
|
|
}
|
|
|
|
private FirebaseApp(Context context, String str, FirebaseOptions firebaseOptions) {
|
|
new CopyOnWriteArrayList();
|
|
this.i = new CopyOnWriteArrayList();
|
|
new CopyOnWriteArrayList();
|
|
Preconditions.a(context);
|
|
this.a = context;
|
|
Preconditions.b(str);
|
|
this.b = str;
|
|
Preconditions.a(firebaseOptions);
|
|
this.c = firebaseOptions;
|
|
new com.google.firebase.internal.zza();
|
|
this.e = context.getSharedPreferences("com.google.firebase.common.prefs", 0);
|
|
this.h = new AtomicBoolean(h());
|
|
this.d = new zzf(p, Component.AnonymousClass1.a(context).a(), Component.a(context, Context.class, new Class[0]), Component.a(this, FirebaseApp.class, new Class[0]), Component.a(firebaseOptions, FirebaseOptions.class, new Class[0]));
|
|
}
|
|
|
|
public static FirebaseApp f() {
|
|
FirebaseApp firebaseApp;
|
|
synchronized (o) {
|
|
firebaseApp = q.get("[DEFAULT]");
|
|
if (firebaseApp == null) {
|
|
throw new IllegalStateException("Default FirebaseApp is not initialized in this process " + ProcessUtils.a() + ". Make sure to call FirebaseApp.initializeApp(Context) first.");
|
|
}
|
|
}
|
|
return firebaseApp;
|
|
}
|
|
|
|
private boolean h() {
|
|
ApplicationInfo applicationInfo;
|
|
if (this.e.contains("firebase_data_collection_default_enabled")) {
|
|
return this.e.getBoolean("firebase_data_collection_default_enabled", true);
|
|
}
|
|
try {
|
|
PackageManager packageManager = this.a.getPackageManager();
|
|
if (packageManager != null && (applicationInfo = packageManager.getApplicationInfo(this.a.getPackageName(), PeripheralType.SERVO)) != null && applicationInfo.metaData != null && applicationInfo.metaData.containsKey("firebase_data_collection_default_enabled")) {
|
|
return applicationInfo.metaData.getBoolean("firebase_data_collection_default_enabled");
|
|
}
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void i() {
|
|
Preconditions.b(!this.g.get(), "FirebaseApp was deleted");
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void j() {
|
|
boolean c = ContextCompat.c(this.a);
|
|
if (c) {
|
|
zzc.a(this.a);
|
|
} else {
|
|
this.d.a(e());
|
|
}
|
|
a(FirebaseApp.class, this, j, c);
|
|
if (e()) {
|
|
a(FirebaseApp.class, this, k, c);
|
|
a(Context.class, this.a, l, c);
|
|
}
|
|
}
|
|
|
|
public FirebaseOptions c() {
|
|
i();
|
|
return this.c;
|
|
}
|
|
|
|
public boolean d() {
|
|
i();
|
|
return this.h.get();
|
|
}
|
|
|
|
public boolean e() {
|
|
return "[DEFAULT]".equals(b());
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof FirebaseApp) {
|
|
return this.b.equals(((FirebaseApp) obj).b());
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.b.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
Objects.ToStringHelper a = Objects.a(this);
|
|
a.a(MediationMetaData.KEY_NAME, this.b);
|
|
a.a("options", this.c);
|
|
return a.toString();
|
|
}
|
|
|
|
public String b() {
|
|
i();
|
|
return this.b;
|
|
}
|
|
|
|
public Context a() {
|
|
i();
|
|
return this.a;
|
|
}
|
|
|
|
/* compiled from: com.google.firebase:firebase-common@@16.0.2 */
|
|
@TargetApi(14)
|
|
static class zza implements BackgroundDetector.BackgroundStateChangeListener {
|
|
private static AtomicReference<zza> a = new AtomicReference<>();
|
|
|
|
private zza() {
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.api.internal.BackgroundDetector.BackgroundStateChangeListener
|
|
public final void a(boolean z) {
|
|
synchronized (FirebaseApp.o) {
|
|
Iterator it = new ArrayList(FirebaseApp.q.values()).iterator();
|
|
while (it.hasNext()) {
|
|
FirebaseApp firebaseApp = (FirebaseApp) it.next();
|
|
if (firebaseApp.f.get()) {
|
|
firebaseApp.a(z);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
static /* synthetic */ void a(Context context) {
|
|
if (PlatformVersion.a() && (context.getApplicationContext() instanceof Application)) {
|
|
Application application = (Application) context.getApplicationContext();
|
|
if (a.get() == null) {
|
|
zza zzaVar = new zza();
|
|
if (a.compareAndSet(null, zzaVar)) {
|
|
BackgroundDetector.a(application);
|
|
BackgroundDetector.b().a(zzaVar);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static FirebaseApp a(Context context) {
|
|
synchronized (o) {
|
|
if (q.containsKey("[DEFAULT]")) {
|
|
return f();
|
|
}
|
|
FirebaseOptions a = FirebaseOptions.a(context);
|
|
if (a == null) {
|
|
Log.d("FirebaseApp", "Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.");
|
|
return null;
|
|
}
|
|
return a(context, a);
|
|
}
|
|
}
|
|
|
|
public static FirebaseApp a(Context context, FirebaseOptions firebaseOptions) {
|
|
return a(context, firebaseOptions, "[DEFAULT]");
|
|
}
|
|
|
|
public static FirebaseApp a(Context context, FirebaseOptions firebaseOptions, String str) {
|
|
FirebaseApp firebaseApp;
|
|
zza.a(context);
|
|
String trim = str.trim();
|
|
if (context.getApplicationContext() != null) {
|
|
context = context.getApplicationContext();
|
|
}
|
|
synchronized (o) {
|
|
Preconditions.b(!q.containsKey(trim), "FirebaseApp name " + trim + " already exists!");
|
|
Preconditions.a(context, "Application context cannot be null.");
|
|
firebaseApp = new FirebaseApp(context, trim, firebaseOptions);
|
|
q.put(trim, firebaseApp);
|
|
}
|
|
firebaseApp.j();
|
|
return firebaseApp;
|
|
}
|
|
|
|
public <T> T a(Class<T> cls) {
|
|
i();
|
|
return (T) this.d.a(cls);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void a(boolean z) {
|
|
Log.d("FirebaseApp", "Notifying background state change listeners.");
|
|
Iterator<BackgroundStateChangeListener> it = this.i.iterator();
|
|
while (it.hasNext()) {
|
|
it.next().a(z);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private static <T> void a(Class<T> cls, T t, Iterable<String> iterable, boolean z) {
|
|
for (String str : iterable) {
|
|
if (z) {
|
|
try {
|
|
} catch (ClassNotFoundException unused) {
|
|
if (n.contains(str)) {
|
|
throw new IllegalStateException(str + " is missing, but is required. Check if it has been removed by Proguard.");
|
|
}
|
|
Log.d("FirebaseApp", str + " is not linked. Skipping initialization.");
|
|
} catch (IllegalAccessException e) {
|
|
Log.wtf("FirebaseApp", "Failed to initialize " + str, e);
|
|
} catch (NoSuchMethodException unused2) {
|
|
throw new IllegalStateException(str + "#getInstance has been removed by Proguard. Add keep rule to prevent it.");
|
|
} catch (InvocationTargetException e2) {
|
|
Log.wtf("FirebaseApp", "Firebase API initialization failure.", e2);
|
|
}
|
|
if (m.contains(str)) {
|
|
}
|
|
}
|
|
Method method = Class.forName(str).getMethod("getInstance", cls);
|
|
int modifiers = method.getModifiers();
|
|
if (Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers)) {
|
|
method.invoke(null, t);
|
|
}
|
|
}
|
|
}
|
|
}
|