package defpackage;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.os.Build;
import android.os.Parcel;
import androidx.media3.exoplayer.rtsp.RtspMediaSource$RtspPlaybackException;
import com.google.common.util.concurrent.ListenableFuture;
import j$.util.DesugarCollections;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

/* JADX INFO: renamed from: ˎᵷˇ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class C1785 implements InterfaceC0765, InterfaceC2865, InterfaceC3750, InterfaceC4833, InterfaceC5444, InterfaceC2559 {

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public final /* synthetic */ int f7161;

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public Object f7162;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public int f7163;

    public C1785(byte b, int i) {
        this.f7161 = i;
        switch (i) {
            case 12:
                this.f7162 = new C4545(8);
                break;
            default:
                this.f7162 = Bitmap.CompressFormat.JPEG;
                this.f7163 = 100;
                break;
        }
    }

    public /* synthetic */ C1785(char c, int i) {
        this.f7161 = i;
    }

    public C1785(int i, int i2) {
        this.f7161 = i2;
        switch (i2) {
            case 10:
                this.f7163 = i;
                break;
            default:
                this.f7162 = new long[i];
                break;
        }
    }

    public /* synthetic */ C1785(int i, int i2, Object obj) {
        this.f7161 = i2;
        this.f7162 = obj;
        this.f7163 = i;
    }

    public C1785(Context context) {
        this.f7161 = 3;
        this.f7162 = context;
        this.f7163 = 0;
    }

    public C1785(C1404 c1404) {
        this.f7161 = 8;
        this.f7163 = c1404.f5808;
        this.f7162 = (InputStream) c1404.f5807;
        DesugarCollections.unmodifiableMap(new HashMap((HashMap) c1404.f5809));
    }

    public C1785(C2646 c2646, int i) {
        this.f7161 = 14;
        ᵘᵞʿⁱ.ᵶᵥᵝ(c2646);
        this.f7162 = c2646;
        this.f7163 = i;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C1785(C4115 c4115, int i) {
        this(i, 10);
        this.f7161 = 10;
        this.f7162 = c4115;
    }

    public C1785(boolean z, boolean z2, boolean z3) {
        this.f7161 = 7;
        this.f7163 = (z || z2 || z3) ? 1 : 0;
    }

    public C1785(int[] iArr, int i) {
        C2901 c2901;
        this.f7161 = 13;
        this.f7163 = i;
        if (iArr != null) {
            C2901 c29012 = C2901.f11150;
            c2901 = iArr.length == 0 ? C2901.f11150 : new C2901(Arrays.copyOf(iArr, iArr.length));
        } else {
            c2901 = C2901.f11150;
        }
        this.f7162 = c2901;
    }

    /* JADX INFO: renamed from: ᵮᵣᵗˈ, reason: contains not printable characters */
    public static void m4922(String str) {
        if (str.equalsIgnoreCase(":memory:")) {
            return;
        }
        int length = str.length() - 1;
        int i = 0;
        boolean z = false;
        while (i <= length) {
            boolean z2 = ᵥˈᵛ.ˊᵙᵾᵲ(str.charAt(!z ? i : length), 32) <= 0;
            if (z) {
                if (!z2) {
                    break;
                } else {
                    length--;
                }
            } else if (z2) {
                i++;
            } else {
                z = true;
            }
        }
        if (str.subSequence(i, length + 1).toString().length() == 0) {
            return;
        }
        try {
            SQLiteDatabase.deleteDatabase(new File(str));
        } catch (Exception unused) {
        }
    }

    @Override // defpackage.InterfaceC2559
    public /* synthetic */ ListenableFuture call() {
        return ((C2781) this.f7162).m6752(this.f7163);
    }

    public String toString() {
        int i = 0;
        switch (this.f7161) {
            case 4:
                return new String((char[]) this.f7162, 0, this.f7163);
            case 13:
                C2901 c2901 = (C2901) this.f7162;
                ArrayList arrayList = new ArrayList(c2901.f11152);
                while (true) {
                    int i2 = c2901.f11152;
                    if (i >= i2) {
                        return "UnsupportedBrands{major=" + AbstractC0956.m3242(this.f7163) + ", compatible=" + arrayList + "}";
                    }
                    ᵻᵪ.ˋˈ(i, i2);
                    arrayList.add(AbstractC0956.m3242(c2901.f11151[i]));
                    i++;
                }
                break;
            default:
                return super.toString();
        }
    }

    @Override // defpackage.InterfaceC4833
    /* JADX INFO: renamed from: ʽˈˋ */
    public void mo1983() throws RtspMediaSource$RtspPlaybackException {
        RtspMediaSource$RtspPlaybackException rtspMediaSource$RtspPlaybackException = ((C5139) this.f7162).f19328;
        if (rtspMediaSource$RtspPlaybackException != null) {
            throw rtspMediaSource$RtspPlaybackException;
        }
    }

    /* JADX INFO: renamed from: ˉᵲ, reason: contains not printable characters */
    public long m4923(C2373 c2373) {
        C4545 c4545 = (C4545) this.f7162;
        int i = 0;
        c2373.mo4708(c4545.f17284, 0, 1, false);
        int i2 = c4545.f17284[0] & 255;
        if (i2 == 0) {
            return Long.MIN_VALUE;
        }
        int i3 = 128;
        int i4 = 0;
        while ((i2 & i3) == 0) {
            i3 >>= 1;
            i4++;
        }
        int i5 = i2 & (~i3);
        c2373.mo4708(c4545.f17284, 1, i4, false);
        while (i < i4) {
            i++;
            i5 = (c4545.f17284[i] & 255) + (i5 << 8);
        }
        this.f7163 = i4 + 1 + this.f7163;
        return i5;
    }

    @Override // defpackage.InterfaceC0765
    /* JADX INFO: renamed from: ˊᵙᵾᵲ */
    public InterfaceC1364 mo2754(InterfaceC1364 interfaceC1364, C2220 c2220) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ((Bitmap) interfaceC1364.get()).compress((Bitmap.CompressFormat) this.f7162, this.f7163, byteArrayOutputStream);
        interfaceC1364.mo2291();
        return new C1107(byteArrayOutputStream.toByteArray());
    }

    /* JADX INFO: renamed from: ˊᵨᵧ, reason: contains not printable characters */
    public void m4924(C5162 c5162) {
        C5162 c51622;
        int i = c5162.f19400;
        if (i == -1) {
            ᵕᵩʽᵲ.ᵮᵣᵗˈ("Failed requirement.");
            return;
        }
        int i2 = this.f7163;
        C5162[] c5162Arr = (C5162[]) this.f7162;
        C5162 c51623 = c5162Arr[i2];
        c5162.f19400 = -1;
        c5162Arr[i2] = null;
        this.f7163 = i2 - 1;
        if (c5162 == c51623) {
            return;
        }
        int i3 = ᵥˈᵛ.ˉᵲ(0L, c51623.f19399 - c5162.f19399);
        if (i3 == 0) {
            ((C5162[]) this.f7162)[i] = c51623;
            c51623.f19400 = i;
            return;
        }
        if (i3 >= 0) {
            m4931(i, c51623);
            return;
        }
        while (true) {
            int i4 = i << 1;
            int i5 = i4 + 1;
            int i6 = this.f7163;
            if (i5 > i6) {
                if (i4 > i6) {
                    break;
                } else {
                    c51622 = ((C5162[]) this.f7162)[i4];
                }
            } else {
                C5162[] c5162Arr2 = (C5162[]) this.f7162;
                c51622 = c5162Arr2[i4];
                C5162 c51624 = c5162Arr2[i5];
                if (ᵥˈᵛ.ˉᵲ(0L, c51624.f19399 - c51622.f19399) >= 0) {
                    c51622 = c51624;
                }
            }
            if (ᵥˈᵛ.ˉᵲ(0L, c51622.f19399 - c51623.f19399) <= 0) {
                break;
            }
            int i7 = c51622.f19400;
            c51622.f19400 = i;
            ((C5162[]) this.f7162)[i] = c51622;
            i = i7;
        }
        ((C5162[]) this.f7162)[i] = c51623;
        c51623.f19400 = i;
    }

    @Override // defpackage.InterfaceC3750
    /* JADX INFO: renamed from: ˊᵫᵗ, reason: contains not printable characters */
    public boolean mo4925(String str, MediaCodecInfo.CodecCapabilities codecCapabilities) {
        return codecCapabilities.isFeatureRequired(str);
    }

    /* JADX INFO: renamed from: ˋˈ, reason: contains not printable characters */
    public void m4926(int i, int i2) {
        int i3 = i2 + i;
        char[] cArr = (char[]) this.f7162;
        if (cArr.length <= i3) {
            int i4 = i * 2;
            if (i3 < i4) {
                i3 = i4;
            }
            this.f7162 = Arrays.copyOf(cArr, i3);
        }
    }

    /* JADX INFO: renamed from: ˌᴵ, reason: contains not printable characters */
    public void m4927(String str) {
        int length = str.length();
        if (length == 0) {
            return;
        }
        m4926(this.f7163, length);
        str.getChars(0, str.length(), (char[]) this.f7162, this.f7163);
        this.f7163 += length;
    }

    /* JADX INFO: renamed from: ˏːˆ, reason: contains not printable characters */
    public void m4928() {
        C3889 c3889 = C3889.f14834;
        char[] cArr = (char[]) this.f7162;
        synchronized (c3889) {
            int i = c3889.f14835;
            if (cArr.length + i < AbstractC3568.f13655) {
                c3889.f14835 = i + cArr.length;
                c3889.f14836.addLast(cArr);
            }
        }
    }

    @Override // defpackage.InterfaceC3750
    /* JADX INFO: renamed from: ːˏᵟᵯ, reason: contains not printable characters */
    public MediaCodecInfo mo4929(int i) {
        if (((MediaCodecInfo[]) this.f7162) == null) {
            this.f7162 = new MediaCodecList(this.f7163).getCodecInfos();
        }
        return ((MediaCodecInfo[]) this.f7162)[i];
    }

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public String m4930(C1131 c1131) {
        C3939 c3939 = (C3939) this.f7162;
        int i = this.f7163;
        try {
            if (c3939.f15059 == null) {
                throw null;
            }
            InterfaceC2805 interfaceC2805 = c3939.f15059;
            String packageName = c3939.f15058.getPackageName();
            String str = i != 2 ? i != 3 ? i != 4 ? i != 5 ? i != 6 ? "QUERY_PRODUCT_DETAILS_ASYNC" : "START_CONNECTION" : "IS_FEATURE_SUPPORTED" : "CONSUME_ASYNC" : "ACKNOWLEDGE_PURCHASE" : "LAUNCH_BILLING_FLOW";
            BinderC3993 binderC3993 = new BinderC3993(c1131);
            C5475 c5475 = (C5475) interfaceC2805;
            Parcel parcelM10692 = c5475.m10692();
            parcelM10692.writeString(packageName);
            parcelM10692.writeString(str);
            int i2 = AbstractC2284.f8986;
            parcelM10692.writeStrongBinder(binderC3993);
            try {
                c5475.f19470.transact(1, parcelM10692, null, 1);
                parcelM10692.recycle();
                return "billingOverrideService.getBillingOverride";
            } catch (Throwable th) {
                parcelM10692.recycle();
                throw th;
            }
        } catch (Exception unused) {
            c3939.m8679(95, 28, AbstractC4228.f16115);
            AbstractC2252.m5866("BillingClientTesting");
            c1131.m3620(0);
            return "billingOverrideService.getBillingOverride";
        }
    }

    @Override // defpackage.InterfaceC4833
    /* JADX INFO: renamed from: ᵝᵶ */
    public int mo1984(ˊˊᵞᵽ r3, C3008 c3008, int i) {
        C5139 c5139 = (C5139) this.f7162;
        int i2 = this.f7163;
        if (c5139.f19319) {
            return -3;
        }
        C2908 c2908 = (C2908) c5139.f19330.get(i2);
        return c2908.f11195.m3091(r3, c3008, i, c2908.f11198);
    }

    /* JADX INFO: renamed from: ᵟᵹᵙ, reason: contains not printable characters */
    public void m4931(int i, C5162 c5162) {
        while (true) {
            int i2 = i >> 1;
            if (i2 == 0) {
                break;
            }
            C5162 c51622 = ((C5162[]) this.f7162)[i2];
            if (ᵥˈᵛ.ˉᵲ(0L, c5162.f19399 - c51622.f19399) <= 0) {
                break;
            }
            c51622.f19400 = i;
            ((C5162[]) this.f7162)[i] = c51622;
            i = i2;
        }
        ((C5162[]) this.f7162)[i] = c5162;
        c5162.f19400 = i;
    }

    /* JADX INFO: renamed from: ᵨᵣ, reason: contains not printable characters */
    public void m4932(long j) {
        int i = this.f7163;
        long[] jArr = (long[]) this.f7162;
        if (i == jArr.length) {
            this.f7162 = Arrays.copyOf(jArr, i * 2);
        }
        long[] jArr2 = (long[]) this.f7162;
        int i2 = this.f7163;
        this.f7163 = i2 + 1;
        jArr2[i2] = j;
    }

    /* JADX INFO: renamed from: ᵪᵹᵥᵻ, reason: contains not printable characters */
    public long m4933(int i) {
        if (i >= 0 && i < this.f7163) {
            return ((long[]) this.f7162)[i];
        }
        ᵷᵝˎ.ᵻʽᵯ(this.f7163, AbstractC3653.m8237(i, "Invalid index ", ", size is "));
        return 0L;
    }

    /* JADX INFO: renamed from: ᵱʡˏ, reason: contains not printable characters */
    public void m4934(C5178 c5178, int i, int i2) {
        ((C4115) this.f7162).m8981(new C3562(c5178), i, i2);
    }

    @Override // defpackage.InterfaceC3750
    /* JADX INFO: renamed from: ᵱᵽʡᵚ, reason: contains not printable characters */
    public boolean mo4935() {
        return true;
    }

    @Override // defpackage.InterfaceC4833
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public boolean mo1985() {
        C5139 c5139 = (C5139) this.f7162;
        int i = this.f7163;
        if (c5139.f19319) {
            return false;
        }
        C2908 c2908 = (C2908) c5139.f19330.get(i);
        return c2908.f11195.m3119(c2908.f11198);
    }

    /* JADX INFO: renamed from: ᵵᵽ, reason: contains not printable characters */
    public void m4936(long[] jArr) {
        int length = this.f7163 + jArr.length;
        long[] jArr2 = (long[]) this.f7162;
        if (length > jArr2.length) {
            this.f7162 = Arrays.copyOf(jArr2, Math.max(jArr2.length * 2, length));
        }
        System.arraycopy(jArr, 0, (long[]) this.f7162, this.f7163, jArr.length);
        this.f7163 = length;
    }

    @Override // defpackage.InterfaceC4833
    /* JADX INFO: renamed from: ᵶᵥᵝ */
    public int mo1986(long j) {
        C5139 c5139 = (C5139) this.f7162;
        int i = this.f7163;
        if (c5139.f19319) {
            return -3;
        }
        C2908 c2908 = (C2908) c5139.f19330.get(i);
        C0890 c0890 = c2908.f11195;
        int iM3107 = c0890.m3107(c2908.f11198, j);
        c0890.m3108(iM3107);
        return iM3107;
    }

    @Override // defpackage.InterfaceC2865
    /* JADX INFO: renamed from: ᵷᵺʾᵖ, reason: contains not printable characters */
    public InterfaceC1595 mo4937(C2781 c2781) {
        int i;
        Context context;
        int i2 = this.f7163;
        int i3 = 1;
        if (i2 != 1 && (i2 != 0 || ((i = Build.VERSION.SDK_INT) < 31 && ((context = (Context) this.f7162) == null || i < 28 || !context.getPackageManager().hasSystemFeature("com.amazon.hardware.tv_screen"))))) {
            return new ᵻᵧˁ(10).ᵷᵺʾᵖ(c2781);
        }
        int iM9141 = AbstractC4208.m9141(((C5286) c2781.f10706).f19987);
        ˋˀᵧ.ˏːˆ("Creating an asynchronous MediaCodec adapter for track type ".concat(AbstractC0956.m3226(iM9141)));
        C5172 c5172 = new C5172(new C0576(iM9141, 0), new C0576(iM9141, i3));
        c5172.f19475 = true;
        return c5172.mo4937(c2781);
    }

    @Override // defpackage.InterfaceC3750
    /* JADX INFO: renamed from: ᵻʽᵯ, reason: contains not printable characters */
    public int mo4938() {
        if (((MediaCodecInfo[]) this.f7162) == null) {
            this.f7162 = new MediaCodecList(this.f7163).getCodecInfos();
        }
        return ((MediaCodecInfo[]) this.f7162).length;
    }

    @Override // defpackage.InterfaceC3750
    /* JADX INFO: renamed from: ᵻˈᵦʼ, reason: contains not printable characters */
    public boolean mo4939(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
        return codecCapabilities.isFeatureSupported(str);
    }
}
