Fix the Xposed Module notification repeated push problem and the other problem (#1886)
* Fix the Xposed Module notification repeated push problem * Fix a possible bug when Xposed Module uninstall the notification push again * Fix after an multi-pie user install the Xposed Module the active notification repeat
This commit is contained in:
parent
44e15da227
commit
a0dd9c0866
|
|
@ -253,9 +253,8 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
|||
|
||||
private static int pushAndGetNotificationId(String modulePackageName, int moduleUserId) {
|
||||
var idKey = getNotificationIdKey(modulePackageName, moduleUserId);
|
||||
var idValue = getAutoIncrementNotificationId();
|
||||
notificationIds.putIfAbsent(idKey, idValue);
|
||||
return idValue;
|
||||
// If there is a new notification, put a new notification id into map
|
||||
return notificationIds.computeIfAbsent(idKey, key -> getAutoIncrementNotificationId());
|
||||
}
|
||||
|
||||
public static void showNotification(String modulePackageName,
|
||||
|
|
@ -302,10 +301,11 @@ public class LSPManagerService extends ILSPManagerService.Stub {
|
|||
public static void cancelNotification(String modulePackageName, int moduleUserId) {
|
||||
try {
|
||||
var idKey = getNotificationIdKey(modulePackageName, moduleUserId);
|
||||
var notificationId = notificationIds.get(idKey);
|
||||
if (notificationId == null) return;
|
||||
var idValue = notificationIds.get(idKey);
|
||||
if (idValue == null) return;
|
||||
var im = INotificationManager.Stub.asInterface(android.os.ServiceManager.getService("notification"));
|
||||
im.cancelNotificationWithTag("android", "android", modulePackageName, notificationId, 0);
|
||||
im.cancelNotificationWithTag("android", "android", modulePackageName, idValue, 0);
|
||||
// Remove the notification id when the notification is canceled or current module app was uninstalled
|
||||
notificationIds.remove(idKey);
|
||||
} catch (Throwable e) {
|
||||
Log.e(TAG, "cancel notification", e);
|
||||
|
|
|
|||
|
|
@ -109,8 +109,14 @@ public class LSPosedService extends ILSPosedService.Stub {
|
|||
isXposedModule = true;
|
||||
broadcastAndShowNotification(moduleName, userId, intent, true);
|
||||
}
|
||||
// Anyway, canceled the notification
|
||||
if (moduleName != null) LSPManagerService.cancelNotification(moduleName, userId);
|
||||
break;
|
||||
}
|
||||
case Intent.ACTION_PACKAGE_REMOVED:
|
||||
// Anyway, canceled the notification
|
||||
if (moduleName != null) LSPManagerService.cancelNotification(moduleName, userId);
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_ADDED:
|
||||
case Intent.ACTION_PACKAGE_CHANGED: {
|
||||
// make sure that the change is for the complete package, not only a
|
||||
|
|
@ -178,8 +184,6 @@ public class LSPosedService extends ILSPosedService.Stub {
|
|||
boolean enabled = Arrays.asList(enabledModules).contains(packageName);
|
||||
if (!(Intent.ACTION_UID_REMOVED.equals(action) || Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action) || allUsers))
|
||||
LSPManagerService.showNotification(packageName, userId, enabled, systemModule);
|
||||
// Canceled the notification when Xposed Module removed
|
||||
if (Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) LSPManagerService.cancelNotification(packageName, userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue