package p138.p176.p177.p242.p265.p266;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Pair;
import com.google.android.gms.measurement.internal.AppMeasurementDynamiteService;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicReference;
import p000.p001.p002.p003.p004.C0567;
import p037.p057.C1714;
import p138.p176.p177.p242.p246.C4200;
import p138.p176.p177.p242.p246.p251.C4303;
import p138.p176.p177.p242.p246.p253.C4312;
import p138.p176.p177.p242.p246.p253.C4315;
import p138.p176.p177.p242.p258.p263.C4464;
import p138.p176.p177.p242.p258.p263.C4494;
import p138.p176.p177.p242.p258.p263.C4495;
import p138.p176.p177.p242.p258.p263.C4606;
import p138.p176.p177.p242.p258.p263.C4658;
import p138.p176.p177.p242.p258.p263.InterfaceC4388;
import p138.p176.p177.p242.p258.p263.InterfaceC4688;

/* JADX INFO: renamed from: ދ.ހ.֏.ހ.ބ.֏.ĭ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public final class C4757 extends AbstractC4812 {

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public C4956 f14327;

    /* JADX INFO: renamed from: ށ, reason: contains not printable characters */
    public InterfaceC4767 f14328;

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public final Set<InterfaceC5003> f14329;

    /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
    public boolean f14330;

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final AtomicReference<String> f14331;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final C4768 f14332;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public boolean f14333;

    public C4757(C4974 c4974) {
        super(c4974);
        this.f14329 = new CopyOnWriteArraySet();
        this.f14333 = true;
        this.f14331 = new AtomicReference<>();
        this.f14332 = new C4768(c4974);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final ArrayList<Bundle> m7966(String str, String str2, String str3) {
        if (mo8163().m8010()) {
            mo8165().f14444.m8034("Cannot get conditional user properties from analytics worker thread");
            return new ArrayList<>(0);
        }
        if (C4785.m8028()) {
            mo8165().f14444.m8034("Cannot get conditional user properties from main thread");
            return new ArrayList<>(0);
        }
        AtomicReference atomicReference = new AtomicReference();
        this.f14588.mo8163().m8002(atomicReference, 5000L, "get conditional user properties", new RunnableC4827(this, atomicReference, str, str2, str3));
        List list = (List) atomicReference.get();
        if (list != null) {
            return C4887.m8229((List<C4891>) list);
        }
        mo8165().f14444.m8035("Timed out waiting for get conditional user properties", str);
        return new ArrayList<>();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Map<String, Object> m7967(String str, String str2, String str3, boolean z) {
        if (mo8163().m8010()) {
            mo8165().f14444.m8034("Cannot get user properties from analytics worker thread");
            return Collections.emptyMap();
        }
        if (C4785.m8028()) {
            mo8165().f14444.m8034("Cannot get user properties from main thread");
            return Collections.emptyMap();
        }
        AtomicReference atomicReference = new AtomicReference();
        this.f14588.mo8163().m8002(atomicReference, 5000L, "get user properties", new RunnableC4990(this, atomicReference, str, str2, str3, z));
        List<C4999> list = (List) atomicReference.get();
        if (list == null) {
            mo8165().f14444.m8035("Timed out waiting for handle get user properties, includeInternal", Boolean.valueOf(z));
            return Collections.emptyMap();
        }
        C1714 c1714 = new C1714(list.size());
        for (C4999 c4999 : list) {
            c1714.put(c4999.f15117, c4999.m8527());
        }
        return c1714;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7968(Bundle bundle, long j) {
        C0567.m1910(bundle);
        mo8055();
        Bundle bundle2 = new Bundle(bundle);
        if (!TextUtils.isEmpty(bundle2.getString("app_id"))) {
            mo8165().f14447.m8034("Package name should be null when calling setConditionalUserProperty");
        }
        bundle2.remove("app_id");
        m7980(bundle2, j);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7969(String str, String str2, long j, Bundle bundle) {
        mo8055();
        mo8008();
        m7970(str, str2, j, bundle, true, this.f14328 == null || C4887.m8234(str2), false, null);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7970(String str, String str2, long j, Bundle bundle, boolean z, boolean z2, boolean z3, String str3) {
        String str4;
        String str5;
        boolean z4;
        long j2;
        String str6;
        String str7;
        C4754 c4754;
        String[] strArr;
        int i;
        long j3;
        Bundle bundle2;
        String str8;
        String str9;
        String str10;
        boolean zM8086;
        boolean z5;
        boolean z6;
        boolean z7;
        List<String> list;
        C0567.m1926(str);
        C0567.m1910(bundle);
        mo8008();
        m8066();
        if (!this.f14588.m8495()) {
            mo8165().f14451.m8034("Event not sent since app measurement is disabled");
            return;
        }
        if (this.f14588.f15015.m8177(C4915.f14884) && (list = m8059().f14530) != null && !list.contains(str2)) {
            mo8165().f14451.m8036("Dropping non-safelisted event. event name, origin", str2, str);
            return;
        }
        if (!this.f14330) {
            this.f14330 = true;
            try {
                try {
                    (!this.f14588.f15013 ? Class.forName("com.google.android.gms.tagmanager.TagManagerService", true, this.f14588.f15009.getClassLoader()) : Class.forName("com.google.android.gms.tagmanager.TagManagerService")).getDeclaredMethod("initialize", Context.class).invoke(null, this.f14588.f15009);
                } catch (Exception e) {
                    mo8165().f14447.m8035("Failed to invoke Tag Manager's initialize() method", e);
                }
            } catch (ClassNotFoundException unused) {
                mo8165().f14450.m8034("Tag Manager is not found and thus will not be used");
            }
        }
        if (this.f14588.f15015.m8177(C4915.f14890) && "_cmp".equals(str2) && bundle.containsKey("gclid")) {
            String string = bundle.getString("gclid");
            if (((C4312) this.f14588.f15022) == null) {
                throw null;
            }
            m7974("auto", "_lgclid", string, System.currentTimeMillis());
        }
        if (((InterfaceC4388) C4494.f13901.mo7259()).mo7285() && this.f14588.f15015.m8177(C4915.f14921)) {
            C4785 c4785 = this.f14588.f15014;
            if (z) {
                String[] strArr2 = C4887.f14702;
                int length = strArr2.length;
                int i2 = 0;
                while (true) {
                    if (i2 >= length) {
                        z7 = true;
                        break;
                    } else {
                        if (strArr2[i2].equals(str2)) {
                            z7 = false;
                            break;
                        }
                        i2++;
                    }
                }
                if (z7) {
                    C4887 c4887M8167 = m8167();
                    Bundle bundleM8090 = m8168().f14673.m8090();
                    if (bundleM8090 != null) {
                        for (String str11 : bundleM8090.keySet()) {
                            if (!bundle.containsKey(str11)) {
                                c4887M8167.m8167().m8246(bundle, str11, bundleM8090.get(str11));
                            }
                        }
                    }
                }
            }
        }
        if (z3) {
            C4785 c47852 = this.f14588.f15014;
            if (!"_iap".equals(str2)) {
                C4887 c4887M8504 = this.f14588.m8504();
                int i3 = 2;
                if (c4887M8504.m8258("event", str2)) {
                    if (!c4887M8504.m8261("event", C4775.f14397, str2)) {
                        i3 = 13;
                    } else if (c4887M8504.m8257("event", 40, str2)) {
                        i3 = 0;
                    }
                }
                if (i3 != 0) {
                    mo8165().f14446.m8035("Invalid public event name. Event will not be logged (FE)", m8161().m8110(str2));
                    this.f14588.m8504();
                    this.f14588.m8504().m8244(i3, "_ev", C4887.m8220(str2, 40, true), str2 != null ? str2.length() : 0);
                    return;
                }
            }
        }
        C4785 c47853 = this.f14588.f15014;
        C4754 c4754M7989 = m8061().m7989(false);
        if (c4754M7989 != null && !bundle.containsKey("_sc")) {
            c4754M7989.f14287 = true;
        }
        C4765.m7988(c4754M7989, bundle, z && z3);
        boolean zEquals = "am".equals(str);
        boolean zM8234 = C4887.m8234(str2);
        if (z && this.f14328 != null && !zM8234 && !zEquals) {
            mo8165().f14451.m8036("Passing event to registered event handler (FE)", m8161().m8110(str2), m8161().m8109(bundle));
            AppMeasurementDynamiteService.C0336 c0336 = (AppMeasurementDynamiteService.C0336) this.f14328;
            if (c0336 == null) {
                throw null;
            }
            try {
                c0336.f2130.mo7281(str, str2, bundle, j);
                return;
            } catch (RemoteException e2) {
                AppMeasurementDynamiteService.this.f2128.mo8165().f14447.m8035("Event interceptor threw exception", e2);
                return;
            }
        }
        if (this.f14588.m8498()) {
            int iM8236 = m8167().m8236(str2);
            if (iM8236 != 0) {
                mo8165().f14446.m8035("Invalid event name. Event will not be logged (FE)", m8161().m8110(str2));
                m8167();
                this.f14588.m8504().m8244(iM8236, "_ev", C4887.m8220(str2, 40, true), str2 != null ? str2.length() : 0);
                return;
            }
            List<String> listUnmodifiableList = Collections.unmodifiableList(Arrays.asList("_o", "_sn", "_sc", "_si"));
            Bundle bundleM8240 = m8167().m8240(str3, str2, bundle, listUnmodifiableList, z3, true);
            C4754 c47542 = (bundleM8240 != null && bundleM8240.containsKey("_sc") && bundleM8240.containsKey("_si")) ? new C4754(bundleM8240.getString("_sn"), bundleM8240.getString("_sc"), Long.valueOf(bundleM8240.getLong("_si")).longValue()) : null;
            C4754 c47543 = c47542 == null ? c4754M7989 : c47542;
            if (this.f14588.f15015.m8177(C4915.f14874)) {
                C4785 c47854 = this.f14588.f15014;
                if (m8061().m7989(false) != null && "_ae".equals(str2)) {
                    long jM8209 = m8063().f14968.m8209();
                    if (jM8209 > 0) {
                        m8167().m8245(bundleM8240, jM8209);
                    }
                }
            }
            if (C4658.m7795() && this.f14588.f15015.m8177(C4915.f14903)) {
                if (!"auto".equals(str) && "_ssr".equals(str2)) {
                    C4887 c4887M81672 = m8167();
                    String string2 = bundleM8240.getString("_ffr");
                    String strTrim = C4315.m7214(string2) ? null : string2.trim();
                    if (C4887.m8232(strTrim, c4887M81672.m8168().f14670.m8083())) {
                        c4887M81672.mo8165().f14451.m8034("Not logging duplicate session_start_with_rollout event");
                        z6 = false;
                    } else {
                        c4887M81672.m8168().f14670.m8084(strTrim);
                        z6 = true;
                    }
                    if (!z6) {
                        return;
                    }
                } else if ("_ae".equals(str2)) {
                    String strM8083 = m8167().m8168().f14670.m8083();
                    if (!TextUtils.isEmpty(strM8083)) {
                        bundleM8240.putString("_ffr", strM8083);
                    }
                }
            }
            ArrayList arrayList = new ArrayList();
            arrayList.add(bundleM8240);
            long jNextLong = m8167().m8273().nextLong();
            if (m8168().f14665.m8316() > 0 && m8168().m8196(j) && m8168().f14667.m8205()) {
                mo8165().f14452.m8034("Current session is expired, remove the session number, ID, and engagement time");
                if (((C4312) this.f14588.f15022) == null) {
                    throw null;
                }
                str5 = "_ae";
                z4 = true;
                j2 = j;
                str4 = "_o";
                m7974("auto", "_sid", (Object) null, System.currentTimeMillis());
                if (((C4312) this.f14588.f15022) == null) {
                    throw null;
                }
                m7974("auto", "_sno", (Object) null, System.currentTimeMillis());
                if (((C4312) this.f14588.f15022) == null) {
                    throw null;
                }
                m7974("auto", "_se", (Object) null, System.currentTimeMillis());
            } else {
                str4 = "_o";
                str5 = "_ae";
                z4 = true;
                j2 = j;
            }
            if (bundleM8240.getLong("extend_session", 0L) == 1) {
                mo8165().f14452.m8034("EXTEND_SESSION param attached: initiate a new session or extend the current active session");
                this.f14588.m8502().f14967.m8202(j2, z4);
            }
            String[] strArr3 = (String[]) bundleM8240.keySet().toArray(new String[bundleM8240.size()]);
            Arrays.sort(strArr3);
            if (C4606.m7638() && this.f14588.f15015.m8177(C4915.f14915) && this.f14588.f15015.m8177(C4915.f14914)) {
                for (String str12 : strArr3) {
                    m8167();
                    Bundle[] bundleArrM8231 = C4887.m8231(bundleM8240.get(str12));
                    if (bundleArrM8231 != null) {
                        bundleM8240.putParcelableArray(str12, bundleArrM8231);
                    }
                }
                str6 = str2;
                str7 = str5;
            } else {
                int length2 = strArr3.length;
                int i4 = 0;
                int length3 = 0;
                while (i4 < length2) {
                    String str13 = strArr3[i4];
                    Object obj = bundleM8240.get(str13);
                    m8167();
                    Bundle[] bundleArrM82312 = C4887.m8231(obj);
                    if (bundleArrM82312 != null) {
                        strArr = strArr3;
                        bundleM8240.putInt(str13, bundleArrM82312.length);
                        i = length2;
                        int i5 = 0;
                        while (i5 < bundleArrM82312.length) {
                            Bundle bundle3 = bundleArrM82312[i5];
                            Bundle[] bundleArr = bundleArrM82312;
                            C4765.m7988(c47543, bundle3, true);
                            long j4 = jNextLong;
                            Bundle bundleM82402 = m8167().m8240(str3, "_ep", bundle3, listUnmodifiableList, z3, false);
                            bundleM82402.putString("_en", str2);
                            bundleM82402.putLong("_eid", j4);
                            bundleM82402.putString("_gn", str13);
                            bundleM82402.putInt("_ll", bundleArr.length);
                            bundleM82402.putInt("_i", i5);
                            arrayList = arrayList;
                            arrayList.add(bundleM82402);
                            i5++;
                            bundleM8240 = bundleM8240;
                            bundleArrM82312 = bundleArr;
                            c47543 = c47543;
                            jNextLong = j4;
                        }
                        c4754 = c47543;
                        j3 = jNextLong;
                        bundle2 = bundleM8240;
                        str8 = str5;
                        length3 += bundleArrM82312.length;
                    } else {
                        c4754 = c47543;
                        strArr = strArr3;
                        i = length2;
                        j3 = jNextLong;
                        bundle2 = bundleM8240;
                        str8 = str5;
                    }
                    i4++;
                    strArr3 = strArr;
                    str5 = str8;
                    bundleM8240 = bundle2;
                    jNextLong = j3;
                    c47543 = c4754;
                    length2 = i;
                }
                str6 = str2;
                str7 = str5;
                long j5 = jNextLong;
                Bundle bundle4 = bundleM8240;
                if (length3 != 0) {
                    bundle4.putLong("_eid", j5);
                    bundle4.putInt("_epc", length3);
                }
            }
            int i6 = 0;
            while (i6 < arrayList.size()) {
                Bundle bundleM8239 = (Bundle) arrayList.get(i6);
                if (i6 != 0) {
                    str10 = "_ep";
                    str9 = str;
                } else {
                    str9 = str;
                    str10 = str6;
                }
                String str14 = str4;
                bundleM8239.putString(str14, str9);
                if (z2) {
                    bundleM8239 = m8167().m8239(bundleM8239);
                }
                Bundle bundle5 = bundleM8239;
                C4913 c4913 = new C4913(str10, new C4908(bundle5), str, j);
                C4987 c4987M8060 = m8060();
                if (c4987M8060 == null) {
                    throw null;
                }
                C0567.m1910(c4913);
                c4987M8060.mo8008();
                c4987M8060.m8066();
                c4987M8060.m8520();
                C4821 c4821M8062 = c4987M8060.m8062();
                if (c4821M8062 == null) {
                    throw null;
                }
                Parcel parcelObtain = Parcel.obtain();
                c4913.writeToParcel(parcelObtain, 0);
                byte[] bArrMarshall = parcelObtain.marshall();
                parcelObtain.recycle();
                if (bArrMarshall.length > 131072) {
                    c4821M8062.mo8165().f14445.m8034("Event is too long for local database. Sending event directly to service");
                    z5 = true;
                    zM8086 = false;
                } else {
                    zM8086 = c4821M8062.m8086(0, bArrMarshall);
                    z5 = true;
                }
                c4987M8060.m8514(new RunnableC4847(c4987M8060, true, zM8086, c4913, c4987M8060.m8513(z5), str3));
                if (!zEquals) {
                    Iterator<InterfaceC5003> it = this.f14329.iterator();
                    while (it.hasNext()) {
                        it.next().mo1419(str, str2, new Bundle(bundle5), j);
                    }
                }
                i6++;
                str4 = str14;
            }
            C4785 c47855 = this.f14588.f15014;
            if (m8061().m7989(false) == null || !str7.equals(str6)) {
                return;
            }
            C4943 c4943M8063 = m8063();
            if (((C4312) this.f14588.f15022) == null) {
                throw null;
            }
            c4943M8063.m8480(true, true, SystemClock.elapsedRealtime());
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7971(String str, String str2, long j, Object obj) {
        C4771 c4771Mo8163 = mo8163();
        RunnableC5004 runnableC5004 = new RunnableC5004(this, str, str2, obj, j);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC5004);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC5004, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7972(String str, String str2, Bundle bundle) {
        if (((C4312) this.f14588.f15022) == null) {
            throw null;
        }
        m7973(str, str2, bundle, true, true, System.currentTimeMillis());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7973(String str, String str2, Bundle bundle, boolean z, boolean z2, long j) {
        mo8055();
        String str3 = str == null ? "app" : str;
        Bundle bundle2 = bundle == null ? new Bundle() : bundle;
        boolean z3 = !z2 || this.f14328 == null || C4887.m8234(str2);
        boolean z4 = !z;
        Bundle bundle3 = new Bundle(bundle2);
        for (String str4 : bundle3.keySet()) {
            Object obj = bundle3.get(str4);
            if (obj instanceof Bundle) {
                bundle3.putBundle(str4, new Bundle((Bundle) obj));
            } else if (obj instanceof Parcelable[]) {
                Parcelable[] parcelableArr = (Parcelable[]) obj;
                for (int i = 0; i < parcelableArr.length; i++) {
                    if (parcelableArr[i] instanceof Bundle) {
                        parcelableArr[i] = new Bundle((Bundle) parcelableArr[i]);
                    }
                }
            } else if (obj instanceof List) {
                List list = (List) obj;
                for (int i2 = 0; i2 < list.size(); i2++) {
                    Object obj2 = list.get(i2);
                    if (obj2 instanceof Bundle) {
                        list.set(i2, new Bundle((Bundle) obj2));
                    }
                }
            }
        }
        C4771 c4771Mo8163 = mo8163();
        RunnableC4764 runnableC4764 = new RunnableC4764(this, str3, str2, j, bundle3, z2, z3, z4, null);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC4764);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4764, "Task exception on worker thread"));
    }

    /* JADX WARN: Removed duplicated region for block: B:16:0x0053  */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m7974(String str, String str2, Object obj, long j) {
        String str3;
        Object obj2;
        C0567.m1926(str);
        C0567.m1926(str2);
        mo8008();
        mo8055();
        m8066();
        if (!"allow_personalized_ads".equals(str2)) {
            str3 = str2;
            obj2 = obj;
        } else if (obj instanceof String) {
            String str4 = (String) obj;
            if (TextUtils.isEmpty(str4)) {
                if (obj == null) {
                    m8168().f14662.m8084("unset");
                    obj2 = obj;
                }
                str3 = str2;
                obj2 = obj;
            } else {
                Long lValueOf = Long.valueOf("false".equals(str4.toLowerCase(Locale.ENGLISH)) ? 1L : 0L);
                m8168().f14662.m8084(lValueOf.longValue() == 1 ? "true" : "false");
                obj2 = lValueOf;
            }
            str3 = "_npa";
        }
        if (!this.f14588.m8495()) {
            mo8165().f14452.m8034("User property not set since app measurement is disabled");
            return;
        }
        if (this.f14588.m8498()) {
            C4999 c4999 = new C4999(str3, j, obj2, str);
            C4987 c4987M8060 = m8060();
            c4987M8060.mo8008();
            c4987M8060.m8066();
            c4987M8060.m8520();
            C4821 c4821M8062 = c4987M8060.m8062();
            if (c4821M8062 == null) {
                throw null;
            }
            Parcel parcelObtain = Parcel.obtain();
            boolean zM8086 = false;
            c4999.writeToParcel(parcelObtain, 0);
            byte[] bArrMarshall = parcelObtain.marshall();
            parcelObtain.recycle();
            if (bArrMarshall.length > 131072) {
                c4821M8062.mo8165().f14445.m8034("User property too long for local database. Sending directly to service");
            } else {
                zM8086 = c4821M8062.m8086(1, bArrMarshall);
            }
            c4987M8060.m8514(new RunnableC4867(c4987M8060, zM8086, c4999, c4987M8060.m8513(true)));
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7975(String str, String str2, Object obj, boolean z) {
        if (((C4312) this.f14588.f15022) == null) {
            throw null;
        }
        m7976(str, str2, obj, z, System.currentTimeMillis());
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7976(String str, String str2, Object obj, boolean z, long j) {
        if (str == null) {
            str = "app";
        }
        String str3 = str;
        int iM8262 = 6;
        if (z) {
            iM8262 = m8167().m8262(str2);
        } else {
            C4887 c4887M8167 = m8167();
            if (c4887M8167.m8258("user property", str2)) {
                if (!c4887M8167.m8261("user property", C4997.f15112, str2)) {
                    iM8262 = 15;
                } else if (c4887M8167.m8257("user property", 24, str2)) {
                    iM8262 = 0;
                }
            }
        }
        if (iM8262 != 0) {
            m8167();
            this.f14588.m8504().m8244(iM8262, "_ev", C4887.m8220(str2, 24, true), str2 != null ? str2.length() : 0);
            return;
        }
        if (obj == null) {
            m7971(str3, str2, j, (Object) null);
            return;
        }
        int iM8263 = m8167().m8263(str2, obj);
        if (iM8263 != 0) {
            m8167();
            this.f14588.m8504().m8244(iM8263, "_ev", C4887.m8220(str2, 24, true), ((obj instanceof String) || (obj instanceof CharSequence)) ? String.valueOf(obj).length() : 0);
        } else {
            Object objM8266 = m8167().m8266(str2, obj);
            if (objM8266 != null) {
                m7971(str3, str2, j, objM8266);
            }
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7977(String str, String str2, String str3, Bundle bundle) {
        if (((C4312) this.f14588.f15022) == null) {
            throw null;
        }
        long jCurrentTimeMillis = System.currentTimeMillis();
        C0567.m1926(str2);
        Bundle bundle2 = new Bundle();
        if (str != null) {
            bundle2.putString("app_id", str);
        }
        bundle2.putString("name", str2);
        bundle2.putLong("creation_timestamp", jCurrentTimeMillis);
        if (str3 != null) {
            bundle2.putString("expired_event_name", str3);
            bundle2.putBundle("expired_event_params", bundle);
        }
        C4771 c4771Mo8163 = mo8163();
        RunnableC4849 runnableC4849 = new RunnableC4849(this, bundle2);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC4849);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4849, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7978(InterfaceC5003 interfaceC5003) {
        mo8055();
        m8066();
        C0567.m1910(interfaceC5003);
        if (this.f14329.add(interfaceC5003)) {
            return;
        }
        mo8165().f14447.m8034("OnEventListener already registered");
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m7979(boolean z) {
        m8066();
        mo8055();
        C4771 c4771Mo8163 = mo8163();
        RunnableC4856 runnableC4856 = new RunnableC4856(this, z);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC4856);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4856, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m7980(Bundle bundle, long j) {
        C0567.m1910(bundle);
        C4303.m7007(bundle, "app_id", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "origin", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "name", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "value", (Class<Object>) Object.class, (Object) null);
        C4303.m7007(bundle, "trigger_event_name", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "trigger_timeout", (Class<long>) Long.class, 0L);
        C4303.m7007(bundle, "timed_out_event_name", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "timed_out_event_params", (Class<Object>) Bundle.class, (Object) null);
        C4303.m7007(bundle, "triggered_event_name", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "triggered_event_params", (Class<Object>) Bundle.class, (Object) null);
        C4303.m7007(bundle, "time_to_live", (Class<long>) Long.class, 0L);
        C4303.m7007(bundle, "expired_event_name", (Class<Object>) String.class, (Object) null);
        C4303.m7007(bundle, "expired_event_params", (Class<Object>) Bundle.class, (Object) null);
        C0567.m1926(bundle.getString("name"));
        C0567.m1926(bundle.getString("origin"));
        C0567.m1910(bundle.get("value"));
        bundle.putLong("creation_timestamp", j);
        String string = bundle.getString("name");
        Object obj = bundle.get("value");
        if (m8167().m8262(string) != 0) {
            mo8165().f14444.m8035("Invalid conditional user property name", m8161().m8114(string));
            return;
        }
        if (m8167().m8263(string, obj) != 0) {
            mo8165().f14444.m8036("Invalid conditional user property value", m8161().m8114(string), obj);
            return;
        }
        Object objM8266 = m8167().m8266(string, obj);
        if (objM8266 == null) {
            mo8165().f14444.m8036("Unable to normalize conditional user property value", m8161().m8114(string), obj);
            return;
        }
        C4303.m7087(bundle, objM8266);
        long j2 = bundle.getLong("trigger_timeout");
        if (!TextUtils.isEmpty(bundle.getString("trigger_event_name")) && (j2 > 15552000000L || j2 < 1)) {
            mo8165().f14444.m8036("Invalid conditional user property timeout", m8161().m8114(string), Long.valueOf(j2));
            return;
        }
        long j3 = bundle.getLong("time_to_live");
        if (j3 > 15552000000L || j3 < 1) {
            mo8165().f14444.m8036("Invalid conditional user property time to live", m8161().m8114(string), Long.valueOf(j3));
            return;
        }
        C4771 c4771Mo8163 = mo8163();
        RunnableC4835 runnableC4835 = new RunnableC4835(this, bundle);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC4835);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4835, "Task exception on worker thread"));
    }

    /* JADX INFO: renamed from: ؠ, reason: contains not printable characters */
    public final void m7981(boolean z) {
        m8066();
        mo8055();
        C4771 c4771Mo8163 = mo8163();
        RunnableC4945 runnableC4945 = new RunnableC4945(this, z);
        c4771Mo8163.m8482();
        C0567.m1910(runnableC4945);
        c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4945, "Task exception on worker thread"));
    }

    @Override // p138.p176.p177.p242.p265.p266.AbstractC4812
    /* JADX INFO: renamed from: ޕ, reason: contains not printable characters */
    public final boolean mo7982() {
        return false;
    }

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public final void m7983() {
        if (this.f14588.f15009.getApplicationContext() instanceof Application) {
            ((Application) this.f14588.f15009.getApplicationContext()).unregisterActivityLifecycleCallbacks(this.f14327);
        }
    }

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public final void m7984() {
        mo8008();
        mo8055();
        m8066();
        if (this.f14588.m8498()) {
            if (this.f14588.f15015.m8177(C4915.f14889)) {
                C4869 c4869 = this.f14588.f15015;
                C4785 c4785 = c4869.f14588.f15014;
                Boolean boolM8181 = c4869.m8181("google_analytics_deferred_deep_link_enabled");
                if (boolM8181 != null && boolM8181.booleanValue()) {
                    mo8165().f14451.m8034("Deferred Deep Link feature enabled.");
                    C4771 c4771Mo8163 = mo8163();
                    Runnable runnable = new Runnable(this) { // from class: ދ.ހ.֏.ހ.ބ.֏.ȋ

                        /* JADX INFO: renamed from: ރ, reason: contains not printable characters */
                        public final C4757 f14405;

                        {
                            this.f14405 = this;
                        }

                        @Override // java.lang.Runnable
                        public final void run() {
                            NetworkInfo activeNetworkInfo;
                            URL url;
                            C4757 c4757 = this.f14405;
                            c4757.mo8008();
                            if (c4757.m8168().f14668.m8205()) {
                                c4757.mo8165().f14451.m8034("Deferred Deep Link already retrieved. Not fetching again.");
                                return;
                            }
                            long jM8316 = c4757.m8168().f14669.m8316();
                            c4757.m8168().f14669.m8317(jM8316 + 1);
                            if (jM8316 >= 5) {
                                c4757.mo8165().f14447.m8034("Permanently failed to retrieve Deferred Deep Link. Reached maximum retries.");
                                c4757.m8168().f14668.m8204(true);
                                return;
                            }
                            C4974 c4974 = c4757.f14588;
                            c4974.mo8163().mo8008();
                            C4974.m8493((AbstractC4954) c4974.m8499());
                            C4828 c4828M8510 = c4974.m8510();
                            c4828M8510.m8066();
                            String str = c4828M8510.f14524;
                            Pair<String, Boolean> pairM8194 = c4974.m8501().m8194(str);
                            if (!c4974.f15015.m8189().booleanValue() || ((Boolean) pairM8194.second).booleanValue() || TextUtils.isEmpty((CharSequence) pairM8194.first)) {
                                c4974.mo8165().f14451.m8034("ADID unavailable to retrieve Deferred Deep Link. Skipping");
                                return;
                            }
                            C4838 c4838M8499 = c4974.m8499();
                            c4838M8499.m8482();
                            try {
                                activeNetworkInfo = ((ConnectivityManager) c4838M8499.f14588.f15009.getSystemService("connectivity")).getActiveNetworkInfo();
                            } catch (SecurityException unused) {
                                activeNetworkInfo = null;
                            }
                            if (!(activeNetworkInfo != null && activeNetworkInfo.isConnected())) {
                                c4974.mo8165().f14447.m8034("Network is not available for Deferred Deep Link request. Skipping");
                                return;
                            }
                            C4887 c4887M8504 = c4974.m8504();
                            c4974.m8510().f14588.f15015.m8186();
                            String str2 = (String) pairM8194.first;
                            long jM83162 = c4974.m8501().f14669.m8316() - 1;
                            if (c4887M8504 == null) {
                                throw null;
                            }
                            try {
                                C0567.m1926(str2);
                                C0567.m1926(str);
                                String strConcat = String.format("https://www.googleadservices.com/pagead/conversion/app/deeplink?id_type=adid&sdk_version=%s&rdid=%s&bundleid=%s&retry=%s", String.format("v%s.%s", 28000L, Integer.valueOf(c4887M8504.m8274())), str2, str, Long.valueOf(jM83162));
                                if (str.equals(c4887M8504.f14588.f15015.m8176("debug.deferred.deeplink", ""))) {
                                    strConcat = strConcat.concat("&ddl_test=1");
                                }
                                url = new URL(strConcat);
                            } catch (IllegalArgumentException | MalformedURLException e) {
                                c4887M8504.mo8165().f14444.m8035("Failed to create BOW URL for Deferred Deep Link. exception", e.getMessage());
                                url = null;
                            }
                            C4838 c4838M84992 = c4974.m8499();
                            C4753 c4753 = new C4753(c4974);
                            c4838M84992.mo8008();
                            c4838M84992.m8482();
                            C0567.m1910(url);
                            C0567.m1910(c4753);
                            c4838M84992.mo8163().m8007(new RunnableC4772(c4838M84992, str, url, c4753));
                        }
                    };
                    c4771Mo8163.m8482();
                    C0567.m1910(runnable);
                    c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnable, "Task exception on worker thread"));
                }
            }
            C4987 c4987M8060 = m8060();
            c4987M8060.mo8008();
            c4987M8060.m8066();
            C4977 c4977M8513 = c4987M8060.m8513(true);
            c4987M8060.m8062().m8086(3, new byte[0]);
            c4987M8060.m8514(new RunnableC4779(c4987M8060, c4977M8513));
            this.f14333 = false;
            C4874 c4874M8168 = m8168();
            c4874M8168.mo8008();
            String string = c4874M8168.m8199().getString("previous_os_version", null);
            c4874M8168.m8160().m8482();
            String str = Build.VERSION.RELEASE;
            if (!TextUtils.isEmpty(str) && !str.equals(string)) {
                SharedPreferences.Editor editorEdit = c4874M8168.m8199().edit();
                editorEdit.putString("previous_os_version", str);
                editorEdit.apply();
            }
            if (TextUtils.isEmpty(string)) {
                return;
            }
            m8160().m8482();
            if (string.equals(Build.VERSION.RELEASE)) {
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putString("_po", string);
            m7972("auto", "_ou", bundle);
        }
    }

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public final String m7985() {
        C4974 c4974 = this.f14588;
        String str = c4974.f15010;
        if (str != null) {
            return str;
        }
        try {
            Context context = c4974.f15009;
            C0567.m1910(context);
            Resources resources = context.getResources();
            int identifier = resources.getIdentifier("google_app_id", "string", resources.getResourcePackageName(C4200.common_google_play_services_unknown_issue));
            if (identifier == 0) {
                return null;
            }
            return resources.getString(identifier);
        } catch (IllegalStateException e) {
            this.f14588.mo8165().f14444.m8035("getGoogleAppId failed with exception", e);
            return null;
        }
    }

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public final void m7986() {
        mo8008();
        String strM8083 = m8168().f14662.m8083();
        if (strM8083 != null) {
            if (!"unset".equals(strM8083)) {
                Long lValueOf = Long.valueOf("true".equals(strM8083) ? 1L : 0L);
                if (((C4312) this.f14588.f15022) == null) {
                    throw null;
                }
                m7974("app", "_npa", lValueOf, System.currentTimeMillis());
            } else {
                if (((C4312) this.f14588.f15022) == null) {
                    throw null;
                }
                m7974("app", "_npa", (Object) null, System.currentTimeMillis());
            }
        }
        if (!this.f14588.m8495() || !this.f14333) {
            mo8165().f14451.m8034("Updating Scion state (FE)");
            C4987 c4987M8060 = m8060();
            c4987M8060.mo8008();
            c4987M8060.m8066();
            c4987M8060.m8514(new RunnableC4993(c4987M8060, c4987M8060.m8513(true)));
            return;
        }
        mo8165().f14451.m8034("Recording app launch after enabling measurement for the first time (FE)");
        m7984();
        if (C4464.m7476() && this.f14588.f15015.m8177(C4915.f14904)) {
            m8063().f14967.m8201();
        }
        if (((InterfaceC4688) C4495.f13903.mo7259()).mo7486() && this.f14588.f15015.m8177(C4915.f14909)) {
            if (!(this.f14588.f15031.f14686.m8501().f14654.m8316() > 0)) {
                C4880 c4880 = this.f14588.f15031;
                C4974 c4974 = c4880.f14686;
                if (c4974 == null) {
                    throw null;
                }
                c4880.m8206(c4974.f15009.getPackageName());
            }
        }
        if (this.f14588.f15015.m8177(C4915.f14881)) {
            C4771 c4771Mo8163 = mo8163();
            RunnableC4873 runnableC4873 = new RunnableC4873(this);
            c4771Mo8163.m8482();
            C0567.m1910(runnableC4873);
            c4771Mo8163.m8005(new C4894<>(c4771Mo8163, runnableC4873, "Task exception on worker thread"));
        }
    }
}
