package com.flurry.android;

import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import org.apache.http.HttpResponse;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/0.dex */
public final class ae extends AsyncTask<Void, Void, String> {
    private final String a = getClass().getSimpleName();
    private Context b;
    private String c;
    private /* synthetic */ be d;

    @Override // android.os.AsyncTask
    protected final /* bridge */ /* synthetic */ String doInBackground(Void[] voidArr) {
        return a();
    }

    public ae(be beVar, Context context, String str) {
        this.d = beVar;
        this.b = context;
        this.c = str;
    }

    private String a() {
        boolean d;
        ax axVar;
        for (int i = 0; i < 5; i++) {
            if (Uri.parse(this.c).getScheme().equals("http")) {
                d = be.d(this.b);
                if (d) {
                    axVar = this.d.h;
                    HttpResponse a = y.a(axVar, this.c, 10000, 15000, false);
                    if (a == null) {
                        continue;
                    } else {
                        int statusCode = a.getStatusLine().getStatusCode();
                        if (statusCode == 200) {
                            String str = "Redirect URL found for: " + this.c;
                            return this.c;
                        } else if (statusCode >= 300 && statusCode < 400) {
                            String str2 = "NumRedirects: " + (i + 1);
                            if (a.containsHeader("Location")) {
                                this.c = a.getFirstHeader("Location").getValue();
                            }
                        } else {
                            String str3 = "Bad Response status code: " + statusCode;
                            return null;
                        }
                    }
                } else {
                    try {
                        Thread.sleep(100L);
                    } catch (InterruptedException e) {
                        e.getMessage();
                    }
                }
            } else if (!be.a(this.b, this.c, "android.intent.action.VIEW")) {
                return null;
            } else {
                return this.c;
            }
        }
        return null;
    }
}
