diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java index 63a8dec2..7e06e04f 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/ModulesActivity.java @@ -188,11 +188,11 @@ public class ModulesActivity extends ListActivity implements ModuleUtil.ModuleLi sb.append(getString(R.string.module_empty_description)); } - int installedXposedVersion = ConfigManager.getXposedApiVersion(); + int installXposedVersion = ConfigManager.getXposedApiVersion(); String warningText = null; if (item.minVersion == 0) { warningText = getString(R.string.no_min_version_specified); - } else if (installedXposedVersion > 0 && item.minVersion > installedXposedVersion) { + } else if (installXposedVersion > 0 && item.minVersion > installXposedVersion) { warningText = String.format(getString(R.string.warning_xposed_min_version), item.minVersion); } else if (item.minVersion < ModuleUtil.MIN_MODULE_VERSION) { warningText = String.format(getString(R.string.warning_min_version_too_low), item.minVersion, ModuleUtil.MIN_MODULE_VERSION); diff --git a/core/src/main/java/io/github/lsposed/lspd/core/Main.java b/core/src/main/java/io/github/lsposed/lspd/core/Main.java index 83de2f51..8a01f846 100644 --- a/core/src/main/java/io/github/lsposed/lspd/core/Main.java +++ b/core/src/main/java/io/github/lsposed/lspd/core/Main.java @@ -43,7 +43,7 @@ public class Main implements KeepAll { LSPApplicationServiceClient.Init(binder); serviceClient.registerHeartBeat(heartBeatBinder); final int variant = serviceClient.getVariant(); - Impl lspd = getEdxpImpl(variant); + Impl lspd = getImpl(variant); if (lspd == null || !lspd.isInitialized()) { Utils.logE("Not started up"); return; @@ -55,18 +55,18 @@ public class Main implements KeepAll { LSPApplicationServiceClient.Init(binder); serviceClient.registerHeartBeat(heartBeatBinder); final int variant = serviceClient.getVariant(); - Impl lspd = getEdxpImpl(variant); + Impl lspd = getImpl(variant); if (lspd == null || !lspd.isInitialized()) { return; } lspd.getNormalProxy().forkSystemServerPost(); } - public static synchronized boolean setEdxpImpl(Impl lspd) { + public static synchronized boolean setImpl(Impl lspd) { return lspdImplRef.compareAndSet(null, lspd); } - public static synchronized Impl getEdxpImpl(int variant) { + public static synchronized Impl getImpl(int variant) { Impl lspd = lspdImplRef.get(); if (lspd != null) { return lspd; @@ -90,15 +90,10 @@ public class Main implements KeepAll { return lspdImplRef.get(); } - public static synchronized Impl getEdxpImpl() { + public static synchronized Impl getImpl() { return lspdImplRef.get(); } - @Impl.Variant - public static synchronized int getEdxpVariant() { - return getEdxpImpl().getVariant(); - } - public static void main(String[] args) { for (String arg : args) { if (arg.equals("--debug")) { diff --git a/core/src/main/java/io/github/lsposed/lspd/hooker/SystemMainHooker.java b/core/src/main/java/io/github/lsposed/lspd/hooker/SystemMainHooker.java index 5f920085..88f28016 100644 --- a/core/src/main/java/io/github/lsposed/lspd/hooker/SystemMainHooker.java +++ b/core/src/main/java/io/github/lsposed/lspd/hooker/SystemMainHooker.java @@ -44,7 +44,7 @@ public class SystemMainHooker extends XC_MethodHook { systemServerCL = Thread.currentThread().getContextClassLoader(); // deopt methods in SYSTEMSERVERCLASSPATH PrebuiltMethodsDeopter.deoptSystemServerMethods(systemServerCL); - Main.getEdxpImpl().getRouter().startSystemServerHook(); + Main.getImpl().getRouter().startSystemServerHook(); } catch (Throwable t) { Hookers.logE("error when hooking systemMain", t); } diff --git a/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java b/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java index 6a059512..d01d8d10 100644 --- a/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java +++ b/core/src/main/java/io/github/lsposed/lspd/sandhook/core/SandHookImpl.java @@ -35,7 +35,7 @@ public class SandHookImpl extends BaseImpl { static { final Impl lspdImpl = new SandHookImpl(); - if (Main.setEdxpImpl(lspdImpl)) { + if (Main.setImpl(lspdImpl)) { lspdImpl.init(); } } diff --git a/core/src/main/java/io/github/lsposed/lspd/service/BridgeService.java b/core/src/main/java/io/github/lsposed/lspd/service/BridgeService.java index 8ea594bf..54b010cc 100644 --- a/core/src/main/java/io/github/lsposed/lspd/service/BridgeService.java +++ b/core/src/main/java/io/github/lsposed/lspd/service/BridgeService.java @@ -37,30 +37,40 @@ public class BridgeService { private static ILSPosedService service = null; // for service - private static final IBinder.DeathRecipient BRIDGE_SERVICE_DEATH_RECIPIENT = () -> { - Log.i(TAG, "service " + SERVICE_NAME + " is dead. "); + static class BridgeServiceDeathRecipient implements IBinder.DeathRecipient { + private final IBinder bridgeService; - try { - @SuppressWarnings("JavaReflectionMemberAccess") - Field field = ServiceManager.class.getDeclaredField("sServiceManager"); - field.setAccessible(true); - field.set(null, null); - - //noinspection JavaReflectionMemberAccess - field = ServiceManager.class.getDeclaredField("sCache"); - field.setAccessible(true); - Object sCache = field.get(null); - if (sCache instanceof Map) { - //noinspection rawtypes - ((Map) sCache).clear(); - } - Log.i(TAG, "clear ServiceManager"); - } catch (Throwable e) { - Log.w(TAG, "clear ServiceManager: " + Log.getStackTraceString(e)); + BridgeServiceDeathRecipient(IBinder bridgeService) throws RemoteException { + this.bridgeService = bridgeService; + bridgeService.linkToDeath(this, 0); } + @Override + public void binderDied() { + Log.i(TAG, "service " + SERVICE_NAME + " is dead. "); - sendToBridge(serviceBinder, true); - }; + try { + @SuppressWarnings("JavaReflectionMemberAccess") + Field field = ServiceManager.class.getDeclaredField("sServiceManager"); + field.setAccessible(true); + field.set(null, null); + + //noinspection JavaReflectionMemberAccess + field = ServiceManager.class.getDeclaredField("sCache"); + field.setAccessible(true); + Object sCache = field.get(null); + if (sCache instanceof Map) { + //noinspection rawtypes + ((Map) sCache).clear(); + } + Log.i(TAG, "clear ServiceManager"); + } catch (Throwable e) { + Log.w(TAG, "clear ServiceManager: " + Log.getStackTraceString(e)); + } + + bridgeService.unlinkToDeath(this, 0); + sendToBridge(serviceBinder, true); + } + } // for client private static final IBinder.DeathRecipient LSPSERVICE_DEATH_RECIPIENT = () -> { @@ -102,7 +112,7 @@ public class BridgeService { } try { - bridgeService.linkToDeath(BRIDGE_SERVICE_DEATH_RECIPIENT, 0); + new BridgeServiceDeathRecipient(bridgeService); } catch (Throwable e) { Log.w(TAG, "linkToDeath " + Log.getStackTraceString(e)); sendToBridge(binder, false); diff --git a/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java b/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java index 4cd9919e..b74500f3 100644 --- a/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java +++ b/core/src/main/java/io/github/lsposed/lspd/yahfa/core/YahfaImpl.java @@ -34,7 +34,7 @@ public class YahfaImpl extends BaseImpl { static { final Impl lspdImpl = new YahfaImpl(); - if (Main.setEdxpImpl(lspdImpl)) { + if (Main.setImpl(lspdImpl)) { lspdImpl.init(); } }