Initial commit
This commit is contained in:
@@ -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