what-the-bank/sources/o/GXL.java

115 lines
3.9 KiB
Java

package o;
import com.airbnb.deeplinkdispatch.UrlTreeKt;
import com.google.firebase.crashlytics.internal.common.IdManager;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.Iterator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public final class GXL implements vbd {
private final JSONObject a;
/* JADX INFO: Access modifiers changed from: package-private */
public GXL(InputStream inputStream, String str) {
JSONObject jSONObject;
JSONObject d = d(inputStream);
this.a = d;
try {
JSONArray jSONArray = d.getJSONArray("appInfos");
int i = 0;
while (true) {
if (i >= jSONArray.length()) {
jSONObject = null;
break;
}
jSONObject = jSONArray.getJSONObject(i);
if (jSONObject.getString("package_name").equals(str)) {
break;
} else {
i++;
}
}
if (jSONObject != null) {
String a = a("/configuration_version", "");
BigDecimal bigDecimal = new BigDecimal(IdManager.DEFAULT_VERSION_NAME);
try {
bigDecimal = BigDecimal.valueOf(Double.parseDouble(a));
} catch (NumberFormatException unused) {
}
if (bigDecimal.compareTo(new BigDecimal("2.0")) == 0) {
this.a.getJSONObject("client").put(HiAnalyticsConstant.BI_KEY_APP_ID, jSONObject.getString(HiAnalyticsConstant.BI_KEY_APP_ID));
return;
}
if (bigDecimal.compareTo(new BigDecimal("3.0")) >= 0) {
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
if (!"package_name".equals(next)) {
d(next, jSONObject.get(next), this.a);
}
}
}
}
} catch (JSONException unused2) {
}
}
public final String toString() {
StringBuilder sb = new StringBuilder("InputStreamReader{config=");
sb.append(this.a.toString().hashCode());
sb.append(UrlTreeKt.componentParamSuffixChar);
return sb.toString();
}
@Override // o.vbd
public final String a(String str, String str2) {
if (str.endsWith("/")) {
return str2;
}
String[] split = str.split("/");
try {
JSONObject jSONObject = this.a;
for (int i = 1; i < split.length; i++) {
if (i == split.length - 1) {
return jSONObject.get(split[i]).toString();
}
jSONObject = jSONObject.getJSONObject(split[i]);
}
} catch (JSONException unused) {
}
return str2;
}
private void d(String str, Object obj, JSONObject jSONObject) throws JSONException {
if (str == null || obj == null || jSONObject == null) {
return;
}
if (!(obj instanceof JSONObject)) {
jSONObject.put(str, obj);
return;
}
JSONObject jSONObject2 = (JSONObject) obj;
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
d(next, jSONObject2.get(next), jSONObject.getJSONObject(str));
}
}
private static JSONObject d(InputStream inputStream) {
if (inputStream != null) {
try {
return new JSONObject(C5595bvy.d(inputStream, "UTF-8"));
} catch (IOException | JSONException unused) {
}
}
return new JSONObject();
}
}