package com.google.android.gms.internal.measurement;

import android.content.Context;
import android.net.Uri;
import android.util.Log;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import v0.AbstractC1664c;

/* JADX INFO: loaded from: classes.dex */
public final class I1 {

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final Object f9605g = new Object();

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static volatile C0722x1 f9606h;
    public static final AtomicInteger i;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final K.g f9607a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final String f9608b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f9609c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public volatile int f9610d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public volatile Object f9611e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ int f9612f;

    static {
        new AtomicReference();
        i = new AtomicInteger();
    }

    public /* synthetic */ I1(K.g gVar, String str, Object obj, int i5) {
        this.f9612f = i5;
        if (((Uri) gVar.f3524b) == null) {
            throw new IllegalArgumentException("Must pass a valid SharedPreferences file name or ContentProvider URI");
        }
        this.f9607a = gVar;
        this.f9608b = str;
        this.f9609c = obj;
    }

    public final Object a(Object obj) {
        switch (this.f9612f) {
            case n4.u0.f15495q /* 0 */:
                if (!(obj instanceof Long)) {
                    if (obj instanceof String) {
                        try {
                            break;
                        } catch (NumberFormatException unused) {
                        }
                    }
                    Log.e("PhenotypeFlag", "Invalid long value for " + this.f9608b + ": " + obj.toString());
                }
                break;
            case 1:
                if (!(obj instanceof Boolean)) {
                    if (obj instanceof String) {
                        String str = (String) obj;
                        if (!AbstractC0702t1.f9967b.matcher(str).matches()) {
                            if (AbstractC0702t1.f9968c.matcher(str).matches()) {
                            }
                        }
                    }
                    Log.e("PhenotypeFlag", "Invalid boolean value for " + this.f9608b + ": " + obj.toString());
                    break;
                }
                break;
            case 2:
                if (!(obj instanceof Double)) {
                    if (!(obj instanceof Float)) {
                        if (obj instanceof String) {
                            try {
                                break;
                            } catch (NumberFormatException unused2) {
                            }
                        }
                        Log.e("PhenotypeFlag", "Invalid double value for " + this.f9608b + ": " + obj.toString());
                    }
                }
                break;
            default:
                if (obj instanceof String) {
                }
                break;
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x005a A[PHI: r2
      0x005a: PHI (r2v1 B3.g) = (r2v0 B3.g), (r2v0 B3.g), (r2v4 B3.g), (r2v4 B3.g) binds: [B:8:0x0014, B:10:0x0018, B:12:0x0024, B:18:0x0049] A[DONT_GENERATE, DONT_INLINE]] */
    /* JADX WARN: Removed duplicated region for block: B:24:0x005d  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x005f  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x006d A[Catch: all -> 0x0057, TryCatch #0 {all -> 0x0057, blocks: (B:5:0x000b, B:7:0x000f, B:9:0x0016, B:11:0x001a, B:13:0x0026, B:15:0x0036, B:19:0x004a, B:26:0x0060, B:28:0x006d, B:30:0x0075, B:33:0x0088, B:35:0x0096, B:47:0x00bb, B:50:0x00c3, B:51:0x00c6, B:52:0x00ca, B:39:0x009f, B:41:0x00a3, B:43:0x00b1, B:45:0x00b7, B:53:0x00cf, B:54:0x00d1, B:16:0x0043, B:55:0x00d2), top: B:61:0x000b }] */
    /* JADX WARN: Removed duplicated region for block: B:36:0x009b  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x00cf A[Catch: all -> 0x0057, TryCatch #0 {all -> 0x0057, blocks: (B:5:0x000b, B:7:0x000f, B:9:0x0016, B:11:0x001a, B:13:0x0026, B:15:0x0036, B:19:0x004a, B:26:0x0060, B:28:0x006d, B:30:0x0075, B:33:0x0088, B:35:0x0096, B:47:0x00bb, B:50:0x00c3, B:51:0x00c6, B:52:0x00ca, B:39:0x009f, B:41:0x00a3, B:43:0x00b1, B:45:0x00b7, B:53:0x00cf, B:54:0x00d1, B:16:0x0043, B:55:0x00d2), top: B:61:0x000b }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object b() {
        String str;
        Uri uri;
        String strL;
        B3.l lVar;
        q.i iVar;
        int i5 = i.get();
        if (this.f9610d < i5) {
            synchronized (this) {
                try {
                    if (this.f9610d < i5) {
                        C0722x1 c0722x1 = f9606h;
                        B3.g gVar = B3.a.f971q;
                        Object objA = null;
                        if (c0722x1 == null || (lVar = c0722x1.f10063b) == null) {
                            str = null;
                            AbstractC1664c.j("Must call PhenotypeFlagInitializer.maybeInit() first", c0722x1 != null);
                            K.g gVar2 = this.f9607a;
                            uri = (Uri) gVar2.f3524b;
                            if (uri == null) {
                                Context context = c0722x1.f10062a;
                                throw null;
                            }
                            C0727y1 c0727y1A = D1.a(c0722x1.f10062a, uri) ? C0727y1.a(c0722x1.f10062a.getContentResolver(), uri, new F1()) : null;
                            if (c0727y1A != null) {
                                String str2 = (String) c0727y1A.b().get(this.f9608b);
                                Object objA2 = str2 != null ? a(str2) : null;
                                if (objA2 == null) {
                                    if (!gVar2.f3523a && (strL = B1.i(c0722x1.f10062a).l(this.f9608b)) != null) {
                                        objA = a(strL);
                                    }
                                    objA2 = objA == null ? this.f9609c : objA;
                                }
                                if (gVar.b()) {
                                    objA2 = str == null ? this.f9609c : a(str);
                                }
                                this.f9611e = objA2;
                                this.f9610d = i5;
                            }
                        } else {
                            gVar = (B3.g) lVar.get();
                            if (gVar.b()) {
                                C0732z1 c0732z1 = (C0732z1) gVar.a();
                                Uri uri2 = (Uri) this.f9607a.f3524b;
                                String str3 = this.f9608b;
                                if (uri2 != null) {
                                    iVar = (q.i) c0732z1.f10082a.get(uri2.toString());
                                } else {
                                    c0732z1.getClass();
                                    iVar = null;
                                }
                                if (iVar == null) {
                                    str = null;
                                    AbstractC1664c.j("Must call PhenotypeFlagInitializer.maybeInit() first", c0722x1 != null);
                                    K.g gVar22 = this.f9607a;
                                    uri = (Uri) gVar22.f3524b;
                                    if (uri == null) {
                                    }
                                } else {
                                    str = (String) iVar.get("".concat(str3));
                                    AbstractC1664c.j("Must call PhenotypeFlagInitializer.maybeInit() first", c0722x1 != null);
                                    K.g gVar222 = this.f9607a;
                                    uri = (Uri) gVar222.f3524b;
                                    if (uri == null) {
                                    }
                                }
                            }
                        }
                    }
                } finally {
                }
            }
        }
        return this.f9611e;
    }
}
