Initial commit
This commit is contained in:
34
sources/io/fabric/sdk/android/services/cache/AbstractValueCache.java
vendored
Normal file
34
sources/io/fabric/sdk/android/services/cache/AbstractValueCache.java
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package io.fabric.sdk.android.services.cache;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class AbstractValueCache<T> implements ValueCache<T> {
|
||||
private final ValueCache<T> a;
|
||||
|
||||
public AbstractValueCache(ValueCache<T> valueCache) {
|
||||
this.a = valueCache;
|
||||
}
|
||||
|
||||
private void b(Context context, T t) {
|
||||
if (t == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
a(context, (Context) t);
|
||||
}
|
||||
|
||||
protected abstract T a(Context context);
|
||||
|
||||
@Override // io.fabric.sdk.android.services.cache.ValueCache
|
||||
public final synchronized T a(Context context, ValueLoader<T> valueLoader) throws Exception {
|
||||
T a;
|
||||
a = a(context);
|
||||
if (a == null) {
|
||||
a = this.a != null ? this.a.a(context, valueLoader) : valueLoader.a(context);
|
||||
b(context, a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
protected abstract void a(Context context, T t);
|
||||
}
|
26
sources/io/fabric/sdk/android/services/cache/MemoryValueCache.java
vendored
Normal file
26
sources/io/fabric/sdk/android/services/cache/MemoryValueCache.java
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
package io.fabric.sdk.android.services.cache;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class MemoryValueCache<T> extends AbstractValueCache<T> {
|
||||
private T b;
|
||||
|
||||
public MemoryValueCache() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.cache.AbstractValueCache
|
||||
protected T a(Context context) {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public MemoryValueCache(ValueCache<T> valueCache) {
|
||||
super(valueCache);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.cache.AbstractValueCache
|
||||
protected void a(Context context, T t) {
|
||||
this.b = t;
|
||||
}
|
||||
}
|
8
sources/io/fabric/sdk/android/services/cache/ValueCache.java
vendored
Normal file
8
sources/io/fabric/sdk/android/services/cache/ValueCache.java
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.cache;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface ValueCache<T> {
|
||||
T a(Context context, ValueLoader<T> valueLoader) throws Exception;
|
||||
}
|
8
sources/io/fabric/sdk/android/services/cache/ValueLoader.java
vendored
Normal file
8
sources/io/fabric/sdk/android/services/cache/ValueLoader.java
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.cache;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface ValueLoader<T> {
|
||||
T a(Context context) throws Exception;
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package io.fabric.sdk.android.services.common;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface AdvertisingInfoStrategy {
|
||||
AdvertisingInfo a();
|
||||
}
|
62
sources/io/fabric/sdk/android/services/common/ApiKey.java
Normal file
62
sources/io/fabric/sdk/android/services/common/ApiKey.java
Normal 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());
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
264
sources/io/fabric/sdk/android/services/common/CommonUtils.java
Normal file
264
sources/io/fabric/sdk/android/services/common/CommonUtils.java
Normal 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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package io.fabric.sdk.android.services.common;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface CurrentTimeProvider {
|
||||
long a();
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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));
|
||||
}
|
||||
}
|
165
sources/io/fabric/sdk/android/services/common/IdManager.java
Normal file
165
sources/io/fabric/sdk/android/services/common/IdManager.java
Normal 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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
349
sources/io/fabric/sdk/android/services/common/QueueFile.java
Normal file
349
sources/io/fabric/sdk/android/services/common/QueueFile.java
Normal 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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,242 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.util.Log;
|
||||
import com.ubtrobot.jimu.robotapi.PeripheralType;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class AsyncTask<Params, Progress, Result> {
|
||||
private static final int f = Runtime.getRuntime().availableProcessors();
|
||||
private static final int g;
|
||||
private static final int h;
|
||||
private static final ThreadFactory i;
|
||||
private static final BlockingQueue<Runnable> j;
|
||||
public static final Executor k;
|
||||
public static final Executor l;
|
||||
private static final InternalHandler m;
|
||||
private volatile Status c = Status.PENDING;
|
||||
private final AtomicBoolean d = new AtomicBoolean();
|
||||
private final AtomicBoolean e = new AtomicBoolean();
|
||||
private final WorkerRunnable<Params, Result> a = new WorkerRunnable<Params, Result>() { // from class: io.fabric.sdk.android.services.concurrency.AsyncTask.2
|
||||
@Override // java.util.concurrent.Callable
|
||||
public Result call() throws Exception {
|
||||
AsyncTask.this.e.set(true);
|
||||
Process.setThreadPriority(10);
|
||||
AsyncTask asyncTask = AsyncTask.this;
|
||||
Result result = (Result) asyncTask.a(this.a);
|
||||
AsyncTask.a(asyncTask, result);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
private final FutureTask<Result> b = new FutureTask<Result>(this.a) { // from class: io.fabric.sdk.android.services.concurrency.AsyncTask.3
|
||||
@Override // java.util.concurrent.FutureTask
|
||||
protected void done() {
|
||||
try {
|
||||
AsyncTask.this.f(get());
|
||||
} catch (InterruptedException e) {
|
||||
Log.w("AsyncTask", e);
|
||||
} catch (CancellationException unused) {
|
||||
AsyncTask.this.f(null);
|
||||
} catch (ExecutionException e2) {
|
||||
throw new RuntimeException("An error occured while executing doInBackground()", e2.getCause());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* renamed from: io.fabric.sdk.android.services.concurrency.AsyncTask$4, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass4 {
|
||||
static final /* synthetic */ int[] a = new int[Status.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[Status.RUNNING.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[Status.FINISHED.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class AsyncTaskResult<Data> {
|
||||
final AsyncTask a;
|
||||
final Data[] b;
|
||||
|
||||
AsyncTaskResult(AsyncTask asyncTask, Data... dataArr) {
|
||||
this.a = asyncTask;
|
||||
this.b = dataArr;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InternalHandler extends Handler {
|
||||
public InternalHandler() {
|
||||
super(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
AsyncTaskResult asyncTaskResult = (AsyncTaskResult) message.obj;
|
||||
int i = message.what;
|
||||
if (i == 1) {
|
||||
asyncTaskResult.a.d(asyncTaskResult.b[0]);
|
||||
} else {
|
||||
if (i != 2) {
|
||||
return;
|
||||
}
|
||||
asyncTaskResult.a.b((Object[]) asyncTaskResult.b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SerialExecutor implements Executor {
|
||||
final LinkedList<Runnable> a;
|
||||
Runnable b;
|
||||
|
||||
private SerialExecutor() {
|
||||
this.a = new LinkedList<>();
|
||||
}
|
||||
|
||||
protected synchronized void a() {
|
||||
Runnable poll = this.a.poll();
|
||||
this.b = poll;
|
||||
if (poll != null) {
|
||||
AsyncTask.k.execute(this.b);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Executor
|
||||
public synchronized void execute(final Runnable runnable) {
|
||||
this.a.offer(new Runnable() { // from class: io.fabric.sdk.android.services.concurrency.AsyncTask.SerialExecutor.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
runnable.run();
|
||||
} finally {
|
||||
SerialExecutor.this.a();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (this.b == null) {
|
||||
a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
PENDING,
|
||||
RUNNING,
|
||||
FINISHED
|
||||
}
|
||||
|
||||
private static abstract class WorkerRunnable<Params, Result> implements Callable<Result> {
|
||||
Params[] a;
|
||||
|
||||
private WorkerRunnable() {
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
int i2 = f;
|
||||
g = i2 + 1;
|
||||
h = (i2 * 2) + 1;
|
||||
i = new ThreadFactory() { // from class: io.fabric.sdk.android.services.concurrency.AsyncTask.1
|
||||
private final AtomicInteger a = new AtomicInteger(1);
|
||||
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public Thread newThread(Runnable runnable) {
|
||||
return new Thread(runnable, "AsyncTask #" + this.a.getAndIncrement());
|
||||
}
|
||||
};
|
||||
j = new LinkedBlockingQueue(PeripheralType.SERVO);
|
||||
k = new ThreadPoolExecutor(g, h, 1L, TimeUnit.SECONDS, j, i);
|
||||
l = new SerialExecutor();
|
||||
m = new InternalHandler();
|
||||
}
|
||||
|
||||
private Result e(Result result) {
|
||||
m.obtainMessage(1, new AsyncTaskResult(this, result)).sendToTarget();
|
||||
return result;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void f(Result result) {
|
||||
if (this.e.get()) {
|
||||
return;
|
||||
}
|
||||
e(result);
|
||||
}
|
||||
|
||||
protected abstract Result a(Params... paramsArr);
|
||||
|
||||
protected abstract void b(Result result);
|
||||
|
||||
protected void b(Progress... progressArr) {
|
||||
}
|
||||
|
||||
protected abstract void c(Result result);
|
||||
|
||||
public final Status d() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
protected void f() {
|
||||
}
|
||||
|
||||
static /* synthetic */ Object a(AsyncTask asyncTask, Object obj) {
|
||||
asyncTask.e(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void d(Result result) {
|
||||
if (e()) {
|
||||
b((AsyncTask<Params, Progress, Result>) result);
|
||||
} else {
|
||||
c(result);
|
||||
}
|
||||
this.c = Status.FINISHED;
|
||||
}
|
||||
|
||||
public final boolean b(boolean z) {
|
||||
this.d.set(true);
|
||||
return this.b.cancel(z);
|
||||
}
|
||||
|
||||
public final AsyncTask<Params, Progress, Result> a(Executor executor, Params... paramsArr) {
|
||||
if (this.c != Status.PENDING) {
|
||||
int i2 = AnonymousClass4.a[this.c.ordinal()];
|
||||
if (i2 == 1) {
|
||||
throw new IllegalStateException("Cannot execute task: the task is already running.");
|
||||
}
|
||||
if (i2 == 2) {
|
||||
throw new IllegalStateException("Cannot execute task: the task has already been executed (a task can be executed only once)");
|
||||
}
|
||||
}
|
||||
this.c = Status.RUNNING;
|
||||
f();
|
||||
this.a.a = paramsArr;
|
||||
executor.execute(this.b);
|
||||
return this;
|
||||
}
|
||||
|
||||
public final boolean e() {
|
||||
return this.d.get();
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface DelegateProvider {
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Dependency<T> {
|
||||
void a(T t);
|
||||
|
||||
boolean c();
|
||||
}
|
@@ -0,0 +1,236 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import io.fabric.sdk.android.services.concurrency.Dependency;
|
||||
import io.fabric.sdk.android.services.concurrency.PriorityProvider;
|
||||
import io.fabric.sdk.android.services.concurrency.Task;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DependencyPriorityBlockingQueue<E extends Dependency & Task & PriorityProvider> extends PriorityBlockingQueue<E> {
|
||||
static final int PEEK = 1;
|
||||
static final int POLL = 2;
|
||||
static final int POLL_WITH_TIMEOUT = 3;
|
||||
static final int TAKE = 0;
|
||||
final Queue<E> blockedQueue = new LinkedList();
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
boolean canProcess(E e) {
|
||||
return e.c();
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractQueue, java.util.AbstractCollection, java.util.Collection
|
||||
public void clear() {
|
||||
try {
|
||||
this.lock.lock();
|
||||
this.blockedQueue.clear();
|
||||
super.clear();
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
<T> T[] concatenate(T[] tArr, T[] tArr2) {
|
||||
int length = tArr.length;
|
||||
int length2 = tArr2.length;
|
||||
T[] tArr3 = (T[]) ((Object[]) Array.newInstance(tArr.getClass().getComponentType(), length + length2));
|
||||
System.arraycopy(tArr, 0, tArr3, 0, length);
|
||||
System.arraycopy(tArr2, 0, tArr3, length, length2);
|
||||
return tArr3;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractCollection, java.util.Collection, java.util.concurrent.BlockingQueue
|
||||
public boolean contains(Object obj) {
|
||||
boolean z;
|
||||
try {
|
||||
this.lock.lock();
|
||||
if (!super.contains(obj)) {
|
||||
if (!this.blockedQueue.contains(obj)) {
|
||||
z = false;
|
||||
return z;
|
||||
}
|
||||
}
|
||||
z = true;
|
||||
return z;
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.concurrent.BlockingQueue
|
||||
public int drainTo(Collection<? super E> collection) {
|
||||
try {
|
||||
this.lock.lock();
|
||||
int drainTo = super.drainTo(collection) + this.blockedQueue.size();
|
||||
while (!this.blockedQueue.isEmpty()) {
|
||||
collection.add(this.blockedQueue.poll());
|
||||
}
|
||||
return drainTo;
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
E get(int i, Long l, TimeUnit timeUnit) throws InterruptedException {
|
||||
E performOperation;
|
||||
while (true) {
|
||||
performOperation = performOperation(i, l, timeUnit);
|
||||
if (performOperation == null || canProcess(performOperation)) {
|
||||
break;
|
||||
}
|
||||
offerBlockedResult(i, performOperation);
|
||||
}
|
||||
return performOperation;
|
||||
}
|
||||
|
||||
boolean offerBlockedResult(int i, E e) {
|
||||
try {
|
||||
this.lock.lock();
|
||||
if (i == 1) {
|
||||
super.remove(e);
|
||||
}
|
||||
return this.blockedQueue.offer(e);
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
E performOperation(int i, Long l, TimeUnit timeUnit) throws InterruptedException {
|
||||
if (i == 0) {
|
||||
return (E) ((Dependency) super.take());
|
||||
}
|
||||
if (i == 1) {
|
||||
return (E) ((Dependency) super.peek());
|
||||
}
|
||||
if (i == 2) {
|
||||
return (E) ((Dependency) super.poll());
|
||||
}
|
||||
if (i != 3) {
|
||||
return null;
|
||||
}
|
||||
return (E) ((Dependency) super.poll(l.longValue(), timeUnit));
|
||||
}
|
||||
|
||||
public void recycleBlockedQueue() {
|
||||
try {
|
||||
this.lock.lock();
|
||||
Iterator<E> it = this.blockedQueue.iterator();
|
||||
while (it.hasNext()) {
|
||||
E next = it.next();
|
||||
if (canProcess(next)) {
|
||||
super.offer(next);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractCollection, java.util.Collection, java.util.concurrent.BlockingQueue
|
||||
public boolean remove(Object obj) {
|
||||
boolean z;
|
||||
try {
|
||||
this.lock.lock();
|
||||
if (!super.remove(obj)) {
|
||||
if (!this.blockedQueue.remove(obj)) {
|
||||
z = false;
|
||||
return z;
|
||||
}
|
||||
}
|
||||
z = true;
|
||||
return z;
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractCollection, java.util.Collection
|
||||
public boolean removeAll(Collection<?> collection) {
|
||||
try {
|
||||
this.lock.lock();
|
||||
return this.blockedQueue.removeAll(collection) | super.removeAll(collection);
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractCollection, java.util.Collection
|
||||
public int size() {
|
||||
try {
|
||||
this.lock.lock();
|
||||
return this.blockedQueue.size() + super.size();
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractCollection, java.util.Collection
|
||||
public <T> T[] toArray(T[] tArr) {
|
||||
try {
|
||||
this.lock.lock();
|
||||
return (T[]) concatenate(super.toArray(tArr), this.blockedQueue.toArray(tArr));
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.Queue
|
||||
public E peek() {
|
||||
try {
|
||||
return get(1, null, null);
|
||||
} catch (InterruptedException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.concurrent.BlockingQueue
|
||||
public E take() throws InterruptedException {
|
||||
return get(0, null, null);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.concurrent.BlockingQueue
|
||||
public E poll(long j, TimeUnit timeUnit) throws InterruptedException {
|
||||
return get(3, Long.valueOf(j), timeUnit);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.Queue
|
||||
public E poll() {
|
||||
try {
|
||||
return get(2, null, null);
|
||||
} catch (InterruptedException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.AbstractCollection, java.util.Collection
|
||||
public Object[] toArray() {
|
||||
try {
|
||||
this.lock.lock();
|
||||
return concatenate(super.toArray(), this.blockedQueue.toArray());
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.PriorityBlockingQueue, java.util.concurrent.BlockingQueue
|
||||
public int drainTo(Collection<? super E> collection, int i) {
|
||||
try {
|
||||
this.lock.lock();
|
||||
int drainTo = super.drainTo(collection, i);
|
||||
while (!this.blockedQueue.isEmpty() && drainTo <= i) {
|
||||
collection.add(this.blockedQueue.poll());
|
||||
drainTo++;
|
||||
}
|
||||
return drainTo;
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/* loaded from: classes2.dex */
|
||||
public @interface DependsOn {
|
||||
Class<?>[] value();
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum Priority {
|
||||
LOW,
|
||||
NORMAL,
|
||||
HIGH,
|
||||
IMMEDIATE;
|
||||
|
||||
static <Y> int compareTo(PriorityProvider priorityProvider, Y y) {
|
||||
return (y instanceof PriorityProvider ? ((PriorityProvider) y).a() : NORMAL).ordinal() - priorityProvider.a().ordinal();
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import io.fabric.sdk.android.services.concurrency.AsyncTask;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class PriorityAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> implements Dependency<Task>, PriorityProvider, Task, DelegateProvider {
|
||||
private final PriorityTask n = new PriorityTask();
|
||||
|
||||
private static class ProxyExecutor<Result> implements Executor {
|
||||
private final Executor a;
|
||||
private final PriorityAsyncTask b;
|
||||
|
||||
public ProxyExecutor(Executor executor, PriorityAsyncTask priorityAsyncTask) {
|
||||
this.a = executor;
|
||||
this.b = priorityAsyncTask;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Executor
|
||||
public void execute(Runnable runnable) {
|
||||
this.a.execute(new PriorityFutureTask<Result>(runnable, null) { // from class: io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.ProxyExecutor.1
|
||||
/* JADX WARN: Incorrect return type in method signature: <T::Lio/fabric/sdk/android/services/concurrency/Dependency<Lio/fabric/sdk/android/services/concurrency/Task;>;:Lio/fabric/sdk/android/services/concurrency/PriorityProvider;:Lio/fabric/sdk/android/services/concurrency/Task;>()TT; */
|
||||
@Override // io.fabric.sdk.android.services.concurrency.PriorityFutureTask
|
||||
public Dependency d() {
|
||||
return ProxyExecutor.this.b;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public boolean b() {
|
||||
return ((Task) ((PriorityProvider) g())).b();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Dependency
|
||||
public boolean c() {
|
||||
return ((Dependency) ((PriorityProvider) g())).c();
|
||||
}
|
||||
|
||||
@Override // java.lang.Comparable
|
||||
public int compareTo(Object obj) {
|
||||
return Priority.compareTo(this, obj);
|
||||
}
|
||||
|
||||
/* JADX WARN: Incorrect return type in method signature: <T::Lio/fabric/sdk/android/services/concurrency/Dependency<Lio/fabric/sdk/android/services/concurrency/Task;>;:Lio/fabric/sdk/android/services/concurrency/PriorityProvider;:Lio/fabric/sdk/android/services/concurrency/Task;>()TT; */
|
||||
public Dependency g() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
public final void a(ExecutorService executorService, Params... paramsArr) {
|
||||
super.a(new ProxyExecutor(executorService, this), paramsArr);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Dependency
|
||||
public void a(Task task) {
|
||||
if (d() == AsyncTask.Status.PENDING) {
|
||||
((Dependency) ((PriorityProvider) g())).a(task);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException("Must not add Dependency after task is running");
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public void a(boolean z) {
|
||||
((Task) ((PriorityProvider) g())).a(z);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public void a(Throwable th) {
|
||||
((Task) ((PriorityProvider) g())).a(th);
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PriorityFutureTask<V> extends FutureTask<V> implements Dependency<Task>, PriorityProvider, Task, DelegateProvider {
|
||||
final Object a;
|
||||
|
||||
public PriorityFutureTask(Callable<V> callable) {
|
||||
super(callable);
|
||||
this.a = b(callable);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public boolean b() {
|
||||
return ((Task) ((PriorityProvider) d())).b();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Dependency
|
||||
public boolean c() {
|
||||
return ((Dependency) ((PriorityProvider) d())).c();
|
||||
}
|
||||
|
||||
@Override // java.lang.Comparable
|
||||
public int compareTo(Object obj) {
|
||||
return ((PriorityProvider) d()).compareTo(obj);
|
||||
}
|
||||
|
||||
/* JADX WARN: Incorrect return type in method signature: <T::Lio/fabric/sdk/android/services/concurrency/Dependency<Lio/fabric/sdk/android/services/concurrency/Task;>;:Lio/fabric/sdk/android/services/concurrency/PriorityProvider;:Lio/fabric/sdk/android/services/concurrency/Task;>()TT; */
|
||||
public Dependency d() {
|
||||
return (Dependency) this.a;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Dependency
|
||||
public void a(Task task) {
|
||||
((Dependency) ((PriorityProvider) d())).a(task);
|
||||
}
|
||||
|
||||
/* JADX WARN: Incorrect return type in method signature: <T::Lio/fabric/sdk/android/services/concurrency/Dependency<Lio/fabric/sdk/android/services/concurrency/Task;>;:Lio/fabric/sdk/android/services/concurrency/PriorityProvider;:Lio/fabric/sdk/android/services/concurrency/Task;>(Ljava/lang/Object;)TT; */
|
||||
protected Dependency b(Object obj) {
|
||||
return PriorityTask.b(obj) ? (Dependency) obj : new PriorityTask();
|
||||
}
|
||||
|
||||
public PriorityFutureTask(Runnable runnable, V v) {
|
||||
super(runnable, v);
|
||||
this.a = b(runnable);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.PriorityProvider
|
||||
public Priority a() {
|
||||
return ((PriorityProvider) d()).a();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public void a(boolean z) {
|
||||
((Task) ((PriorityProvider) d())).a(z);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public void a(Throwable th) {
|
||||
((Task) ((PriorityProvider) d())).a(th);
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PriorityProvider<T> extends Comparable<T> {
|
||||
Priority a();
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PriorityTask implements Dependency<Task>, PriorityProvider, Task {
|
||||
private final List<Task> a = new ArrayList();
|
||||
private final AtomicBoolean b = new AtomicBoolean(false);
|
||||
private final AtomicReference<Throwable> c = new AtomicReference<>(null);
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public boolean b() {
|
||||
return this.b.get();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Dependency
|
||||
public boolean c() {
|
||||
Iterator<Task> it = d().iterator();
|
||||
while (it.hasNext()) {
|
||||
if (!it.next().b()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // java.lang.Comparable
|
||||
public int compareTo(Object obj) {
|
||||
return Priority.compareTo(this, obj);
|
||||
}
|
||||
|
||||
public synchronized Collection<Task> d() {
|
||||
return Collections.unmodifiableCollection(this.a);
|
||||
}
|
||||
|
||||
public static boolean b(Object obj) {
|
||||
try {
|
||||
return (((Dependency) obj) == null || ((Task) obj) == null || ((PriorityProvider) obj) == null) ? false : true;
|
||||
} catch (ClassCastException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Dependency
|
||||
public synchronized void a(Task task) {
|
||||
this.a.add(task);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public synchronized void a(boolean z) {
|
||||
this.b.set(z);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.PriorityProvider
|
||||
public Priority a() {
|
||||
return Priority.NORMAL;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.concurrency.Task
|
||||
public void a(Throwable th) {
|
||||
this.c.set(th);
|
||||
}
|
||||
}
|
@@ -0,0 +1,84 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.RunnableFuture;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PriorityThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
private static final int a = Runtime.getRuntime().availableProcessors();
|
||||
private static final int b;
|
||||
private static final int c;
|
||||
|
||||
protected static final class PriorityThreadFactory implements ThreadFactory {
|
||||
private final int a;
|
||||
|
||||
public PriorityThreadFactory(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public Thread newThread(Runnable runnable) {
|
||||
Thread thread = new Thread(runnable);
|
||||
thread.setPriority(this.a);
|
||||
thread.setName("Queue");
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
int i = a;
|
||||
b = i + 1;
|
||||
c = (i * 2) + 1;
|
||||
}
|
||||
|
||||
<T extends Runnable & Dependency & Task & PriorityProvider> PriorityThreadPoolExecutor(int i, int i2, long j, TimeUnit timeUnit, DependencyPriorityBlockingQueue<T> dependencyPriorityBlockingQueue, ThreadFactory threadFactory) {
|
||||
super(i, i2, j, timeUnit, dependencyPriorityBlockingQueue, threadFactory);
|
||||
prestartAllCoreThreads();
|
||||
}
|
||||
|
||||
public static <T extends Runnable & Dependency & Task & PriorityProvider> PriorityThreadPoolExecutor a(int i, int i2) {
|
||||
return new PriorityThreadPoolExecutor(i, i2, 1L, TimeUnit.SECONDS, new DependencyPriorityBlockingQueue(), new PriorityThreadFactory(10));
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadPoolExecutor
|
||||
protected void afterExecute(Runnable runnable, Throwable th) {
|
||||
Task task = (Task) runnable;
|
||||
task.a(true);
|
||||
task.a(th);
|
||||
getQueue().recycleBlockedQueue();
|
||||
super.afterExecute(runnable, th);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadPoolExecutor, java.util.concurrent.Executor
|
||||
@TargetApi(9)
|
||||
public void execute(Runnable runnable) {
|
||||
if (PriorityTask.b(runnable)) {
|
||||
super.execute(runnable);
|
||||
} else {
|
||||
super.execute(newTaskFor(runnable, null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.AbstractExecutorService
|
||||
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T t) {
|
||||
return new PriorityFutureTask(runnable, t);
|
||||
}
|
||||
|
||||
public static PriorityThreadPoolExecutor a() {
|
||||
return a(b, c);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadPoolExecutor
|
||||
public DependencyPriorityBlockingQueue getQueue() {
|
||||
return (DependencyPriorityBlockingQueue) super.getQueue();
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.AbstractExecutorService
|
||||
protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
|
||||
return new PriorityFutureTask(callable);
|
||||
}
|
||||
}
|
10
sources/io/fabric/sdk/android/services/concurrency/Task.java
Normal file
10
sources/io/fabric/sdk/android/services/concurrency/Task.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Task {
|
||||
void a(Throwable th);
|
||||
|
||||
void a(boolean z);
|
||||
|
||||
boolean b();
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package io.fabric.sdk.android.services.concurrency;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UnmetDependencyException extends RuntimeException {
|
||||
public UnmetDependencyException() {
|
||||
}
|
||||
|
||||
public UnmetDependencyException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public UnmetDependencyException(String str, Throwable th) {
|
||||
super(str, th);
|
||||
}
|
||||
|
||||
public UnmetDependencyException(Throwable th) {
|
||||
super(th);
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DisabledEventsStrategy<T> implements EventsStrategy<T> {
|
||||
@Override // io.fabric.sdk.android.services.events.EventsManager
|
||||
public void a(T t) {
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsManager
|
||||
public void b() {
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.FileRollOverManager
|
||||
public boolean c() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.FileRollOverManager
|
||||
public void d() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class EnabledEventsStrategy<T> implements EventsStrategy<T> {
|
||||
protected final Context a;
|
||||
protected final EventsFilesManager<T> b;
|
||||
final ScheduledExecutorService c;
|
||||
volatile int e = -1;
|
||||
final AtomicReference<ScheduledFuture<?>> d = new AtomicReference<>();
|
||||
|
||||
public EnabledEventsStrategy(Context context, ScheduledExecutorService scheduledExecutorService, EventsFilesManager<T> eventsFilesManager) {
|
||||
this.a = context;
|
||||
this.c = scheduledExecutorService;
|
||||
this.b = eventsFilesManager;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsManager
|
||||
public void a(T t) {
|
||||
CommonUtils.b(this.a, t.toString());
|
||||
try {
|
||||
this.b.a((EventsFilesManager<T>) t);
|
||||
} catch (IOException e) {
|
||||
CommonUtils.a(this.a, "Failed to write event.", e);
|
||||
}
|
||||
e();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsManager
|
||||
public void b() {
|
||||
f();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.FileRollOverManager
|
||||
public boolean c() {
|
||||
try {
|
||||
return this.b.f();
|
||||
} catch (IOException e) {
|
||||
CommonUtils.a(this.a, "Failed to roll file over.", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.FileRollOverManager
|
||||
public void d() {
|
||||
if (this.d.get() != null) {
|
||||
CommonUtils.b(this.a, "Cancelling time-based rollover because no events are currently being generated.");
|
||||
this.d.get().cancel(false);
|
||||
this.d.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void e() {
|
||||
if (this.e != -1) {
|
||||
a(this.e, this.e);
|
||||
}
|
||||
}
|
||||
|
||||
void f() {
|
||||
FilesSender a = a();
|
||||
if (a == null) {
|
||||
CommonUtils.b(this.a, "skipping files send because we don't yet know the target endpoint");
|
||||
return;
|
||||
}
|
||||
CommonUtils.b(this.a, "Sending all files");
|
||||
List<File> c = this.b.c();
|
||||
int i = 0;
|
||||
while (c.size() > 0) {
|
||||
try {
|
||||
CommonUtils.b(this.a, String.format(Locale.US, "attempt to send batch of %d files", Integer.valueOf(c.size())));
|
||||
boolean a2 = a.a(c);
|
||||
if (a2) {
|
||||
i += c.size();
|
||||
this.b.a(c);
|
||||
}
|
||||
if (!a2) {
|
||||
break;
|
||||
} else {
|
||||
c = this.b.c();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CommonUtils.a(this.a, "Failed to send batch of analytics files to server: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (i == 0) {
|
||||
this.b.a();
|
||||
}
|
||||
}
|
||||
|
||||
protected void a(int i) {
|
||||
this.e = i;
|
||||
a(0L, this.e);
|
||||
}
|
||||
|
||||
void a(long j, long j2) {
|
||||
if (this.d.get() == null) {
|
||||
TimeBasedFileRollOverRunnable timeBasedFileRollOverRunnable = new TimeBasedFileRollOverRunnable(this.a, this);
|
||||
CommonUtils.b(this.a, "Scheduling time based file roll over every " + j2 + " seconds");
|
||||
try {
|
||||
this.d.set(this.c.scheduleAtFixedRate(timeBasedFileRollOverRunnable, j, j2, TimeUnit.SECONDS));
|
||||
} catch (RejectedExecutionException e) {
|
||||
CommonUtils.a(this.a, "Failed to schedule time based file roll over", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface EventTransform<T> {
|
||||
byte[] a(T t) throws IOException;
|
||||
}
|
@@ -0,0 +1,149 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import io.fabric.sdk.android.services.common.CurrentTimeProvider;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class EventsFilesManager<T> {
|
||||
protected final Context a;
|
||||
protected final EventTransform<T> b;
|
||||
protected final CurrentTimeProvider c;
|
||||
protected final EventsStorage d;
|
||||
private final int e;
|
||||
protected final List<EventsStorageListener> f = new CopyOnWriteArrayList();
|
||||
|
||||
static class FileWithTimestamp {
|
||||
final File a;
|
||||
final long b;
|
||||
|
||||
public FileWithTimestamp(File file, long j) {
|
||||
this.a = file;
|
||||
this.b = j;
|
||||
}
|
||||
}
|
||||
|
||||
public EventsFilesManager(Context context, EventTransform<T> eventTransform, CurrentTimeProvider currentTimeProvider, EventsStorage eventsStorage, int i) throws IOException {
|
||||
this.a = context.getApplicationContext();
|
||||
this.b = eventTransform;
|
||||
this.d = eventsStorage;
|
||||
this.c = currentTimeProvider;
|
||||
this.c.a();
|
||||
this.e = i;
|
||||
}
|
||||
|
||||
private void b(String str) {
|
||||
Iterator<EventsStorageListener> it = this.f.iterator();
|
||||
while (it.hasNext()) {
|
||||
try {
|
||||
it.next().a(str);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.a(this.a, "One of the roll over listeners threw an exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(T t) throws IOException {
|
||||
byte[] a = this.b.a(t);
|
||||
a(a.length);
|
||||
this.d.a(a);
|
||||
}
|
||||
|
||||
protected abstract String b();
|
||||
|
||||
public List<File> c() {
|
||||
return this.d.a(1);
|
||||
}
|
||||
|
||||
protected int d() {
|
||||
return 8000;
|
||||
}
|
||||
|
||||
protected int e() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public boolean f() throws IOException {
|
||||
String str;
|
||||
boolean z = true;
|
||||
if (this.d.b()) {
|
||||
str = null;
|
||||
z = false;
|
||||
} else {
|
||||
str = b();
|
||||
this.d.a(str);
|
||||
CommonUtils.a(this.a, 4, "Fabric", String.format(Locale.US, "generated new file %s", str));
|
||||
this.c.a();
|
||||
}
|
||||
b(str);
|
||||
return z;
|
||||
}
|
||||
|
||||
public void a(EventsStorageListener eventsStorageListener) {
|
||||
if (eventsStorageListener != null) {
|
||||
this.f.add(eventsStorageListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(int i) throws IOException {
|
||||
if (this.d.a(i, d())) {
|
||||
return;
|
||||
}
|
||||
CommonUtils.a(this.a, 4, "Fabric", String.format(Locale.US, "session analytics events file is %d bytes, new event is %d bytes, this is over flush limit of %d, rolling it over", Integer.valueOf(this.d.a()), Integer.valueOf(i), Integer.valueOf(d())));
|
||||
f();
|
||||
}
|
||||
|
||||
public void a(List<File> list) {
|
||||
this.d.a(list);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
List<File> c = this.d.c();
|
||||
int e = e();
|
||||
if (c.size() <= e) {
|
||||
return;
|
||||
}
|
||||
int size = c.size() - e;
|
||||
CommonUtils.b(this.a, String.format(Locale.US, "Found %d files in roll over directory, this is greater than %d, deleting %d oldest files", Integer.valueOf(c.size()), Integer.valueOf(e), Integer.valueOf(size)));
|
||||
TreeSet treeSet = new TreeSet(new Comparator<FileWithTimestamp>(this) { // from class: io.fabric.sdk.android.services.events.EventsFilesManager.1
|
||||
@Override // java.util.Comparator
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public int compare(FileWithTimestamp fileWithTimestamp, FileWithTimestamp fileWithTimestamp2) {
|
||||
return (int) (fileWithTimestamp.b - fileWithTimestamp2.b);
|
||||
}
|
||||
});
|
||||
for (File file : c) {
|
||||
treeSet.add(new FileWithTimestamp(file, a(file.getName())));
|
||||
}
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator it = treeSet.iterator();
|
||||
while (it.hasNext()) {
|
||||
arrayList.add(((FileWithTimestamp) it.next()).a);
|
||||
if (arrayList.size() == size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.d.a(arrayList);
|
||||
}
|
||||
|
||||
public long a(String str) {
|
||||
String[] split = str.split("_");
|
||||
if (split.length != 3) {
|
||||
return 0L;
|
||||
}
|
||||
try {
|
||||
return Long.valueOf(split[2]).longValue();
|
||||
} catch (NumberFormatException unused) {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class EventsHandler<T> implements EventsStorageListener {
|
||||
protected final Context a;
|
||||
protected final ScheduledExecutorService b;
|
||||
protected EventsStrategy<T> c;
|
||||
|
||||
public EventsHandler(Context context, EventsStrategy<T> eventsStrategy, EventsFilesManager eventsFilesManager, ScheduledExecutorService scheduledExecutorService) {
|
||||
this.a = context.getApplicationContext();
|
||||
this.b = scheduledExecutorService;
|
||||
this.c = eventsStrategy;
|
||||
eventsFilesManager.a((EventsStorageListener) this);
|
||||
}
|
||||
|
||||
public void a(final T t, final boolean z) {
|
||||
a(new Runnable() { // from class: io.fabric.sdk.android.services.events.EventsHandler.1
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
EventsHandler.this.c.a(t);
|
||||
if (z) {
|
||||
EventsHandler.this.c.c();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CommonUtils.a(EventsHandler.this.a, "Failed to record event.", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorageListener
|
||||
public void a(String str) {
|
||||
a(new Runnable() { // from class: io.fabric.sdk.android.services.events.EventsHandler.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
EventsHandler.this.c.b();
|
||||
} catch (Exception e) {
|
||||
CommonUtils.a(EventsHandler.this.a, "Failed to send events files.", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void a(Runnable runnable) {
|
||||
try {
|
||||
this.b.submit(runnable);
|
||||
} catch (Exception e) {
|
||||
CommonUtils.a(this.a, "Failed to submit events task", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface EventsManager<T> {
|
||||
void a(T t);
|
||||
|
||||
void b();
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface EventsStorage {
|
||||
int a();
|
||||
|
||||
List<File> a(int i);
|
||||
|
||||
void a(String str) throws IOException;
|
||||
|
||||
void a(List<File> list);
|
||||
|
||||
void a(byte[] bArr) throws IOException;
|
||||
|
||||
boolean a(int i, int i2);
|
||||
|
||||
boolean b();
|
||||
|
||||
List<File> c();
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface EventsStorageListener {
|
||||
void a(String str);
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface EventsStrategy<T> extends FileRollOverManager, EventsManager<T> {
|
||||
FilesSender a();
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface FileRollOverManager {
|
||||
boolean c() throws IOException;
|
||||
|
||||
void d();
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface FilesSender {
|
||||
boolean a(List<File> list);
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import android.content.Context;
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import io.fabric.sdk.android.services.common.QueueFile;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class QueueFileEventStorage implements EventsStorage {
|
||||
private final Context a;
|
||||
private final File b;
|
||||
private final String c;
|
||||
private final File d;
|
||||
private QueueFile e;
|
||||
private File f;
|
||||
|
||||
public QueueFileEventStorage(Context context, File file, String str, String str2) throws IOException {
|
||||
this.a = context;
|
||||
this.b = file;
|
||||
this.c = str2;
|
||||
this.d = new File(this.b, str);
|
||||
this.e = new QueueFile(this.d);
|
||||
d();
|
||||
}
|
||||
|
||||
private void d() {
|
||||
this.f = new File(this.b, this.c);
|
||||
if (this.f.exists()) {
|
||||
return;
|
||||
}
|
||||
this.f.mkdirs();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public void a(byte[] bArr) throws IOException {
|
||||
this.e.a(bArr);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public boolean b() {
|
||||
return this.e.a();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public List<File> c() {
|
||||
return Arrays.asList(this.f.listFiles());
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public int a() {
|
||||
return this.e.b();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public void a(String str) throws IOException {
|
||||
this.e.close();
|
||||
a(this.d, new File(this.f, str));
|
||||
this.e = new QueueFile(this.d);
|
||||
}
|
||||
|
||||
private void a(File file, File file2) throws IOException {
|
||||
FileInputStream fileInputStream;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(file);
|
||||
try {
|
||||
outputStream = a(file2);
|
||||
CommonUtils.a(fileInputStream, outputStream, new byte[DataDecryptTool.DECRYPT_SP_FILE]);
|
||||
CommonUtils.a((Closeable) fileInputStream, "Failed to close file input stream");
|
||||
CommonUtils.a(outputStream, "Failed to close output stream");
|
||||
file.delete();
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
CommonUtils.a((Closeable) fileInputStream, "Failed to close file input stream");
|
||||
CommonUtils.a(outputStream, "Failed to close output stream");
|
||||
file.delete();
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
fileInputStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public OutputStream a(File file) throws IOException {
|
||||
return new FileOutputStream(file);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public List<File> a(int i) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (File file : this.f.listFiles()) {
|
||||
arrayList.add(file);
|
||||
if (arrayList.size() >= i) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public void a(List<File> list) {
|
||||
for (File file : list) {
|
||||
CommonUtils.b(this.a, String.format("deleting sent analytics file %s", file.getName()));
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.events.EventsStorage
|
||||
public boolean a(int i, int i2) {
|
||||
return this.e.a(i, i2);
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package io.fabric.sdk.android.services.events;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class TimeBasedFileRollOverRunnable implements Runnable {
|
||||
private final Context a;
|
||||
private final FileRollOverManager b;
|
||||
|
||||
public TimeBasedFileRollOverRunnable(Context context, FileRollOverManager fileRollOverManager) {
|
||||
this.a = context;
|
||||
this.b = fileRollOverManager;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
CommonUtils.b(this.a, "Performing time based file roll over.");
|
||||
if (this.b.c()) {
|
||||
return;
|
||||
}
|
||||
this.b.d();
|
||||
} catch (Exception e) {
|
||||
CommonUtils.a(this.a, "Failed to roll over file", e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class CertificateChainCleaner {
|
||||
public static X509Certificate[] a(X509Certificate[] x509CertificateArr, SystemKeyStore systemKeyStore) throws CertificateException {
|
||||
LinkedList linkedList = new LinkedList();
|
||||
boolean b = systemKeyStore.b(x509CertificateArr[0]);
|
||||
linkedList.add(x509CertificateArr[0]);
|
||||
boolean z = true;
|
||||
boolean z2 = b;
|
||||
int i = 1;
|
||||
while (i < x509CertificateArr.length) {
|
||||
if (systemKeyStore.b(x509CertificateArr[i])) {
|
||||
z2 = true;
|
||||
}
|
||||
if (!a(x509CertificateArr[i], x509CertificateArr[i - 1])) {
|
||||
break;
|
||||
}
|
||||
linkedList.add(x509CertificateArr[i]);
|
||||
i++;
|
||||
}
|
||||
X509Certificate a = systemKeyStore.a(x509CertificateArr[i - 1]);
|
||||
if (a != null) {
|
||||
linkedList.add(a);
|
||||
} else {
|
||||
z = z2;
|
||||
}
|
||||
if (z) {
|
||||
return (X509Certificate[]) linkedList.toArray(new X509Certificate[linkedList.size()]);
|
||||
}
|
||||
throw new CertificateException("Didn't find a trust anchor in chain cleanup!");
|
||||
}
|
||||
|
||||
private static boolean a(X509Certificate x509Certificate, X509Certificate x509Certificate2) {
|
||||
if (!x509Certificate.getSubjectX500Principal().equals(x509Certificate2.getIssuerX500Principal())) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
x509Certificate2.verify(x509Certificate.getPublicKey());
|
||||
return true;
|
||||
} catch (GeneralSecurityException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import io.fabric.sdk.android.DefaultLogger;
|
||||
import io.fabric.sdk.android.Logger;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DefaultHttpRequestFactory implements HttpRequestFactory {
|
||||
private final Logger a;
|
||||
private PinningInfoProvider b;
|
||||
private SSLSocketFactory c;
|
||||
private boolean d;
|
||||
|
||||
/* renamed from: io.fabric.sdk.android.services.network.DefaultHttpRequestFactory$1, reason: invalid class name */
|
||||
static /* synthetic */ class AnonymousClass1 {
|
||||
static final /* synthetic */ int[] a = new int[HttpMethod.values().length];
|
||||
|
||||
static {
|
||||
try {
|
||||
a[HttpMethod.GET.ordinal()] = 1;
|
||||
} catch (NoSuchFieldError unused) {
|
||||
}
|
||||
try {
|
||||
a[HttpMethod.POST.ordinal()] = 2;
|
||||
} catch (NoSuchFieldError unused2) {
|
||||
}
|
||||
try {
|
||||
a[HttpMethod.PUT.ordinal()] = 3;
|
||||
} catch (NoSuchFieldError unused3) {
|
||||
}
|
||||
try {
|
||||
a[HttpMethod.DELETE.ordinal()] = 4;
|
||||
} catch (NoSuchFieldError unused4) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DefaultHttpRequestFactory() {
|
||||
this(new DefaultLogger());
|
||||
}
|
||||
|
||||
private synchronized SSLSocketFactory b() {
|
||||
SSLSocketFactory a;
|
||||
this.d = true;
|
||||
try {
|
||||
a = NetworkUtils.a(this.b);
|
||||
this.a.d("Fabric", "Custom SSL pinning enabled");
|
||||
} catch (Exception e) {
|
||||
this.a.b("Fabric", "Exception while validating pinned certs", e);
|
||||
return null;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.network.HttpRequestFactory
|
||||
public HttpRequest a(HttpMethod httpMethod, String str, Map<String, String> map) {
|
||||
HttpRequest a;
|
||||
SSLSocketFactory a2;
|
||||
int i = AnonymousClass1.a[httpMethod.ordinal()];
|
||||
if (i == 1) {
|
||||
a = HttpRequest.a((CharSequence) str, (Map<?, ?>) map, true);
|
||||
} else if (i == 2) {
|
||||
a = HttpRequest.b((CharSequence) str, (Map<?, ?>) map, true);
|
||||
} else if (i == 3) {
|
||||
a = HttpRequest.f((CharSequence) str);
|
||||
} else {
|
||||
if (i != 4) {
|
||||
throw new IllegalArgumentException("Unsupported HTTP method!");
|
||||
}
|
||||
a = HttpRequest.b((CharSequence) str);
|
||||
}
|
||||
if (a(str) && this.b != null && (a2 = a()) != null) {
|
||||
((HttpsURLConnection) a.j()).setSSLSocketFactory(a2);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
public DefaultHttpRequestFactory(Logger logger) {
|
||||
this.a = logger;
|
||||
}
|
||||
|
||||
private boolean a(String str) {
|
||||
return str != null && str.toLowerCase(Locale.US).startsWith("https");
|
||||
}
|
||||
|
||||
private synchronized SSLSocketFactory a() {
|
||||
if (this.c == null && !this.d) {
|
||||
this.c = b();
|
||||
}
|
||||
return this.c;
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum HttpMethod {
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE
|
||||
}
|
698
sources/io/fabric/sdk/android/services/network/HttpRequest.java
Normal file
698
sources/io/fabric/sdk/android/services/network/HttpRequest.java
Normal file
@@ -0,0 +1,698 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import com.ubt.jimu.unity.bluetooth.UnityActivity;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.Flushable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class HttpRequest {
|
||||
private static ConnectionFactory k = ConnectionFactory.a;
|
||||
public final URL b;
|
||||
private final String c;
|
||||
private RequestOutputStream d;
|
||||
private boolean e;
|
||||
private String i;
|
||||
private int j;
|
||||
private HttpURLConnection a = null;
|
||||
private boolean f = true;
|
||||
private boolean g = false;
|
||||
private int h = UnityActivity.BLOCKLY_TYPE_NONE;
|
||||
|
||||
protected static abstract class CloseOperation<V> extends Operation<V> {
|
||||
private final Closeable a;
|
||||
private final boolean b;
|
||||
|
||||
protected CloseOperation(Closeable closeable, boolean z) {
|
||||
this.a = closeable;
|
||||
this.b = z;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.network.HttpRequest.Operation
|
||||
protected void a() throws IOException {
|
||||
Closeable closeable = this.a;
|
||||
if (closeable instanceof Flushable) {
|
||||
((Flushable) closeable).flush();
|
||||
}
|
||||
if (!this.b) {
|
||||
this.a.close();
|
||||
} else {
|
||||
try {
|
||||
this.a.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface ConnectionFactory {
|
||||
public static final ConnectionFactory a = new ConnectionFactory() { // from class: io.fabric.sdk.android.services.network.HttpRequest.ConnectionFactory.1
|
||||
@Override // io.fabric.sdk.android.services.network.HttpRequest.ConnectionFactory
|
||||
public HttpURLConnection a(URL url) throws IOException {
|
||||
return (HttpURLConnection) url.openConnection();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.network.HttpRequest.ConnectionFactory
|
||||
public HttpURLConnection a(URL url, Proxy proxy) throws IOException {
|
||||
return (HttpURLConnection) url.openConnection(proxy);
|
||||
}
|
||||
};
|
||||
|
||||
HttpURLConnection a(URL url) throws IOException;
|
||||
|
||||
HttpURLConnection a(URL url, Proxy proxy) throws IOException;
|
||||
}
|
||||
|
||||
public static class HttpRequestException extends RuntimeException {
|
||||
private static final long serialVersionUID = -1170466989781746231L;
|
||||
|
||||
protected HttpRequestException(IOException iOException) {
|
||||
super(iOException);
|
||||
}
|
||||
|
||||
@Override // java.lang.Throwable
|
||||
public IOException getCause() {
|
||||
return (IOException) super.getCause();
|
||||
}
|
||||
}
|
||||
|
||||
protected static abstract class Operation<V> implements Callable<V> {
|
||||
protected Operation() {
|
||||
}
|
||||
|
||||
protected abstract void a() throws IOException;
|
||||
|
||||
protected abstract V b() throws HttpRequestException, IOException;
|
||||
|
||||
@Override // java.util.concurrent.Callable
|
||||
public V call() throws HttpRequestException {
|
||||
Throwable th;
|
||||
boolean z = true;
|
||||
try {
|
||||
try {
|
||||
V b = b();
|
||||
try {
|
||||
a();
|
||||
return b;
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
} catch (HttpRequestException e2) {
|
||||
throw e2;
|
||||
} catch (IOException e3) {
|
||||
throw new HttpRequestException(e3);
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
z = false;
|
||||
try {
|
||||
a();
|
||||
} catch (IOException e4) {
|
||||
if (!z) {
|
||||
throw new HttpRequestException(e4);
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
a();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class RequestOutputStream extends BufferedOutputStream {
|
||||
private final CharsetEncoder a;
|
||||
|
||||
public RequestOutputStream(OutputStream outputStream, String str, int i) {
|
||||
super(outputStream, i);
|
||||
this.a = Charset.forName(HttpRequest.f(str)).newEncoder();
|
||||
}
|
||||
|
||||
public RequestOutputStream a(String str) throws IOException {
|
||||
ByteBuffer encode = this.a.encode(CharBuffer.wrap(str));
|
||||
super.write(encode.array(), 0, encode.limit());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequest(CharSequence charSequence, String str) throws HttpRequestException {
|
||||
try {
|
||||
this.b = new URL(charSequence.toString());
|
||||
this.c = str;
|
||||
} catch (MalformedURLException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static StringBuilder b(String str, StringBuilder sb) {
|
||||
if (str.indexOf(58) + 2 == str.lastIndexOf(47)) {
|
||||
sb.append('/');
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static String c(CharSequence charSequence) throws HttpRequestException {
|
||||
int i;
|
||||
try {
|
||||
URL url = new URL(charSequence.toString());
|
||||
String host = url.getHost();
|
||||
int port = url.getPort();
|
||||
if (port != -1) {
|
||||
host = host + ':' + Integer.toString(port);
|
||||
}
|
||||
try {
|
||||
String aSCIIString = new URI(url.getProtocol(), host, url.getPath(), url.getQuery(), null).toASCIIString();
|
||||
int indexOf = aSCIIString.indexOf(63);
|
||||
if (indexOf <= 0 || (i = indexOf + 1) >= aSCIIString.length()) {
|
||||
return aSCIIString;
|
||||
}
|
||||
return aSCIIString.substring(0, i) + aSCIIString.substring(i).replace("+", "%2B");
|
||||
} catch (URISyntaxException e) {
|
||||
IOException iOException = new IOException("Parsing URI failed");
|
||||
iOException.initCause(e);
|
||||
throw new HttpRequestException(iOException);
|
||||
}
|
||||
} catch (IOException e2) {
|
||||
throw new HttpRequestException(e2);
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpRequest d(CharSequence charSequence) throws HttpRequestException {
|
||||
return new HttpRequest(charSequence, "GET");
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static String f(String str) {
|
||||
return (str == null || str.length() <= 0) ? "UTF-8" : str;
|
||||
}
|
||||
|
||||
private HttpURLConnection p() {
|
||||
try {
|
||||
HttpURLConnection a = this.i != null ? k.a(this.b, q()) : k.a(this.b);
|
||||
a.setRequestMethod(this.c);
|
||||
return a;
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Proxy q() {
|
||||
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(this.i, this.j));
|
||||
}
|
||||
|
||||
public int g() throws HttpRequestException {
|
||||
try {
|
||||
e();
|
||||
return j().getResponseCode();
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String h() {
|
||||
return c("Content-Encoding");
|
||||
}
|
||||
|
||||
public int i() {
|
||||
return d("Content-Length");
|
||||
}
|
||||
|
||||
public HttpURLConnection j() {
|
||||
if (this.a == null) {
|
||||
this.a = p();
|
||||
}
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public String k() {
|
||||
return j().getRequestMethod();
|
||||
}
|
||||
|
||||
protected HttpRequest l() throws IOException {
|
||||
if (this.d != null) {
|
||||
return this;
|
||||
}
|
||||
j().setDoOutput(true);
|
||||
this.d = new RequestOutputStream(j().getOutputStream(), b(j().getRequestProperty("Content-Type"), "charset"), this.h);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected HttpRequest m() throws IOException {
|
||||
if (this.e) {
|
||||
this.d.a("\r\n--00content0boundary00\r\n");
|
||||
} else {
|
||||
this.e = true;
|
||||
b("multipart/form-data; boundary=00content0boundary00");
|
||||
l();
|
||||
this.d.a("--00content0boundary00\r\n");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public InputStream n() throws HttpRequestException {
|
||||
InputStream inputStream;
|
||||
if (g() < 400) {
|
||||
try {
|
||||
inputStream = j().getInputStream();
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
} else {
|
||||
inputStream = j().getErrorStream();
|
||||
if (inputStream == null) {
|
||||
try {
|
||||
inputStream = j().getInputStream();
|
||||
} catch (IOException e2) {
|
||||
throw new HttpRequestException(e2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.g || !"gzip".equals(h())) {
|
||||
return inputStream;
|
||||
}
|
||||
try {
|
||||
return new GZIPInputStream(inputStream);
|
||||
} catch (IOException e3) {
|
||||
throw new HttpRequestException(e3);
|
||||
}
|
||||
}
|
||||
|
||||
public URL o() {
|
||||
return j().getURL();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return k() + ' ' + o();
|
||||
}
|
||||
|
||||
private static StringBuilder a(String str, StringBuilder sb) {
|
||||
int indexOf = str.indexOf(63);
|
||||
int length = sb.length() - 1;
|
||||
if (indexOf == -1) {
|
||||
sb.append('?');
|
||||
} else if (indexOf < length && str.charAt(length) != '&') {
|
||||
sb.append('&');
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static HttpRequest e(CharSequence charSequence) throws HttpRequestException {
|
||||
return new HttpRequest(charSequence, "POST");
|
||||
}
|
||||
|
||||
public static HttpRequest f(CharSequence charSequence) throws HttpRequestException {
|
||||
return new HttpRequest(charSequence, "PUT");
|
||||
}
|
||||
|
||||
public int d(String str) throws HttpRequestException {
|
||||
return a(str, -1);
|
||||
}
|
||||
|
||||
public static HttpRequest b(CharSequence charSequence, Map<?, ?> map, boolean z) {
|
||||
String a = a(charSequence, map);
|
||||
if (z) {
|
||||
a = c((CharSequence) a);
|
||||
}
|
||||
return e((CharSequence) a);
|
||||
}
|
||||
|
||||
public String d(String str, String str2) {
|
||||
return b(c(str), str2);
|
||||
}
|
||||
|
||||
protected HttpRequest e() throws IOException {
|
||||
RequestOutputStream requestOutputStream = this.d;
|
||||
if (requestOutputStream == null) {
|
||||
return this;
|
||||
}
|
||||
if (this.e) {
|
||||
requestOutputStream.a("\r\n--00content0boundary00--\r\n");
|
||||
}
|
||||
if (this.f) {
|
||||
try {
|
||||
this.d.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
} else {
|
||||
this.d.close();
|
||||
}
|
||||
this.d = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected HttpRequest f() throws HttpRequestException {
|
||||
try {
|
||||
e();
|
||||
return this;
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String d() {
|
||||
return d("Content-Type", "charset");
|
||||
}
|
||||
|
||||
public static HttpRequest b(CharSequence charSequence) throws HttpRequestException {
|
||||
return new HttpRequest(charSequence, "DELETE");
|
||||
}
|
||||
|
||||
public HttpRequest f(String str, String str2) throws HttpRequestException {
|
||||
a((CharSequence) str);
|
||||
a(": ");
|
||||
a((CharSequence) str2);
|
||||
a("\r\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
public BufferedInputStream b() throws HttpRequestException {
|
||||
return new BufferedInputStream(n(), this.h);
|
||||
}
|
||||
|
||||
public static String a(CharSequence charSequence, Map<?, ?> map) {
|
||||
String charSequence2 = charSequence.toString();
|
||||
if (map == null || map.isEmpty()) {
|
||||
return charSequence2;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(charSequence2);
|
||||
b(charSequence2, sb);
|
||||
a(charSequence2, sb);
|
||||
Iterator<Map.Entry<?, ?>> it = map.entrySet().iterator();
|
||||
Map.Entry<?, ?> next = it.next();
|
||||
sb.append(next.getKey().toString());
|
||||
sb.append('=');
|
||||
Object value = next.getValue();
|
||||
if (value != null) {
|
||||
sb.append(value);
|
||||
}
|
||||
while (it.hasNext()) {
|
||||
sb.append('&');
|
||||
Map.Entry<?, ?> next2 = it.next();
|
||||
sb.append(next2.getKey().toString());
|
||||
sb.append('=');
|
||||
Object value2 = next2.getValue();
|
||||
if (value2 != null) {
|
||||
sb.append(value2);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected String b(String str, String str2) {
|
||||
String trim;
|
||||
int length;
|
||||
if (str != null && str.length() != 0) {
|
||||
int length2 = str.length();
|
||||
int indexOf = str.indexOf(59) + 1;
|
||||
if (indexOf != 0 && indexOf != length2) {
|
||||
int indexOf2 = str.indexOf(59, indexOf);
|
||||
if (indexOf2 == -1) {
|
||||
indexOf2 = length2;
|
||||
}
|
||||
while (indexOf < indexOf2) {
|
||||
int indexOf3 = str.indexOf(61, indexOf);
|
||||
if (indexOf3 != -1 && indexOf3 < indexOf2 && str2.equals(str.substring(indexOf, indexOf3).trim()) && (length = (trim = str.substring(indexOf3 + 1, indexOf2).trim()).length()) != 0) {
|
||||
if (length > 2 && '\"' == trim.charAt(0)) {
|
||||
int i = length - 1;
|
||||
if ('\"' == trim.charAt(i)) {
|
||||
return trim.substring(1, i);
|
||||
}
|
||||
}
|
||||
return trim;
|
||||
}
|
||||
indexOf = indexOf2 + 1;
|
||||
indexOf2 = str.indexOf(59, indexOf);
|
||||
if (indexOf2 == -1) {
|
||||
indexOf2 = length2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpRequest e(String str, String str2) {
|
||||
a(str, (String) null, str2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Base64 {
|
||||
private static final byte[] a = {65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47};
|
||||
|
||||
private static byte[] a(byte[] bArr, int i, int i2, byte[] bArr2, int i3) {
|
||||
byte[] bArr3 = a;
|
||||
int i4 = (i2 > 0 ? (bArr[i] << 24) >>> 8 : 0) | (i2 > 1 ? (bArr[i + 1] << 24) >>> 16 : 0) | (i2 > 2 ? (bArr[i + 2] << 24) >>> 24 : 0);
|
||||
if (i2 == 1) {
|
||||
bArr2[i3] = bArr3[i4 >>> 18];
|
||||
bArr2[i3 + 1] = bArr3[(i4 >>> 12) & 63];
|
||||
bArr2[i3 + 2] = 61;
|
||||
bArr2[i3 + 3] = 61;
|
||||
return bArr2;
|
||||
}
|
||||
if (i2 == 2) {
|
||||
bArr2[i3] = bArr3[i4 >>> 18];
|
||||
bArr2[i3 + 1] = bArr3[(i4 >>> 12) & 63];
|
||||
bArr2[i3 + 2] = bArr3[(i4 >>> 6) & 63];
|
||||
bArr2[i3 + 3] = 61;
|
||||
return bArr2;
|
||||
}
|
||||
if (i2 != 3) {
|
||||
return bArr2;
|
||||
}
|
||||
bArr2[i3] = bArr3[i4 >>> 18];
|
||||
bArr2[i3 + 1] = bArr3[(i4 >>> 12) & 63];
|
||||
bArr2[i3 + 2] = bArr3[(i4 >>> 6) & 63];
|
||||
bArr2[i3 + 3] = bArr3[i4 & 63];
|
||||
return bArr2;
|
||||
}
|
||||
|
||||
public static byte[] b(byte[] bArr, int i, int i2) {
|
||||
if (bArr == null) {
|
||||
throw new NullPointerException("Cannot serialize a null array.");
|
||||
}
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("Cannot have negative offset: " + i);
|
||||
}
|
||||
if (i2 < 0) {
|
||||
throw new IllegalArgumentException("Cannot have length offset: " + i2);
|
||||
}
|
||||
if (i + i2 > bArr.length) {
|
||||
throw new IllegalArgumentException(String.format(Locale.ENGLISH, "Cannot have offset of %d and length of %d with array of length %d", Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(bArr.length)));
|
||||
}
|
||||
byte[] bArr2 = new byte[((i2 / 3) * 4) + (i2 % 3 <= 0 ? 0 : 4)];
|
||||
int i3 = i2 - 2;
|
||||
int i4 = 0;
|
||||
int i5 = 0;
|
||||
while (i4 < i3) {
|
||||
a(bArr, i4 + i, 3, bArr2, i5);
|
||||
i4 += 3;
|
||||
i5 += 4;
|
||||
}
|
||||
if (i4 < i2) {
|
||||
a(bArr, i + i4, i2 - i4, bArr2, i5);
|
||||
i5 += 4;
|
||||
}
|
||||
if (i5 > bArr2.length - 1) {
|
||||
return bArr2;
|
||||
}
|
||||
byte[] bArr3 = new byte[i5];
|
||||
System.arraycopy(bArr2, 0, bArr3, 0, i5);
|
||||
return bArr3;
|
||||
}
|
||||
|
||||
public static String a(String str) {
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = str.getBytes("US-ASCII");
|
||||
} catch (UnsupportedEncodingException unused) {
|
||||
bytes = str.getBytes();
|
||||
}
|
||||
return a(bytes);
|
||||
}
|
||||
|
||||
public static String a(byte[] bArr) {
|
||||
return a(bArr, 0, bArr.length);
|
||||
}
|
||||
|
||||
public static String a(byte[] bArr, int i, int i2) {
|
||||
byte[] b = b(bArr, i, i2);
|
||||
try {
|
||||
return new String(b, "US-ASCII");
|
||||
} catch (UnsupportedEncodingException unused) {
|
||||
return new String(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ByteArrayOutputStream c() {
|
||||
int i = i();
|
||||
if (i > 0) {
|
||||
return new ByteArrayOutputStream(i);
|
||||
}
|
||||
return new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public HttpRequest c(String str, String str2) {
|
||||
j().setRequestProperty(str, str2);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest b(String str) {
|
||||
a(str, (String) null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String c(String str) throws HttpRequestException {
|
||||
f();
|
||||
return j().getHeaderField(str);
|
||||
}
|
||||
|
||||
protected HttpRequest b(String str, String str2, String str3) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("form-data; name=\"");
|
||||
sb.append(str);
|
||||
if (str2 != null) {
|
||||
sb.append("\"; filename=\"");
|
||||
sb.append(str2);
|
||||
}
|
||||
sb.append('\"');
|
||||
f("Content-Disposition", sb.toString());
|
||||
if (str3 != null) {
|
||||
f("Content-Type", str3);
|
||||
}
|
||||
a("\r\n");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static HttpRequest a(CharSequence charSequence, Map<?, ?> map, boolean z) {
|
||||
String a = a(charSequence, map);
|
||||
if (z) {
|
||||
a = c((CharSequence) a);
|
||||
}
|
||||
return d((CharSequence) a);
|
||||
}
|
||||
|
||||
public String a(String str) throws HttpRequestException {
|
||||
ByteArrayOutputStream c = c();
|
||||
try {
|
||||
a(b(), c);
|
||||
return c.toString(f(str));
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String a() throws HttpRequestException {
|
||||
return a(d());
|
||||
}
|
||||
|
||||
public HttpRequest a(int i) {
|
||||
j().setConnectTimeout(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int a(String str, int i) throws HttpRequestException {
|
||||
f();
|
||||
return j().getHeaderFieldInt(str, i);
|
||||
}
|
||||
|
||||
public HttpRequest a(boolean z) {
|
||||
j().setUseCaches(z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest a(String str, String str2) {
|
||||
if (str2 != null && str2.length() > 0) {
|
||||
c("Content-Type", str + "; charset=" + str2);
|
||||
return this;
|
||||
}
|
||||
c("Content-Type", str);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected HttpRequest a(final InputStream inputStream, final OutputStream outputStream) throws IOException {
|
||||
return new CloseOperation<HttpRequest>(inputStream, this.f) { // from class: io.fabric.sdk.android.services.network.HttpRequest.6
|
||||
@Override // io.fabric.sdk.android.services.network.HttpRequest.Operation
|
||||
public HttpRequest b() throws IOException {
|
||||
byte[] bArr = new byte[HttpRequest.this.h];
|
||||
while (true) {
|
||||
int read = inputStream.read(bArr);
|
||||
if (read == -1) {
|
||||
return HttpRequest.this;
|
||||
}
|
||||
outputStream.write(bArr, 0, read);
|
||||
}
|
||||
}
|
||||
}.call();
|
||||
}
|
||||
|
||||
public HttpRequest a(String str, String str2, String str3) throws HttpRequestException {
|
||||
a(str, str2, (String) null, str3);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest a(String str, String str2, String str3, String str4) throws HttpRequestException {
|
||||
try {
|
||||
m();
|
||||
b(str, str2, str3);
|
||||
this.d.a(str4);
|
||||
return this;
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequest a(String str, Number number) throws HttpRequestException {
|
||||
a(str, (String) null, number);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest a(String str, String str2, Number number) throws HttpRequestException {
|
||||
a(str, str2, number != null ? number.toString() : null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpRequest a(String str, String str2, String str3, InputStream inputStream) throws HttpRequestException {
|
||||
try {
|
||||
m();
|
||||
b(str, str2, str3);
|
||||
a(inputStream, this.d);
|
||||
return this;
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public HttpRequest a(CharSequence charSequence) throws HttpRequestException {
|
||||
try {
|
||||
l();
|
||||
this.d.a(charSequence.toString());
|
||||
return this;
|
||||
} catch (IOException e) {
|
||||
throw new HttpRequestException(e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface HttpRequestFactory {
|
||||
HttpRequest a(HttpMethod httpMethod, String str, Map<String, String> map);
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class NetworkUtils {
|
||||
public static final SSLSocketFactory a(PinningInfoProvider pinningInfoProvider) throws KeyManagementException, NoSuchAlgorithmException {
|
||||
SSLContext sSLContext = SSLContext.getInstance("TLS");
|
||||
sSLContext.init(null, new TrustManager[]{new PinningTrustManager(new SystemKeyStore(pinningInfoProvider.c(), pinningInfoProvider.a()), pinningInfoProvider)}, null);
|
||||
return sSLContext.getSocketFactory();
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PinningInfoProvider {
|
||||
String a();
|
||||
|
||||
long b();
|
||||
|
||||
InputStream c();
|
||||
|
||||
String[] d();
|
||||
}
|
@@ -0,0 +1,112 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.net.ssl.TrustManager;
|
||||
import javax.net.ssl.TrustManagerFactory;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class PinningTrustManager implements X509TrustManager {
|
||||
private static final X509Certificate[] f = new X509Certificate[0];
|
||||
private final TrustManager[] a;
|
||||
private final SystemKeyStore b;
|
||||
private final long c;
|
||||
private final List<byte[]> d = new LinkedList();
|
||||
private final Set<X509Certificate> e = Collections.synchronizedSet(new HashSet());
|
||||
|
||||
public PinningTrustManager(SystemKeyStore systemKeyStore, PinningInfoProvider pinningInfoProvider) {
|
||||
this.a = a(systemKeyStore);
|
||||
this.b = systemKeyStore;
|
||||
this.c = pinningInfoProvider.b();
|
||||
for (String str : pinningInfoProvider.d()) {
|
||||
this.d.add(a(str));
|
||||
}
|
||||
}
|
||||
|
||||
private TrustManager[] a(SystemKeyStore systemKeyStore) {
|
||||
try {
|
||||
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("X509");
|
||||
trustManagerFactory.init(systemKeyStore.a);
|
||||
return trustManagerFactory.getTrustManagers();
|
||||
} catch (KeyStoreException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (NoSuchAlgorithmException e2) {
|
||||
throw new AssertionError(e2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // javax.net.ssl.X509TrustManager
|
||||
public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
|
||||
throw new CertificateException("Client certificates not supported!");
|
||||
}
|
||||
|
||||
@Override // javax.net.ssl.X509TrustManager
|
||||
public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
|
||||
if (this.e.contains(x509CertificateArr[0])) {
|
||||
return;
|
||||
}
|
||||
a(x509CertificateArr, str);
|
||||
a(x509CertificateArr);
|
||||
this.e.add(x509CertificateArr[0]);
|
||||
}
|
||||
|
||||
@Override // javax.net.ssl.X509TrustManager
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return f;
|
||||
}
|
||||
|
||||
private boolean a(X509Certificate x509Certificate) throws CertificateException {
|
||||
try {
|
||||
byte[] digest = MessageDigest.getInstance("SHA1").digest(x509Certificate.getPublicKey().getEncoded());
|
||||
Iterator<byte[]> it = this.d.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (Arrays.equals(it.next(), digest)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new CertificateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(X509Certificate[] x509CertificateArr, String str) throws CertificateException {
|
||||
for (TrustManager trustManager : this.a) {
|
||||
((X509TrustManager) trustManager).checkServerTrusted(x509CertificateArr, str);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(X509Certificate[] x509CertificateArr) throws CertificateException {
|
||||
if (this.c != -1 && System.currentTimeMillis() - this.c > 15552000000L) {
|
||||
Fabric.g().w("Fabric", "Certificate pins are stale, (" + (System.currentTimeMillis() - this.c) + " millis vs 15552000000 millis) falling back to system trust.");
|
||||
return;
|
||||
}
|
||||
for (X509Certificate x509Certificate : CertificateChainCleaner.a(x509CertificateArr, this.b)) {
|
||||
if (a(x509Certificate)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new CertificateException("No valid pins found in chain!");
|
||||
}
|
||||
|
||||
private byte[] a(String str) {
|
||||
int length = str.length();
|
||||
byte[] bArr = new byte[length / 2];
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
bArr[i / 2] = (byte) ((Character.digit(str.charAt(i), 16) << 4) + Character.digit(str.charAt(i + 1), 16));
|
||||
}
|
||||
return bArr;
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.Principal;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class SystemKeyStore {
|
||||
final KeyStore a;
|
||||
private final HashMap<Principal, X509Certificate> b;
|
||||
|
||||
public SystemKeyStore(InputStream inputStream, String str) {
|
||||
KeyStore a = a(inputStream, str);
|
||||
this.b = a(a);
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public X509Certificate a(X509Certificate x509Certificate) {
|
||||
X509Certificate x509Certificate2 = this.b.get(x509Certificate.getIssuerX500Principal());
|
||||
if (x509Certificate2 == null || x509Certificate2.getSubjectX500Principal().equals(x509Certificate.getSubjectX500Principal())) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
x509Certificate.verify(x509Certificate2.getPublicKey());
|
||||
return x509Certificate2;
|
||||
} catch (GeneralSecurityException unused) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean b(X509Certificate x509Certificate) {
|
||||
X509Certificate x509Certificate2 = this.b.get(x509Certificate.getSubjectX500Principal());
|
||||
return x509Certificate2 != null && x509Certificate2.getPublicKey().equals(x509Certificate.getPublicKey());
|
||||
}
|
||||
|
||||
private HashMap<Principal, X509Certificate> a(KeyStore keyStore) {
|
||||
try {
|
||||
HashMap<Principal, X509Certificate> hashMap = new HashMap<>();
|
||||
Enumeration<String> aliases = keyStore.aliases();
|
||||
while (aliases.hasMoreElements()) {
|
||||
X509Certificate x509Certificate = (X509Certificate) keyStore.getCertificate(aliases.nextElement());
|
||||
if (x509Certificate != null) {
|
||||
hashMap.put(x509Certificate.getSubjectX500Principal(), x509Certificate);
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
} catch (KeyStoreException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private KeyStore a(InputStream inputStream, String str) {
|
||||
try {
|
||||
KeyStore keyStore = KeyStore.getInstance("BKS");
|
||||
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
|
||||
try {
|
||||
keyStore.load(bufferedInputStream, str.toCharArray());
|
||||
return keyStore;
|
||||
} finally {
|
||||
bufferedInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (KeyStoreException e2) {
|
||||
throw new AssertionError(e2);
|
||||
} catch (NoSuchAlgorithmException e3) {
|
||||
throw new AssertionError(e3);
|
||||
} catch (CertificateException e4) {
|
||||
throw new AssertionError(e4);
|
||||
}
|
||||
}
|
||||
}
|
87
sources/io/fabric/sdk/android/services/network/UrlUtils.java
Normal file
87
sources/io/fabric/sdk/android/services/network/UrlUtils.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package io.fabric.sdk.android.services.network;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URI;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class UrlUtils {
|
||||
public static TreeMap<String, String> a(URI uri, boolean z) {
|
||||
return a(uri.getRawQuery(), z);
|
||||
}
|
||||
|
||||
public static String b(String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return URLDecoder.decode(str, "UTF8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String c(String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return URLEncoder.encode(str, "UTF8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static TreeMap<String, String> a(String str, boolean z) {
|
||||
TreeMap<String, String> treeMap = new TreeMap<>();
|
||||
if (str == null) {
|
||||
return treeMap;
|
||||
}
|
||||
for (String str2 : str.split("&")) {
|
||||
String[] split = str2.split("=");
|
||||
if (split.length == 2) {
|
||||
if (z) {
|
||||
treeMap.put(b(split[0]), b(split[1]));
|
||||
} else {
|
||||
treeMap.put(split[0], split[1]);
|
||||
}
|
||||
} else if (!TextUtils.isEmpty(split[0])) {
|
||||
if (z) {
|
||||
treeMap.put(b(split[0]), "");
|
||||
} else {
|
||||
treeMap.put(split[0], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return treeMap;
|
||||
}
|
||||
|
||||
public static String a(String str) {
|
||||
int i;
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String c = c(str);
|
||||
int length = c.length();
|
||||
int i2 = 0;
|
||||
while (i2 < length) {
|
||||
char charAt = c.charAt(i2);
|
||||
if (charAt == '*') {
|
||||
sb.append("%2A");
|
||||
} else if (charAt == '+') {
|
||||
sb.append("%20");
|
||||
} else if (charAt == '%' && (i = i2 + 2) < length && c.charAt(i2 + 1) == '7' && c.charAt(i) == 'E') {
|
||||
sb.append('~');
|
||||
i2 = i;
|
||||
} else {
|
||||
sb.append(charAt);
|
||||
}
|
||||
i2++;
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface FileStore {
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FileStoreImpl implements FileStore {
|
||||
private final Context a;
|
||||
|
||||
public FileStoreImpl(Kit kit) {
|
||||
if (kit.d() == null) {
|
||||
throw new IllegalStateException("Cannot get directory before context has been set. Call Fabric.with() first");
|
||||
}
|
||||
this.a = kit.d();
|
||||
kit.h();
|
||||
String str = "Android/" + this.a.getPackageName();
|
||||
}
|
||||
|
||||
public File a() {
|
||||
return a(this.a.getFilesDir());
|
||||
}
|
||||
|
||||
File a(File file) {
|
||||
if (file == null) {
|
||||
Fabric.g().d("Fabric", "Null File");
|
||||
return null;
|
||||
}
|
||||
if (file.exists() || file.mkdirs()) {
|
||||
return file;
|
||||
}
|
||||
Fabric.g().w("Fabric", "Couldn't create file");
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PersistenceStrategy<T> {
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PreferenceStore {
|
||||
boolean a(SharedPreferences.Editor editor);
|
||||
|
||||
SharedPreferences.Editor edit();
|
||||
|
||||
SharedPreferences get();
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PreferenceStoreImpl implements PreferenceStore {
|
||||
private final SharedPreferences a;
|
||||
private final String b;
|
||||
private final Context c;
|
||||
|
||||
public PreferenceStoreImpl(Context context, String str) {
|
||||
if (context == null) {
|
||||
throw new IllegalStateException("Cannot get directory before context has been set. Call Fabric.with() first");
|
||||
}
|
||||
this.c = context;
|
||||
this.b = str;
|
||||
this.a = this.c.getSharedPreferences(this.b, 0);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.persistence.PreferenceStore
|
||||
@TargetApi(9)
|
||||
public boolean a(SharedPreferences.Editor editor) {
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
return editor.commit();
|
||||
}
|
||||
editor.apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.persistence.PreferenceStore
|
||||
public SharedPreferences.Editor edit() {
|
||||
return this.a.edit();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.persistence.PreferenceStore
|
||||
public SharedPreferences get() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PreferenceStoreImpl(Kit kit) {
|
||||
this(kit.d(), kit.getClass().getName());
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PreferenceStoreStrategy<T> implements PersistenceStrategy<T> {
|
||||
private final PreferenceStore a;
|
||||
private final SerializationStrategy<T> b;
|
||||
private final String c;
|
||||
|
||||
public PreferenceStoreStrategy(PreferenceStore preferenceStore, SerializationStrategy<T> serializationStrategy, String str) {
|
||||
this.a = preferenceStore;
|
||||
this.b = serializationStrategy;
|
||||
this.c = str;
|
||||
}
|
||||
|
||||
@SuppressLint({"CommitPrefEdits"})
|
||||
public void a(T t) {
|
||||
PreferenceStore preferenceStore = this.a;
|
||||
preferenceStore.a(preferenceStore.edit().putString(this.c, this.b.serialize(t)));
|
||||
}
|
||||
|
||||
public T b() {
|
||||
return this.b.a(this.a.get().getString(this.c, null));
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.a.edit().remove(this.c).commit();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SerializationStrategy<T> {
|
||||
T a(String str);
|
||||
|
||||
String serialize(T t);
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.KitInfo;
|
||||
import io.fabric.sdk.android.services.common.AbstractSpiCall;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import io.fabric.sdk.android.services.common.ResponseParser;
|
||||
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.io.Closeable;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class AbstractAppSpiCall extends AbstractSpiCall implements AppSpiCall {
|
||||
public AbstractAppSpiCall(Kit kit, String str, String str2, HttpRequestFactory httpRequestFactory, HttpMethod httpMethod) {
|
||||
super(kit, str, str2, httpRequestFactory, httpMethod);
|
||||
}
|
||||
|
||||
private HttpRequest b(HttpRequest httpRequest, AppRequestData appRequestData) {
|
||||
httpRequest.e("app[identifier]", appRequestData.b);
|
||||
httpRequest.e("app[name]", appRequestData.f);
|
||||
httpRequest.e("app[display_version]", appRequestData.c);
|
||||
httpRequest.e("app[build_version]", appRequestData.d);
|
||||
httpRequest.a("app[source]", Integer.valueOf(appRequestData.g));
|
||||
httpRequest.e("app[minimum_sdk_version]", appRequestData.h);
|
||||
httpRequest.e("app[built_sdk_version]", appRequestData.i);
|
||||
if (!CommonUtils.a(appRequestData.e)) {
|
||||
httpRequest.e("app[instance_identifier]", appRequestData.e);
|
||||
}
|
||||
if (appRequestData.j != null) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
try {
|
||||
inputStream = this.e.d().getResources().openRawResource(appRequestData.j.b);
|
||||
httpRequest.e("app[icon][hash]", appRequestData.j.a);
|
||||
httpRequest.a("app[icon][data]", "icon.png", "application/octet-stream", inputStream);
|
||||
httpRequest.a("app[icon][width]", Integer.valueOf(appRequestData.j.c));
|
||||
httpRequest.a("app[icon][height]", Integer.valueOf(appRequestData.j.d));
|
||||
} catch (Resources.NotFoundException e) {
|
||||
Fabric.g().b("Fabric", "Failed to find app icon with resource ID: " + appRequestData.j.b, e);
|
||||
}
|
||||
} finally {
|
||||
CommonUtils.a((Closeable) inputStream, "Failed to close app icon InputStream.");
|
||||
}
|
||||
}
|
||||
Collection<KitInfo> collection = appRequestData.k;
|
||||
if (collection != null) {
|
||||
for (KitInfo kitInfo : collection) {
|
||||
httpRequest.e(b(kitInfo), kitInfo.c());
|
||||
httpRequest.e(a(kitInfo), kitInfo.a());
|
||||
}
|
||||
}
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
public boolean a(AppRequestData appRequestData) {
|
||||
HttpRequest a = a();
|
||||
a(a, appRequestData);
|
||||
b(a, appRequestData);
|
||||
Fabric.g().d("Fabric", "Sending app info to " + b());
|
||||
if (appRequestData.j != null) {
|
||||
Fabric.g().d("Fabric", "App icon hash is " + appRequestData.j.a);
|
||||
Fabric.g().d("Fabric", "App icon size is " + appRequestData.j.c + "x" + appRequestData.j.d);
|
||||
}
|
||||
int g = a.g();
|
||||
String str = "POST".equals(a.k()) ? "Create" : "Update";
|
||||
Fabric.g().d("Fabric", str + " app request ID: " + a.c("X-REQUEST-ID"));
|
||||
Fabric.g().d("Fabric", "Result was " + g);
|
||||
return ResponseParser.a(g) == 0;
|
||||
}
|
||||
|
||||
private HttpRequest a(HttpRequest httpRequest, AppRequestData appRequestData) {
|
||||
httpRequest.c("X-CRASHLYTICS-API-KEY", appRequestData.a);
|
||||
httpRequest.c("X-CRASHLYTICS-API-CLIENT-TYPE", "android");
|
||||
httpRequest.c("X-CRASHLYTICS-API-CLIENT-VERSION", this.e.i());
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
String a(KitInfo kitInfo) {
|
||||
return String.format(Locale.US, "app[build][libraries][%s][type]", kitInfo.b());
|
||||
}
|
||||
|
||||
String b(KitInfo kitInfo) {
|
||||
return String.format(Locale.US, "app[build][libraries][%s][version]", kitInfo.b());
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AnalyticsSettingsData {
|
||||
public final int a;
|
||||
public final int b;
|
||||
|
||||
public AnalyticsSettingsData(String str, int i, int i2, int i3, int i4, boolean z, boolean z2, int i5, boolean z3) {
|
||||
this.a = i;
|
||||
this.b = i4;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class AppIconSettingsData {
|
||||
public AppIconSettingsData(String str, int i, int i2) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import io.fabric.sdk.android.KitInfo;
|
||||
import java.util.Collection;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AppRequestData {
|
||||
public final String a;
|
||||
public final String b;
|
||||
public final String c;
|
||||
public final String d;
|
||||
public final String e;
|
||||
public final String f;
|
||||
public final int g;
|
||||
public final String h;
|
||||
public final String i;
|
||||
public final IconRequest j;
|
||||
public final Collection<KitInfo> k;
|
||||
|
||||
public AppRequestData(String str, String str2, String str3, String str4, String str5, String str6, int i, String str7, String str8, IconRequest iconRequest, Collection<KitInfo> collection) {
|
||||
this.a = str;
|
||||
this.b = str2;
|
||||
this.c = str3;
|
||||
this.d = str4;
|
||||
this.e = str5;
|
||||
this.f = str6;
|
||||
this.g = i;
|
||||
this.h = str7;
|
||||
this.i = str8;
|
||||
this.j = iconRequest;
|
||||
this.k = collection;
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class AppSettingsData {
|
||||
public final String a;
|
||||
public final String b;
|
||||
public final boolean c;
|
||||
|
||||
public AppSettingsData(String str, String str2, String str3, String str4, boolean z, AppIconSettingsData appIconSettingsData) {
|
||||
this.a = str2;
|
||||
this.b = str3;
|
||||
this.c = z;
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
interface AppSpiCall {
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BetaSettingsData {
|
||||
public BetaSettingsData(String str, int i) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface CachedSettingsIo {
|
||||
JSONObject a();
|
||||
|
||||
void a(long j, JSONObject jSONObject);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.network.HttpMethod;
|
||||
import io.fabric.sdk.android.services.network.HttpRequestFactory;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class CreateAppSpiCall extends AbstractAppSpiCall {
|
||||
public CreateAppSpiCall(Kit kit, String str, String str2, HttpRequestFactory httpRequestFactory) {
|
||||
super(kit, str, str2, httpRequestFactory, HttpMethod.POST);
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import io.fabric.sdk.android.services.persistence.FileStoreImpl;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class DefaultCachedSettingsIo implements CachedSettingsIo {
|
||||
private final Kit a;
|
||||
|
||||
public DefaultCachedSettingsIo(Kit kit) {
|
||||
this.a = kit;
|
||||
}
|
||||
|
||||
/* JADX WARN: Not initialized variable reg: 4, insn: 0x005a: MOVE (r1 I:??[OBJECT, ARRAY]) = (r4 I:??[OBJECT, ARRAY]), block:B:20:0x0059 */
|
||||
@Override // io.fabric.sdk.android.services.settings.CachedSettingsIo
|
||||
public JSONObject a() {
|
||||
FileInputStream fileInputStream;
|
||||
FileInputStream fileInputStream2;
|
||||
JSONObject jSONObject;
|
||||
Fabric.g().d("Fabric", "Reading cached settings...");
|
||||
FileInputStream fileInputStream3 = null;
|
||||
try {
|
||||
try {
|
||||
File file = new File(new FileStoreImpl(this.a).a(), "com.crashlytics.settings.json");
|
||||
if (file.exists()) {
|
||||
fileInputStream = new FileInputStream(file);
|
||||
try {
|
||||
jSONObject = new JSONObject(CommonUtils.b(fileInputStream));
|
||||
fileInputStream3 = fileInputStream;
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
Fabric.g().b("Fabric", "Failed to fetch cached settings", e);
|
||||
CommonUtils.a((Closeable) fileInputStream, "Error while closing settings cache file.");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
Fabric.g().d("Fabric", "No cached settings found.");
|
||||
jSONObject = null;
|
||||
}
|
||||
CommonUtils.a((Closeable) fileInputStream3, "Error while closing settings cache file.");
|
||||
return jSONObject;
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
fileInputStream = null;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
CommonUtils.a((Closeable) fileInputStream3, "Error while closing settings cache file.");
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
fileInputStream3 = fileInputStream2;
|
||||
CommonUtils.a((Closeable) fileInputStream3, "Error while closing settings cache file.");
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.settings.CachedSettingsIo
|
||||
public void a(long j, JSONObject jSONObject) {
|
||||
Fabric.g().d("Fabric", "Writing settings to cache file...");
|
||||
if (jSONObject == null) {
|
||||
return;
|
||||
}
|
||||
FileWriter fileWriter = null;
|
||||
try {
|
||||
try {
|
||||
jSONObject.put("expires_at", j);
|
||||
FileWriter fileWriter2 = new FileWriter(new File(new FileStoreImpl(this.a).a(), "com.crashlytics.settings.json"));
|
||||
try {
|
||||
fileWriter2.write(jSONObject.toString());
|
||||
fileWriter2.flush();
|
||||
CommonUtils.a(fileWriter2, "Failed to close settings writer.");
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
fileWriter = fileWriter2;
|
||||
Fabric.g().b("Fabric", "Failed to cache settings", e);
|
||||
CommonUtils.a(fileWriter, "Failed to close settings writer.");
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
fileWriter = fileWriter2;
|
||||
CommonUtils.a(fileWriter, "Failed to close settings writer.");
|
||||
throw th;
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import io.fabric.sdk.android.services.common.CurrentTimeProvider;
|
||||
import io.fabric.sdk.android.services.persistence.PreferenceStore;
|
||||
import io.fabric.sdk.android.services.persistence.PreferenceStoreImpl;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class DefaultSettingsController implements SettingsController {
|
||||
private final SettingsRequest a;
|
||||
private final SettingsJsonTransform b;
|
||||
private final CurrentTimeProvider c;
|
||||
private final CachedSettingsIo d;
|
||||
private final SettingsSpiCall e;
|
||||
private final Kit f;
|
||||
private final PreferenceStore g;
|
||||
|
||||
public DefaultSettingsController(Kit kit, SettingsRequest settingsRequest, CurrentTimeProvider currentTimeProvider, SettingsJsonTransform settingsJsonTransform, CachedSettingsIo cachedSettingsIo, SettingsSpiCall settingsSpiCall) {
|
||||
this.f = kit;
|
||||
this.a = settingsRequest;
|
||||
this.c = currentTimeProvider;
|
||||
this.b = settingsJsonTransform;
|
||||
this.d = cachedSettingsIo;
|
||||
this.e = settingsSpiCall;
|
||||
this.g = new PreferenceStoreImpl(this.f);
|
||||
}
|
||||
|
||||
private SettingsData b(SettingsCacheBehavior settingsCacheBehavior) {
|
||||
SettingsData settingsData = null;
|
||||
try {
|
||||
if (!SettingsCacheBehavior.SKIP_CACHE_LOOKUP.equals(settingsCacheBehavior)) {
|
||||
JSONObject a = this.d.a();
|
||||
if (a != null) {
|
||||
SettingsData a2 = this.b.a(this.c, a);
|
||||
if (a2 != null) {
|
||||
a(a, "Loaded cached settings: ");
|
||||
long a3 = this.c.a();
|
||||
if (!SettingsCacheBehavior.IGNORE_CACHE_EXPIRATION.equals(settingsCacheBehavior) && a2.a(a3)) {
|
||||
Fabric.g().d("Fabric", "Cached settings have expired.");
|
||||
}
|
||||
try {
|
||||
Fabric.g().d("Fabric", "Returning cached settings.");
|
||||
settingsData = a2;
|
||||
} catch (Exception e) {
|
||||
e = e;
|
||||
settingsData = a2;
|
||||
Fabric.g().b("Fabric", "Failed to get cached settings", e);
|
||||
return settingsData;
|
||||
}
|
||||
} else {
|
||||
Fabric.g().b("Fabric", "Failed to transform cached settings data.", null);
|
||||
}
|
||||
} else {
|
||||
Fabric.g().d("Fabric", "No cached settings data found.");
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
e = e2;
|
||||
}
|
||||
return settingsData;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.settings.SettingsController
|
||||
public SettingsData a() {
|
||||
return a(SettingsCacheBehavior.USE_CACHE);
|
||||
}
|
||||
|
||||
String c() {
|
||||
return CommonUtils.a(CommonUtils.g(this.f.d()));
|
||||
}
|
||||
|
||||
String d() {
|
||||
return this.g.get().getString("existing_instance_identifier", "");
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.settings.SettingsController
|
||||
public SettingsData a(SettingsCacheBehavior settingsCacheBehavior) {
|
||||
JSONObject a;
|
||||
SettingsData settingsData = null;
|
||||
try {
|
||||
if (!Fabric.i() && !b()) {
|
||||
settingsData = b(settingsCacheBehavior);
|
||||
}
|
||||
if (settingsData == null && (a = this.e.a(this.a)) != null) {
|
||||
settingsData = this.b.a(this.c, a);
|
||||
this.d.a(settingsData.c, a);
|
||||
a(a, "Loaded settings: ");
|
||||
a(c());
|
||||
}
|
||||
return settingsData == null ? b(SettingsCacheBehavior.IGNORE_CACHE_EXPIRATION) : settingsData;
|
||||
} catch (Exception e) {
|
||||
Fabric.g().b("Fabric", "Unknown error while loading Crashlytics settings. Crashes will be cached until settings can be retrieved.", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(JSONObject jSONObject, String str) throws JSONException {
|
||||
Fabric.g().d("Fabric", str + jSONObject.toString());
|
||||
}
|
||||
|
||||
@SuppressLint({"CommitPrefEdits"})
|
||||
boolean a(String str) {
|
||||
SharedPreferences.Editor edit = this.g.edit();
|
||||
edit.putString("existing_instance_identifier", str);
|
||||
return this.g.a(edit);
|
||||
}
|
||||
|
||||
boolean b() {
|
||||
return !d().equals(c());
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import com.baidu.cloud.media.player.misc.IMediaFormat;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import io.fabric.sdk.android.services.common.CurrentTimeProvider;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class DefaultSettingsJsonTransform implements SettingsJsonTransform {
|
||||
DefaultSettingsJsonTransform() {
|
||||
}
|
||||
|
||||
private AppSettingsData b(JSONObject jSONObject) throws JSONException {
|
||||
return new AppSettingsData(jSONObject.getString("identifier"), jSONObject.getString(FileDownloadModel.STATUS), jSONObject.getString("url"), jSONObject.getString("reports_url"), jSONObject.optBoolean("update_required", false), (jSONObject.has("icon") && jSONObject.getJSONObject("icon").has("hash")) ? e(jSONObject.getJSONObject("icon")) : null);
|
||||
}
|
||||
|
||||
private BetaSettingsData c(JSONObject jSONObject) throws JSONException {
|
||||
return new BetaSettingsData(jSONObject.optString("update_endpoint", SettingsJsonConstants.a), jSONObject.optInt("update_suspend_duration", 3600));
|
||||
}
|
||||
|
||||
private FeaturesSettingsData d(JSONObject jSONObject) {
|
||||
return new FeaturesSettingsData(jSONObject.optBoolean("prompt_enabled", false), jSONObject.optBoolean("collect_logged_exceptions", true), jSONObject.optBoolean("collect_reports", true), jSONObject.optBoolean("collect_analytics", false));
|
||||
}
|
||||
|
||||
private AppIconSettingsData e(JSONObject jSONObject) throws JSONException {
|
||||
return new AppIconSettingsData(jSONObject.getString("hash"), jSONObject.getInt(IMediaFormat.KEY_WIDTH), jSONObject.getInt(IMediaFormat.KEY_HEIGHT));
|
||||
}
|
||||
|
||||
private PromptSettingsData f(JSONObject jSONObject) throws JSONException {
|
||||
return new PromptSettingsData(jSONObject.optString("title", "Send Crash Report?"), jSONObject.optString("message", "Looks like we crashed! Please help us fix the problem by sending a crash report."), jSONObject.optString("send_button_title", "Send"), jSONObject.optBoolean("show_cancel_button", true), jSONObject.optString("cancel_button_title", "Don't Send"), jSONObject.optBoolean("show_always_send_button", true), jSONObject.optString("always_send_button_title", "Always Send"));
|
||||
}
|
||||
|
||||
private SessionSettingsData g(JSONObject jSONObject) throws JSONException {
|
||||
return new SessionSettingsData(jSONObject.optInt("log_buffer_size", 64000), jSONObject.optInt("max_chained_exception_depth", 8), jSONObject.optInt("max_custom_exception_events", 64), jSONObject.optInt("max_custom_key_value_pairs", 64), jSONObject.optInt("identifier_mask", 255), jSONObject.optBoolean("send_session_without_crash", false), jSONObject.optInt("max_complete_sessions_count", 4));
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.settings.SettingsJsonTransform
|
||||
public SettingsData a(CurrentTimeProvider currentTimeProvider, JSONObject jSONObject) throws JSONException {
|
||||
int optInt = jSONObject.optInt("settings_version", 0);
|
||||
int optInt2 = jSONObject.optInt("cache_duration", 3600);
|
||||
return new SettingsData(a(currentTimeProvider, optInt2, jSONObject), b(jSONObject.getJSONObject("app")), g(jSONObject.getJSONObject("session")), f(jSONObject.getJSONObject("prompt")), d(jSONObject.getJSONObject("features")), a(jSONObject.getJSONObject("analytics")), c(jSONObject.getJSONObject("beta")), optInt, optInt2);
|
||||
}
|
||||
|
||||
private AnalyticsSettingsData a(JSONObject jSONObject) {
|
||||
return new AnalyticsSettingsData(jSONObject.optString("url", "https://e.crashlytics.com/spi/v2/events"), jSONObject.optInt("flush_interval_secs", 600), jSONObject.optInt("max_byte_size_per_file", 8000), jSONObject.optInt("max_file_count_per_send", 1), jSONObject.optInt("max_pending_send_file_count", 100), jSONObject.optBoolean("track_custom_events", true), jSONObject.optBoolean("track_predefined_events", true), jSONObject.optInt("sampling_rate", 1), jSONObject.optBoolean("flush_on_background", true));
|
||||
}
|
||||
|
||||
private long a(CurrentTimeProvider currentTimeProvider, long j, JSONObject jSONObject) throws JSONException {
|
||||
if (jSONObject.has("expires_at")) {
|
||||
return jSONObject.getLong("expires_at");
|
||||
}
|
||||
return currentTimeProvider.a() + (j * 1000);
|
||||
}
|
||||
}
|
@@ -0,0 +1,172 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import com.tencent.open.SocialConstants;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.common.AbstractSpiCall;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
class DefaultSettingsSpiCall extends AbstractSpiCall implements SettingsSpiCall {
|
||||
public DefaultSettingsSpiCall(Kit kit, String str, String str2, HttpRequestFactory httpRequestFactory) {
|
||||
this(kit, str, str2, httpRequestFactory, HttpMethod.GET);
|
||||
}
|
||||
|
||||
private Map<String, String> b(SettingsRequest settingsRequest) {
|
||||
HashMap hashMap = new HashMap();
|
||||
hashMap.put("build_version", settingsRequest.j);
|
||||
hashMap.put("display_version", settingsRequest.i);
|
||||
hashMap.put(SocialConstants.PARAM_SOURCE, Integer.toString(settingsRequest.k));
|
||||
String str = settingsRequest.l;
|
||||
if (str != null) {
|
||||
hashMap.put("icon_hash", str);
|
||||
}
|
||||
String str2 = settingsRequest.h;
|
||||
if (!CommonUtils.a(str2)) {
|
||||
hashMap.put("instance", str2);
|
||||
}
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
/* JADX WARN: Removed duplicated region for block: B:19:0x0087 */
|
||||
/* JADX WARN: Type inference failed for: r3v0, types: [io.fabric.sdk.android.services.network.HttpRequest] */
|
||||
/* JADX WARN: Type inference failed for: r3v10 */
|
||||
/* JADX WARN: Type inference failed for: r3v9 */
|
||||
@Override // io.fabric.sdk.android.services.settings.SettingsSpiCall
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
public org.json.JSONObject a(io.fabric.sdk.android.services.settings.SettingsRequest r9) {
|
||||
/*
|
||||
r8 = this;
|
||||
java.lang.String r0 = "X-REQUEST-ID"
|
||||
java.lang.String r1 = "Settings request ID: "
|
||||
java.lang.String r2 = "Fabric"
|
||||
r3 = 0
|
||||
java.util.Map r4 = r8.b(r9) // Catch: java.lang.Throwable -> L69 io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L6c
|
||||
io.fabric.sdk.android.services.network.HttpRequest r5 = r8.a(r4) // Catch: java.lang.Throwable -> L69 io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L6c
|
||||
r8.a(r5, r9) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
io.fabric.sdk.android.Logger r9 = io.fabric.sdk.android.Fabric.g() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.StringBuilder r6 = new java.lang.StringBuilder // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
r6.<init>() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.String r7 = "Requesting settings from "
|
||||
r6.append(r7) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.String r7 = r8.b() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
r6.append(r7) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.String r6 = r6.toString() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
r9.d(r2, r6) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
io.fabric.sdk.android.Logger r9 = io.fabric.sdk.android.Fabric.g() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.StringBuilder r6 = new java.lang.StringBuilder // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
r6.<init>() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.String r7 = "Settings query params were: "
|
||||
r6.append(r7) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
r6.append(r4) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
java.lang.String r4 = r6.toString() // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
r9.d(r2, r4) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
org.json.JSONObject r3 = r8.a(r5) // Catch: io.fabric.sdk.android.services.network.HttpRequest.HttpRequestException -> L67 java.lang.Throwable -> L84
|
||||
if (r5 == 0) goto L83
|
||||
io.fabric.sdk.android.Logger r9 = io.fabric.sdk.android.Fabric.g()
|
||||
java.lang.StringBuilder r4 = new java.lang.StringBuilder
|
||||
r4.<init>()
|
||||
L55:
|
||||
r4.append(r1)
|
||||
java.lang.String r0 = r5.c(r0)
|
||||
r4.append(r0)
|
||||
java.lang.String r0 = r4.toString()
|
||||
r9.d(r2, r0)
|
||||
goto L83
|
||||
L67:
|
||||
r9 = move-exception
|
||||
goto L6e
|
||||
L69:
|
||||
r9 = move-exception
|
||||
r5 = r3
|
||||
goto L85
|
||||
L6c:
|
||||
r9 = move-exception
|
||||
r5 = r3
|
||||
L6e:
|
||||
io.fabric.sdk.android.Logger r4 = io.fabric.sdk.android.Fabric.g() // Catch: java.lang.Throwable -> L84
|
||||
java.lang.String r6 = "Settings request failed."
|
||||
r4.b(r2, r6, r9) // Catch: java.lang.Throwable -> L84
|
||||
if (r5 == 0) goto L83
|
||||
io.fabric.sdk.android.Logger r9 = io.fabric.sdk.android.Fabric.g()
|
||||
java.lang.StringBuilder r4 = new java.lang.StringBuilder
|
||||
r4.<init>()
|
||||
goto L55
|
||||
L83:
|
||||
return r3
|
||||
L84:
|
||||
r9 = move-exception
|
||||
L85:
|
||||
if (r5 == 0) goto La1
|
||||
io.fabric.sdk.android.Logger r3 = io.fabric.sdk.android.Fabric.g()
|
||||
java.lang.StringBuilder r4 = new java.lang.StringBuilder
|
||||
r4.<init>()
|
||||
r4.append(r1)
|
||||
java.lang.String r0 = r5.c(r0)
|
||||
r4.append(r0)
|
||||
java.lang.String r0 = r4.toString()
|
||||
r3.d(r2, r0)
|
||||
La1:
|
||||
throw r9
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: io.fabric.sdk.android.services.settings.DefaultSettingsSpiCall.a(io.fabric.sdk.android.services.settings.SettingsRequest):org.json.JSONObject");
|
||||
}
|
||||
|
||||
boolean a(int i) {
|
||||
return i == 200 || i == 201 || i == 202 || i == 203;
|
||||
}
|
||||
|
||||
DefaultSettingsSpiCall(Kit kit, String str, String str2, HttpRequestFactory httpRequestFactory, HttpMethod httpMethod) {
|
||||
super(kit, str, str2, httpRequestFactory, httpMethod);
|
||||
}
|
||||
|
||||
JSONObject a(HttpRequest httpRequest) {
|
||||
int g = httpRequest.g();
|
||||
Fabric.g().d("Fabric", "Settings result was: " + g);
|
||||
if (a(g)) {
|
||||
return a(httpRequest.a());
|
||||
}
|
||||
Fabric.g().e("Fabric", "Failed to retrieve settings from " + b());
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONObject a(String str) {
|
||||
try {
|
||||
return new JSONObject(str);
|
||||
} catch (Exception e) {
|
||||
Fabric.g().c("Fabric", "Failed to parse settings JSON from " + b(), e);
|
||||
Fabric.g().d("Fabric", "Settings response " + str);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest a(HttpRequest httpRequest, SettingsRequest settingsRequest) {
|
||||
a(httpRequest, "X-CRASHLYTICS-API-KEY", settingsRequest.a);
|
||||
a(httpRequest, "X-CRASHLYTICS-API-CLIENT-TYPE", "android");
|
||||
a(httpRequest, "X-CRASHLYTICS-API-CLIENT-VERSION", this.e.i());
|
||||
a(httpRequest, "Accept", "application/json");
|
||||
a(httpRequest, "X-CRASHLYTICS-DEVICE-MODEL", settingsRequest.b);
|
||||
a(httpRequest, "X-CRASHLYTICS-OS-BUILD-VERSION", settingsRequest.c);
|
||||
a(httpRequest, "X-CRASHLYTICS-OS-DISPLAY-VERSION", settingsRequest.d);
|
||||
a(httpRequest, "X-CRASHLYTICS-ADVERTISING-TOKEN", settingsRequest.e);
|
||||
a(httpRequest, "X-CRASHLYTICS-INSTALLATION-ID", settingsRequest.f);
|
||||
a(httpRequest, "X-CRASHLYTICS-ANDROID-ID", settingsRequest.g);
|
||||
return httpRequest;
|
||||
}
|
||||
|
||||
private void a(HttpRequest httpRequest, String str, String str2) {
|
||||
if (str2 != null) {
|
||||
httpRequest.c(str, str2);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FeaturesSettingsData {
|
||||
public FeaturesSettingsData(boolean z, boolean z2, boolean z3, boolean z4) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class IconRequest {
|
||||
public final String a;
|
||||
public final int b;
|
||||
public final int c;
|
||||
public final int d;
|
||||
|
||||
public IconRequest(String str, int i, int i2, int i3) {
|
||||
this.a = str;
|
||||
this.b = i;
|
||||
this.c = i2;
|
||||
this.d = i3;
|
||||
}
|
||||
|
||||
public static IconRequest a(Context context, String str) {
|
||||
if (str != null) {
|
||||
try {
|
||||
int b = CommonUtils.b(context);
|
||||
Fabric.g().d("Fabric", "App icon resource ID is " + b);
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeResource(context.getResources(), b, options);
|
||||
return new IconRequest(str, b, options.outWidth, options.outHeight);
|
||||
} catch (Exception e) {
|
||||
Fabric.g().b("Fabric", "Failed to load icon", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PromptSettingsData {
|
||||
public PromptSettingsData(String str, String str2, String str3, boolean z, String str4, boolean z2, String str5) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SessionSettingsData {
|
||||
public SessionSettingsData(int i, int i2, int i3, int i4, int i5, boolean z, int i6) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.common.ApiKey;
|
||||
import io.fabric.sdk.android.services.common.CommonUtils;
|
||||
import io.fabric.sdk.android.services.common.DeliveryMechanism;
|
||||
import io.fabric.sdk.android.services.common.IdManager;
|
||||
import io.fabric.sdk.android.services.common.SystemCurrentTimeProvider;
|
||||
import io.fabric.sdk.android.services.network.HttpRequestFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Settings {
|
||||
private final AtomicReference<SettingsData> a;
|
||||
private final CountDownLatch b;
|
||||
private SettingsController c;
|
||||
private boolean d;
|
||||
|
||||
static class LazyHolder {
|
||||
private static final Settings a = new Settings();
|
||||
}
|
||||
|
||||
public static Settings d() {
|
||||
return LazyHolder.a;
|
||||
}
|
||||
|
||||
public synchronized Settings a(Kit kit, IdManager idManager, HttpRequestFactory httpRequestFactory, String str, String str2, String str3) {
|
||||
if (this.d) {
|
||||
return this;
|
||||
}
|
||||
if (this.c == null) {
|
||||
Context d = kit.d();
|
||||
String d2 = idManager.d();
|
||||
String c = new ApiKey().c(d);
|
||||
String g = idManager.g();
|
||||
this.c = new DefaultSettingsController(kit, new SettingsRequest(c, idManager.h(), idManager.i(), idManager.j(), idManager.a(), idManager.e(), idManager.c(), CommonUtils.a(CommonUtils.g(d)), str2, str, DeliveryMechanism.determineFrom(g).getId(), CommonUtils.a(d)), new SystemCurrentTimeProvider(), new DefaultSettingsJsonTransform(), new DefaultCachedSettingsIo(kit), new DefaultSettingsSpiCall(kit, str3, String.format(Locale.US, "https://settings.crashlytics.com/spi/v2/platforms/android/apps/%s/settings", d2), httpRequestFactory));
|
||||
}
|
||||
this.d = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public synchronized boolean b() {
|
||||
SettingsData a;
|
||||
a = this.c.a();
|
||||
a(a);
|
||||
return a != null;
|
||||
}
|
||||
|
||||
public synchronized boolean c() {
|
||||
SettingsData a;
|
||||
a = this.c.a(SettingsCacheBehavior.SKIP_CACHE_LOOKUP);
|
||||
a(a);
|
||||
if (a == null) {
|
||||
Fabric.g().b("Fabric", "Failed to force reload of settings from Crashlytics.", null);
|
||||
}
|
||||
return a != null;
|
||||
}
|
||||
|
||||
private Settings() {
|
||||
this.a = new AtomicReference<>();
|
||||
this.b = new CountDownLatch(1);
|
||||
this.d = false;
|
||||
}
|
||||
|
||||
public SettingsData a() {
|
||||
try {
|
||||
this.b.await();
|
||||
return this.a.get();
|
||||
} catch (InterruptedException unused) {
|
||||
Fabric.g().e("Fabric", "Interrupted while waiting for settings data.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void a(SettingsData settingsData) {
|
||||
this.a.set(settingsData);
|
||||
this.b.countDown();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public enum SettingsCacheBehavior {
|
||||
USE_CACHE,
|
||||
SKIP_CACHE_LOOKUP,
|
||||
IGNORE_CACHE_EXPIRATION
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SettingsController {
|
||||
SettingsData a();
|
||||
|
||||
SettingsData a(SettingsCacheBehavior settingsCacheBehavior);
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SettingsData {
|
||||
public final AppSettingsData a;
|
||||
public final AnalyticsSettingsData b;
|
||||
public final long c;
|
||||
|
||||
public SettingsData(long j, AppSettingsData appSettingsData, SessionSettingsData sessionSettingsData, PromptSettingsData promptSettingsData, FeaturesSettingsData featuresSettingsData, AnalyticsSettingsData analyticsSettingsData, BetaSettingsData betaSettingsData, int i, int i2) {
|
||||
this.c = j;
|
||||
this.a = appSettingsData;
|
||||
this.b = analyticsSettingsData;
|
||||
}
|
||||
|
||||
public boolean a(long j) {
|
||||
return this.c < j;
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SettingsJsonConstants {
|
||||
public static final String a = null;
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import io.fabric.sdk.android.services.common.CurrentTimeProvider;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SettingsJsonTransform {
|
||||
SettingsData a(CurrentTimeProvider currentTimeProvider, JSONObject jSONObject) throws JSONException;
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class SettingsRequest {
|
||||
public final String a;
|
||||
public final String b;
|
||||
public final String c;
|
||||
public final String d;
|
||||
public final String e;
|
||||
public final String f;
|
||||
public final String g;
|
||||
public final String h;
|
||||
public final String i;
|
||||
public final String j;
|
||||
public final int k;
|
||||
public final String l;
|
||||
|
||||
public SettingsRequest(String str, String str2, String str3, String str4, String str5, String str6, String str7, String str8, String str9, String str10, int i, String str11) {
|
||||
this.a = str;
|
||||
this.b = str2;
|
||||
this.c = str3;
|
||||
this.d = str4;
|
||||
this.e = str5;
|
||||
this.f = str6;
|
||||
this.g = str7;
|
||||
this.h = str8;
|
||||
this.i = str9;
|
||||
this.j = str10;
|
||||
this.k = i;
|
||||
this.l = str11;
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SettingsSpiCall {
|
||||
JSONObject a(SettingsRequest settingsRequest);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package io.fabric.sdk.android.services.settings;
|
||||
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import io.fabric.sdk.android.services.network.HttpMethod;
|
||||
import io.fabric.sdk.android.services.network.HttpRequestFactory;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class UpdateAppSpiCall extends AbstractAppSpiCall {
|
||||
public UpdateAppSpiCall(Kit kit, String str, String str2, HttpRequestFactory httpRequestFactory) {
|
||||
super(kit, str, str2, httpRequestFactory, HttpMethod.PUT);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user