Migrate importance of Background channel from Other channel.

fork-5.53.8
Greyson Parrelli 2022-02-18 16:00:11 -05:00
rodzic 719f5e28d0
commit 80622147ab
1 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -598,7 +598,7 @@ public class NotificationChannels {
NotificationChannel other = new NotificationChannel(OTHER, context.getString(R.string.NotificationChannel_other), NotificationManager.IMPORTANCE_LOW);
NotificationChannel voiceNotes = new NotificationChannel(VOICE_NOTES, context.getString(R.string.NotificationChannel_voice_notes), NotificationManager.IMPORTANCE_LOW);
NotificationChannel joinEvents = new NotificationChannel(JOIN_EVENTS, context.getString(R.string.NotificationChannel_contact_joined_signal), NotificationManager.IMPORTANCE_DEFAULT);
NotificationChannel background = new NotificationChannel(BACKGROUND, context.getString(R.string.NotificationChannel_background_connection), NotificationManager.IMPORTANCE_LOW);
NotificationChannel background = new NotificationChannel(BACKGROUND, context.getString(R.string.NotificationChannel_background_connection), getDefaultBackgroundChannelImportance(notificationManager));
NotificationChannel callStatus = new NotificationChannel(CALL_STATUS, context.getString(R.string.NotificationChannel_call_status), NotificationManager.IMPORTANCE_LOW);
messages.setGroup(CATEGORY_MESSAGES);
@ -626,6 +626,18 @@ public class NotificationChannels {
}
}
@TargetApi(26)
private static int getDefaultBackgroundChannelImportance(NotificationManager notificationManager) {
NotificationChannel existingOther = notificationManager.getNotificationChannel(OTHER);
if (existingOther != null && existingOther.getImportance() != NotificationManager.IMPORTANCE_LOW) {
return existingOther.getImportance();
} else {
return NotificationManager.IMPORTANCE_LOW;
}
}
@TargetApi(26)
private static void onUpgrade(@NonNull NotificationManager notificationManager, int oldVersion, int newVersion) {
Log.i(TAG, "Upgrading channels from " + oldVersion + " to " + newVersion);