Free Fire v1.103.1版本的 MD5 值为:f6c45f9f1485263aa5af0fb400f973fc
以下内容为反编译后的 j0.java 源代码,内容仅作参考
package h2;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import h2.j0;
import h2.n0;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import x2.h0;
public final class j0 {
public static final c f8485n = new c(null);
public static final String f8486o = j0.class.getSimpleName();
private static final String f8487p;
private static String f8488q;
private static final Pattern f8489r;
private static volatile String f8490s;
private h2.a f8491a;
private String f8492b;
private JSONObject f8493c;
private String f8494d;
private String f8495e;
private boolean f8496f;
private Bundle f8497g;
private Object f8498h;
private String f8499i;
private b f8500j;
private p0 f8501k;
private boolean f8502l;
private String f8503m;
public static final class a {
private final j0 f8504a;
private final Object f8505b;
public a(j0 j0Var, Object obj) {
ia.i.e(j0Var, "request");
this.f8504a = j0Var;
this.f8505b = obj;
}
public final j0 a() {
return this.f8504a;
}
public final Object b() {
return this.f8505b;
}
}
public interface b {
void b(o0 o0Var);
}
public static final class c {
private c() {
}
public c(ia.f fVar) {
this();
}
public final String C(Object obj) {
if (obj instanceof String) {
return (String) obj;
}
if ((obj instanceof Boolean) || (obj instanceof Number)) {
return obj.toString();
}
if (obj instanceof Date) {
String format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US).format((Date) obj);
ia.i.d(format, "iso8601DateFormat.format(value)");
return format;
}
throw new IllegalArgumentException("Unsupported parameter type.");
}
public final void D(JSONObject jSONObject, String str, e eVar) {
boolean z10;
Iterator<String> keys;
boolean z11;
boolean f10;
int z12;
int z13;
if (u(str)) {
z12 = pa.q.z(str, ":", 0, false, 6, null);
z13 = pa.q.z(str, "?", 0, false, 6, null);
if (z12 > 3 && (z13 == -1 || z12 < z13)) {
z10 = true;
keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
Object opt = jSONObject.opt(next);
if (z10) {
f10 = pa.p.f(next, "image", true);
if (f10) {
z11 = true;
ia.i.d(next, "key");
ia.i.d(opt, "value");
E(next, opt, eVar, z11);
}
}
z11 = false;
ia.i.d(next, "key");
ia.i.d(opt, "value");
E(next, opt, eVar, z11);
}
}
}
z10 = false;
keys = jSONObject.keys();
while (keys.hasNext()) {
}
}
private final void E(String str, Object obj, e eVar, boolean z10) {
String obj2;
String jSONObject;
String str2;
Class<?> cls = obj.getClass();
if (JSONObject.class.isAssignableFrom(cls)) {
JSONObject jSONObject2 = (JSONObject) obj;
if (z10) {
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
ia.n nVar = ia.n.f9196a;
String format = String.format("%s[%s]", Arrays.copyOf(new Object[]{str, next}, 2));
ia.i.d(format, "java.lang.String.format(format, *args)");
Object opt = jSONObject2.opt(next);
ia.i.d(opt, "jsonObject.opt(propertyName)");
E(format, opt, eVar, z10);
}
return;
}
if (jSONObject2.has("id")) {
jSONObject = jSONObject2.optString("id");
str2 = "jsonObject.optString(\"id\")";
} else if (jSONObject2.has("url")) {
jSONObject = jSONObject2.optString("url");
str2 = "jsonObject.optString(\"url\")";
} else if (!jSONObject2.has("fbsdk:create_object")) {
return;
} else {
jSONObject = jSONObject2.toString();
str2 = "jsonObject.toString()";
}
ia.i.d(jSONObject, str2);
E(str, jSONObject, eVar, z10);
} else if (!JSONArray.class.isAssignableFrom(cls)) {
if (String.class.isAssignableFrom(cls) || Number.class.isAssignableFrom(cls) || Boolean.class.isAssignableFrom(cls)) {
obj2 = obj.toString();
} else if (!Date.class.isAssignableFrom(cls)) {
x2.t0 t0Var = x2.t0.f14355a;
String str3 = j0.f8486o;
x2.t0.k0(str3, "The type of property " + str + " in the graph object is unknown. It won't be sent in the request.");
return;
} else {
obj2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US).format((Date) obj);
ia.i.d(obj2, "iso8601DateFormat.format(date)");
}
eVar.a(str, obj2);
} else {
JSONArray jSONArray = (JSONArray) obj;
int length = jSONArray.length();
if (length <= 0) {
return;
}
int i10 = 0;
while (true) {
int i11 = i10 + 1;
ia.n nVar2 = ia.n.f9196a;
String format2 = String.format(Locale.ROOT, "%s[%d]", Arrays.copyOf(new Object[]{str, Integer.valueOf(i10)}, 2));
ia.i.d(format2, "java.lang.String.format(locale, format, *args)");
Object opt2 = jSONArray.opt(i10);
ia.i.d(opt2, "jsonArray.opt(i)");
E(format2, opt2, eVar, z10);
if (i11 >= length) {
return;
}
i10 = i11;
}
}
}
private final void F(n0 n0Var, x2.h0 h0Var, int i10, URL url, OutputStream outputStream, boolean z10) {
h hVar = new h(outputStream, h0Var, z10);
if (i10 != 1) {
String p10 = p(n0Var);
if (p10.length() == 0) {
throw new s("App ID was not specified at the request or Settings.");
}
hVar.a("batch_app_id", p10);
Map<String, a> hashMap = new HashMap<>();
K(hVar, n0Var, hashMap);
if (h0Var != null) {
h0Var.b(" Attachments:\n");
}
I(hashMap, hVar);
return;
}
j0 j0Var = n0Var.get(0);
Map<String, a> hashMap2 = new HashMap<>();
for (String str : j0Var.u().keySet()) {
Object obj = j0Var.u().get(str);
if (v(obj)) {
ia.i.d(str, "key");
hashMap2.put(str, new a(j0Var, obj));
}
}
if (h0Var != null) {
h0Var.b(" Parameters:\n");
}
J(j0Var.u(), hVar, j0Var);
if (h0Var != null) {
h0Var.b(" Attachments:\n");
}
I(hashMap2, hVar);
JSONObject q10 = j0Var.q();
if (q10 != null) {
String path = url.getPath();
ia.i.d(path, "url.path");
D(q10, path, hVar);
}
}
public static final void H(ArrayList arrayList, n0 n0Var) {
ia.i.e(arrayList, "$callbacks");
ia.i.e(n0Var, "$requests");
Iterator it = arrayList.iterator();
while (it.hasNext()) {
Pair pair = (Pair) it.next();
Object obj = pair.second;
ia.i.d(obj, "pair.second");
((b) pair.first).b((o0) obj);
}
for (n0.a aVar : n0Var.n()) {
aVar.b(n0Var);
}
}
private final void I(Map<String, a> map, h hVar) {
for (Map.Entry<String, a> entry : map.entrySet()) {
if (j0.f8485n.v(entry.getValue().b())) {
hVar.j(entry.getKey(), entry.getValue().b(), entry.getValue().a());
}
}
}
private final void J(Bundle bundle, h hVar, j0 j0Var) {
for (String str : bundle.keySet()) {
Object obj = bundle.get(str);
if (w(obj)) {
ia.i.d(str, "key");
hVar.j(str, obj, j0Var);
}
}
}
private final void K(h hVar, Collection<j0> collection, Map<String, a> map) {
JSONArray jSONArray = new JSONArray();
for (j0 j0Var : collection) {
j0Var.C(jSONArray, map);
}
hVar.l("batch", jSONArray, collection);
}
private final void M(HttpURLConnection httpURLConnection, boolean z10) {
if (!z10) {
httpURLConnection.setRequestProperty("Content-Type", q());
return;
}
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpURLConnection.setRequestProperty("Content-Encoding", "gzip");
}
private final HttpURLConnection g(URL url) {
URLConnection openConnection = url.openConnection();
if (openConnection != null) {
HttpURLConnection httpURLConnection = (HttpURLConnection) openConnection;
httpURLConnection.setRequestProperty("User-Agent", r());
httpURLConnection.setRequestProperty("Accept-Language", Locale.getDefault().toString());
httpURLConnection.setChunkedStreamingMode(0);
return httpURLConnection;
}
throw new NullPointerException("null cannot be cast to non-null type java.net.HttpURLConnection");
}
private final String p(n0 n0Var) {
String l10 = n0Var.l();
if (l10 == null || !(!n0Var.isEmpty())) {
Iterator<j0> it = n0Var.iterator();
while (it.hasNext()) {
h2.a m10 = it.next().m();
if (m10 != null) {
return m10.A();
}
}
String str = j0.f8488q;
if (str != null) {
if (str.length() > 0) {
return str;
}
}
return f0.m();
}
return l10;
}
private final String q() {
ia.n nVar = ia.n.f9196a;
String format = String.format("multipart/form-data; boundary=%s", Arrays.copyOf(new Object[]{j0.f8487p}, 1));
ia.i.d(format, "java.lang.String.format(format, *args)");
return format;
}
private final String r() {
if (j0.f8490s == null) {
ia.n nVar = ia.n.f9196a;
String format = String.format("%s.%s", Arrays.copyOf(new Object[]{"FBAndroidSDK", "16.2.0"}, 2));
ia.i.d(format, "java.lang.String.format(format, *args)");
j0.f8490s = format;
String a10 = x2.e0.a();
if (!x2.t0.d0(a10)) {
String format2 = String.format(Locale.ROOT, "%s/%s", Arrays.copyOf(new Object[]{j0.f8490s, a10}, 2));
ia.i.d(format2, "java.lang.String.format(locale, format, *args)");
j0.f8490s = format2;
}
}
return j0.f8490s;
}
private final boolean s(n0 n0Var) {
for (n0.a aVar : n0Var.n()) {
if (aVar instanceof n0.c) {
return true;
}
}
Iterator<j0> it = n0Var.iterator();
while (it.hasNext()) {
if (it.next().o() instanceof f) {
return true;
}
}
return false;
}
private final boolean t(n0 n0Var) {
Iterator<j0> it = n0Var.iterator();
while (it.hasNext()) {
j0 next = it.next();
for (String str : next.u().keySet()) {
if (v(next.u().get(str))) {
return false;
}
}
}
return true;
}
private final boolean u(String str) {
boolean n10;
boolean n11;
Matcher matcher = j0.f8489r.matcher(str);
if (matcher.matches()) {
str = matcher.group(1);
ia.i.d(str, "matcher.group(1)");
}
n10 = pa.p.n(str, "me/", false, 2, null);
if (n10) {
return true;
}
n11 = pa.p.n(str, "/me/", false, 2, null);
return n11;
}
public final boolean v(Object obj) {
return (obj instanceof Bitmap) || (obj instanceof byte[]) || (obj instanceof Uri) || (obj instanceof ParcelFileDescriptor) || (obj instanceof g);
}
public final boolean w(Object obj) {
return (obj instanceof String) || (obj instanceof Boolean) || (obj instanceof Number) || (obj instanceof Date);
}
public static final void z(d dVar, o0 o0Var) {
ia.i.e(o0Var, "response");
if (dVar == null) {
return;
}
dVar.a(o0Var.c(), o0Var);
}
public final j0 A(h2.a aVar, String str, JSONObject jSONObject, b bVar) {
j0 j0Var = new j0(aVar, str, null, p0.POST, bVar, null, 32, null);
j0Var.F(jSONObject);
return j0Var;
}
public final j0 B(h2.a aVar, String str, Bundle bundle, b bVar) {
return new j0(aVar, str, bundle, p0.POST, bVar, null, 32, null);
}
public final void G(final n0 n0Var, List<o0> list) {
ia.i.e(n0Var, "requests");
ia.i.e(list, "responses");
int size = n0Var.size();
final ArrayList arrayList = new ArrayList();
if (size > 0) {
int i10 = 0;
while (true) {
int i11 = i10 + 1;
j0 j0Var = n0Var.get(i10);
if (j0Var.o() != null) {
arrayList.add(new Pair(j0Var.o(), list.get(i10)));
}
if (i11 >= size) {
break;
}
i10 = i11;
}
}
if (arrayList.size() > 0) {
Runnable runnable = new Runnable() {
@Override
public final void run() {
j0.c.H(arrayList, n0Var);
}
};
Handler m10 = n0Var.m();
if ((m10 == null ? null : Boolean.valueOf(m10.post(runnable))) == null) {
runnable.run();
}
}
}
public final void L(n0 n0Var, HttpURLConnection httpURLConnection) {
OutputStream gZIPOutputStream;
ia.i.e(n0Var, "requests");
ia.i.e(httpURLConnection, "connection");
x2.h0 h0Var = new x2.h0(r0.REQUESTS, "Request");
int size = n0Var.size();
boolean t10 = t(n0Var);
OutputStream outputStream = null;
p0 t11 = size == 1 ? n0Var.get(0).t() : null;
if (t11 == null) {
t11 = p0.POST;
}
httpURLConnection.setRequestMethod(t11.name());
M(httpURLConnection, t10);
URL url = httpURLConnection.getURL();
h0Var.b("Request:\n");
h0Var.d("Id", n0Var.p());
ia.i.d(url, "url");
h0Var.d("URL", url);
Object requestMethod = httpURLConnection.getRequestMethod();
ia.i.d(requestMethod, "connection.requestMethod");
h0Var.d("Method", requestMethod);
Object requestProperty = httpURLConnection.getRequestProperty("User-Agent");
ia.i.d(requestProperty, "connection.getRequestProperty(\"User-Agent\")");
h0Var.d("User-Agent", requestProperty);
Object requestProperty2 = httpURLConnection.getRequestProperty("Content-Type");
ia.i.d(requestProperty2, "connection.getRequestProperty(\"Content-Type\")");
h0Var.d("Content-Type", requestProperty2);
httpURLConnection.setConnectTimeout(n0Var.s());
httpURLConnection.setReadTimeout(n0Var.s());
if (!(t11 == p0.POST)) {
h0Var.e();
return;
}
httpURLConnection.setDoOutput(true);
try {
OutputStream bufferedOutputStream = new BufferedOutputStream(httpURLConnection.getOutputStream());
if (t10) {
try {
gZIPOutputStream = new GZIPOutputStream(bufferedOutputStream);
} catch (Throwable th) {
th = th;
outputStream = bufferedOutputStream;
if (outputStream != null) {
}
throw th;
}
} else {
gZIPOutputStream = bufferedOutputStream;
}
try {
gZIPOutputStream = gZIPOutputStream;
if (s(n0Var)) {
v0 v0Var = new v0(n0Var.m());
F(n0Var, null, size, url, v0Var, t10);
gZIPOutputStream = new x0(gZIPOutputStream, n0Var, v0Var.d(), v0Var.c());
}
F(n0Var, h0Var, size, url, gZIPOutputStream, t10);
gZIPOutputStream.close();
h0Var.e();
} catch (Throwable th2) {
th = th2;
outputStream = gZIPOutputStream;
if (outputStream != null) {
outputStream.close();
}
throw th;
}
} catch (Throwable th3) {
th = th3;
}
}
public final HttpURLConnection N(n0 n0Var) {
ia.i.e(n0Var, "requests");
O(n0Var);
try {
HttpURLConnection httpURLConnection = null;
try {
httpURLConnection = g(n0Var.size() == 1 ? new URL(n0Var.get(0).x()) : new URL(x2.n0.h()));
L(n0Var, httpURLConnection);
return httpURLConnection;
} catch (IOException e10) {
x2.t0.q(httpURLConnection);
throw new s("could not construct request body", e10);
} catch (JSONException e11) {
x2.t0.q(httpURLConnection);
throw new s("could not construct request body", e11);
}
} catch (MalformedURLException e12) {
throw new s("could not construct URL for request", e12);
}
}
public final void O(n0 n0Var) {
ia.i.e(n0Var, "requests");
Iterator<j0> it = n0Var.iterator();
while (it.hasNext()) {
j0 next = it.next();
if (p0.GET == next.t()) {
x2.t0 t0Var = x2.t0.f14355a;
if (x2.t0.d0(next.u().getString("fields"))) {
h0.a aVar = x2.h0.f14240e;
r0 r0Var = r0.DEVELOPER_ERRORS;
StringBuilder sb = new StringBuilder();
sb.append("GET requests for /");
String r10 = next.r();
if (r10 == null) {
r10 = "";
}
sb.append(r10);
sb.append(" should contain an explicit \"fields\" parameter.");
aVar.a(r0Var, 5, "Request", sb.toString());
}
}
}
}
public final o0 h(j0 j0Var) {
ia.i.e(j0Var, "request");
List<o0> k10 = k(j0Var);
if (k10.size() == 1) {
return k10.get(0);
}
throw new s("invalid state: expected a single response");
}
public final List<o0> i(n0 n0Var) {
Exception exc;
HttpURLConnection httpURLConnection;
List<o0> list;
ia.i.e(n0Var, "requests");
x2.u0.l(n0Var, "requests");
HttpURLConnection httpURLConnection2 = null;
try {
httpURLConnection = N(n0Var);
exc = null;
} catch (Exception e10) {
exc = e10;
httpURLConnection = null;
} catch (Throwable th) {
th = th;
x2.t0.q(httpURLConnection2);
throw th;
}
try {
if (httpURLConnection != null) {
list = o(httpURLConnection, n0Var);
} else {
List<o0> a10 = o0.f8557i.a(n0Var.q(), null, new s(exc));
G(n0Var, a10);
list = a10;
}
x2.t0.q(httpURLConnection);
return list;
} catch (Throwable th2) {
th = th2;
httpURLConnection2 = httpURLConnection;
x2.t0.q(httpURLConnection2);
throw th;
}
}
public final List<o0> j(Collection<j0> collection) {
ia.i.e(collection, "requests");
return i(new n0(collection));
}
public final List<o0> k(j0... j0VarArr) {
List k10;
ia.i.e(j0VarArr, "requests");
k10 = y9.g.k(j0VarArr);
return j(k10);
}
public final m0 l(n0 n0Var) {
ia.i.e(n0Var, "requests");
x2.u0.l(n0Var, "requests");
m0 m0Var = new m0(n0Var);
m0Var.executeOnExecutor(f0.t(), new Void[0]);
return m0Var;
}
public final m0 m(Collection<j0> collection) {
ia.i.e(collection, "requests");
return l(new n0(collection));
}
public final m0 n(j0... j0VarArr) {
List k10;
ia.i.e(j0VarArr, "requests");
k10 = y9.g.k(j0VarArr);
return m(k10);
}
public final List<o0> o(HttpURLConnection httpURLConnection, n0 n0Var) {
ia.i.e(httpURLConnection, "connection");
ia.i.e(n0Var, "requests");
List<o0> f10 = o0.f8557i.f(httpURLConnection, n0Var);
x2.t0.q(httpURLConnection);
int size = n0Var.size();
if (size == f10.size()) {
G(n0Var, f10);
h2.g.f8443f.e().h();
return f10;
}
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.US, "Received %d responses while expecting %d", Arrays.copyOf(new Object[]{Integer.valueOf(f10.size()), Integer.valueOf(size)}, 2));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
throw new s(format);
}
public final j0 x(h2.a aVar, String str, b bVar) {
return new j0(aVar, str, null, null, bVar, null, 32, null);
}
public final j0 y(h2.a aVar, final d dVar) {
return new j0(aVar, "me", null, null, new b() {
@Override
public final void b(o0 o0Var) {
j0.c.z(j0.d.this, o0Var);
}
}, null, 32, null);
}
}
public interface d {
void a(JSONObject jSONObject, o0 o0Var);
}
public interface e {
void a(String str, String str2);
}
public interface f extends b {
void a(long j10, long j11);
}
public static final class g<RESOURCE extends Parcelable> implements Parcelable {
private final String f8507a;
private final RESOURCE f8508b;
public static final b f8506c = new b(null);
public static final Parcelable.Creator<g<?>> CREATOR = new a();
public static final class a implements Parcelable.Creator<g<?>> {
a() {
}
@Override
public g<?> createFromParcel(Parcel parcel) {
ia.i.e(parcel, "source");
return new g<>(parcel, (ia.f) null);
}
@Override
public g<?>[] newArray(int i10) {
return new g[i10];
}
}
public static final class b {
private b() {
}
public b(ia.f fVar) {
this();
}
}
private g(Parcel parcel) {
this.f8507a = parcel.readString();
this.f8508b = (RESOURCE) parcel.readParcelable(f0.l().getClassLoader());
}
public g(Parcel parcel, ia.f fVar) {
this(parcel);
}
public g(RESOURCE resource, String str) {
this.f8507a = str;
this.f8508b = resource;
}
@Override
public int describeContents() {
return 1;
}
public final String f() {
return this.f8507a;
}
public final RESOURCE h() {
return this.f8508b;
}
@Override
public void writeToParcel(Parcel parcel, int i10) {
ia.i.e(parcel, "out");
parcel.writeString(this.f8507a);
parcel.writeParcelable(this.f8508b, i10);
}
}
public static final class h implements e {
private final OutputStream f8509a;
private final x2.h0 f8510b;
private boolean f8511c;
private final boolean f8512d;
public h(OutputStream outputStream, x2.h0 h0Var, boolean z10) {
ia.i.e(outputStream, "outputStream");
this.f8509a = outputStream;
this.f8510b = h0Var;
this.f8511c = true;
this.f8512d = z10;
}
private final RuntimeException b() {
return new IllegalArgumentException("value is not a supported type.");
}
@Override
public void a(String str, String str2) {
ia.i.e(str, "key");
ia.i.e(str2, "value");
f(str, null, null);
i("%s", str2);
k();
x2.h0 h0Var = this.f8510b;
if (h0Var == null) {
return;
}
h0Var.d(ia.i.l(" ", str), str2);
}
public final void c(String str, Object... objArr) {
ia.i.e(str, "format");
ia.i.e(objArr, "args");
if (this.f8512d) {
OutputStream outputStream = this.f8509a;
ia.n nVar = ia.n.f9196a;
Locale locale = Locale.US;
Object[] copyOf = Arrays.copyOf(objArr, objArr.length);
String format = String.format(locale, str, Arrays.copyOf(copyOf, copyOf.length));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
String encode = URLEncoder.encode(format, "UTF-8");
ia.i.d(encode, "encode(String.format(Locale.US, format, *args), \"UTF-8\")");
byte[] bytes = encode.getBytes(pa.d.f11952b);
ia.i.d(bytes, "(this as java.lang.String).getBytes(charset)");
outputStream.write(bytes);
return;
}
if (this.f8511c) {
OutputStream outputStream2 = this.f8509a;
Charset charset = pa.d.f11952b;
byte[] bytes2 = "--".getBytes(charset);
ia.i.d(bytes2, "(this as java.lang.String).getBytes(charset)");
outputStream2.write(bytes2);
OutputStream outputStream3 = this.f8509a;
String str2 = j0.f8487p;
if (str2 == null) {
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
byte[] bytes3 = str2.getBytes(charset);
ia.i.d(bytes3, "(this as java.lang.String).getBytes(charset)");
outputStream3.write(bytes3);
OutputStream outputStream4 = this.f8509a;
byte[] bytes4 = "\r\n".getBytes(charset);
ia.i.d(bytes4, "(this as java.lang.String).getBytes(charset)");
outputStream4.write(bytes4);
this.f8511c = false;
}
OutputStream outputStream5 = this.f8509a;
ia.n nVar2 = ia.n.f9196a;
Object[] copyOf2 = Arrays.copyOf(objArr, objArr.length);
String format2 = String.format(str, Arrays.copyOf(copyOf2, copyOf2.length));
ia.i.d(format2, "java.lang.String.format(format, *args)");
Charset charset2 = pa.d.f11952b;
if (format2 == null) {
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
byte[] bytes5 = format2.getBytes(charset2);
ia.i.d(bytes5, "(this as java.lang.String).getBytes(charset)");
outputStream5.write(bytes5);
}
public final void d(String str, Bitmap bitmap) {
ia.i.e(str, "key");
ia.i.e(bitmap, "bitmap");
f(str, str, "image/png");
bitmap.compress(Bitmap.CompressFormat.PNG, 100, this.f8509a);
i("", new Object[0]);
k();
x2.h0 h0Var = this.f8510b;
if (h0Var == null) {
return;
}
h0Var.d(ia.i.l(" ", str), "<Image>");
}
public final void e(String str, byte[] bArr) {
ia.i.e(str, "key");
ia.i.e(bArr, "bytes");
f(str, str, "content/unknown");
this.f8509a.write(bArr);
i("", new Object[0]);
k();
x2.h0 h0Var = this.f8510b;
if (h0Var == null) {
return;
}
String l10 = ia.i.l(" ", str);
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.ROOT, "<Data: %d>", Arrays.copyOf(new Object[]{Integer.valueOf(bArr.length)}, 1));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
h0Var.d(l10, format);
}
public final void f(String str, String str2, String str3) {
if (!this.f8512d) {
c("Content-Disposition: form-data; name=\"%s\"", str);
if (str2 != null) {
c("; filename=\"%s\"", str2);
}
i("", new Object[0]);
if (str3 != null) {
i("%s: %s", "Content-Type", str3);
}
i("", new Object[0]);
return;
}
OutputStream outputStream = this.f8509a;
ia.n nVar = ia.n.f9196a;
String format = String.format("%s=", Arrays.copyOf(new Object[]{str}, 1));
ia.i.d(format, "java.lang.String.format(format, *args)");
Charset charset = pa.d.f11952b;
if (format == null) {
throw new NullPointerException("null cannot be cast to non-null type java.lang.String");
}
byte[] bytes = format.getBytes(charset);
ia.i.d(bytes, "(this as java.lang.String).getBytes(charset)");
outputStream.write(bytes);
}
public final void g(String str, Uri uri, String str2) {
int p10;
ia.i.e(str, "key");
ia.i.e(uri, "contentUri");
if (str2 == null) {
str2 = "content/unknown";
}
f(str, str, str2);
if (this.f8509a instanceof v0) {
((v0) this.f8509a).b(x2.t0.z(uri));
p10 = 0;
} else {
InputStream openInputStream = f0.l().getContentResolver().openInputStream(uri);
x2.t0 t0Var = x2.t0.f14355a;
p10 = x2.t0.p(openInputStream, this.f8509a) + 0;
}
i("", new Object[0]);
k();
x2.h0 h0Var = this.f8510b;
if (h0Var == null) {
return;
}
String l10 = ia.i.l(" ", str);
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.ROOT, "<Data: %d>", Arrays.copyOf(new Object[]{Integer.valueOf(p10)}, 1));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
h0Var.d(l10, format);
}
public final void h(String str, ParcelFileDescriptor parcelFileDescriptor, String str2) {
int p10;
ia.i.e(str, "key");
ia.i.e(parcelFileDescriptor, "descriptor");
if (str2 == null) {
str2 = "content/unknown";
}
f(str, str, str2);
OutputStream outputStream = this.f8509a;
if (outputStream instanceof v0) {
((v0) outputStream).b(parcelFileDescriptor.getStatSize());
p10 = 0;
} else {
ParcelFileDescriptor.AutoCloseInputStream autoCloseInputStream = new ParcelFileDescriptor.AutoCloseInputStream(parcelFileDescriptor);
x2.t0 t0Var = x2.t0.f14355a;
p10 = x2.t0.p(autoCloseInputStream, this.f8509a) + 0;
}
i("", new Object[0]);
k();
x2.h0 h0Var = this.f8510b;
if (h0Var == null) {
return;
}
String l10 = ia.i.l(" ", str);
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.ROOT, "<Data: %d>", Arrays.copyOf(new Object[]{Integer.valueOf(p10)}, 1));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
h0Var.d(l10, format);
}
public final void i(String str, Object... objArr) {
ia.i.e(str, "format");
ia.i.e(objArr, "args");
c(str, Arrays.copyOf(objArr, objArr.length));
if (this.f8512d) {
return;
}
c("\r\n", new Object[0]);
}
public final void j(String str, Object obj, j0 j0Var) {
ia.i.e(str, "key");
OutputStream outputStream = this.f8509a;
if (outputStream instanceof y0) {
((y0) outputStream).a(j0Var);
}
c cVar = j0.f8485n;
if (cVar.w(obj)) {
a(str, cVar.C(obj));
} else if (obj instanceof Bitmap) {
d(str, (Bitmap) obj);
} else if (obj instanceof byte[]) {
e(str, (byte[]) obj);
} else if (obj instanceof Uri) {
g(str, (Uri) obj, null);
} else if (obj instanceof ParcelFileDescriptor) {
h(str, (ParcelFileDescriptor) obj, null);
} else if (!(obj instanceof g)) {
throw b();
} else {
g gVar = (g) obj;
Parcelable h10 = gVar.h();
String f10 = gVar.f();
if (h10 instanceof ParcelFileDescriptor) {
h(str, (ParcelFileDescriptor) h10, f10);
} else if (!(h10 instanceof Uri)) {
throw b();
} else {
g(str, (Uri) h10, f10);
}
}
}
public final void k() {
if (!this.f8512d) {
i("--%s", j0.f8487p);
return;
}
OutputStream outputStream = this.f8509a;
byte[] bytes = "&".getBytes(pa.d.f11952b);
ia.i.d(bytes, "(this as java.lang.String).getBytes(charset)");
outputStream.write(bytes);
}
public final void l(String str, JSONArray jSONArray, Collection<j0> collection) {
ia.i.e(str, "key");
ia.i.e(jSONArray, "requestJsonArray");
ia.i.e(collection, "requests");
OutputStream outputStream = this.f8509a;
if (!(outputStream instanceof y0)) {
String jSONArray2 = jSONArray.toString();
ia.i.d(jSONArray2, "requestJsonArray.toString()");
a(str, jSONArray2);
return;
}
y0 y0Var = (y0) outputStream;
f(str, null, null);
c("[", new Object[0]);
int i10 = 0;
for (j0 j0Var : collection) {
int i11 = i10 + 1;
JSONObject jSONObject = jSONArray.getJSONObject(i10);
y0Var.a(j0Var);
if (i10 > 0) {
c(",%s", jSONObject.toString());
} else {
c("%s", jSONObject.toString());
}
i10 = i11;
}
c("]", new Object[0]);
x2.h0 h0Var = this.f8510b;
if (h0Var == null) {
return;
}
String l10 = ia.i.l(" ", str);
String jSONArray3 = jSONArray.toString();
ia.i.d(jSONArray3, "requestJsonArray.toString()");
h0Var.d(l10, jSONArray3);
}
}
public static final class i implements e {
final ArrayList<String> f8513a;
i(ArrayList<String> arrayList) {
this.f8513a = arrayList;
}
@Override
public void a(String str, String str2) {
ia.i.e(str, "key");
ia.i.e(str2, "value");
ArrayList<String> arrayList = this.f8513a;
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.US, "%s=%s", Arrays.copyOf(new Object[]{str, URLEncoder.encode(str2, "UTF-8")}, 2));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
arrayList.add(format);
}
}
static {
char[] charArray = "-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
ia.i.d(charArray, "(this as java.lang.String).toCharArray()");
StringBuilder sb = new StringBuilder();
SecureRandom secureRandom = new SecureRandom();
int nextInt = secureRandom.nextInt(11) + 30;
if (nextInt <= 0) {
String sb2 = sb.toString();
ia.i.d(sb2, "buffer.toString()");
f8487p = sb2;
f8489r = Pattern.compile("^/?v\\d+\\.\\d+/(.*)");
}
int i10 = 0;
do {
i10++;
sb.append(charArray[secureRandom.nextInt(charArray.length)]);
} while (i10 < nextInt);
String sb22 = sb.toString();
ia.i.d(sb22, "buffer.toString()");
f8487p = sb22;
f8489r = Pattern.compile("^/?v\\d+\\.\\d+/(.*)");
}
public j0() {
this(null, null, null, null, null, null, 63, null);
}
public j0(h2.a aVar, String str, Bundle bundle, p0 p0Var, b bVar, String str2) {
this.f8496f = true;
this.f8491a = aVar;
this.f8492b = str;
this.f8499i = str2;
D(bVar);
G(p0Var);
this.f8497g = bundle != null ? new Bundle(bundle) : new Bundle();
if (this.f8499i == null) {
this.f8499i = f0.w();
}
}
public j0(h2.a aVar, String str, Bundle bundle, p0 p0Var, b bVar, String str2, int i10, ia.f fVar) {
this((i10 & 1) != 0 ? null : aVar, (i10 & 2) != 0 ? null : str, (i10 & 4) != 0 ? null : bundle, (i10 & 8) != 0 ? null : p0Var, (i10 & 16) != 0 ? null : bVar, (i10 & 32) != 0 ? null : str2);
}
private final boolean A() {
if (ia.i.a(f0.x(), "instagram.com")) {
return !z();
}
return true;
}
public static final j0 B(h2.a aVar, d dVar) {
return f8485n.y(aVar, dVar);
}
public final void C(JSONArray jSONArray, Map<String, a> map) {
JSONObject jSONObject = new JSONObject();
String str = this.f8494d;
if (str != null) {
jSONObject.put("name", str);
jSONObject.put("omit_response_on_success", this.f8496f);
}
String str2 = this.f8495e;
if (str2 != null) {
jSONObject.put("depends_on", str2);
}
String v10 = v();
jSONObject.put("relative_url", v10);
jSONObject.put("method", this.f8501k);
h2.a aVar = this.f8491a;
if (aVar != null) {
x2.h0.f14240e.d(aVar.v());
}
ArrayList arrayList = new ArrayList();
for (String str3 : this.f8497g.keySet()) {
Object obj = this.f8497g.get(str3);
if (f8485n.v(obj)) {
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.ROOT, "%s%d", Arrays.copyOf(new Object[]{"file", Integer.valueOf(map.size())}, 2));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
arrayList.add(format);
map.put(format, new a(this, obj));
}
}
if (!arrayList.isEmpty()) {
jSONObject.put("attached_files", TextUtils.join(",", arrayList));
}
JSONObject jSONObject2 = this.f8493c;
if (jSONObject2 != null) {
ArrayList arrayList2 = new ArrayList();
f8485n.D(jSONObject2, v10, new i(arrayList2));
jSONObject.put("body", TextUtils.join("&", arrayList2));
}
jSONArray.put(jSONObject);
}
private final boolean J() {
boolean z10;
boolean n10;
String n11 = n();
boolean q10 = n11 == null ? false : pa.q.q(n11, "|", false, 2, null);
if (n11 != null) {
n10 = pa.p.n(n11, "IG", false, 2, null);
if (n10 && !q10) {
z10 = true;
if (z10 || !z()) {
return A() && !q10;
}
return true;
}
}
z10 = false;
if (z10) {
}
if (A()) {
}
}
public static final void b(b bVar, o0 o0Var) {
int length;
ia.i.e(o0Var, "response");
JSONObject c10 = o0Var.c();
JSONObject optJSONObject = c10 == null ? null : c10.optJSONObject("__debug__");
JSONArray optJSONArray = optJSONObject == null ? null : optJSONObject.optJSONArray("messages");
if (optJSONArray != null && (length = optJSONArray.length()) > 0) {
int i10 = 0;
while (true) {
int i11 = i10 + 1;
JSONObject optJSONObject2 = optJSONArray.optJSONObject(i10);
String optString = optJSONObject2 == null ? null : optJSONObject2.optString("message");
String optString2 = optJSONObject2 == null ? null : optJSONObject2.optString("type");
String optString3 = optJSONObject2 == null ? null : optJSONObject2.optString("link");
if (optString != null && optString2 != null) {
r0 r0Var = r0.GRAPH_API_DEBUG_INFO;
if (ia.i.a(optString2, "warning")) {
r0Var = r0.GRAPH_API_DEBUG_WARNING;
}
if (!x2.t0.d0(optString3)) {
optString = ((Object) optString) + " Link: " + ((Object) optString3);
}
h0.a aVar = x2.h0.f14240e;
String str = f8486o;
ia.i.d(str, "TAG");
aVar.b(r0Var, str, optString);
}
if (i11 >= length) {
break;
}
i10 = i11;
}
}
if (bVar == null) {
return;
}
bVar.b(o0Var);
}
private final void i() {
String str;
Bundle bundle = this.f8497g;
String n10 = J() ? p() : n();
bundle.putString("access_token", n10);
if (!bundle.containsKey("access_token")) {
x2.t0 t0Var = x2.t0.f14355a;
if (x2.t0.d0(f0.r())) {
Log.w(f8486o, "Starting with v13 of the SDK, a client token must be embedded in your client code before making Graph API calls. Visit https://developers.facebook.com/docs/android/getting-started#client-token to learn how to implement this change.");
}
}
bundle.putString("sdk", "android");
bundle.putString("format", "json");
f0 f0Var = f0.f8419a;
if (f0.H(r0.GRAPH_API_DEBUG_INFO)) {
str = "info";
} else if (!f0.H(r0.GRAPH_API_DEBUG_WARNING)) {
return;
} else {
str = "warning";
}
bundle.putString("debug", str);
}
private final String j(String str, boolean z10) {
if (z10 || this.f8501k != p0.POST) {
Uri.Builder buildUpon = Uri.parse(str).buildUpon();
for (String str2 : this.f8497g.keySet()) {
Object obj = this.f8497g.get(str2);
if (obj == null) {
obj = "";
}
c cVar = f8485n;
if (cVar.w(obj)) {
buildUpon.appendQueryParameter(str2, cVar.C(obj).toString());
} else if (this.f8501k != p0.GET) {
ia.n nVar = ia.n.f9196a;
String format = String.format(Locale.US, "Unsupported parameter type for GET request: %s", Arrays.copyOf(new Object[]{obj.getClass().getSimpleName()}, 1));
ia.i.d(format, "java.lang.String.format(locale, format, *args)");
throw new IllegalArgumentException(format);
}
}
String builder = buildUpon.toString();
ia.i.d(builder, "uriBuilder.toString()");
return builder;
}
return str;
}
private final String n() {
h2.a aVar = this.f8491a;
if (aVar != null) {
if (!this.f8497g.containsKey("access_token")) {
String v10 = aVar.v();
x2.h0.f14240e.d(v10);
return v10;
}
} else if (!this.f8497g.containsKey("access_token")) {
return p();
}
return this.f8497g.getString("access_token");
}
private final String p() {
String m10 = f0.m();
String r10 = f0.r();
if (m10.length() > 0) {
if (r10.length() > 0) {
return m10 + '|' + r10;
}
}
x2.t0 t0Var = x2.t0.f14355a;
x2.t0.k0(f8486o, "Warning: Request without access token missing application ID or client token.");
return null;
}
private final String s() {
if (f8489r.matcher(this.f8492b).matches()) {
return this.f8492b;
}
ia.n nVar = ia.n.f9196a;
String format = String.format("%s/%s", Arrays.copyOf(new Object[]{this.f8499i, this.f8492b}, 2));
ia.i.d(format, "java.lang.String.format(format, *args)");
return format;
}
private final String y(String str) {
if (!A()) {
str = x2.n0.f();
}
ia.n nVar = ia.n.f9196a;
String format = String.format("%s/%s", Arrays.copyOf(new Object[]{str, s()}, 2));
ia.i.d(format, "java.lang.String.format(format, *args)");
return format;
}
private final boolean z() {
if (this.f8492b == null) {
return false;
}
StringBuilder sb = new StringBuilder();
sb.append("^/?");
sb.append(f0.m());
sb.append("/?.*");
return this.f8502l || Pattern.matches(sb.toString(), this.f8492b) || Pattern.matches("^/?app/?.*", this.f8492b);
}
public final void D(final b bVar) {
f0 f0Var = f0.f8419a;
if (f0.H(r0.GRAPH_API_DEBUG_INFO) || f0.H(r0.GRAPH_API_DEBUG_WARNING)) {
this.f8500j = new b() {
@Override
public final void b(o0 o0Var) {
j0.b(j0.b.this, o0Var);
}
};
} else {
this.f8500j = bVar;
}
}
public final void E(boolean z10) {
this.f8502l = z10;
}
public final void F(JSONObject jSONObject) {
this.f8493c = jSONObject;
}
public final void G(p0 p0Var) {
if (this.f8503m != null && p0Var != p0.GET) {
throw new s("Can't change HTTP method on request with overridden URL.");
}
if (p0Var == null) {
p0Var = p0.GET;
}
this.f8501k = p0Var;
}
public final void H(Bundle bundle) {
ia.i.e(bundle, "<set-?>");
this.f8497g = bundle;
}
public final void I(Object obj) {
this.f8498h = obj;
}
public final o0 k() {
return f8485n.h(this);
}
public final m0 l() {
return f8485n.n(this);
}
public final h2.a m() {
return this.f8491a;
}
public final b o() {
return this.f8500j;
}
public final JSONObject q() {
return this.f8493c;
}
public final String r() {
return this.f8492b;
}
public final p0 t() {
return this.f8501k;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{Request: ");
sb.append(" accessToken: ");
Object obj = this.f8491a;
if (obj == null) {
obj = "null";
}
sb.append(obj);
sb.append(", graphPath: ");
sb.append(this.f8492b);
sb.append(", graphObject: ");
sb.append(this.f8493c);
sb.append(", httpMethod: ");
sb.append(this.f8501k);
sb.append(", parameters: ");
sb.append(this.f8497g);
sb.append("}");
String sb2 = sb.toString();
ia.i.d(sb2, "StringBuilder()\n .append(\"{Request: \")\n .append(\" accessToken: \")\n .append(if (accessToken == null) \"null\" else accessToken)\n .append(\", graphPath: \")\n .append(graphPath)\n .append(\", graphObject: \")\n .append(graphObject)\n .append(\", httpMethod: \")\n .append(httpMethod)\n .append(\", parameters: \")\n .append(parameters)\n .append(\"}\")\n .toString()");
return sb2;
}
public final Bundle u() {
return this.f8497g;
}
public final String v() {
if (this.f8503m == null) {
String y10 = y(x2.n0.h());
i();
Uri parse = Uri.parse(j(y10, true));
ia.n nVar = ia.n.f9196a;
String format = String.format("%s?%s", Arrays.copyOf(new Object[]{parse.getPath(), parse.getQuery()}, 2));
ia.i.d(format, "java.lang.String.format(format, *args)");
return format;
}
throw new s("Can't override URL for a batch request");
}
public final Object w() {
return this.f8498h;
}
public final String x() {
String i10;
boolean e10;
String str = this.f8503m;
if (str != null) {
return String.valueOf(str);
}
String str2 = this.f8492b;
if (this.f8501k == p0.POST && str2 != null) {
e10 = pa.p.e(str2, "/videos", false, 2, null);
if (e10) {
i10 = x2.n0.j();
String y10 = y(i10);
i();
return j(y10, false);
}
}
x2.n0 n0Var = x2.n0.f14294a;
i10 = x2.n0.i(f0.x());
String y102 = y(i10);
i();
return j(y102, false);
}
}