Skip to content

Commit 36f27c0

Browse files
committed
Fix Notification
1 parent 4660345 commit 36f27c0

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

daemon/src/main/java/org/lsposed/lspd/service/LSPManagerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void onSystemServerDied() {
264264

265265
@Override
266266
public IBinder asBinder() {
267-
return this;
267+
return super.asBinder();
268268
}
269269

270270
@Override

daemon/src/main/java/org/lsposed/lspd/service/LSPNotificationManager.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.lsposed.lspd.service.ServiceManager.TAG;
44

5+
import android.annotation.SuppressLint;
56
import android.app.INotificationManager;
67
import android.app.Notification;
78
import android.app.NotificationChannel;
@@ -27,6 +28,7 @@
2728
import org.lsposed.daemon.R;
2829
import org.lsposed.lspd.util.FakeContext;
2930

31+
import java.lang.reflect.Field;
3032
import java.util.ArrayList;
3133
import java.util.Map;
3234
import java.util.UUID;
@@ -51,6 +53,37 @@ public class LSPNotificationManager {
5153
private static INotificationManager notificationManager = null;
5254
private static IBinder binder = null;
5355

56+
static {
57+
try {
58+
@SuppressLint("PrivateApi")
59+
Class<?> flagsClass = Class.forName("android.app.Flags", false, null);
60+
Field featureFlagsField = flagsClass.getDeclaredField("FEATURE_FLAGS");
61+
featureFlagsField.setAccessible(true);
62+
Object featureFlags = featureFlagsField.get(null);
63+
Field cacheField;
64+
if (featureFlags != null) {
65+
cacheField = featureFlags.getClass().getDeclaredField("systemui_is_cached");
66+
cacheField.setAccessible(true);
67+
cacheField.set(featureFlags, Boolean.TRUE);
68+
}
69+
} catch (Throwable ignored) {
70+
}
71+
try {
72+
Class<?> ConfigClass = Class.forName("com.mediatek.res.AsyncDrawableCache", false, null);
73+
Field featureConfigField = ConfigClass.getDeclaredField("sFeatureConfig");
74+
featureConfigField.setAccessible(true);
75+
featureConfigField.set(null, "0");
76+
} catch (Throwable ignored) {
77+
}
78+
try {
79+
new Notification.Builder(new FakeContext(), "LSPosed").build();
80+
} catch (AbstractMethodError unused) {
81+
FakeContext.ContentResolver = !FakeContext.ContentResolver;
82+
} catch (Throwable th) {
83+
Log.e(TAG, "failed to build notifications", th);
84+
}
85+
}
86+
5487
private static final IBinder.DeathRecipient recipient = new IBinder.DeathRecipient() {
5588
@Override
5689
public void binderDied() {

daemon/src/main/java/org/lsposed/lspd/util/FakeContext.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.os.UserHandle;
1212
import android.util.Log;
1313

14+
import androidx.annotation.NonNull;
1415
import androidx.annotation.Nullable;
1516

1617
import org.lsposed.lspd.service.ConfigFileManager;
@@ -22,6 +23,7 @@ public class FakeContext extends ContextWrapper {
2223
static ApplicationInfo systemApplicationInfo = null;
2324
static Resources.Theme theme = null;
2425
private String packageName = "android";
26+
public static boolean ContentResolver = true;
2527
public FakeContext() {
2628
super(null);
2729
}
@@ -41,6 +43,7 @@ public Resources getResources() {
4143
return ConfigFileManager.getResources();
4244
}
4345

46+
@NonNull
4447
@Override
4548
public String getOpPackageName() {
4649
return "android";
@@ -59,8 +62,10 @@ public ApplicationInfo getApplicationInfo() {
5962

6063
@Override
6164
public ContentResolver getContentResolver() {
62-
return new ContentResolver(this) {
63-
};
65+
if(ContentResolver) {
66+
return new ContentResolver(this) {};
67+
}
68+
return null;
6469
}
6570

6671
public int getUserId() {

0 commit comments

Comments
 (0)