fix daemon could not post notification after soft reboot (#2899)

This commit is contained in:
5ec1cff 2023-12-28 17:34:13 +08:00 committed by GitHub
parent 58e8fcfa07
commit edecd5c253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package org.lsposed.lspd.service;
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 class BridgeService {
((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));
}