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;

/* renamed from: ˑᵼ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final /* synthetic */ class C2124 implements InterfaceC2395, InterfaceC2147, InterfaceC0832, InterfaceC0772, InterfaceC5524, InterfaceC4607 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public int f8374;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final /* synthetic */ int f8375;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public Object f8376;

    public C2124(byte b, int i) {
        this.f8375 = i;
        switch (i) {
            case 12:
                this.f8376 = new C3493(8);
                break;
            default:
                this.f8376 = Bitmap.CompressFormat.JPEG;
                this.f8374 = 100;
                break;
        }
    }

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

    public C2124(int i, int i2) {
        this.f8375 = i2;
        switch (i2) {
            case 10:
                this.f8374 = i;
                break;
            default:
                this.f8376 = new long[i];
                break;
        }
    }

    public /* synthetic */ C2124(int i, int i2, Object obj) {
        this.f8375 = i2;
        this.f8376 = obj;
        this.f8374 = i;
    }

    public C2124(Context context) {
        this.f8375 = 3;
        this.f8376 = context;
        this.f8374 = 0;
    }

    public C2124(C0548 c0548, int i) {
        this.f8375 = 14;
        ᵩʛʽ.ᵝᵵᵺ(c0548);
        this.f8376 = c0548;
        this.f8374 = i;
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public C2124(C4463 c4463, int i) {
        this(i, 10);
        this.f8375 = 10;
        this.f8376 = c4463;
    }

    public C2124(C4782 c4782) {
        this.f8375 = 8;
        this.f8374 = c4782.f17765;
        this.f8376 = (InputStream) c4782.f17768;
        DesugarCollections.unmodifiableMap(new HashMap((HashMap) c4782.f17767));
    }

    public C2124(boolean z, boolean z2, boolean z3) {
        this.f8375 = 7;
        this.f8374 = (z || z2 || z3) ? 1 : 0;
    }

    public C2124(int[] iArr, int i) {
        C3938 c3938;
        this.f8375 = 13;
        this.f8374 = i;
        if (iArr != null) {
            C3938 c39382 = C3938.f14875;
            c3938 = iArr.length == 0 ? C3938.f14875 : new C3938(Arrays.copyOf(iArr, iArr.length));
        } else {
            c3938 = C3938.f14875;
        }
        this.f8376 = c3938;
    }

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public static void m5714(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.InterfaceC4607
    public /* synthetic */ ListenableFuture call() {
        return ((C3460) this.f8376).m7876(this.f8374);
    }

    public String toString() {
        int i = 0;
        switch (this.f8375) {
            case 4:
                return new String((char[]) this.f8376, 0, this.f8374);
            case 13:
                C3938 c3938 = (C3938) this.f8376;
                ArrayList arrayList = new ArrayList(c3938.f14876);
                while (true) {
                    int i2 = c3938.f14876;
                    if (i >= i2) {
                        return "UnsupportedBrands{major=" + AbstractC3558.m8137(this.f8374) + ", compatible=" + arrayList + "}";
                    }
                    ᵛᵾˏ.ᵡʠ(i, i2);
                    arrayList.add(AbstractC3558.m8137(c3938.f14877[i]));
                    i++;
                }
            default:
                return super.toString();
        }
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ˇʼʤˎ */
    public int mo1125(C2720 c2720, C2441 c2441, int i) {
        C3896 c3896 = (C3896) this.f8376;
        int i2 = this.f8374;
        if (c3896.f14528) {
            return -3;
        }
        C2314 c2314 = (C2314) c3896.f14520.get(i2);
        return c2314.f9080.m4780(c2720, c2441, i, c2314.f9083);
    }

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public void m5715(int i, C4657 c4657) {
        while (true) {
            int i2 = i >> 1;
            if (i2 == 0) {
                break;
            }
            C4657 c46572 = ((C4657[]) this.f8376)[i2];
            if (ᵲᵝᵪ.ˌʾˀ(0L, c4657.f17238 - c46572.f17238) <= 0) {
                break;
            }
            c46572.f17239 = i;
            ((C4657[]) this.f8376)[i] = c46572;
            i = i2;
        }
        ((C4657[]) this.f8376)[i] = c4657;
        c4657.f17239 = i;
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ˌᵜᵹᵩ */
    public int mo1126(long j) {
        C3896 c3896 = (C3896) this.f8376;
        int i = this.f8374;
        if (c3896.f14528) {
            return -3;
        }
        C2314 c2314 = (C2314) c3896.f14520.get(i);
        C1666 c1666 = c2314.f9080;
        int iM4789 = c1666.m4789(c2314.f9083, j);
        c1666.m4768(iM4789);
        return iM4789;
    }

    @Override // defpackage.InterfaceC0832
    /* renamed from: ˎˏʜʾ */
    public boolean mo2946(String str, MediaCodecInfo.CodecCapabilities codecCapabilities) {
        return codecCapabilities.isFeatureRequired(str);
    }

    @Override // defpackage.InterfaceC0832
    /* renamed from: ˏˋٴ */
    public boolean mo2947(String str, String str2, MediaCodecInfo.CodecCapabilities codecCapabilities) {
        return codecCapabilities.isFeatureSupported(str);
    }

    @Override // defpackage.InterfaceC0832
    /* renamed from: ˏᵙ */
    public MediaCodecInfo mo2948(int i) {
        if (((MediaCodecInfo[]) this.f8376) == null) {
            this.f8376 = new MediaCodecList(this.f8374).getCodecInfos();
        }
        return ((MediaCodecInfo[]) this.f8376)[i];
    }

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public void m5716(String str) {
        int length = str.length();
        if (length == 0) {
            return;
        }
        m5721(this.f8374, length);
        str.getChars(0, str.length(), (char[]) this.f8376, this.f8374);
        this.f8374 += length;
    }

    @Override // defpackage.InterfaceC0832
    /* renamed from: ᵝᵵᵺ */
    public boolean mo2949() {
        return true;
    }

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public void m5717() {
        C5229 c5229 = C5229.f19601;
        char[] cArr = (char[]) this.f8376;
        synchronized (c5229) {
            int i = c5229.f19603;
            if (cArr.length + i < AbstractC1228.f5170) {
                c5229.f19603 = i + cArr.length;
                c5229.f19602.addLast(cArr);
            }
        }
    }

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public void m5718(C2559 c2559, int i, int i2) {
        ((C4463) this.f8376).m9490(new C5171(c2559), i, i2);
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ᵥᵯˎ */
    public boolean mo1128() {
        C3896 c3896 = (C3896) this.f8376;
        int i = this.f8374;
        if (c3896.f14528) {
            return false;
        }
        C2314 c2314 = (C2314) c3896.f14520.get(i);
        return c2314.f9080.m4773(c2314.f9083);
    }

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public String m5719(C4861 c4861) {
        C0405 c0405 = (C0405) this.f8376;
        int i = this.f8374;
        try {
            if (c0405.f2294 == null) {
                throw null;
            }
            InterfaceC2876 interfaceC2876 = c0405.f2294;
            String packageName = c0405.f2296.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";
            BinderC3776 binderC3776 = new BinderC3776(c4861);
            C4223 c4223 = (C4223) interfaceC2876;
            Parcel parcelM8907 = c4223.m8907();
            parcelM8907.writeString(packageName);
            parcelM8907.writeString(str);
            int i2 = AbstractC1474.f5933;
            parcelM8907.writeStrongBinder(binderC3776);
            try {
                c4223.f15206.transact(1, parcelM8907, null, 1);
                parcelM8907.recycle();
                return "billingOverrideService.getBillingOverride";
            } catch (Throwable th) {
                parcelM8907.recycle();
                throw th;
            }
        } catch (Exception unused) {
            c0405.m1876(95, 28, AbstractC5497.f20615);
            AbstractC1845.m5213("BillingClientTesting");
            c4861.m10185(0);
            return "billingOverrideService.getBillingOverride";
        }
    }

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public void m5720(C4657 c4657) {
        C4657 c46572;
        int i = c4657.f17239;
        if (i == -1) {
            ᵹˉᵞ.ˌᵜᵹᵩ("Failed requirement.");
            return;
        }
        int i2 = this.f8374;
        C4657[] c4657Arr = (C4657[]) this.f8376;
        C4657 c46573 = c4657Arr[i2];
        c4657.f17239 = -1;
        c4657Arr[i2] = null;
        this.f8374 = i2 - 1;
        if (c4657 == c46573) {
            return;
        }
        int i3 = ᵲᵝᵪ.ˌʾˀ(0L, c46573.f17238 - c4657.f17238);
        if (i3 == 0) {
            ((C4657[]) this.f8376)[i] = c46573;
            c46573.f17239 = i;
            return;
        }
        if (i3 >= 0) {
            m5715(i, c46573);
            return;
        }
        while (true) {
            int i4 = i << 1;
            int i5 = i4 + 1;
            int i6 = this.f8374;
            if (i5 > i6) {
                if (i4 > i6) {
                    break;
                } else {
                    c46572 = ((C4657[]) this.f8376)[i4];
                }
            } else {
                C4657[] c4657Arr2 = (C4657[]) this.f8376;
                c46572 = c4657Arr2[i4];
                C4657 c46574 = c4657Arr2[i5];
                if (ᵲᵝᵪ.ˌʾˀ(0L, c46574.f17238 - c46572.f17238) >= 0) {
                    c46572 = c46574;
                }
            }
            if (ᵲᵝᵪ.ˌʾˀ(0L, c46572.f17238 - c46573.f17238) <= 0) {
                break;
            }
            int i7 = c46572.f17239;
            c46572.f17239 = i;
            ((C4657[]) this.f8376)[i] = c46572;
            i = i7;
        }
        ((C4657[]) this.f8376)[i] = c46573;
        c46573.f17239 = i;
    }

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public void m5721(int i, int i2) {
        int i3 = i2 + i;
        char[] cArr = (char[]) this.f8376;
        if (cArr.length <= i3) {
            int i4 = i * 2;
            if (i3 < i4) {
                i3 = i4;
            }
            this.f8376 = Arrays.copyOf(cArr, i3);
        }
    }

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public long m5722(int i) {
        if (i >= 0 && i < this.f8374) {
            return ((long[]) this.f8376)[i];
        }
        ᵨᴵᵺ.ᵹᵝᵶ(this.f8374, AbstractC1327.m4097(i, "Invalid index ", ", size is "));
        return 0L;
    }

    @Override // defpackage.InterfaceC0772
    /* renamed from: ᵴᵳ */
    public void mo1129() throws RtspMediaSource$RtspPlaybackException {
        RtspMediaSource$RtspPlaybackException rtspMediaSource$RtspPlaybackException = ((C3896) this.f8376).f14521;
        if (rtspMediaSource$RtspPlaybackException != null) {
            throw rtspMediaSource$RtspPlaybackException;
        }
    }

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public void m5723(long j) {
        int i = this.f8374;
        long[] jArr = (long[]) this.f8376;
        if (i == jArr.length) {
            this.f8376 = Arrays.copyOf(jArr, i * 2);
        }
        long[] jArr2 = (long[]) this.f8376;
        int i2 = this.f8374;
        this.f8374 = i2 + 1;
        jArr2[i2] = j;
    }

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public long m5724(C1938 c1938) {
        C3493 c3493 = (C3493) this.f8376;
        int i = 0;
        c1938.mo4251(c3493.f13082, 0, 1, false);
        int i2 = c3493.f13082[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);
        c1938.mo4251(c3493.f13082, 1, i4, false);
        while (i < i4) {
            i++;
            i5 = (c3493.f13082[i] & 255) + (i5 << 8);
        }
        this.f8374 = i4 + 1 + this.f8374;
        return i5;
    }

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public void m5725(long[] jArr) {
        int length = this.f8374 + jArr.length;
        long[] jArr2 = (long[]) this.f8376;
        if (length > jArr2.length) {
            this.f8376 = Arrays.copyOf(jArr2, Math.max(jArr2.length * 2, length));
        }
        System.arraycopy(jArr, 0, (long[]) this.f8376, this.f8374, jArr.length);
        this.f8374 = length;
    }

    @Override // defpackage.InterfaceC0832
    /* renamed from: ᵹᵝᵶ */
    public int mo2950() {
        if (((MediaCodecInfo[]) this.f8376) == null) {
            this.f8376 = new MediaCodecList(this.f8374).getCodecInfos();
        }
        return ((MediaCodecInfo[]) this.f8376).length;
    }

    @Override // defpackage.InterfaceC2147
    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public InterfaceC4316 mo5726(C3460 c3460) {
        int i;
        Context context;
        int i2 = this.f8374;
        int i3 = 1;
        if (i2 != 1 && (i2 != 0 || ((i = Build.VERSION.SDK_INT) < 31 && ((context = (Context) this.f8376) == null || i < 28 || !context.getPackageManager().hasSystemFeature("com.amazon.hardware.tv_screen"))))) {
            return new ˉᵻ(10).ᵻᵢﹳᵰ(c3460);
        }
        int iM7106 = AbstractC2924.m7106(((C3446) c3460.f12990).f12929);
        ᵳʿˉ.ᵿʗᵝʽ("Creating an asynchronous MediaCodec adapter for track type ".concat(AbstractC3558.m8162(iM7106)));
        C4118 c4118 = new C4118(new C5135(iM7106, 0), new C5135(iM7106, i3));
        c4118.f15381 = true;
        return c4118.mo5726(c3460);
    }

    @Override // defpackage.InterfaceC2395
    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public InterfaceC1725 mo5727(InterfaceC1725 interfaceC1725, C0210 c0210) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ((Bitmap) interfaceC1725.get()).compress((Bitmap.CompressFormat) this.f8376, this.f8374, byteArrayOutputStream);
        interfaceC1725.mo3009();
        return new C1219(byteArrayOutputStream.toByteArray());
    }
}
