package X6FRs_4.IMuAHx_6.X6FRs_4;

import android.content.Context;
import android.os.Process;
/* compiled from: PermissionChecker.java */
/* loaded from: classes.dex */
public final class QxJ9d_1 {
    public static int KQgRr5e_0(Context context, String str, int i, int i2, String str2) {
        if (context.checkPermission(str, i, i2) == -1) {
            return -1;
        }
        String KQgRr5e_0 = X6FRs_4.IMuAHx_6.Mqv2r_3.QxJ9d_1.KQgRr5e_0(str);
        if (KQgRr5e_0 == null) {
            return 0;
        }
        if (str2 == null) {
            String[] packagesForUid = context.getPackageManager().getPackagesForUid(i2);
            if (packagesForUid == null || packagesForUid.length <= 0) {
                return -1;
            }
            str2 = packagesForUid[0];
        }
        return X6FRs_4.IMuAHx_6.Mqv2r_3.QxJ9d_1.KQgRr5e_0(context, KQgRr5e_0, str2) != 0 ? -2 : 0;
    }

    public static int KQgRr5e_0(Context context, String str) {
        return KQgRr5e_0(context, str, Process.myPid(), Process.myUid(), context.getPackageName());
    }
}
