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

import android.content.Context;
import android.database.ContentObserver;
import o.AbstractC1692kh0;
import o.AbstractC1714ks0;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class c {
    public static c d;
    public final Context a;
    public final ContentObserver b;
    public boolean c;

    public c() {
        this.c = false;
        this.a = null;
        this.b = null;
    }

    public static c a(Context context) {
        c cVar;
        synchronized (c.class) {
            try {
                if (d == null) {
                    d = AbstractC1692kh0.n(context, "com.google.android.providers.gsf.permission.READ_GSERVICES") == 0 ? new c(context) : new c();
                }
                c cVar2 = d;
                if (cVar2 != null && cVar2.b != null && !cVar2.c) {
                    try {
                        context.getContentResolver().registerContentObserver(AbstractC1714ks0.a, true, d.b);
                        c cVar3 = d;
                        cVar3.getClass();
                        cVar3.c = true;
                    } catch (SecurityException unused) {
                    }
                }
                cVar = d;
                cVar.getClass();
            } catch (Throwable th) {
                throw th;
            }
        }
        return cVar;
    }

    /* JADX WARN: Code restructure failed: missing block: B:28:0x003f, code lost:
    
        r6 = true;
     */
    /* JADX WARN: Type inference failed for: r0v2, types: [com.google.android.gms.internal.measurement.b] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final java.lang.String b(final java.lang.String r9) {
        /*
            r8 = this;
            android.content.Context r0 = r8.a
            r1 = 0
            if (r0 == 0) goto L78
            boolean r2 = o.AbstractC2378rs0.b
            r3 = 1
            if (r2 == 0) goto Lb
            goto L50
        Lb:
            java.lang.Class<o.rs0> r2 = o.AbstractC2378rs0.class
            monitor-enter(r2)
            boolean r4 = o.AbstractC2378rs0.b     // Catch: java.lang.Throwable -> L14
            if (r4 == 0) goto L16
            monitor-exit(r2)     // Catch: java.lang.Throwable -> L14
            goto L50
        L14:
            r9 = move-exception
            goto L76
        L16:
            r4 = r3
        L17:
            r5 = 2
            r6 = 0
            if (r4 > r5) goto L46
            android.os.UserManager r5 = o.AbstractC2378rs0.a     // Catch: java.lang.Throwable -> L14
            if (r5 != 0) goto L29
            java.lang.Class<android.os.UserManager> r5 = android.os.UserManager.class
            java.lang.Object r5 = r0.getSystemService(r5)     // Catch: java.lang.Throwable -> L14
            android.os.UserManager r5 = (android.os.UserManager) r5     // Catch: java.lang.Throwable -> L14
            o.AbstractC2378rs0.a = r5     // Catch: java.lang.Throwable -> L14
        L29:
            android.os.UserManager r5 = o.AbstractC2378rs0.a     // Catch: java.lang.Throwable -> L14
            if (r5 != 0) goto L2f
            r6 = r3
            goto L4a
        L2f:
            boolean r7 = r5.isUserUnlocked()     // Catch: java.lang.Throwable -> L14 java.lang.NullPointerException -> L41
            if (r7 != 0) goto L3f
            android.os.UserHandle r7 = android.os.Process.myUserHandle()     // Catch: java.lang.Throwable -> L14 java.lang.NullPointerException -> L41
            boolean r0 = r5.isUserRunning(r7)     // Catch: java.lang.Throwable -> L14 java.lang.NullPointerException -> L41
            if (r0 != 0) goto L46
        L3f:
            r6 = r3
            goto L46
        L41:
            o.AbstractC2378rs0.a = r1     // Catch: java.lang.Throwable -> L14
            int r4 = r4 + 1
            goto L17
        L46:
            if (r6 == 0) goto L4a
            o.AbstractC2378rs0.a = r1     // Catch: java.lang.Throwable -> L14
        L4a:
            if (r6 == 0) goto L4e
            o.AbstractC2378rs0.b = r3     // Catch: java.lang.Throwable -> L14
        L4e:
            monitor-exit(r2)     // Catch: java.lang.Throwable -> L14
            r3 = r6
        L50:
            if (r3 != 0) goto L53
            goto L78
        L53:
            com.google.android.gms.internal.measurement.b r0 = new com.google.android.gms.internal.measurement.b     // Catch: java.lang.Throwable -> L70
            r0.<init>()     // Catch: java.lang.Throwable -> L70
            java.lang.Object r0 = r0.a()     // Catch: java.lang.SecurityException -> L5d java.lang.Throwable -> L70 java.lang.Throwable -> L70
            goto L68
        L5d:
            long r2 = android.os.Binder.clearCallingIdentity()     // Catch: java.lang.Throwable -> L70 java.lang.Throwable -> L70 java.lang.Throwable -> L70
            java.lang.Object r0 = r0.a()     // Catch: java.lang.Throwable -> L6b
            android.os.Binder.restoreCallingIdentity(r2)     // Catch: java.lang.Throwable -> L70 java.lang.Throwable -> L70 java.lang.Throwable -> L70
        L68:
            java.lang.String r0 = (java.lang.String) r0     // Catch: java.lang.Throwable -> L70 java.lang.Throwable -> L70 java.lang.Throwable -> L70
            return r0
        L6b:
            r0 = move-exception
            android.os.Binder.restoreCallingIdentity(r2)     // Catch: java.lang.Throwable -> L70 java.lang.Throwable -> L70 java.lang.Throwable -> L70
            throw r0     // Catch: java.lang.Throwable -> L70 java.lang.Throwable -> L70 java.lang.Throwable -> L70
        L70:
            java.lang.String r0 = "Unable to read GServices for: "
            r0.concat(r9)
            return r1
        L76:
            monitor-exit(r2)     // Catch: java.lang.Throwable -> L14
            throw r9
        L78:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.internal.measurement.c.b(java.lang.String):java.lang.String");
    }

    public c(Context context) {
        this.c = false;
        this.a = context;
        this.b = new zzjw(null);
    }
}
