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

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabaseLockedException;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteFullException;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import com.google.android.gms.common.internal.safeparcel.SafeParcelReader$ParseException;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import p000.p001.p002.p003.p004.C0567;
import p138.p176.p177.p242.p246.C4196;
import p138.p176.p177.p242.p246.p249.p250.AbstractC4283;
import p138.p176.p177.p242.p246.p252.C4306;
import p138.p176.p177.p242.p246.p253.C4312;
import p138.p176.p177.p242.p246.p255.C4322;
import p138.p176.p177.p242.p258.p263.C4538;
import p138.p176.p177.p242.p258.p263.C4652;
import p138.p176.p177.p242.p258.p263.InterfaceC4655;

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

    /* JADX INFO: renamed from: ހ, reason: contains not printable characters */
    public final ServiceConnectionC4991 f15083;

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

    /* JADX INFO: renamed from: ނ, reason: contains not printable characters */
    public volatile Boolean f15085;

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

    /* JADX INFO: renamed from: ބ, reason: contains not printable characters */
    public final C4862 f15087;

    /* JADX INFO: renamed from: ޅ, reason: contains not printable characters */
    public final List<Runnable> f15088;

    /* JADX INFO: renamed from: ކ, reason: contains not printable characters */
    public final AbstractC4905 f15089;

    public C4987(C4974 c4974) {
        super(c4974);
        this.f15088 = new ArrayList();
        this.f15087 = new C4862(c4974.f15022);
        this.f15083 = new ServiceConnectionC4991(this);
        this.f15086 = new C4955(this, c4974);
        this.f15089 = new C4970(this, c4974);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public static /* synthetic */ void m8512(C4987 c4987, ComponentName componentName) {
        c4987.mo8008();
        if (c4987.f15084 != null) {
            c4987.f15084 = null;
            c4987.mo8165().f14452.m8035("Disconnected from device MeasurementService", componentName);
            c4987.mo8008();
            c4987.m8518();
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final C4977 m8513(boolean z) {
        String str;
        String str2;
        long j;
        C4785 c4785 = this.f14588.f15014;
        C4828 c4828M8059 = m8059();
        String strM8052 = z ? mo8165().m8052() : null;
        c4828M8059.mo8008();
        c4828M8059.mo8055();
        c4828M8059.m8066();
        String str3 = c4828M8059.f14524;
        c4828M8059.m8066();
        String str4 = c4828M8059.f14532;
        c4828M8059.m8066();
        String str5 = c4828M8059.f14525;
        c4828M8059.m8066();
        long j2 = c4828M8059.f14526;
        c4828M8059.m8066();
        String str6 = c4828M8059.f14527;
        c4828M8059.f14588.f15015.m8186();
        c4828M8059.m8066();
        c4828M8059.mo8008();
        if (c4828M8059.f14528 == 0) {
            C4887 c4887M8504 = c4828M8059.f14588.m8504();
            Context context = c4828M8059.f14588.f15009;
            String packageName = context.getPackageName();
            c4887M8504.mo8008();
            C0567.m1910(context);
            C0567.m1926(packageName);
            PackageManager packageManager = context.getPackageManager();
            MessageDigest messageDigestM8235 = C4887.m8235();
            long jM8218 = -1;
            if (messageDigestM8235 == null) {
                c4887M8504.mo8165().f14444.m8034("Could not get MD5 instance");
            } else {
                if (packageManager != null) {
                    try {
                        if (!c4887M8504.m8255(context, packageName)) {
                            PackageInfo packageInfoM7222 = C4322.m7223(context).m7222(c4887M8504.f14588.f15009.getPackageName(), 64);
                            if (packageInfoM7222.signatures == null || packageInfoM7222.signatures.length <= 0) {
                                c4887M8504.mo8165().f14447.m8034("Could not get signatures");
                            } else {
                                jM8218 = C4887.m8218(messageDigestM8235.digest(packageInfoM7222.signatures[0].toByteArray()));
                            }
                        }
                    } catch (PackageManager.NameNotFoundException e) {
                        c4887M8504.mo8165().f14444.m8035("Package name not found", e);
                    }
                }
                j = 0;
                c4828M8059.f14528 = j;
            }
            j = jM8218;
            c4828M8059.f14528 = j;
        }
        long j3 = c4828M8059.f14528;
        boolean zM8495 = c4828M8059.f14588.m8495();
        boolean z2 = !c4828M8059.m8168().f14666;
        c4828M8059.mo8008();
        c4828M8059.mo8055();
        if (c4828M8059.f14588.m8495()) {
            if (((InterfaceC4655) C4652.f14147.mo7259()).mo7535() && c4828M8059.f14588.f15015.m8177(C4915.f14899)) {
                c4828M8059.mo8165().f14452.m8034("Disabled IID for tests.");
            } else {
                try {
                    Class<?> clsLoadClass = c4828M8059.f14588.f15009.getClassLoader().loadClass("disabled_com.google.firebase.analytics.FirebaseAnalytics");
                    if (clsLoadClass != null) {
                        try {
                            Object objInvoke = clsLoadClass.getDeclaredMethod("getInstance", Context.class).invoke(null, c4828M8059.f14588.f15009);
                            if (objInvoke == null) {
                                str = null;
                            } else {
                                try {
                                    str = (String) clsLoadClass.getDeclaredMethod("getFirebaseInstanceId", new Class[0]).invoke(objInvoke, new Object[0]);
                                } catch (Exception unused) {
                                    c4828M8059.mo8165().f14449.m8034("Failed to retrieve Firebase Instance Id");
                                    str = null;
                                }
                            }
                        } catch (Exception unused2) {
                            c4828M8059.mo8165().f14448.m8034("Failed to obtain Firebase Analytics instance");
                        }
                    }
                } catch (ClassNotFoundException unused3) {
                }
            }
            str = null;
        } else {
            str = null;
        }
        C4974 c4974 = c4828M8059.f14588;
        Long lValueOf = Long.valueOf(c4974.m8501().f14653.m8316());
        long jMin = lValueOf.longValue() == 0 ? c4974.f15040 : Math.min(c4974.f15040, lValueOf.longValue());
        c4828M8059.m8066();
        int i = c4828M8059.f14531;
        boolean zBooleanValue = c4828M8059.f14588.f15015.m8189().booleanValue();
        C4869 c4869 = c4828M8059.f14588.f15015;
        c4869.mo8055();
        Boolean boolM8181 = c4869.m8181("google_analytics_ssaid_collection_enabled");
        boolean zBooleanValue2 = Boolean.valueOf(boolM8181 == null || boolM8181.booleanValue()).booleanValue();
        C4874 c4874M8168 = c4828M8059.m8168();
        c4874M8168.mo8008();
        boolean z3 = c4874M8168.m8199().getBoolean("deferred_analytics_collection", false);
        c4828M8059.m8066();
        String str7 = c4828M8059.f14533;
        Boolean boolValueOf = c4828M8059.f14588.f15015.m8181("google_analytics_default_allow_ad_personalization_signals") == null ? null : Boolean.valueOf(!r11.booleanValue());
        long j4 = c4828M8059.f14529;
        List<String> list = c4828M8059.f14588.f15015.m8177(C4915.f14884) ? c4828M8059.f14530 : null;
        if (C4538.m7580() && c4828M8059.f14588.f15015.m8177(C4915.f14896)) {
            c4828M8059.m8066();
            str2 = c4828M8059.f14534;
        } else {
            str2 = null;
        }
        return new C4977(str3, str4, str5, j2, str6, 28000L, j3, strM8052, zM8495, z2, str, 0L, jMin, i, zBooleanValue, zBooleanValue2, z3, str7, boolValueOf, j4, list, str2);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8514(Runnable runnable) {
        mo8008();
        if (m8517()) {
            runnable.run();
        } else {
            if (this.f15088.size() >= 1000) {
                mo8165().f14444.m8034("Discarding data. Max runnable queue size reached");
                return;
            }
            this.f15088.add(runnable);
            this.f15089.m8361(60000L);
            m8518();
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:119:0x01f7  */
    /* JADX WARN: Removed duplicated region for block: B:121:0x01fc  */
    /* JADX WARN: Removed duplicated region for block: B:128:0x020c  */
    /* JADX WARN: Removed duplicated region for block: B:130:0x0211  */
    /* JADX WARN: Removed duplicated region for block: B:136:0x0228  */
    /* JADX WARN: Removed duplicated region for block: B:138:0x022d  */
    /* JADX WARN: Removed duplicated region for block: B:144:0x0248  */
    /* JADX WARN: Removed duplicated region for block: B:146:0x024d  */
    /* JADX WARN: Removed duplicated region for block: B:190:0x01e0 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:218:0x0230 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:220:0x0230 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:222:0x0230 A[SYNTHETIC] */
    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void m8515(InterfaceC4823 interfaceC4823, AbstractC4283 abstractC4283, C4977 c4977) throws Throwable {
        ArrayList arrayList;
        Cursor cursor;
        SQLiteDatabase sQLiteDatabase;
        SQLiteDatabase sQLiteDatabaseM8089;
        Cursor cursorQuery;
        Cursor cursor2;
        String str;
        String[] strArr;
        String[] strArr2;
        Parcel parcelObtain;
        C4891 c4891CreateFromParcel;
        C4999 c4999CreateFromParcel;
        int size;
        mo8008();
        mo8055();
        m8066();
        m8520();
        int i = 100;
        int i2 = 0;
        int i3 = 100;
        int i4 = 0;
        while (i4 < 1001 && i3 == i) {
            ArrayList arrayList2 = new ArrayList();
            C4821 c4821M8062 = m8062();
            c4821M8062.mo8008();
            c4821M8062.mo8055();
            if (c4821M8062.f14509) {
                arrayList = null;
            } else {
                ArrayList arrayList3 = new ArrayList();
                if (c4821M8062.f14588.f15009.getDatabasePath("google_app_measurement_local.db").exists()) {
                    int i5 = 5;
                    int i6 = 0;
                    int i7 = 5;
                    while (true) {
                        if (i6 >= i5) {
                            c4821M8062.mo8165().f14447.m8034("Failed to read events from database in reasonable time");
                            arrayList = null;
                            break;
                        }
                        try {
                            sQLiteDatabaseM8089 = c4821M8062.m8089();
                            if (sQLiteDatabaseM8089 == null) {
                                try {
                                    try {
                                        c4821M8062.f14509 = true;
                                        if (sQLiteDatabaseM8089 != null) {
                                            sQLiteDatabaseM8089.close();
                                        }
                                    } catch (SQLiteDatabaseLockedException unused) {
                                        cursorQuery = null;
                                        SystemClock.sleep(i7);
                                        i7 += 20;
                                        if (cursorQuery != null) {
                                            cursorQuery.close();
                                        }
                                        if (sQLiteDatabaseM8089 == null) {
                                            sQLiteDatabaseM8089.close();
                                        }
                                        i6++;
                                        i = 100;
                                        i2 = 0;
                                        i5 = 5;
                                    }
                                } catch (SQLiteFullException e) {
                                    e = e;
                                    cursorQuery = null;
                                    c4821M8062.mo8165().f14444.m8035("Error reading entries from local database", e);
                                    c4821M8062.f14509 = true;
                                    if (cursorQuery != null) {
                                    }
                                    if (sQLiteDatabaseM8089 != null) {
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                } catch (SQLiteException e2) {
                                    e = e2;
                                    cursorQuery = null;
                                    if (sQLiteDatabaseM8089 != null) {
                                    }
                                    c4821M8062.mo8165().f14444.m8035("Error reading entries from local database", e);
                                    c4821M8062.f14509 = true;
                                    if (cursorQuery != null) {
                                    }
                                    if (sQLiteDatabaseM8089 != null) {
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                } catch (Throwable th) {
                                    th = th;
                                    cursor2 = null;
                                    Cursor cursor3 = cursor2;
                                    sQLiteDatabase = sQLiteDatabaseM8089;
                                    cursor = cursor3;
                                    if (cursor != null) {
                                    }
                                    if (sQLiteDatabase != null) {
                                    }
                                    throw th;
                                }
                            } else {
                                sQLiteDatabaseM8089.beginTransaction();
                                long jM8085 = C4821.m8085(sQLiteDatabaseM8089);
                                long j = -1;
                                if (jM8085 != -1) {
                                    String[] strArr3 = new String[1];
                                    strArr3[i2] = String.valueOf(jM8085);
                                    str = "rowid<?";
                                    strArr = strArr3;
                                } else {
                                    str = null;
                                    strArr = null;
                                }
                                try {
                                    cursorQuery = sQLiteDatabaseM8089.query("messages", new String[]{"rowid", "type", "entry"}, str, strArr, null, null, "rowid asc", Integer.toString(i));
                                    while (cursorQuery.moveToNext()) {
                                        try {
                                            try {
                                                j = cursorQuery.getLong(i2);
                                                int i8 = cursorQuery.getInt(1);
                                                byte[] blob = cursorQuery.getBlob(2);
                                                if (i8 == 0) {
                                                    parcelObtain = Parcel.obtain();
                                                    try {
                                                        try {
                                                            parcelObtain.unmarshall(blob, i2, blob.length);
                                                            parcelObtain.setDataPosition(i2);
                                                            C4913 c4913CreateFromParcel = C4913.CREATOR.createFromParcel(parcelObtain);
                                                            if (c4913CreateFromParcel != null) {
                                                                arrayList3.add(c4913CreateFromParcel);
                                                            }
                                                        } catch (SafeParcelReader$ParseException unused2) {
                                                            c4821M8062.mo8165().f14444.m8034("Failed to load event from local database");
                                                            parcelObtain.recycle();
                                                        }
                                                    } finally {
                                                    }
                                                } else if (i8 == 1) {
                                                    parcelObtain = Parcel.obtain();
                                                    try {
                                                        try {
                                                            parcelObtain.unmarshall(blob, i2, blob.length);
                                                            parcelObtain.setDataPosition(i2);
                                                            c4999CreateFromParcel = C4999.CREATOR.createFromParcel(parcelObtain);
                                                        } catch (SafeParcelReader$ParseException unused3) {
                                                            c4821M8062.mo8165().f14444.m8034("Failed to load user property from local database");
                                                            parcelObtain.recycle();
                                                            c4999CreateFromParcel = null;
                                                        }
                                                        if (c4999CreateFromParcel != null) {
                                                            arrayList3.add(c4999CreateFromParcel);
                                                        }
                                                    } finally {
                                                    }
                                                } else if (i8 == 2) {
                                                    parcelObtain = Parcel.obtain();
                                                    try {
                                                        try {
                                                            parcelObtain.unmarshall(blob, i2, blob.length);
                                                            parcelObtain.setDataPosition(i2);
                                                            c4891CreateFromParcel = C4891.CREATOR.createFromParcel(parcelObtain);
                                                        } finally {
                                                        }
                                                    } catch (SafeParcelReader$ParseException unused4) {
                                                        c4821M8062.mo8165().f14444.m8034("Failed to load conditional user property from local database");
                                                        parcelObtain.recycle();
                                                        c4891CreateFromParcel = null;
                                                    }
                                                    if (c4891CreateFromParcel != null) {
                                                        arrayList3.add(c4891CreateFromParcel);
                                                    }
                                                } else if (i8 == 3) {
                                                    c4821M8062.mo8165().f14447.m8034("Skipping app launch break");
                                                } else {
                                                    c4821M8062.mo8165().f14444.m8034("Unknown record type in local database");
                                                }
                                            } catch (Throwable th2) {
                                                th = th2;
                                                sQLiteDatabase = sQLiteDatabaseM8089;
                                                cursor = cursorQuery;
                                            }
                                        } catch (SQLiteDatabaseLockedException unused5) {
                                        } catch (SQLiteFullException e3) {
                                            e = e3;
                                        } catch (SQLiteException e4) {
                                            e = e4;
                                        }
                                    }
                                    strArr2 = new String[1];
                                } catch (SQLiteFullException e5) {
                                    e = e5;
                                    cursorQuery = null;
                                    c4821M8062.mo8165().f14444.m8035("Error reading entries from local database", e);
                                    c4821M8062.f14509 = true;
                                    if (cursorQuery != null) {
                                        cursorQuery.close();
                                    }
                                    if (sQLiteDatabaseM8089 != null) {
                                        sQLiteDatabaseM8089.close();
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                } catch (SQLiteException e6) {
                                    e = e6;
                                    cursorQuery = null;
                                    if (sQLiteDatabaseM8089 != null) {
                                        try {
                                            if (sQLiteDatabaseM8089.inTransaction()) {
                                                sQLiteDatabaseM8089.endTransaction();
                                            }
                                        } catch (Throwable th3) {
                                            cursor2 = cursorQuery;
                                            sQLiteDatabaseM8089 = sQLiteDatabaseM8089;
                                            th = th3;
                                            Cursor cursor32 = cursor2;
                                            sQLiteDatabase = sQLiteDatabaseM8089;
                                            cursor = cursor32;
                                            if (cursor != null) {
                                            }
                                            if (sQLiteDatabase != null) {
                                            }
                                            throw th;
                                        }
                                    }
                                    c4821M8062.mo8165().f14444.m8035("Error reading entries from local database", e);
                                    c4821M8062.f14509 = true;
                                    if (cursorQuery != null) {
                                        cursorQuery.close();
                                    }
                                    if (sQLiteDatabaseM8089 != null) {
                                        sQLiteDatabaseM8089.close();
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                } catch (Throwable th4) {
                                    th = th4;
                                    sQLiteDatabase = sQLiteDatabaseM8089;
                                    cursor = null;
                                }
                                try {
                                    strArr2[0] = Long.toString(j);
                                    if (sQLiteDatabaseM8089.delete("messages", "rowid <= ?", strArr2) < arrayList3.size()) {
                                        c4821M8062.mo8165().f14444.m8034("Fewer entries removed from local database than expected");
                                    }
                                    sQLiteDatabaseM8089.setTransactionSuccessful();
                                    sQLiteDatabaseM8089.endTransaction();
                                    cursorQuery.close();
                                    sQLiteDatabaseM8089.close();
                                    arrayList = arrayList3;
                                } catch (SQLiteDatabaseLockedException unused6) {
                                    SystemClock.sleep(i7);
                                    i7 += 20;
                                    if (cursorQuery != null) {
                                    }
                                    if (sQLiteDatabaseM8089 == null) {
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                } catch (SQLiteFullException e7) {
                                    e = e7;
                                    c4821M8062.mo8165().f14444.m8035("Error reading entries from local database", e);
                                    c4821M8062.f14509 = true;
                                    if (cursorQuery != null) {
                                    }
                                    if (sQLiteDatabaseM8089 != null) {
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                } catch (SQLiteException e8) {
                                    e = e8;
                                    if (sQLiteDatabaseM8089 != null) {
                                    }
                                    c4821M8062.mo8165().f14444.m8035("Error reading entries from local database", e);
                                    c4821M8062.f14509 = true;
                                    if (cursorQuery != null) {
                                    }
                                    if (sQLiteDatabaseM8089 != null) {
                                    }
                                    i6++;
                                    i = 100;
                                    i2 = 0;
                                    i5 = 5;
                                }
                            }
                        } catch (SQLiteDatabaseLockedException unused7) {
                            sQLiteDatabaseM8089 = null;
                        } catch (SQLiteFullException e9) {
                            e = e9;
                            sQLiteDatabaseM8089 = null;
                        } catch (SQLiteException e10) {
                            e = e10;
                            sQLiteDatabaseM8089 = null;
                        } catch (Throwable th5) {
                            th = th5;
                            cursor = null;
                            sQLiteDatabase = null;
                        }
                        if (cursor != null) {
                            cursor.close();
                        }
                        if (sQLiteDatabase != null) {
                            sQLiteDatabase.close();
                        }
                        throw th;
                        i6++;
                        i = 100;
                        i2 = 0;
                        i5 = 5;
                    }
                } else {
                    arrayList = arrayList3;
                }
            }
            if (arrayList != null) {
                arrayList2.addAll(arrayList);
                size = arrayList.size();
            } else {
                size = 0;
            }
            if (abstractC4283 != null && size < 100) {
                arrayList2.add(abstractC4283);
            }
            int size2 = arrayList2.size();
            int i9 = 0;
            while (i9 < size2) {
                int i10 = i9 + 1;
                AbstractC4283 abstractC42832 = (AbstractC4283) arrayList2.get(i9);
                if (abstractC42832 instanceof C4913) {
                    try {
                        interfaceC4823.mo8101((C4913) abstractC42832, c4977);
                    } catch (RemoteException e11) {
                        mo8165().f14444.m8035("Failed to send event to the service", e11);
                    }
                } else if (abstractC42832 instanceof C4999) {
                    try {
                        interfaceC4823.mo8103((C4999) abstractC42832, c4977);
                    } catch (RemoteException e12) {
                        mo8165().f14444.m8035("Failed to send user property to the service", e12);
                    }
                } else if (abstractC42832 instanceof C4891) {
                    try {
                        interfaceC4823.mo8099((C4891) abstractC42832, c4977);
                    } catch (RemoteException e13) {
                        mo8165().f14444.m8035("Failed to send conditional user property to the service", e13);
                    }
                } else {
                    mo8165().f14444.m8034("Discarding data. Unrecognized parcel type.");
                }
                i9 = i10;
            }
            i4++;
            i3 = size;
            i = 100;
            i2 = 0;
        }
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final void m8516(C4891 c4891) {
        boolean zM8086;
        C0567.m1910(c4891);
        mo8008();
        m8066();
        C4785 c4785 = this.f14588.f15014;
        C4821 c4821M8062 = m8062();
        c4821M8062.m8167();
        byte[] bArrM8228 = C4887.m8228((Parcelable) c4891);
        if (bArrM8228.length > 131072) {
            c4821M8062.mo8165().f14445.m8034("Conditional user property too long for local database. Sending directly to service");
            zM8086 = false;
        } else {
            zM8086 = c4821M8062.m8086(2, bArrM8228);
        }
        m8514(new RunnableC4842(this, true, zM8086, new C4891(c4891), m8513(true), c4891));
    }

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

    /* JADX INFO: renamed from: ޖ, reason: contains not printable characters */
    public final boolean m8517() {
        mo8008();
        m8066();
        return this.f15084 != null;
    }

    /* JADX INFO: renamed from: ޗ, reason: contains not printable characters */
    public final void m8518() {
        mo8008();
        m8066();
        if (m8517()) {
            return;
        }
        if (m8522()) {
            this.f15083.m8525();
            return;
        }
        if (this.f14588.f15015.m8191()) {
            return;
        }
        C4974 c4974 = this.f14588;
        C4785 c4785 = c4974.f15014;
        List<ResolveInfo> listQueryIntentServices = c4974.f15009.getPackageManager().queryIntentServices(new Intent().setClassName(this.f14588.f15009, "com.google.android.gms.measurement.AppMeasurementService"), 65536);
        if (!(listQueryIntentServices != null && listQueryIntentServices.size() > 0)) {
            mo8165().f14444.m8034("Unable to use remote or local measurement implementation. Please register the AppMeasurementService service in the app manifest");
            return;
        }
        Intent intent = new Intent("com.google.android.gms.measurement.START");
        C4974 c49742 = this.f14588;
        Context context = c49742.f15009;
        C4785 c47852 = c49742.f15014;
        intent.setComponent(new ComponentName(context, "com.google.android.gms.measurement.AppMeasurementService"));
        this.f15083.m8526(intent);
    }

    /* JADX INFO: renamed from: ޘ, reason: contains not printable characters */
    public final void m8519() {
        C4306 c4306M7206;
        Context context;
        ServiceConnectionC4991 serviceConnectionC4991;
        mo8008();
        m8066();
        ServiceConnectionC4991 serviceConnectionC49912 = this.f15083;
        if (serviceConnectionC49912.f15103 != null && (serviceConnectionC49912.f15103.m6917() || serviceConnectionC49912.f15103.m6922())) {
            serviceConnectionC49912.f15103.m6925();
        }
        serviceConnectionC49912.f15103 = null;
        try {
            c4306M7206 = C4306.m7206();
            context = this.f14588.f15009;
            serviceConnectionC4991 = this.f15083;
        } catch (IllegalArgumentException | IllegalStateException unused) {
        }
        if (c4306M7206 == null) {
            throw null;
        }
        context.unbindService(serviceConnectionC4991);
        this.f15084 = null;
    }

    /* JADX INFO: renamed from: ޙ, reason: contains not printable characters */
    public final boolean m8520() {
        C4785 c4785 = this.f14588.f15014;
        return true;
    }

    /* JADX INFO: renamed from: ޚ, reason: contains not printable characters */
    public final void m8521() {
        mo8008();
        C4862 c4862 = this.f15087;
        if (((C4312) c4862.f14607) == null) {
            throw null;
        }
        c4862.f14608 = SystemClock.elapsedRealtime();
        this.f15086.m8361(C4915.f14863.m8054(null).longValue());
    }

    /* JADX WARN: Removed duplicated region for block: B:46:0x00ee  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0104  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x0107  */
    /* JADX INFO: renamed from: ޛ, reason: contains not printable characters */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean m8522() {
        boolean z;
        mo8008();
        m8066();
        if (this.f15085 == null) {
            mo8008();
            m8066();
            C4874 c4874M8168 = m8168();
            c4874M8168.mo8008();
            boolean z2 = false;
            Boolean boolValueOf = !c4874M8168.m8199().contains("use_service") ? null : Boolean.valueOf(c4874M8168.m8199().getBoolean("use_service", false));
            if (boolValueOf == null || !boolValueOf.booleanValue()) {
                C4785 c4785 = this.f14588.f15014;
                C4828 c4828M8059 = m8059();
                c4828M8059.m8066();
                if (c4828M8059.f14531 == 1) {
                    z = true;
                    if (z && this.f14588.f15015.m8191()) {
                        mo8165().f14444.m8034("No way to upload. Consider using the full version of Analytics");
                    } else {
                        z2 = z;
                    }
                    if (z2) {
                        C4874 c4874M81682 = m8168();
                        c4874M81682.mo8008();
                        SharedPreferences.Editor editorEdit = c4874M81682.m8199().edit();
                        editorEdit.putBoolean("use_service", z);
                        editorEdit.apply();
                    }
                } else {
                    mo8165().f14452.m8034("Checking service availability");
                    C4887 c4887M8167 = m8167();
                    if (c4887M8167 == null) {
                        throw null;
                    }
                    int iMo6844 = C4196.f13406.mo6844(c4887M8167.f14588.f15009, 12451000);
                    if (iMo6844 != 0) {
                        if (iMo6844 == 1) {
                            mo8165().f14452.m8034("Service missing");
                        } else if (iMo6844 != 2) {
                            if (iMo6844 == 3) {
                                mo8165().f14447.m8034("Service disabled");
                            } else if (iMo6844 == 9) {
                                mo8165().f14447.m8034("Service invalid");
                            } else if (iMo6844 != 18) {
                                mo8165().f14447.m8035("Unexpected service status", Integer.valueOf(iMo6844));
                            } else {
                                mo8165().f14447.m8034("Service updating");
                            }
                            z = false;
                        } else {
                            mo8165().f14451.m8034("Service container out of date");
                            if (m8167().m8274() >= 17443) {
                                z = boolValueOf == null;
                                z = false;
                            }
                            if (z) {
                                z2 = z;
                                if (z2) {
                                }
                            }
                        }
                        z = z;
                        z = false;
                        if (z) {
                        }
                    } else {
                        mo8165().f14452.m8034("Service available");
                    }
                    z = true;
                    if (z) {
                    }
                }
            }
            this.f15085 = Boolean.valueOf(z);
        }
        return this.f15085.booleanValue();
    }

    /* JADX INFO: renamed from: ޜ, reason: contains not printable characters */
    public final void m8523() {
        mo8008();
        mo8165().f14452.m8035("Processing queued up service tasks", Integer.valueOf(this.f15088.size()));
        Iterator<Runnable> it = this.f15088.iterator();
        while (it.hasNext()) {
            try {
                it.next().run();
            } catch (Exception e) {
                mo8165().f14444.m8035("Task exception while flushing queue", e);
            }
        }
        this.f15088.clear();
        this.f15089.m8362();
    }
}
