package l2;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.AssetFileDescriptor;
import android.os.Build;
import androidx.navigation.C1134i;
import java.io.File;
import java.io.IOException;

/* JADX INFO: loaded from: classes.dex */
public abstract class j {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final androidx.concurrent.futures.k f20286a = new androidx.concurrent.futures.k();

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static C1134i f20288c = null;

    public static long a(Context context) {
        PackageManager packageManager = context.getApplicationContext().getPackageManager();
        return Build.VERSION.SDK_INT >= 33 ? h.a(packageManager, context).lastUpdateTime : packageManager.getPackageInfo(context.getPackageName(), 0).lastUpdateTime;
    }

    public static C1134i b() {
        C1134i c1134i = new C1134i(9);
        f20288c = c1134i;
        f20286a.set(c1134i);
        return f20288c;
    }

    /* JADX WARN: Removed duplicated region for block: B:101:0x00f4 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:109:0x00a8 A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:20:0x002c  */
    /* JADX WARN: Removed duplicated region for block: B:21:0x002e  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x006f  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:58:0x00b2  */
    /* JADX WARN: Removed duplicated region for block: B:67:0x00c3  */
    /* JADX WARN: Removed duplicated region for block: B:68:0x00c5  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x00c8  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static void c(Context context, boolean z6) {
        int i6;
        boolean z7;
        int i7;
        long length;
        File file;
        i iVarA;
        i iVar;
        int i8;
        AssetFileDescriptor assetFileDescriptorOpenFd;
        if (z6 || f20288c == null) {
            synchronized (f20287b) {
                if (z6) {
                    i6 = 0;
                    assetFileDescriptorOpenFd = context.getAssets().openFd("dexopt/baseline.prof");
                    if (assetFileDescriptorOpenFd.getLength() <= 0) {
                    }
                    assetFileDescriptorOpenFd.close();
                    i7 = Build.VERSION.SDK_INT;
                    if (i7 >= 28) {
                        File file2 = new File(new File("/data/misc/profiles/ref/", context.getPackageName()), "primary.prof");
                        long length2 = file2.length();
                        if (file2.exists()) {
                            File file3 = new File(new File("/data/misc/profiles/cur/0/", context.getPackageName()), "primary.prof");
                            length = file3.length();
                            if (file3.exists()) {
                                long jA = a(context);
                                file = new File(context.getFilesDir(), "profileInstalled");
                                if (file.exists()) {
                                }
                                if (iVarA == null) {
                                    if (z7) {
                                    }
                                }
                                if (z6) {
                                    i6 = 2;
                                }
                                if (iVarA != null) {
                                    i6 = 3;
                                }
                                iVar = new i(1, i6, jA, length);
                                if (iVarA != null) {
                                    iVar.b(file);
                                }
                                b();
                                return;
                            }
                        }
                    }
                    b();
                    return;
                }
                if (f20288c != null) {
                    return;
                }
                i6 = 0;
                try {
                    assetFileDescriptorOpenFd = context.getAssets().openFd("dexopt/baseline.prof");
                    try {
                        z7 = assetFileDescriptorOpenFd.getLength() <= 0;
                        assetFileDescriptorOpenFd.close();
                    } finally {
                    }
                } catch (IOException unused) {
                    z7 = false;
                }
                i7 = Build.VERSION.SDK_INT;
                if (i7 >= 28 && i7 != 30) {
                    File file22 = new File(new File("/data/misc/profiles/ref/", context.getPackageName()), "primary.prof");
                    long length22 = file22.length();
                    boolean z8 = !file22.exists() && length22 > 0;
                    File file32 = new File(new File("/data/misc/profiles/cur/0/", context.getPackageName()), "primary.prof");
                    length = file32.length();
                    boolean z9 = !file32.exists() && length > 0;
                    try {
                        long jA2 = a(context);
                        file = new File(context.getFilesDir(), "profileInstalled");
                        if (file.exists()) {
                            iVarA = null;
                        } else {
                            try {
                                iVarA = i.a(file);
                            } catch (IOException unused2) {
                                b();
                                return;
                            }
                        }
                        if (iVarA == null && iVarA.f20284c == jA2 && (i8 = iVarA.f20283b) != 2) {
                            i6 = i8;
                        } else if (z7) {
                            i6 = 327680;
                        } else if (z8) {
                            i6 = 1;
                        } else if (z9) {
                            i6 = 2;
                        }
                        if (z6 && z9 && i6 != 1) {
                            i6 = 2;
                        }
                        if (iVarA != null && iVarA.f20283b == 2 && i6 == 1 && length22 < iVarA.f20285d) {
                            i6 = 3;
                        }
                        iVar = new i(1, i6, jA2, length);
                        if (iVarA != null || !iVarA.equals(iVar)) {
                            try {
                                iVar.b(file);
                            } catch (IOException unused3) {
                            }
                        }
                        b();
                        return;
                    } catch (PackageManager.NameNotFoundException unused4) {
                        b();
                        return;
                    }
                }
                b();
                return;
            }
        }
    }
}
