package d3;

import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.util.Log;
import java.io.IOException;
import java.util.Map;

/* JADX INFO: loaded from: classes.dex */
public final class W implements Runnable {

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public final /* synthetic */ int f11785q = 0;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public final int f11786r;

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

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

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

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

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

    public W(Z z8, int i, String str, Object obj, Object obj2, Object obj3) {
        this.f11786r = i;
        this.f11787s = str;
        this.f11788t = obj;
        this.f11789u = obj2;
        this.f11790v = obj3;
        this.f11791w = z8;
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.f11785q) {
            case n4.u0.f15495q /* 0 */:
                Z z8 = (Z) this.f11791w;
                C0785g0 c0785g0 = ((C0817r0) z8.f5146q).f12149x;
                C0817r0.i(c0785g0);
                if (!c0785g0.f11423r) {
                    Log.println(6, z8.P(), "Persisted config not initialized. Not logging error/warn");
                    return;
                }
                if (z8.f11872s == 0) {
                    C0784g c0784g = ((C0817r0) z8.f5146q).f12148w;
                    if (c0784g.f11955u == null) {
                        synchronized (c0784g) {
                            try {
                                if (c0784g.f11955u == null) {
                                    C0817r0 c0817r0 = (C0817r0) c0784g.f5146q;
                                    ApplicationInfo applicationInfo = c0817r0.f12142q.getApplicationInfo();
                                    String strB = T2.b.b();
                                    if (applicationInfo != null) {
                                        String str = applicationInfo.processName;
                                        c0784g.f11955u = Boolean.valueOf(str != null && str.equals(strB));
                                    }
                                    if (c0784g.f11955u == null) {
                                        c0784g.f11955u = Boolean.TRUE;
                                        Z z9 = c0817r0.f12150y;
                                        C0817r0.k(z9);
                                        z9.f11875v.b("My process not in the list of running processes");
                                    }
                                }
                            } finally {
                            }
                        }
                    }
                    if (c0784g.f11955u.booleanValue()) {
                        z8.f11872s = 'C';
                    } else {
                        z8.f11872s = 'c';
                    }
                    break;
                }
                if (z8.f11873t < 0) {
                    ((C0817r0) z8.f5146q).f12148w.L();
                    z8.f11873t = 119002L;
                }
                char cCharAt = "01VDIWEA?".charAt(this.f11786r);
                char c3 = z8.f11872s;
                long j8 = z8.f11873t;
                String str2 = this.f11787s;
                String strN = Z.N(true, str2, this.f11788t, this.f11789u, this.f11790v);
                StringBuilder sb = new StringBuilder("2");
                sb.append(cCharAt);
                sb.append(c3);
                sb.append(j8);
                String strR = I1.a.r(sb, ":", strN);
                if (strR.length() > 1024) {
                    strR = str2.substring(0, 1024);
                }
                C0782f0 c0782f0 = c0785g0.f11974v;
                if (c0782f0 != null) {
                    C0785g0 c0785g02 = (C0785g0) c0782f0.f11943e;
                    c0785g02.E();
                    if (((C0785g0) c0782f0.f11943e).J().getLong((String) c0782f0.f11940b, 0L) == 0) {
                        c0782f0.b();
                    }
                    if (strR == null) {
                        strR = "";
                    }
                    SharedPreferences sharedPreferencesJ = c0785g02.J();
                    String str3 = (String) c0782f0.f11941c;
                    long j9 = sharedPreferencesJ.getLong(str3, 0L);
                    String str4 = (String) c0782f0.f11942d;
                    if (j9 <= 0) {
                        SharedPreferences.Editor editorEdit = c0785g02.J().edit();
                        editorEdit.putString(str4, strR);
                        editorEdit.putLong(str3, 1L);
                        editorEdit.apply();
                        return;
                    }
                    W1 w12 = ((C0817r0) c0785g02.f5146q).f12122B;
                    C0817r0.i(w12);
                    long jNextLong = w12.Q().nextLong() & Long.MAX_VALUE;
                    long j10 = j9 + 1;
                    long j11 = Long.MAX_VALUE / j10;
                    SharedPreferences.Editor editorEdit2 = c0785g02.J().edit();
                    if (jNextLong < j11) {
                        editorEdit2.putString(str4, strR);
                    }
                    editorEdit2.putLong(str3, j10);
                    editorEdit2.apply();
                    return;
                }
                return;
            default:
                ((InterfaceC0767a0) this.f11788t).d(this.f11787s, this.f11786r, (IOException) this.f11789u, (byte[]) this.f11790v, (Map) this.f11791w);
                return;
        }
    }

    public /* synthetic */ W(String str, InterfaceC0767a0 interfaceC0767a0, int i, IOException iOException, byte[] bArr, Map map) {
        P2.w.f(interfaceC0767a0);
        this.f11788t = interfaceC0767a0;
        this.f11786r = i;
        this.f11789u = iOException;
        this.f11790v = bArr;
        this.f11787s = str;
        this.f11791w = map;
    }
}
