package o;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Xml;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.gms.common.wrappers.Wrappers;
import java.lang.reflect.Array;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.zf, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C3111zf implements T8, InterfaceC1955nT, InterfaceC1219fj0 {
    public final /* synthetic */ int l;
    public int m;
    public int n;

    /* renamed from: o, reason: collision with root package name */
    public final Object f826o;

    public C3111zf(Context context) {
        this.l = 6;
        this.n = 0;
        this.f826o = context;
    }

    @Override // o.T8
    public void c(int i, Object obj) {
        ((T8) this.f826o).c(i + (this.n == 0 ? this.m : 0), obj);
    }

    @Override // o.T8
    public void d(Object obj) {
        this.n++;
        ((T8) this.f826o).d(obj);
    }

    @Override // o.T8
    public void e() {
        ((T8) this.f826o).e();
    }

    @Override // o.T8
    public void f(int i, Object obj) {
        ((T8) this.f826o).f(i + (this.n == 0 ? this.m : 0), obj);
    }

    @Override // o.T8
    public void g(int i, int i2, int i3) {
        int i4 = this.n == 0 ? this.m : 0;
        ((T8) this.f826o).g(i + i4, i2 + i4, i3);
    }

    @Override // o.T8
    public Object h() {
        return ((T8) this.f826o).h();
    }

    @Override // o.T8
    public void i(int i, int i2) {
        ((T8) this.f826o).i(i + (this.n == 0 ? this.m : 0), i2);
    }

    @Override // o.InterfaceC1219fj0
    public int j() {
        return this.n;
    }

    @Override // o.T8
    public void k(Object obj, SC sc) {
        ((T8) this.f826o).k(obj, sc);
    }

    @Override // o.InterfaceC1028dj0
    public Y6 l(long j, Y6 y6, Y6 y62, Y6 y63) {
        return ((S60) this.f826o).l(j, y6, y62, y63);
    }

    @Override // o.InterfaceC1028dj0
    public Y6 m(long j, Y6 y6, Y6 y62, Y6 y63) {
        return ((S60) this.f826o).m(j, y6, y62, y63);
    }

    @Override // o.InterfaceC1955nT
    public int n(int i) {
        int iN = ((InterfaceC1955nT) this.f826o).n(i);
        if (i >= 0 && i <= this.n) {
            AbstractC2833wi0.c(iN, this.m, i);
        }
        return iN;
    }

    @Override // o.InterfaceC1219fj0
    public int o() {
        return this.m;
    }

    @Override // o.InterfaceC1955nT
    public int p(int i) {
        int iP = ((InterfaceC1955nT) this.f826o).p(i);
        if (i >= 0 && i <= this.m) {
            AbstractC2833wi0.b(iP, this.n, i);
        }
        return iP;
    }

    @Override // o.T8
    public void q() {
        if (!(this.n > 0)) {
            AbstractC0373Ok.c("OffsetApplier up called with no corresponding down");
        }
        this.n--;
        ((T8) this.f826o).q();
    }

    public byte s(int i, int i2) {
        return ((byte[][]) this.f826o)[i2][i];
    }

    public void t(int i, int i2, int i3) {
        ((byte[][]) this.f826o)[i2][i] = (byte) i3;
    }

    public String toString() {
        switch (this.l) {
            case 0:
                int i = this.m;
                int i2 = this.n;
                StringBuilder sb = new StringBuilder((i * 2 * i2) + 2);
                for (int i3 = 0; i3 < i2; i3++) {
                    byte[] bArr = ((byte[][]) this.f826o)[i3];
                    for (int i4 = 0; i4 < i; i4++) {
                        byte b = bArr[i4];
                        if (b == 0) {
                            sb.append(" 0");
                        } else if (b != 1) {
                            sb.append("  ");
                        } else {
                            sb.append(" 1");
                        }
                    }
                    sb.append('\n');
                }
                return sb.toString();
            default:
                return super.toString();
        }
    }

    public synchronized int u() {
        PackageInfo packageInfo;
        if (this.m == 0) {
            try {
                packageInfo = Wrappers.packageManager((Context) this.f826o).getPackageInfo("com.google.android.gms", 0);
            } catch (PackageManager.NameNotFoundException e) {
                "Failed to find package ".concat(e.toString());
                packageInfo = null;
            }
            if (packageInfo != null) {
                this.m = packageInfo.versionCode;
            }
        }
        return this.m;
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0043 A[Catch: all -> 0x0041, TryCatch #0 {all -> 0x0041, blocks: (B:3:0x0001, B:7:0x0007, B:12:0x0021, B:14:0x0028, B:16:0x003a, B:26:0x005d, B:21:0x0043, B:23:0x0056, B:29:0x0061, B:33:0x0069), top: B:38:0x0001 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public synchronized int v() {
        /*
            r5 = this;
            monitor-enter(r5)
            int r0 = r5.n     // Catch: java.lang.Throwable -> L41
            if (r0 == 0) goto L7
            monitor-exit(r5)
            return r0
        L7:
            java.lang.Object r0 = r5.f826o     // Catch: java.lang.Throwable -> L41
            android.content.Context r0 = (android.content.Context) r0     // Catch: java.lang.Throwable -> L41
            android.content.pm.PackageManager r1 = r0.getPackageManager()     // Catch: java.lang.Throwable -> L41
            com.google.android.gms.common.wrappers.PackageManagerWrapper r0 = com.google.android.gms.common.wrappers.Wrappers.packageManager(r0)     // Catch: java.lang.Throwable -> L41
            java.lang.String r2 = "com.google.android.c2dm.permission.SEND"
            java.lang.String r3 = "com.google.android.gms"
            int r0 = r0.checkPermission(r2, r3)     // Catch: java.lang.Throwable -> L41
            r2 = -1
            r3 = 0
            if (r0 != r2) goto L21
            monitor-exit(r5)
            return r3
        L21:
            boolean r0 = com.google.android.gms.common.util.PlatformVersion.isAtLeastO()     // Catch: java.lang.Throwable -> L41
            r2 = 1
            if (r0 != 0) goto L43
            android.content.Intent r0 = new android.content.Intent     // Catch: java.lang.Throwable -> L41
            java.lang.String r4 = "com.google.android.c2dm.intent.REGISTER"
            r0.<init>(r4)     // Catch: java.lang.Throwable -> L41
            java.lang.String r4 = "com.google.android.gms"
            r0.setPackage(r4)     // Catch: java.lang.Throwable -> L41
            java.util.List r0 = r1.queryIntentServices(r0, r3)     // Catch: java.lang.Throwable -> L41
            if (r0 == 0) goto L43
            boolean r0 = r0.isEmpty()     // Catch: java.lang.Throwable -> L41
            if (r0 != 0) goto L43
            goto L5d
        L41:
            r0 = move-exception
            goto L6d
        L43:
            android.content.Intent r0 = new android.content.Intent     // Catch: java.lang.Throwable -> L41
            java.lang.String r4 = "com.google.iid.TOKEN_REQUEST"
            r0.<init>(r4)     // Catch: java.lang.Throwable -> L41
            java.lang.String r4 = "com.google.android.gms"
            r0.setPackage(r4)     // Catch: java.lang.Throwable -> L41
            java.util.List r0 = r1.queryBroadcastReceivers(r0, r3)     // Catch: java.lang.Throwable -> L41
            r1 = 2
            if (r0 == 0) goto L61
            boolean r0 = r0.isEmpty()     // Catch: java.lang.Throwable -> L41
            if (r0 != 0) goto L61
            r2 = r1
        L5d:
            r5.n = r2     // Catch: java.lang.Throwable -> L41
            monitor-exit(r5)
            return r2
        L61:
            boolean r0 = com.google.android.gms.common.util.PlatformVersion.isAtLeastO()     // Catch: java.lang.Throwable -> L41
            if (r2 == r0) goto L68
            goto L69
        L68:
            r2 = r1
        L69:
            r5.n = r2     // Catch: java.lang.Throwable -> L41
            monitor-exit(r5)
            return r2
        L6d:
            monitor-exit(r5)     // Catch: java.lang.Throwable -> L41
            throw r0
        */
        throw new UnsupportedOperationException("Method not decompiled: o.C3111zf.v():int");
    }

    public C3111zf(int i, int i2, int i3) {
        this.l = i3;
        switch (i3) {
            case 2:
                this.f826o = null;
                this.m = i;
                int i4 = i2 & 7;
                this.n = i4 == 0 ? 8 : i4;
                break;
            default:
                this.f826o = (byte[][]) Array.newInstance((Class<?>) Byte.TYPE, i2, i);
                this.m = i;
                this.n = i2;
                break;
        }
    }

    public C3111zf(InterfaceC1955nT interfaceC1955nT, int i, int i2) {
        this.l = 4;
        this.f826o = interfaceC1955nT;
        this.m = i;
        this.n = i2;
    }

    public C3111zf(Context context, XmlResourceParser xmlResourceParser) throws Resources.NotFoundException {
        this.l = 1;
        this.f826o = new ArrayList();
        this.n = -1;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlResourceParser), RZ.h);
        int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int index = typedArrayObtainStyledAttributes.getIndex(i);
            if (index == 0) {
                this.m = typedArrayObtainStyledAttributes.getResourceId(index, this.m);
            } else if (index == 1) {
                int resourceId = typedArrayObtainStyledAttributes.getResourceId(index, this.n);
                this.n = resourceId;
                String resourceTypeName = context.getResources().getResourceTypeName(resourceId);
                context.getResources().getResourceName(resourceId);
                if ("layout".equals(resourceTypeName)) {
                    new C0426Ql().b((ConstraintLayout) LayoutInflater.from(context).inflate(resourceId, (ViewGroup) null));
                }
            }
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public C3111zf() {
        this.l = 2;
        this.f826o = new C3111zf[256];
        this.m = 0;
        this.n = 0;
    }

    public C3111zf(T8 t8, int i) {
        this.l = 3;
        this.f826o = t8;
        this.m = i;
    }

    public C3111zf(int i, int i2, InterfaceC0564Vt interfaceC0564Vt) {
        this.l = 5;
        this.m = i;
        this.n = i2;
        this.f826o = new S60(new C1819lz(i, i2, interfaceC0564Vt));
    }
}
