[core] Fix death receipent leak
This commit is contained in:
parent
b5cd5e303d
commit
7fcd689192
|
|
@ -188,11 +188,11 @@ public class ModulesActivity extends ListActivity implements ModuleUtil.ModuleLi
|
||||||
sb.append(getString(R.string.module_empty_description));
|
sb.append(getString(R.string.module_empty_description));
|
||||||
}
|
}
|
||||||
|
|
||||||
int installedXposedVersion = ConfigManager.getXposedApiVersion();
|
int installXposedVersion = ConfigManager.getXposedApiVersion();
|
||||||
String warningText = null;
|
String warningText = null;
|
||||||
if (item.minVersion == 0) {
|
if (item.minVersion == 0) {
|
||||||
warningText = getString(R.string.no_min_version_specified);
|
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);
|
warningText = String.format(getString(R.string.warning_xposed_min_version), item.minVersion);
|
||||||
} else if (item.minVersion < ModuleUtil.MIN_MODULE_VERSION) {
|
} 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);
|
warningText = String.format(getString(R.string.warning_min_version_too_low), item.minVersion, ModuleUtil.MIN_MODULE_VERSION);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class Main implements KeepAll {
|
||||||
LSPApplicationServiceClient.Init(binder);
|
LSPApplicationServiceClient.Init(binder);
|
||||||
serviceClient.registerHeartBeat(heartBeatBinder);
|
serviceClient.registerHeartBeat(heartBeatBinder);
|
||||||
final int variant = serviceClient.getVariant();
|
final int variant = serviceClient.getVariant();
|
||||||
Impl lspd = getEdxpImpl(variant);
|
Impl lspd = getImpl(variant);
|
||||||
if (lspd == null || !lspd.isInitialized()) {
|
if (lspd == null || !lspd.isInitialized()) {
|
||||||
Utils.logE("Not started up");
|
Utils.logE("Not started up");
|
||||||
return;
|
return;
|
||||||
|
|
@ -55,18 +55,18 @@ public class Main implements KeepAll {
|
||||||
LSPApplicationServiceClient.Init(binder);
|
LSPApplicationServiceClient.Init(binder);
|
||||||
serviceClient.registerHeartBeat(heartBeatBinder);
|
serviceClient.registerHeartBeat(heartBeatBinder);
|
||||||
final int variant = serviceClient.getVariant();
|
final int variant = serviceClient.getVariant();
|
||||||
Impl lspd = getEdxpImpl(variant);
|
Impl lspd = getImpl(variant);
|
||||||
if (lspd == null || !lspd.isInitialized()) {
|
if (lspd == null || !lspd.isInitialized()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lspd.getNormalProxy().forkSystemServerPost();
|
lspd.getNormalProxy().forkSystemServerPost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized boolean setEdxpImpl(Impl lspd) {
|
public static synchronized boolean setImpl(Impl lspd) {
|
||||||
return lspdImplRef.compareAndSet(null, lspd);
|
return lspdImplRef.compareAndSet(null, lspd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Impl getEdxpImpl(int variant) {
|
public static synchronized Impl getImpl(int variant) {
|
||||||
Impl lspd = lspdImplRef.get();
|
Impl lspd = lspdImplRef.get();
|
||||||
if (lspd != null) {
|
if (lspd != null) {
|
||||||
return lspd;
|
return lspd;
|
||||||
|
|
@ -90,15 +90,10 @@ public class Main implements KeepAll {
|
||||||
return lspdImplRef.get();
|
return lspdImplRef.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Impl getEdxpImpl() {
|
public static synchronized Impl getImpl() {
|
||||||
return lspdImplRef.get();
|
return lspdImplRef.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Impl.Variant
|
|
||||||
public static synchronized int getEdxpVariant() {
|
|
||||||
return getEdxpImpl().getVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (arg.equals("--debug")) {
|
if (arg.equals("--debug")) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class SystemMainHooker extends XC_MethodHook {
|
||||||
systemServerCL = Thread.currentThread().getContextClassLoader();
|
systemServerCL = Thread.currentThread().getContextClassLoader();
|
||||||
// deopt methods in SYSTEMSERVERCLASSPATH
|
// deopt methods in SYSTEMSERVERCLASSPATH
|
||||||
PrebuiltMethodsDeopter.deoptSystemServerMethods(systemServerCL);
|
PrebuiltMethodsDeopter.deoptSystemServerMethods(systemServerCL);
|
||||||
Main.getEdxpImpl().getRouter().startSystemServerHook();
|
Main.getImpl().getRouter().startSystemServerHook();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Hookers.logE("error when hooking systemMain", t);
|
Hookers.logE("error when hooking systemMain", t);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ public class SandHookImpl extends BaseImpl {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Impl lspdImpl = new SandHookImpl();
|
final Impl lspdImpl = new SandHookImpl();
|
||||||
if (Main.setEdxpImpl(lspdImpl)) {
|
if (Main.setImpl(lspdImpl)) {
|
||||||
lspdImpl.init();
|
lspdImpl.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,15 @@ public class BridgeService {
|
||||||
private static ILSPosedService service = null;
|
private static ILSPosedService service = null;
|
||||||
|
|
||||||
// for service
|
// for service
|
||||||
private static final IBinder.DeathRecipient BRIDGE_SERVICE_DEATH_RECIPIENT = () -> {
|
static class BridgeServiceDeathRecipient implements IBinder.DeathRecipient {
|
||||||
|
private final IBinder bridgeService;
|
||||||
|
|
||||||
|
BridgeServiceDeathRecipient(IBinder bridgeService) throws RemoteException {
|
||||||
|
this.bridgeService = bridgeService;
|
||||||
|
bridgeService.linkToDeath(this, 0);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void binderDied() {
|
||||||
Log.i(TAG, "service " + SERVICE_NAME + " is dead. ");
|
Log.i(TAG, "service " + SERVICE_NAME + " is dead. ");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -59,8 +67,10 @@ public class BridgeService {
|
||||||
Log.w(TAG, "clear ServiceManager: " + Log.getStackTraceString(e));
|
Log.w(TAG, "clear ServiceManager: " + Log.getStackTraceString(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bridgeService.unlinkToDeath(this, 0);
|
||||||
sendToBridge(serviceBinder, true);
|
sendToBridge(serviceBinder, true);
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// for client
|
// for client
|
||||||
private static final IBinder.DeathRecipient LSPSERVICE_DEATH_RECIPIENT = () -> {
|
private static final IBinder.DeathRecipient LSPSERVICE_DEATH_RECIPIENT = () -> {
|
||||||
|
|
@ -102,7 +112,7 @@ public class BridgeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bridgeService.linkToDeath(BRIDGE_SERVICE_DEATH_RECIPIENT, 0);
|
new BridgeServiceDeathRecipient(bridgeService);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.w(TAG, "linkToDeath " + Log.getStackTraceString(e));
|
Log.w(TAG, "linkToDeath " + Log.getStackTraceString(e));
|
||||||
sendToBridge(binder, false);
|
sendToBridge(binder, false);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class YahfaImpl extends BaseImpl {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final Impl lspdImpl = new YahfaImpl();
|
final Impl lspdImpl = new YahfaImpl();
|
||||||
if (Main.setEdxpImpl(lspdImpl)) {
|
if (Main.setImpl(lspdImpl)) {
|
||||||
lspdImpl.init();
|
lspdImpl.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue