package p069x;

import android.content.Context;
import android.os.Process;
import p020g0.C0734d;
import p067w.C1775g;

/* renamed from: x.g */
/* loaded from: classes.dex */
public final class C1803g {
    /* renamed from: a */
    public static int m373a(Context context, String str, int i, int i2, String str2) {
        if (context.checkPermission(str, i, i2) == -1) {
            return -1;
        }
        String m431c = C1775g.m431c(str);
        if (m431c == null) {
            return 0;
        }
        if (str2 == null) {
            String[] packagesForUid = context.getPackageManager().getPackagesForUid(i2);
            if (packagesForUid == null || packagesForUid.length <= 0) {
                return -1;
            }
            str2 = packagesForUid[0];
        }
        return (Process.myUid() == i2 && C0734d.m3043a(context.getPackageName(), str2) ? C1775g.m433a(context, i2, m431c, str2) : C1775g.m432b(context, m431c, str2)) == 0 ? 0 : -2;
    }

    /* renamed from: b */
    public static int m372b(Context context, String str) {
        return m373a(context, str, Process.myPid(), Process.myUid(), context.getPackageName());
    }
}