package com.facebook; import android.os.AsyncTask; import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import androidx.annotation.VisibleForTesting; import com.facebook.internal.Utility; import com.facebook.internal.instrument.crashshield.CrashShieldHandler; import java.net.HttpURLConnection; import java.util.Arrays; import java.util.Collection; import java.util.List; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.StringCompanionObject; /* loaded from: classes2.dex */ public class GraphRequestAsyncTask extends AsyncTask> { public static final Companion Companion = new Companion(null); private static final String TAG = GraphRequestAsyncTask.class.getCanonicalName(); private final HttpURLConnection connection; private Exception exception; private final GraphRequestBatch requests; public final Exception getException() { return this.exception; } public final GraphRequestBatch getRequests() { return this.requests; } @Override // android.os.AsyncTask public /* bridge */ /* synthetic */ List doInBackground(Void[] voidArr) { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { return doInBackground2(voidArr); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } catch (Throwable th2) { CrashShieldHandler.handleThrowable(th2, this); return null; } } catch (Throwable th3) { CrashShieldHandler.handleThrowable(th3, this); return null; } } @Override // android.os.AsyncTask public /* bridge */ /* synthetic */ void onPostExecute(List list) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { onPostExecute2((List) list); } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } catch (Throwable th2) { CrashShieldHandler.handleThrowable(th2, this); } } catch (Throwable th3) { CrashShieldHandler.handleThrowable(th3, this); } } public GraphRequestAsyncTask(HttpURLConnection httpURLConnection, GraphRequestBatch requests) { Intrinsics.checkNotNullParameter(requests, "requests"); this.connection = httpURLConnection; this.requests = requests; } public static final class Companion { public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } private Companion() { } } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public GraphRequestAsyncTask(GraphRequest... requests) { this((HttpURLConnection) null, new GraphRequestBatch((GraphRequest[]) Arrays.copyOf(requests, requests.length))); Intrinsics.checkNotNullParameter(requests, "requests"); } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public GraphRequestAsyncTask(Collection requests) { this((HttpURLConnection) null, new GraphRequestBatch(requests)); Intrinsics.checkNotNullParameter(requests, "requests"); } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public GraphRequestAsyncTask(GraphRequestBatch requests) { this((HttpURLConnection) null, requests); Intrinsics.checkNotNullParameter(requests, "requests"); } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public GraphRequestAsyncTask(HttpURLConnection httpURLConnection, GraphRequest... requests) { this(httpURLConnection, new GraphRequestBatch((GraphRequest[]) Arrays.copyOf(requests, requests.length))); Intrinsics.checkNotNullParameter(requests, "requests"); } /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */ public GraphRequestAsyncTask(HttpURLConnection httpURLConnection, Collection requests) { this(httpURLConnection, new GraphRequestBatch(requests)); Intrinsics.checkNotNullParameter(requests, "requests"); } public String toString() { String str = "{RequestAsyncTask: connection: " + this.connection + ", requests: " + this.requests + "}"; Intrinsics.checkNotNullExpressionValue(str, "StringBuilder()\n .append(\"{RequestAsyncTask: \")\n .append(\" connection: \")\n .append(connection)\n .append(\", requests: \")\n .append(requests)\n .append(\"}\")\n .toString()"); return str; } @Override // android.os.AsyncTask @VisibleForTesting(otherwise = 4) public void onPreExecute() { Handler handler; if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { super.onPreExecute(); if (FacebookSdk.isDebugEnabled()) { Utility utility = Utility.INSTANCE; String str = TAG; StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE; String format = String.format("execute async task: %s", Arrays.copyOf(new Object[]{this}, 1)); Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)"); Utility.logd(str, format); } if (this.requests.getCallbackHandler() == null) { if (Thread.currentThread() instanceof HandlerThread) { handler = new Handler(); } else { handler = new Handler(Looper.getMainLooper()); } this.requests.setCallbackHandler(handler); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } catch (Throwable th2) { CrashShieldHandler.handleThrowable(th2, this); } } catch (Throwable th3) { CrashShieldHandler.handleThrowable(th3, this); } } /* renamed from: onPostExecute, reason: avoid collision after fix types in other method */ public void onPostExecute2(List result) { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return; } try { Intrinsics.checkNotNullParameter(result, "result"); super.onPostExecute((GraphRequestAsyncTask) result); Exception exc = this.exception; if (exc != null) { Utility utility = Utility.INSTANCE; String str = TAG; StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE; String format = String.format("onPostExecute: exception encountered during request: %s", Arrays.copyOf(new Object[]{exc.getMessage()}, 1)); Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)"); Utility.logd(str, format); } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); } } catch (Throwable th2) { CrashShieldHandler.handleThrowable(th2, this); } } catch (Throwable th3) { CrashShieldHandler.handleThrowable(th3, this); } } @VisibleForTesting(otherwise = 4) /* renamed from: doInBackground, reason: avoid collision after fix types in other method */ public List doInBackground2(Void... params) { List executeConnectionAndWait; if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { if (CrashShieldHandler.isObjectCrashing(this)) { return null; } try { Intrinsics.checkNotNullParameter(params, "params"); try { HttpURLConnection httpURLConnection = this.connection; if (httpURLConnection == null) { executeConnectionAndWait = this.requests.executeAndWait(); } else { executeConnectionAndWait = GraphRequest.Companion.executeConnectionAndWait(httpURLConnection, this.requests); } return executeConnectionAndWait; } catch (Exception e) { this.exception = e; return null; } } catch (Throwable th) { CrashShieldHandler.handleThrowable(th, this); return null; } } catch (Throwable th2) { CrashShieldHandler.handleThrowable(th2, this); return null; } } catch (Throwable th3) { CrashShieldHandler.handleThrowable(th3, this); return null; } } }