package com.pgl.ssdk;

import android.content.Context;
import com.google.common.net.HttpHeaders;
import java.net.HttpURLConnection;
import java.util.Locale;
/* loaded from: classes6.dex */
public abstract class G {

    /* renamed from: a  reason: collision with root package name */
    private String f4735a;
    private int c;
    private int d;
    private byte[] e;
    public String b = "";
    private int f = -1;
    private byte[] g = null;
    private int h = 10000;
    private int i = 2;
    private int j = 0;
    private boolean k = false;
    private HttpURLConnection l = null;
    private Runnable m = new a();

    /* loaded from: classes6.dex */
    class a implements Runnable {
        a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            if (G.this.a() || G.this.j >= G.this.i) {
                return;
            }
            G.c(G.this);
            Q b = M.a().b();
            if (b != null) {
                b.post(this);
            }
        }
    }

    public G(Context context, String str) {
        this.f4735a = (str == null || str.length() <= 0) ? "" : "";
    }

    static /* synthetic */ int c(G g) {
        int i = g.j;
        g.j = i + 1;
        return i;
    }

    public abstract boolean a(int i, byte[] bArr);

    private void a(int i) {
        String str = i != 1 ? i != 2 ? "" : "application/octet-stream" : "application/json; charset=utf-8";
        if (str.length() > 0) {
            this.l.addRequestProperty("Content-Type", str);
        }
        this.l.addRequestProperty(HttpHeaders.COOKIE, "sessionid=" + this.f4735a);
        try {
            String language = Locale.getDefault().getLanguage();
            if (language.equalsIgnoreCase("zh")) {
                this.l.addRequestProperty(HttpHeaders.ACCEPT_LANGUAGE, Locale.getDefault().toString() + com.amazon.a.a.o.b.f.f114a + language + ";q=0.9");
            } else {
                this.l.addRequestProperty(HttpHeaders.ACCEPT_LANGUAGE, Locale.getDefault().toString() + com.amazon.a.a.o.b.f.f114a + language + ";q=0.9,en-US;q=0.6,en;q=0.4");
            }
        } catch (Throwable unused) {
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* JADX WARN: Code restructure failed: missing block: B:39:0x00b5, code lost:
        if (r2 == null) goto L35;
     */
    /* JADX WARN: Code restructure failed: missing block: B:42:0x00ba, code lost:
        if (r1 != null) goto L42;
     */
    /* JADX WARN: Code restructure failed: missing block: B:48:0x00c4, code lost:
        r1.disconnect();
        r8.l = null;
     */
    /* JADX WARN: Code restructure failed: missing block: B:49:0x00c9, code lost:
        r1 = r3;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean a() {
        /*
            Method dump skipped, instructions count: 212
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: com.pgl.ssdk.G.a():boolean");
    }

    public void a(int i, int i2, byte[] bArr) {
        Q b;
        this.c = i;
        this.d = i2;
        this.e = bArr;
        Runnable runnable = this.m;
        if (runnable == null || (b = M.a().b()) == null) {
            return;
        }
        b.post(runnable);
    }
}
