Update isolated process checking method
This commit is contained in:
parent
11e6eeb397
commit
02adea8691
|
|
@ -1,4 +1,4 @@
|
|||
version: '0.5.0.5 ({build})'
|
||||
version: '0.5.0.6 ({build})'
|
||||
|
||||
environment:
|
||||
ANDROID_HOME: C:\android-sdk-windows
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.elderdrivers.riru.edxp.framework;
|
||||
|
||||
import android.os.Process;
|
||||
|
||||
import de.robv.android.xposed.XposedHelpers;
|
||||
import de.robv.android.xposed.annotation.ApiSensitive;
|
||||
import de.robv.android.xposed.annotation.Level;
|
||||
|
|
@ -31,11 +33,25 @@ public class ProcessHelper {
|
|||
*/
|
||||
public static final int LAST_ISOLATED_UID = 99999;
|
||||
|
||||
/**
|
||||
* First uid used for fully isolated sandboxed processes spawned from an app zygote
|
||||
*/
|
||||
public static final int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000;
|
||||
/**
|
||||
* Number of UIDs we allocate per application zygote
|
||||
*/
|
||||
public static final int NUM_UIDS_PER_APP_ZYGOTE = 100;
|
||||
/**
|
||||
* Last uid used for fully isolated sandboxed processes spawned from an app zygote
|
||||
*/
|
||||
public static final int LAST_APP_ZYGOTE_ISOLATED_UID = 98999;
|
||||
|
||||
/**
|
||||
* Range of uids allocated for a user.
|
||||
*/
|
||||
public static final int PER_USER_RANGE = 100000;
|
||||
|
||||
// @see UserHandle#getAppId(int)
|
||||
public static int getAppId(int uid) {
|
||||
return uid % PER_USER_RANGE;
|
||||
}
|
||||
|
|
@ -49,7 +65,32 @@ public class ProcessHelper {
|
|||
}
|
||||
|
||||
public static boolean isIsolated(int uid) {
|
||||
uid = getAppId(uid);
|
||||
return uid >= FIRST_ISOLATED_UID && uid <= LAST_ISOLATED_UID;
|
||||
return (boolean) XposedHelpers.callStaticMethod(
|
||||
Process.class, "isIsolated", uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a UID belongs to a regular app. *Note* "Not a regular app" does not mean
|
||||
* "it's system", because of isolated UIDs. Use {@link #isCore} for that.
|
||||
*/
|
||||
public static boolean isApp(int uid) {
|
||||
if (uid > 0) {
|
||||
final int appId = getAppId(uid);
|
||||
return appId >= Process.FIRST_APPLICATION_UID && appId <= Process.LAST_APPLICATION_UID;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a UID belongs to a system core component or not.
|
||||
*/
|
||||
public static boolean isCore(int uid) {
|
||||
if (uid >= 0) {
|
||||
final int appId = getAppId(uid);
|
||||
return appId < Process.FIRST_APPLICATION_UID;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,8 @@ public class Versions {
|
|||
public static boolean hasR() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
|
||||
}
|
||||
|
||||
public static boolean hasQ() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.gradle.internal.os.OperatingSystem
|
|||
apply plugin: 'com.android.library'
|
||||
|
||||
// Values set here will be overriden by AppVeyor, feel free to modify during development.
|
||||
def buildVersionName = 'v0.5.0.5'
|
||||
def buildVersionName = 'v0.5.0.6'
|
||||
def buildVersionCode = 233
|
||||
|
||||
if (System.env.APPVEYOR_BUILD_VERSION != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue