From edecd5c253bc882cc6bb139d7e99b95fa8bc9664 Mon Sep 17 00:00:00 2001 From: 5ec1cff <56485584+5ec1cff@users.noreply.github.com> Date: Thu, 28 Dec 2023 17:34:13 +0800 Subject: [PATCH] fix daemon could not post notification after soft reboot (#2899) --- .../org/lsposed/lspd/service/BridgeService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/daemon/src/main/java/org/lsposed/lspd/service/BridgeService.java b/daemon/src/main/java/org/lsposed/lspd/service/BridgeService.java index fa87142fb35..8dc687419bc 100644 --- a/daemon/src/main/java/org/lsposed/lspd/service/BridgeService.java +++ b/daemon/src/main/java/org/lsposed/lspd/service/BridgeService.java @@ -2,6 +2,7 @@ import static org.lsposed.lspd.service.ServiceManager.TAG; +import android.app.ActivityManager; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -61,6 +62,20 @@ public void binderDied() { ((Map) sCache).clear(); } Log.i(TAG, "clear ServiceManager"); + + //noinspection JavaReflectionMemberAccess DiscouragedPrivateApi + field = ActivityManager.class.getDeclaredField("IActivityManagerSingleton"); + field.setAccessible(true); + Object singleton = field.get(null); + if (singleton != null) { + //noinspection PrivateApi DiscouragedPrivateApi + field = Class.forName("android.util.Singleton").getDeclaredField("mInstance"); + field.setAccessible(true); + synchronized (singleton) { + field.set(singleton, null); + } + } + Log.i(TAG, "clear ActivityManager"); } catch (Throwable e) { Log.w(TAG, "clear ServiceManager: " + Log.getStackTraceString(e)); }