[core] Consolidate MIUI check (#663)
This commit is contained in:
parent
136be666ab
commit
bf63d97fb6
|
|
@ -25,8 +25,6 @@ import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_BOOT_IMAGE;
|
||||||
import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_BOOT_IMAGE_MIUI_RES;
|
import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_BOOT_IMAGE_MIUI_RES;
|
||||||
import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_SYSTEM_SERVER;
|
import static org.lsposed.lspd.deopt.InlinedMethodCallers.KEY_SYSTEM_SERVER;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import org.lsposed.lspd.nativebridge.Yahfa;
|
import org.lsposed.lspd.nativebridge.Yahfa;
|
||||||
import org.lsposed.lspd.util.Utils;
|
import org.lsposed.lspd.util.Utils;
|
||||||
import org.lsposed.lspd.yahfa.hooker.YahfaHooker;
|
import org.lsposed.lspd.yahfa.hooker.YahfaHooker;
|
||||||
|
|
@ -62,8 +60,7 @@ public class PrebuiltMethodsDeopter {
|
||||||
public static void deoptBootMethods() {
|
public static void deoptBootMethods() {
|
||||||
// todo check if has been done before
|
// todo check if has been done before
|
||||||
deoptMethods(KEY_BOOT_IMAGE, null);
|
deoptMethods(KEY_BOOT_IMAGE, null);
|
||||||
if (!TextUtils.isEmpty(Utils.getSysProp("ro.miui.ui.version.code"))
|
if (Utils.isMIUI && serviceClient.isResourcesHookEnabled()) {
|
||||||
&& serviceClient.isResourcesHookEnabled()) {
|
|
||||||
//deopt these only for MIUI with resources hook enabled
|
//deopt these only for MIUI with resources hook enabled
|
||||||
deoptMethods(KEY_BOOT_IMAGE_MIUI_RES, null);
|
deoptMethods(KEY_BOOT_IMAGE_MIUI_RES, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ import static org.lsposed.lspd.service.ServiceManager.TAG;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
import org.lsposed.lspd.util.Utils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
@ -38,7 +38,6 @@ public class LSPApplicationService extends ILSPApplicationService.Stub {
|
||||||
private final static Set<Pair<Integer, Integer>> cache = ConcurrentHashMap.newKeySet();
|
private final static Set<Pair<Integer, Integer>> cache = ConcurrentHashMap.newKeySet();
|
||||||
private final static Map<Integer, IBinder> handles = new ConcurrentHashMap<>();
|
private final static Map<Integer, IBinder> handles = new ConcurrentHashMap<>();
|
||||||
private final static Set<IBinder.DeathRecipient> recipients = ConcurrentHashMap.newKeySet();
|
private final static Set<IBinder.DeathRecipient> recipients = ConcurrentHashMap.newKeySet();
|
||||||
private final static boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name"));
|
|
||||||
|
|
||||||
public boolean registerHeartBeat(int uid, int pid, IBinder handle) {
|
public boolean registerHeartBeat(int uid, int pid, IBinder handle) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -106,7 +105,7 @@ public class LSPApplicationService extends ILSPApplicationService.Stub {
|
||||||
ensureRegistered();
|
ensureRegistered();
|
||||||
if (ConfigManager.getInstance().isManager(getCallingUid())) {
|
if (ConfigManager.getInstance().isManager(getCallingUid())) {
|
||||||
var service = ServiceManager.getManagerService();
|
var service = ServiceManager.getManagerService();
|
||||||
if (isMIUI) {
|
if (Utils.isMIUI) {
|
||||||
service.new ManagerGuard(handles.get(getCallingPid()));
|
service.new ManagerGuard(handles.get(getCallingPid()));
|
||||||
}
|
}
|
||||||
return service;
|
return service;
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,16 @@
|
||||||
|
|
||||||
package org.lsposed.lspd.util;
|
package org.lsposed.lspd.util;
|
||||||
|
|
||||||
|
import android.os.SystemProperties;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.lsposed.lspd.BuildConfig;
|
import org.lsposed.lspd.BuildConfig;
|
||||||
|
|
||||||
import de.robv.android.xposed.XposedHelpers;
|
|
||||||
|
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
public static final String LOG_TAG = "LSPosed";
|
public static final String LOG_TAG = "LSPosed";
|
||||||
|
public static final boolean isMIUI = !TextUtils.isEmpty(SystemProperties.get("ro.miui.ui.version.name"));
|
||||||
|
|
||||||
public static void logD(Object msg) {
|
public static void logD(Object msg) {
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
|
|
@ -64,16 +64,4 @@ public class Utils {
|
||||||
public static void logE(String msg, Throwable throwable) {
|
public static void logE(String msg, Throwable throwable) {
|
||||||
Log.e(LOG_TAG, msg, throwable);
|
Log.e(LOG_TAG, msg, throwable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSysProp(String key) {
|
|
||||||
try {
|
|
||||||
Class sysProps = XposedHelpers.findClassIfExists("android.os.SystemProperties", null);
|
|
||||||
if (sysProps != null) {
|
|
||||||
return (String) XposedHelpers.callStaticMethod(sysProps, "get", key);
|
|
||||||
}
|
|
||||||
} catch (Throwable throwable) {
|
|
||||||
Utils.logE("error when get sys prop", throwable);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue