package io.fabric.sdk.android.services.common; import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.provider.Settings; import io.fabric.sdk.android.Fabric; import io.fabric.sdk.android.Kit; import java.util.Collection; import java.util.Locale; import java.util.UUID; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; /* loaded from: classes2.dex */ public class IdManager { private static final Pattern k = Pattern.compile("[^\\p{Alnum}]"); private static final String l = Pattern.quote("/"); private final ReentrantLock a = new ReentrantLock(); private final InstallerPackageNameProvider b; private final boolean c; private final boolean d; private final Context e; private final String f; private final String g; AdvertisingInfoProvider h; AdvertisingInfo i; boolean j; public enum DeviceIdentifierType { WIFI_MAC_ADDRESS(1), BLUETOOTH_MAC_ADDRESS(2), FONT_TOKEN(53), ANDROID_ID(100), ANDROID_DEVICE_ID(101), ANDROID_SERIAL(102), ANDROID_ADVERTISING_ID(103); public final int protobufIndex; DeviceIdentifierType(int i) { this.protobufIndex = i; } } public IdManager(Context context, String str, String str2, Collection collection) { if (context == null) { throw new IllegalArgumentException("appContext must not be null"); } if (str == null) { throw new IllegalArgumentException("appIdentifier must not be null"); } if (collection == null) { throw new IllegalArgumentException("kits must not be null"); } this.e = context; this.f = str; this.g = str2; this.b = new InstallerPackageNameProvider(); this.h = new AdvertisingInfoProvider(context); this.c = CommonUtils.a(context, "com.crashlytics.CollectDeviceIdentifiers", true); if (!this.c) { Fabric.g().d("Fabric", "Device ID collection disabled for " + context.getPackageName()); } this.d = CommonUtils.a(context, "com.crashlytics.CollectUserIdentifiers", true); if (this.d) { return; } Fabric.g().d("Fabric", "User information collection disabled for " + context.getPackageName()); } private String a(String str) { if (str == null) { return null; } return k.matcher(str).replaceAll("").toLowerCase(Locale.US); } private String b(String str) { return str.replaceAll(l, ""); } public String c() { if (this.c) { String string = Settings.Secure.getString(this.e.getContentResolver(), "android_id"); if (!"9774d56d682e549c".equals(string)) { return a(string); } } return null; } public String d() { return this.f; } public String e() { String str = this.g; if (str != null) { return str; } SharedPreferences d = CommonUtils.d(this.e); String string = d.getString("crashlytics.installation.id", null); return string == null ? a(d) : string; } public String f() { if (!this.c) { return ""; } String c = c(); if (c != null) { return c; } SharedPreferences d = CommonUtils.d(this.e); String string = d.getString("crashlytics.installation.id", null); return string == null ? a(d) : string; } public String g() { return this.b.a(this.e); } public String h() { return String.format(Locale.US, "%s/%s", b(Build.MANUFACTURER), b(Build.MODEL)); } public String i() { return b(Build.VERSION.INCREMENTAL); } public String j() { return b(Build.VERSION.RELEASE); } private String a(SharedPreferences sharedPreferences) { this.a.lock(); try { String string = sharedPreferences.getString("crashlytics.installation.id", null); if (string == null) { string = a(UUID.randomUUID().toString()); sharedPreferences.edit().putString("crashlytics.installation.id", string).commit(); } return string; } finally { this.a.unlock(); } } synchronized AdvertisingInfo b() { if (!this.j) { this.i = this.h.a(); this.j = true; } return this.i; } public String a() { AdvertisingInfo b; if (!this.c || (b = b()) == null) { return null; } return b.a; } }