package x7;

import android.content.Context;
import android.content.pm.PackageManager;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import kotlin.jvm.internal.t;
import sm.u;

/* loaded from: classes.dex */
public final class b {

    /* renamed from: a, reason: collision with root package name */
    public static final b f50572a = new b();

    private b() {
    }

    private final boolean a() {
        return new File("/system/app/Superuser.apk").exists() || new File("/data/app/magisk.apk").exists() || new File("/system/app/xposed.apk").exists();
    }

    private final boolean b(Context context) {
        ArrayList g10;
        boolean z10;
        g10 = u.g("com.topjohnwu.magisk");
        PackageManager packageManager = context.getPackageManager();
        if ((g10 instanceof Collection) && g10.isEmpty()) {
            return false;
        }
        Iterator it = g10.iterator();
        while (it.hasNext()) {
            try {
                packageManager.getPackageInfo((String) it.next(), 0);
                z10 = true;
            } catch (PackageManager.NameNotFoundException unused) {
                z10 = false;
            }
            if (z10) {
                return true;
            }
        }
        return false;
    }

    private final boolean d() {
        String[] strArr = {"/system/bin/su", "/system/xbin/su", "/sbin/su", "/system/sd/xbin/su", "/system/bin/failsafe/su", "/data/local/su", "/data/local/bin/su", "/data/local/xbin/su"};
        for (int i10 = 0; i10 < 8; i10++) {
            if (new File(strArr[i10]).exists()) {
                return true;
            }
        }
        return false;
    }

    public final boolean c(Context context) {
        t.g(context, "context");
        return a() || d() || b(context);
    }
}
