@@ -80,6 +80,7 @@ public class WeChatDecorator extends NevoDecoratorService {
8080 private static final String OLD_CHANNEL_MISC = "misc" ; // old name for migration
8181 private static final String CHANNEL_DND = "message_dnd_mode_channel_id" ; // Channel ID used by WeChat for its own DND mode
8282 private static final String CHANNEL_GROUP_CONVERSATION = "group" ; // WeChat has no separate group for group conversation
83+ private static final String GROUP_MISC = "misc" ;
8384
8485 private static final @ ColorInt int PRIMARY_COLOR = 0xFF33B332 ;
8586 private static final @ ColorInt int LIGHT_COLOR = 0xFF00FF00 ;
@@ -99,14 +100,11 @@ public class WeChatDecorator extends NevoDecoratorService {
99100 n .color = PRIMARY_COLOR ; // Tint the small icon
100101
101102 final String channel_id = SDK_INT >= O ? n .getChannelId () : null ;
102- if (CHANNEL_MISC .equals (channel_id )) { // Misc. notifications on Android 8+.
103- if (SDK_INT >= O && (n .flags & Notification .FLAG_ONGOING_EVENT ) != 0 ) {
104- VoiceCall .tweakIfNeeded (this , n );
105- } else Log .d (TAG , "Skip further process for non-conversation notification: " + title ); // E.g. web login confirmation notification.
106- return ;
107- } else if (n .tickerText == null ) { // Legacy misc. notifications.
103+ if (n .tickerText == null /* Legacy misc. notifications */ || CHANNEL_MISC .equals (channel_id )) {
108104 if (SDK_INT >= O && channel_id == null ) n .setChannelId (CHANNEL_MISC );
109- Log .d (TAG , "Skip further process for non-conversation notification: " + title ); // E.g. web login confirmation notification.
105+ n .setGroup (GROUP_MISC ); // Avoid being auto-grouped
106+ if (! mOngoingCallTweaker .apply (this , evolving .getOriginalKey (), n ))
107+ Log .d (TAG , "Skip further process for non-conversation notification: " + title ); // E.g. web login confirmation notification.
110108 return ;
111109 }
112110 final CharSequence content_text = extras .getCharSequence (EXTRA_TEXT );
@@ -173,7 +171,7 @@ private boolean isDistinctId(final Notification n, final String pkg) {
173171 @ Override protected void onNotificationRemoved (final String key , final int reason ) {
174172 if (reason == REASON_APP_CANCEL ) { // Only if "Removal-Aware" of Nevolution is activated
175173 Log .d (TAG , "Cancel notification: " + key );
176- cancelNotification (key ); // Will cancel all notifications evolved from this original key, thus trigger the "else" branch below
174+ mOngoingCallTweaker . onNotificationRemoved (key );
177175 } else if (reason == REASON_CHANNEL_BANNED ) { // In case WeChat deleted our notification channel for group conversation in Insider delivery mode
178176 mHandler .post (() -> reviveNotification (key ));
179177 } else if (SDK_INT < O || reason == REASON_CANCEL ) { // Exclude the removal request by us in above case. (Removal-Aware is only supported on Android 8+)
@@ -241,6 +239,7 @@ private boolean isWeChatTargeting26OrAbove() {
241239 mPrefKeyWear = getString (R .string .pref_wear );
242240
243241 mMessagingBuilder = new MessagingBuilder (this , mPreferences , this ::recastNotification ); // Must be called after loadPreferences().
242+ mOngoingCallTweaker = new OngoingCallTweaker (this , this ::recastNotification );
244243 final IntentFilter filter = new IntentFilter (Intent .ACTION_PACKAGE_REMOVED ); filter .addDataScheme ("package" );
245244 registerReceiver (mPackageEventReceiver , filter );
246245 registerReceiver (mSettingsChangedReceiver , new IntentFilter (ACTION_SETTINGS_CHANGED ));
@@ -249,6 +248,7 @@ private boolean isWeChatTargeting26OrAbove() {
249248 @ Override public void onDestroy () {
250249 unregisterReceiver (mSettingsChangedReceiver );
251250 unregisterReceiver (mPackageEventReceiver );
251+ mOngoingCallTweaker .close ();
252252 mMessagingBuilder .close ();
253253 super .onDestroy ();
254254 }
@@ -303,6 +303,7 @@ private static String getDefaultSharedPreferencesName(final Context context) {
303303
304304 private final ConversationManager mConversationManager = new ConversationManager ();
305305 private MessagingBuilder mMessagingBuilder ;
306+ private OngoingCallTweaker mOngoingCallTweaker ;
306307 private boolean mWeChatTargetingO ;
307308 private SharedPreferences mPreferences ;
308309 private String mPrefKeyWear ;
0 commit comments