93 lines
2.9 KiB
Java
93 lines
2.9 KiB
Java
package androidx.core.os;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.os.Build;
|
|
import android.os.Process;
|
|
import android.os.UserHandle;
|
|
import androidx.annotation.RequiresApi;
|
|
import java.lang.reflect.Method;
|
|
/* loaded from: classes.dex */
|
|
public final class ProcessCompat {
|
|
|
|
@RequiresApi(16)
|
|
/* loaded from: classes.dex */
|
|
public static class Api16Impl {
|
|
private static Method sMethodUserIdIsAppMethod;
|
|
private static boolean sResolved;
|
|
private static final Object sResolvedLock = new Object();
|
|
|
|
private Api16Impl() {
|
|
}
|
|
|
|
@SuppressLint({"PrivateApi"})
|
|
public static boolean isApplicationUid(int i) {
|
|
try {
|
|
synchronized (sResolvedLock) {
|
|
if (!sResolved) {
|
|
sResolved = true;
|
|
sMethodUserIdIsAppMethod = Class.forName("android.os.UserId").getDeclaredMethod("isApp", Integer.TYPE);
|
|
}
|
|
}
|
|
Method method = sMethodUserIdIsAppMethod;
|
|
if (method != null) {
|
|
Boolean bool = (Boolean) method.invoke(null, Integer.valueOf(i));
|
|
if (bool != null) {
|
|
return bool.booleanValue();
|
|
}
|
|
throw new NullPointerException();
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@RequiresApi(17)
|
|
/* loaded from: classes.dex */
|
|
public static class Api17Impl {
|
|
private static Method sMethodUserHandleIsAppMethod;
|
|
private static boolean sResolved;
|
|
private static final Object sResolvedLock = new Object();
|
|
|
|
private Api17Impl() {
|
|
}
|
|
|
|
@SuppressLint({"DiscouragedPrivateApi"})
|
|
public static boolean isApplicationUid(int i) {
|
|
try {
|
|
synchronized (sResolvedLock) {
|
|
if (!sResolved) {
|
|
sResolved = true;
|
|
sMethodUserHandleIsAppMethod = UserHandle.class.getDeclaredMethod("isApp", Integer.TYPE);
|
|
}
|
|
}
|
|
Method method = sMethodUserHandleIsAppMethod;
|
|
if (method != null && ((Boolean) method.invoke(null, Integer.valueOf(i))) == null) {
|
|
throw new NullPointerException();
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@RequiresApi(24)
|
|
/* loaded from: classes.dex */
|
|
public static class Api24Impl {
|
|
private Api24Impl() {
|
|
}
|
|
|
|
public static boolean isApplicationUid(int i) {
|
|
return Process.isApplicationUid(i);
|
|
}
|
|
}
|
|
|
|
private ProcessCompat() {
|
|
}
|
|
|
|
public static boolean isApplicationUid(int i) {
|
|
return Build.VERSION.SDK_INT >= 24 ? Api24Impl.isApplicationUid(i) : Api17Impl.isApplicationUid(i);
|
|
}
|
|
}
|