Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
package io.fabric.sdk.android.services.common;
import com.thoughtworks.xstream.XStream;
import io.fabric.sdk.android.Kit;
import io.fabric.sdk.android.services.network.HttpMethod;
import io.fabric.sdk.android.services.network.HttpRequest;
import io.fabric.sdk.android.services.network.HttpRequestFactory;
import java.util.Collections;
import java.util.Map;
import java.util.regex.Pattern;
/* loaded from: classes2.dex */
public abstract class AbstractSpiCall {
private static final Pattern f = Pattern.compile("http(s?)://[^\\/]+", 2);
private final String a;
private final HttpRequestFactory b;
private final HttpMethod c;
private final String d;
protected final Kit e;
public AbstractSpiCall(Kit kit, String str, String str2, HttpRequestFactory httpRequestFactory, HttpMethod httpMethod) {
if (str2 == null) {
throw new IllegalArgumentException("url must not be null.");
}
if (httpRequestFactory == null) {
throw new IllegalArgumentException("requestFactory must not be null.");
}
this.e = kit;
this.d = str;
this.a = a(str2);
this.b = httpRequestFactory;
this.c = httpMethod;
}
protected HttpRequest a() {
return a(Collections.emptyMap());
}
protected String b() {
return this.a;
}
protected HttpRequest a(Map<String, String> map) {
HttpRequest a = this.b.a(this.c, b(), map);
a.a(false);
a.a(XStream.PRIORITY_VERY_HIGH);
a.c("User-Agent", "Crashlytics Android SDK/" + this.e.i());
a.c("X-CRASHLYTICS-DEVELOPER-TOKEN", "470fa2b4ae81cd56ecbcda9735803434cec591fa");
return a;
}
private String a(String str) {
return !CommonUtils.a(this.d) ? f.matcher(str).replaceFirst(this.d) : str;
}
}

View File

@@ -0,0 +1,33 @@
package io.fabric.sdk.android.services.common;
/* loaded from: classes2.dex */
class AdvertisingInfo {
public final String a;
public final boolean b;
AdvertisingInfo(String str, boolean z) {
this.a = str;
this.b = z;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || AdvertisingInfo.class != obj.getClass()) {
return false;
}
AdvertisingInfo advertisingInfo = (AdvertisingInfo) obj;
if (this.b != advertisingInfo.b) {
return false;
}
String str = this.a;
String str2 = advertisingInfo.a;
return str == null ? str2 == null : str.equals(str2);
}
public int hashCode() {
String str = this.a;
return ((str != null ? str.hashCode() : 0) * 31) + (this.b ? 1 : 0);
}
}

View File

@@ -0,0 +1,89 @@
package io.fabric.sdk.android.services.common;
import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import io.fabric.sdk.android.Fabric;
import io.fabric.sdk.android.services.persistence.PreferenceStore;
import io.fabric.sdk.android.services.persistence.PreferenceStoreImpl;
/* loaded from: classes2.dex */
class AdvertisingInfoProvider {
private final Context a;
private final PreferenceStore b;
public AdvertisingInfoProvider(Context context) {
this.a = context.getApplicationContext();
this.b = new PreferenceStoreImpl(context, "TwitterAdvertisingInfoPreferences");
}
private void b(final AdvertisingInfo advertisingInfo) {
new Thread(new BackgroundPriorityRunnable() { // from class: io.fabric.sdk.android.services.common.AdvertisingInfoProvider.1
@Override // io.fabric.sdk.android.services.common.BackgroundPriorityRunnable
public void a() {
AdvertisingInfo e = AdvertisingInfoProvider.this.e();
if (advertisingInfo.equals(e)) {
return;
}
Fabric.g().d("Fabric", "Asychronously getting Advertising Info and storing it to preferences");
AdvertisingInfoProvider.this.c(e);
}
}).start();
}
/* JADX INFO: Access modifiers changed from: private */
@SuppressLint({"CommitPrefEdits"})
public void c(AdvertisingInfo advertisingInfo) {
if (a(advertisingInfo)) {
PreferenceStore preferenceStore = this.b;
preferenceStore.a(preferenceStore.edit().putString("advertising_id", advertisingInfo.a).putBoolean("limit_ad_tracking_enabled", advertisingInfo.b));
} else {
PreferenceStore preferenceStore2 = this.b;
preferenceStore2.a(preferenceStore2.edit().remove("advertising_id").remove("limit_ad_tracking_enabled"));
}
}
/* JADX INFO: Access modifiers changed from: private */
public AdvertisingInfo e() {
AdvertisingInfo a = c().a();
if (a(a)) {
Fabric.g().d("Fabric", "Using AdvertisingInfo from Reflection Provider");
} else {
a = d().a();
if (a(a)) {
Fabric.g().d("Fabric", "Using AdvertisingInfo from Service Provider");
} else {
Fabric.g().d("Fabric", "AdvertisingInfo not present");
}
}
return a;
}
public AdvertisingInfoStrategy d() {
return new AdvertisingInfoServiceStrategy(this.a);
}
public AdvertisingInfo a() {
AdvertisingInfo b = b();
if (a(b)) {
Fabric.g().d("Fabric", "Using AdvertisingInfo from Preference Store");
b(b);
return b;
}
AdvertisingInfo e = e();
c(e);
return e;
}
protected AdvertisingInfo b() {
return new AdvertisingInfo(this.b.get().getString("advertising_id", ""), this.b.get().getBoolean("limit_ad_tracking_enabled", false));
}
private boolean a(AdvertisingInfo advertisingInfo) {
return (advertisingInfo == null || TextUtils.isEmpty(advertisingInfo.a)) ? false : true;
}
public AdvertisingInfoStrategy c() {
return new AdvertisingInfoReflectionStrategy(this.a);
}
}

View File

@@ -0,0 +1,56 @@
package io.fabric.sdk.android.services.common;
import android.content.Context;
import io.fabric.sdk.android.Fabric;
/* loaded from: classes2.dex */
class AdvertisingInfoReflectionStrategy implements AdvertisingInfoStrategy {
private final Context a;
public AdvertisingInfoReflectionStrategy(Context context) {
this.a = context.getApplicationContext();
}
private String b() {
try {
return (String) Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient$Info").getMethod("getId", new Class[0]).invoke(c(), new Object[0]);
} catch (Exception unused) {
Fabric.g().w("Fabric", "Could not call getId on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info");
return null;
}
}
private Object c() {
try {
return Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient").getMethod("getAdvertisingIdInfo", Context.class).invoke(null, this.a);
} catch (Exception unused) {
Fabric.g().w("Fabric", "Could not call getAdvertisingIdInfo on com.google.android.gms.ads.identifier.AdvertisingIdClient");
return null;
}
}
private boolean d() {
try {
return ((Boolean) Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient$Info").getMethod("isLimitAdTrackingEnabled", new Class[0]).invoke(c(), new Object[0])).booleanValue();
} catch (Exception unused) {
Fabric.g().w("Fabric", "Could not call isLimitAdTrackingEnabled on com.google.android.gms.ads.identifier.AdvertisingIdClient$Info");
return false;
}
}
boolean a(Context context) {
try {
return ((Integer) Class.forName("com.google.android.gms.common.GooglePlayServicesUtil").getMethod("isGooglePlayServicesAvailable", Context.class).invoke(null, context)).intValue() == 0;
} catch (Exception unused) {
return false;
}
}
@Override // io.fabric.sdk.android.services.common.AdvertisingInfoStrategy
public AdvertisingInfo a() {
if (a(this.a)) {
return new AdvertisingInfo(b(), d());
}
return null;
}
}

View File

@@ -0,0 +1,158 @@
package io.fabric.sdk.android.services.common;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.IBinder;
import android.os.IInterface;
import android.os.Looper;
import android.os.Parcel;
import android.os.RemoteException;
import io.fabric.sdk.android.Fabric;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
/* loaded from: classes2.dex */
class AdvertisingInfoServiceStrategy implements AdvertisingInfoStrategy {
private final Context a;
private static final class AdvertisingConnection implements ServiceConnection {
private boolean a;
private final LinkedBlockingQueue<IBinder> b;
private AdvertisingConnection() {
this.a = false;
this.b = new LinkedBlockingQueue<>(1);
}
public IBinder a() {
if (this.a) {
Fabric.g().e("Fabric", "getBinder already called");
}
this.a = true;
try {
return this.b.poll(200L, TimeUnit.MILLISECONDS);
} catch (InterruptedException unused) {
return null;
}
}
@Override // android.content.ServiceConnection
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
try {
this.b.put(iBinder);
} catch (InterruptedException unused) {
}
}
@Override // android.content.ServiceConnection
public void onServiceDisconnected(ComponentName componentName) {
this.b.clear();
}
}
private static final class AdvertisingInterface implements IInterface {
private final IBinder a;
public AdvertisingInterface(IBinder iBinder) {
this.a = iBinder;
}
@Override // android.os.IInterface
public IBinder asBinder() {
return this.a;
}
public String getId() throws RemoteException {
String str;
Parcel obtain = Parcel.obtain();
Parcel obtain2 = Parcel.obtain();
try {
try {
obtain.writeInterfaceToken("com.google.android.gms.ads.identifier.internal.IAdvertisingIdService");
this.a.transact(1, obtain, obtain2, 0);
obtain2.readException();
str = obtain2.readString();
} catch (Exception unused) {
Fabric.g().d("Fabric", "Could not get parcel from Google Play Service to capture AdvertisingId");
obtain2.recycle();
obtain.recycle();
str = null;
}
return str;
} finally {
obtain2.recycle();
obtain.recycle();
}
}
public boolean i() throws RemoteException {
Parcel obtain = Parcel.obtain();
Parcel obtain2 = Parcel.obtain();
boolean z = false;
try {
try {
obtain.writeInterfaceToken("com.google.android.gms.ads.identifier.internal.IAdvertisingIdService");
obtain.writeInt(1);
this.a.transact(2, obtain, obtain2, 0);
obtain2.readException();
if (obtain2.readInt() != 0) {
z = true;
}
} catch (Exception unused) {
Fabric.g().d("Fabric", "Could not get parcel from Google Play Service to capture Advertising limitAdTracking");
}
return z;
} finally {
obtain2.recycle();
obtain.recycle();
}
}
}
public AdvertisingInfoServiceStrategy(Context context) {
this.a = context.getApplicationContext();
}
@Override // io.fabric.sdk.android.services.common.AdvertisingInfoStrategy
public AdvertisingInfo a() {
if (Looper.myLooper() == Looper.getMainLooper()) {
Fabric.g().d("Fabric", "AdvertisingInfoServiceStrategy cannot be called on the main thread");
return null;
}
try {
this.a.getPackageManager().getPackageInfo("com.android.vending", 0);
AdvertisingConnection advertisingConnection = new AdvertisingConnection();
Intent intent = new Intent("com.google.android.gms.ads.identifier.service.START");
intent.setPackage("com.google.android.gms");
try {
if (this.a.bindService(intent, advertisingConnection, 1)) {
try {
try {
AdvertisingInterface advertisingInterface = new AdvertisingInterface(advertisingConnection.a());
return new AdvertisingInfo(advertisingInterface.getId(), advertisingInterface.i());
} catch (Exception e) {
Fabric.g().a("Fabric", "Exception in binding to Google Play Service to capture AdvertisingId", e);
this.a.unbindService(advertisingConnection);
}
} finally {
this.a.unbindService(advertisingConnection);
}
} else {
Fabric.g().d("Fabric", "Could not bind to Google Play Service to capture AdvertisingId");
}
} catch (Throwable th) {
Fabric.g().c("Fabric", "Could not bind to Google Play Service to capture AdvertisingId", th);
}
return null;
} catch (PackageManager.NameNotFoundException unused) {
Fabric.g().d("Fabric", "Unable to find Google Play Services package name");
return null;
} catch (Exception e2) {
Fabric.g().c("Fabric", "Unable to determine if Google Play Services is available", e2);
return null;
}
}
}

View File

@@ -0,0 +1,6 @@
package io.fabric.sdk.android.services.common;
/* loaded from: classes2.dex */
public interface AdvertisingInfoStrategy {
AdvertisingInfo a();
}

View File

@@ -0,0 +1,62 @@
package io.fabric.sdk.android.services.common;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.ubtrobot.jimu.robotapi.PeripheralType;
import io.fabric.sdk.android.Fabric;
/* loaded from: classes2.dex */
public class ApiKey {
protected String a() {
return "Fabric could not be initialized, API key missing from AndroidManifest.xml. Add the following tag to your Application element \n\t<meta-data android:name=\"io.fabric.ApiKey\" android:value=\"YOUR_API_KEY\"/>";
}
protected String a(Context context) {
try {
Bundle bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), PeripheralType.SERVO).metaData;
if (bundle == null) {
return null;
}
String string = bundle.getString("io.fabric.ApiKey");
if (string != null) {
return string;
}
Fabric.g().d("Fabric", "Falling back to Crashlytics key lookup from Manifest");
return bundle.getString("com.crashlytics.ApiKey");
} catch (Exception e) {
Fabric.g().d("Fabric", "Caught non-fatal exception while retrieving apiKey: " + e);
return null;
}
}
protected String b(Context context) {
int a = CommonUtils.a(context, "io.fabric.ApiKey", "string");
if (a == 0) {
Fabric.g().d("Fabric", "Falling back to Crashlytics key lookup from Strings");
a = CommonUtils.a(context, "com.crashlytics.ApiKey", "string");
}
if (a != 0) {
return context.getResources().getString(a);
}
return null;
}
public String c(Context context) {
String a = a(context);
if (TextUtils.isEmpty(a)) {
a = b(context);
}
if (TextUtils.isEmpty(a)) {
d(context);
}
return a;
}
protected void d(Context context) {
if (Fabric.i() || CommonUtils.e(context)) {
throw new IllegalArgumentException(a());
}
Fabric.g().e("Fabric", a());
}
}

View File

@@ -0,0 +1,14 @@
package io.fabric.sdk.android.services.common;
import android.os.Process;
/* loaded from: classes2.dex */
public abstract class BackgroundPriorityRunnable implements Runnable {
protected abstract void a();
@Override // java.lang.Runnable
public final void run() {
Process.setThreadPriority(10);
a();
}
}

View File

@@ -0,0 +1,264 @@
package io.fabric.sdk.android.services.common;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import com.ijm.dataencryption.de.DataDecryptTool;
import io.fabric.sdk.android.Fabric;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Locale;
import java.util.Scanner;
/* loaded from: classes2.dex */
public class CommonUtils {
private static Boolean a;
private static final char[] b = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
static {
new Comparator<File>() { // from class: io.fabric.sdk.android.services.common.CommonUtils.1
@Override // java.util.Comparator
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public int compare(File file, File file2) {
return (int) (file.lastModified() - file2.lastModified());
}
};
}
public static String a(InputStream inputStream) {
return a(inputStream, "SHA-1");
}
public static String b(InputStream inputStream) throws IOException {
Scanner useDelimiter = new Scanner(inputStream).useDelimiter("\\A");
return useDelimiter.hasNext() ? useDelimiter.next() : "";
}
public static String c(Context context) {
int i = context.getApplicationContext().getApplicationInfo().icon;
return i > 0 ? context.getResources().getResourcePackageName(i) : context.getPackageName();
}
public static SharedPreferences d(Context context) {
return context.getSharedPreferences("com.crashlytics.prefs", 0);
}
public static boolean e(Context context) {
return (context.getApplicationInfo().flags & 2) != 0;
}
public static boolean f(Context context) {
if (a == null) {
a = Boolean.valueOf(a(context, "com.crashlytics.Trace", false));
}
return a.booleanValue();
}
public static String g(Context context) {
int a2 = a(context, "io.fabric.android.build_id", "string");
if (a2 == 0) {
a2 = a(context, "com.crashlytics.android.build_id", "string");
}
if (a2 == 0) {
return null;
}
String string = context.getResources().getString(a2);
Fabric.g().d("Fabric", "Build ID is: " + string);
return string;
}
private static String a(InputStream inputStream, String str) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
byte[] bArr = new byte[DataDecryptTool.DECRYPT_SP_FILE];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
return a(messageDigest.digest());
}
messageDigest.update(bArr, 0, read);
}
} catch (Exception e) {
Fabric.g().b("Fabric", "Could not calculate hash for app icon.", e);
return "";
}
}
public static String b(String str) {
return a(str, "SHA-1");
}
public static void b(Context context, String str) {
if (f(context)) {
Fabric.g().d("Fabric", str);
}
}
public static int b(Context context) {
return context.getApplicationContext().getApplicationInfo().icon;
}
private static String a(byte[] bArr, String str) {
try {
MessageDigest messageDigest = MessageDigest.getInstance(str);
messageDigest.update(bArr);
return a(messageDigest.digest());
} catch (NoSuchAlgorithmException e) {
Fabric.g().b("Fabric", "Could not create hashing algorithm: " + str + ", returning empty string.", e);
return "";
}
}
private static String a(String str, String str2) {
return a(str.getBytes(), str2);
}
public static String a(String... strArr) {
if (strArr == null || strArr.length == 0) {
return null;
}
ArrayList arrayList = new ArrayList();
for (String str : strArr) {
if (str != null) {
arrayList.add(str.replace("-", "").toLowerCase(Locale.US));
}
}
Collections.sort(arrayList);
StringBuilder sb = new StringBuilder();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
sb.append((String) it.next());
}
String sb2 = sb.toString();
if (sb2.length() > 0) {
return b(sb2);
}
return null;
}
public static void a(Context context, String str, Throwable th) {
if (f(context)) {
Fabric.g().e("Fabric", str);
}
}
public static void a(Context context, int i, String str, String str2) {
if (f(context)) {
Fabric.g().a(i, "Fabric", str2);
}
}
public static boolean a(Context context, String str, boolean z) {
Resources resources;
if (context != null && (resources = context.getResources()) != null) {
int a2 = a(context, str, "bool");
if (a2 > 0) {
return resources.getBoolean(a2);
}
int a3 = a(context, str, "string");
if (a3 > 0) {
return Boolean.parseBoolean(context.getString(a3));
}
}
return z;
}
public static int a(Context context, String str, String str2) {
return context.getResources().getIdentifier(str, str2, c(context));
}
public static String a(byte[] bArr) {
char[] cArr = new char[bArr.length * 2];
for (int i = 0; i < bArr.length; i++) {
int i2 = bArr[i] & 255;
int i3 = i * 2;
char[] cArr2 = b;
cArr[i3] = cArr2[i2 >>> 4];
cArr[i3 + 1] = cArr2[i2 & 15];
}
return new String(cArr);
}
public static String a(Context context, String str) {
int a2 = a(context, str, "string");
return a2 > 0 ? context.getString(a2) : "";
}
public static void a(Closeable closeable, String str) {
if (closeable != null) {
try {
closeable.close();
} catch (IOException e) {
Fabric.g().b("Fabric", str, e);
}
}
}
public static boolean a(String str) {
return str == null || str.length() == 0;
}
public static void a(InputStream inputStream, OutputStream outputStream, byte[] bArr) throws IOException {
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
return;
} else {
outputStream.write(bArr, 0, read);
}
}
}
public static String a(Context context) {
Throwable th;
InputStream inputStream;
try {
inputStream = context.getResources().openRawResource(b(context));
} catch (Exception e) {
e = e;
inputStream = null;
} catch (Throwable th2) {
th = th2;
inputStream = null;
a((Closeable) inputStream, "Failed to close icon input stream.");
throw th;
}
try {
try {
String a2 = a(inputStream);
String str = a(a2) ? null : a2;
a((Closeable) inputStream, "Failed to close icon input stream.");
return str;
} catch (Throwable th3) {
th = th3;
a((Closeable) inputStream, "Failed to close icon input stream.");
throw th;
}
} catch (Exception e2) {
e = e2;
Fabric.g().b("Fabric", "Could not calculate hash for app icon.", e);
a((Closeable) inputStream, "Failed to close icon input stream.");
return null;
}
}
public static void a(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception unused) {
}
}
}
}

View File

@@ -0,0 +1,6 @@
package io.fabric.sdk.android.services.common;
/* loaded from: classes2.dex */
public interface CurrentTimeProvider {
long a();
}

View File

@@ -0,0 +1,29 @@
package io.fabric.sdk.android.services.common;
/* loaded from: classes2.dex */
public enum DeliveryMechanism {
DEVELOPER(1),
USER_SIDELOAD(2),
TEST_DISTRIBUTION(3),
APP_STORE(4);
public static final String BETA_APP_PACKAGE_NAME = "io.crash.air";
private final int id;
DeliveryMechanism(int i) {
this.id = i;
}
public static DeliveryMechanism determineFrom(String str) {
return BETA_APP_PACKAGE_NAME.equals(str) ? TEST_DISTRIBUTION : str != null ? APP_STORE : DEVELOPER;
}
public int getId() {
return this.id;
}
@Override // java.lang.Enum
public String toString() {
return Integer.toString(this.id);
}
}

View File

@@ -0,0 +1,60 @@
package io.fabric.sdk.android.services.common;
import io.fabric.sdk.android.Fabric;
import java.util.Locale;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
/* loaded from: classes2.dex */
public final class ExecutorUtils {
public static ScheduledExecutorService a(String str) {
ScheduledExecutorService newSingleThreadScheduledExecutor = Executors.newSingleThreadScheduledExecutor(b(str));
a(str, newSingleThreadScheduledExecutor);
return newSingleThreadScheduledExecutor;
}
public static final ThreadFactory b(final String str) {
final AtomicLong atomicLong = new AtomicLong(1L);
return new ThreadFactory() { // from class: io.fabric.sdk.android.services.common.ExecutorUtils.1
@Override // java.util.concurrent.ThreadFactory
public Thread newThread(final Runnable runnable) {
Thread newThread = Executors.defaultThreadFactory().newThread(new BackgroundPriorityRunnable(this) { // from class: io.fabric.sdk.android.services.common.ExecutorUtils.1.1
@Override // io.fabric.sdk.android.services.common.BackgroundPriorityRunnable
public void a() {
runnable.run();
}
});
newThread.setName(str + atomicLong.getAndIncrement());
return newThread;
}
};
}
private static final void a(String str, ExecutorService executorService) {
a(str, executorService, 2L, TimeUnit.SECONDS);
}
public static final void a(final String str, final ExecutorService executorService, final long j, final TimeUnit timeUnit) {
Runtime.getRuntime().addShutdownHook(new Thread(new BackgroundPriorityRunnable() { // from class: io.fabric.sdk.android.services.common.ExecutorUtils.2
@Override // io.fabric.sdk.android.services.common.BackgroundPriorityRunnable
public void a() {
try {
Fabric.g().d("Fabric", "Executing shutdown hook for " + str);
executorService.shutdown();
if (executorService.awaitTermination(j, timeUnit)) {
return;
}
Fabric.g().d("Fabric", str + " did not shut down in the allocated time. Requesting immediate shutdown.");
executorService.shutdownNow();
} catch (InterruptedException unused) {
Fabric.g().d("Fabric", String.format(Locale.US, "Interrupted while waiting for %s to shut down. Requesting immediate shutdown.", str));
executorService.shutdownNow();
}
}
}, "Crashlytics Shutdown Hook for " + str));
}
}

View File

@@ -0,0 +1,165 @@
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<Kit> 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;
}
}

View File

@@ -0,0 +1,31 @@
package io.fabric.sdk.android.services.common;
import android.content.Context;
import io.fabric.sdk.android.Fabric;
import io.fabric.sdk.android.services.cache.MemoryValueCache;
import io.fabric.sdk.android.services.cache.ValueLoader;
/* loaded from: classes2.dex */
public class InstallerPackageNameProvider {
private final ValueLoader<String> a = new ValueLoader<String>(this) { // from class: io.fabric.sdk.android.services.common.InstallerPackageNameProvider.1
@Override // io.fabric.sdk.android.services.cache.ValueLoader
public String a(Context context) throws Exception {
String installerPackageName = context.getPackageManager().getInstallerPackageName(context.getPackageName());
return installerPackageName == null ? "" : installerPackageName;
}
};
private final MemoryValueCache<String> b = new MemoryValueCache<>();
public String a(Context context) {
try {
String a = this.b.a(context, this.a);
if ("".equals(a)) {
return null;
}
return a;
} catch (Exception e) {
Fabric.g().b("Fabric", "Failed to determine installer package name", e);
return null;
}
}
}

View File

@@ -0,0 +1,349 @@
package io.fabric.sdk.android.services.common;
import com.ubt.jimu.base.util.FileUtil;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.util.logging.Level;
import java.util.logging.Logger;
/* loaded from: classes2.dex */
public class QueueFile implements Closeable {
private static final Logger g = Logger.getLogger(QueueFile.class.getName());
private final RandomAccessFile a;
int b;
private int c;
private Element d;
private Element e;
private final byte[] f = new byte[16];
static class Element {
static final Element c = new Element(0, 0);
final int a;
final int b;
Element(int i, int i2) {
this.a = i;
this.b = i2;
}
public String toString() {
return Element.class.getSimpleName() + "[position = " + this.a + ", length = " + this.b + "]";
}
}
private final class ElementInputStream extends InputStream {
private int a;
private int b;
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
QueueFile.a(bArr, "buffer");
if ((i | i2) < 0 || i2 > bArr.length - i) {
throw new ArrayIndexOutOfBoundsException();
}
int i3 = this.b;
if (i3 <= 0) {
return -1;
}
if (i2 > i3) {
i2 = i3;
}
QueueFile.this.a(this.a, bArr, i, i2);
this.a = QueueFile.this.d(this.a + i2);
this.b -= i2;
return i2;
}
private ElementInputStream(Element element) {
this.a = QueueFile.this.d(element.a + 4);
this.b = element.b;
}
@Override // java.io.InputStream
public int read() throws IOException {
if (this.b == 0) {
return -1;
}
QueueFile.this.a.seek(this.a);
int read = QueueFile.this.a.read();
this.a = QueueFile.this.d(this.a + 1);
this.b--;
return read;
}
}
public interface ElementReader {
void a(InputStream inputStream, int i) throws IOException;
}
public QueueFile(File file) throws IOException {
if (!file.exists()) {
a(file);
}
this.a = b(file);
c();
}
private static void b(byte[] bArr, int i, int i2) {
bArr[i] = (byte) (i2 >> 24);
bArr[i + 1] = (byte) (i2 >> 16);
bArr[i + 2] = (byte) (i2 >> 8);
bArr[i + 3] = (byte) i2;
}
private void c() throws IOException {
this.a.seek(0L);
this.a.readFully(this.f);
this.b = a(this.f, 0);
if (this.b <= this.a.length()) {
this.c = a(this.f, 4);
int a = a(this.f, 8);
int a2 = a(this.f, 12);
this.d = b(a);
this.e = b(a2);
return;
}
throw new IOException("File is truncated. Expected length: " + this.b + ", Actual length: " + this.a.length());
}
/* JADX INFO: Access modifiers changed from: private */
public int d(int i) {
int i2 = this.b;
return i < i2 ? i : (i + 16) - i2;
}
@Override // java.io.Closeable, java.lang.AutoCloseable
public synchronized void close() throws IOException {
this.a.close();
}
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append(QueueFile.class.getSimpleName());
sb.append('[');
sb.append("fileLength=");
sb.append(this.b);
sb.append(", size=");
sb.append(this.c);
sb.append(", first=");
sb.append(this.d);
sb.append(", last=");
sb.append(this.e);
sb.append(", element lengths=[");
try {
a(new ElementReader(this) { // from class: io.fabric.sdk.android.services.common.QueueFile.1
boolean a = true;
@Override // io.fabric.sdk.android.services.common.QueueFile.ElementReader
public void a(InputStream inputStream, int i) throws IOException {
if (this.a) {
this.a = false;
} else {
sb.append(", ");
}
sb.append(i);
}
});
} catch (IOException e) {
g.log(Level.WARNING, "read error", (Throwable) e);
}
sb.append("]]");
return sb.toString();
}
static /* synthetic */ Object a(Object obj, String str) {
b(obj, str);
return obj;
}
private int d() {
return this.b - b();
}
private static void a(byte[] bArr, int... iArr) {
int i = 0;
for (int i2 : iArr) {
b(bArr, i, i2);
i += 4;
}
}
private Element b(int i) throws IOException {
if (i == 0) {
return Element.c;
}
this.a.seek(i);
return new Element(i, this.a.readInt());
}
private static int a(byte[] bArr, int i) {
return ((bArr[i] & 255) << 24) + ((bArr[i + 1] & 255) << 16) + ((bArr[i + 2] & 255) << 8) + (bArr[i + 3] & 255);
}
private void a(int i, int i2, int i3, int i4) throws IOException {
a(this.f, i, i2, i3, i4);
this.a.seek(0L);
this.a.write(this.f);
}
private static RandomAccessFile b(File file) throws FileNotFoundException {
return new RandomAccessFile(file, "rwd");
}
private void b(int i, byte[] bArr, int i2, int i3) throws IOException {
int d = d(i);
int i4 = d + i3;
int i5 = this.b;
if (i4 <= i5) {
this.a.seek(d);
this.a.write(bArr, i2, i3);
return;
}
int i6 = i5 - d;
this.a.seek(d);
this.a.write(bArr, i2, i6);
this.a.seek(16L);
this.a.write(bArr, i2 + i6, i3 - i6);
}
private static void a(File file) throws IOException {
File file2 = new File(file.getPath() + ".tmp");
RandomAccessFile b = b(file2);
try {
b.setLength(4096L);
b.seek(0L);
byte[] bArr = new byte[16];
a(bArr, FileUtil.ZIP_BUFFER_SIZE, 0, 0, 0);
b.write(bArr);
b.close();
if (!file2.renameTo(file)) {
throw new IOException("Rename failed!");
}
} catch (Throwable th) {
b.close();
throw th;
}
}
private void c(int i) throws IOException {
this.a.setLength(i);
this.a.getChannel().force(true);
}
public int b() {
if (this.c == 0) {
return 16;
}
Element element = this.e;
int i = element.a;
int i2 = this.d.a;
if (i >= i2) {
return (i - i2) + 4 + element.b + 16;
}
return (((i + 4) + element.b) + this.b) - i2;
}
/* JADX INFO: Access modifiers changed from: private */
public void a(int i, byte[] bArr, int i2, int i3) throws IOException {
int d = d(i);
int i4 = d + i3;
int i5 = this.b;
if (i4 <= i5) {
this.a.seek(d);
this.a.readFully(bArr, i2, i3);
return;
}
int i6 = i5 - d;
this.a.seek(d);
this.a.readFully(bArr, i2, i6);
this.a.seek(16L);
this.a.readFully(bArr, i2 + i6, i3 - i6);
}
private static <T> T b(T t, String str) {
if (t != null) {
return t;
}
throw new NullPointerException(str);
}
public void a(byte[] bArr) throws IOException {
a(bArr, 0, bArr.length);
}
public synchronized void a(byte[] bArr, int i, int i2) throws IOException {
b(bArr, "buffer");
if ((i | i2) >= 0 && i2 <= bArr.length - i) {
a(i2);
boolean a = a();
Element element = new Element(a ? 16 : d(this.e.a + 4 + this.e.b), i2);
b(this.f, 0, i2);
b(element.a, this.f, 0, 4);
b(element.a + 4, bArr, i, i2);
a(this.b, this.c + 1, a ? element.a : this.d.a, element.a);
this.e = element;
this.c++;
if (a) {
this.d = this.e;
}
} else {
throw new IndexOutOfBoundsException();
}
}
public synchronized boolean a() {
return this.c == 0;
}
private void a(int i) throws IOException {
int i2 = i + 4;
int d = d();
if (d >= i2) {
return;
}
int i3 = this.b;
do {
d += i3;
i3 <<= 1;
} while (d < i2);
c(i3);
Element element = this.e;
int d2 = d(element.a + 4 + element.b);
if (d2 < this.d.a) {
FileChannel channel = this.a.getChannel();
channel.position(this.b);
long j = d2 - 4;
if (channel.transferTo(16L, j, channel) != j) {
throw new AssertionError("Copied insufficient number of bytes!");
}
}
int i4 = this.e.a;
int i5 = this.d.a;
if (i4 < i5) {
int i6 = (this.b + i4) - 16;
a(i3, this.c, i5, i6);
this.e = new Element(i6, this.e.b);
} else {
a(i3, this.c, i5, i4);
}
this.b = i3;
}
public synchronized void a(ElementReader elementReader) throws IOException {
int i = this.d.a;
for (int i2 = 0; i2 < this.c; i2++) {
Element b = b(i);
elementReader.a(new ElementInputStream(b), b.b);
i = d(b.a + 4 + b.b);
}
}
public boolean a(int i, int i2) {
return (b() + 4) + i <= i2;
}
}

View File

@@ -0,0 +1,19 @@
package io.fabric.sdk.android.services.common;
/* loaded from: classes2.dex */
public class ResponseParser {
public static int a(int i) {
if (i >= 200 && i <= 299) {
return 0;
}
if (i >= 300 && i <= 399) {
return 1;
}
if (i >= 400 && i <= 499) {
return 0;
}
if (i >= 500) {
}
return 1;
}
}

View File

@@ -0,0 +1,9 @@
package io.fabric.sdk.android.services.common;
/* loaded from: classes2.dex */
public class SystemCurrentTimeProvider implements CurrentTimeProvider {
@Override // io.fabric.sdk.android.services.common.CurrentTimeProvider
public long a() {
return System.currentTimeMillis();
}
}

View File

@@ -0,0 +1,42 @@
package io.fabric.sdk.android.services.common;
import android.os.SystemClock;
import android.util.Log;
/* loaded from: classes2.dex */
public class TimingMetric {
private final String a;
private final String b;
private final boolean c;
private long d;
private long e;
public TimingMetric(String str, String str2) {
this.a = str;
this.b = str2;
this.c = !Log.isLoggable(str2, 2);
}
private void c() {
Log.v(this.b, this.a + ": " + this.e + "ms");
}
public synchronized void a() {
if (this.c) {
return;
}
this.d = SystemClock.elapsedRealtime();
this.e = 0L;
}
public synchronized void b() {
if (this.c) {
return;
}
if (this.e != 0) {
return;
}
this.e = SystemClock.elapsedRealtime() - this.d;
c();
}
}