Loading services/core/java/com/android/server/notification/NotificationManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -9256,7 +9256,7 @@ public class NotificationManagerService extends SystemService { } BackgroundThread.getHandler().post(() -> { if (hasCompanionDevice(serviceInfo)) { if (serviceInfo.isSystem || hasCompanionDevice(serviceInfo)) { notifyNotificationChannelChanged( serviceInfo, pkg, user, channel, modificationType); } Loading @@ -9276,7 +9276,7 @@ public class NotificationManagerService extends SystemService { } BackgroundThread.getHandler().post(() -> { if (hasCompanionDevice(serviceInfo)) { if (serviceInfo.isSystem || hasCompanionDevice(serviceInfo)) { notifyNotificationChannelGroupChanged( serviceInfo, pkg, user, group, modificationType); } Loading services/people/java/com/android/server/people/data/ConversationInfo.java +10 −10 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ import java.util.Objects; */ public class ConversationInfo { private static final int FLAG_VIP = 1; private static final int FLAG_IMPORTANT = 1; private static final int FLAG_NOTIFICATION_SILENCED = 1 << 1; Loading @@ -50,7 +50,7 @@ public class ConversationInfo { private static final int FLAG_DEMOTED = 1 << 6; @IntDef(flag = true, prefix = {"FLAG_"}, value = { FLAG_VIP, FLAG_IMPORTANT, FLAG_NOTIFICATION_SILENCED, FLAG_BUBBLED, FLAG_PERSON_IMPORTANT, Loading Loading @@ -129,9 +129,9 @@ public class ConversationInfo { return hasShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED); } /** Whether this conversation is marked as VIP by the user. */ public boolean isVip() { return hasConversationFlags(FLAG_VIP); /** Whether this conversation is marked as important by the user. */ public boolean isImportant() { return hasConversationFlags(FLAG_IMPORTANT); } /** Whether the notifications for this conversation should be silenced. */ Loading Loading @@ -208,8 +208,8 @@ public class ConversationInfo { sb.append("]"); sb.append(", conversationFlags=0x").append(Integer.toHexString(mConversationFlags)); sb.append(" ["); if (isVip()) { sb.append("Vip"); if (isImportant()) { sb.append("Imp"); } if (isNotificationSilenced()) { sb.append("Sil"); Loading @@ -221,7 +221,7 @@ public class ConversationInfo { sb.append("Dem"); } if (isPersonImportant()) { sb.append("Imp"); sb.append("PIm"); } if (isPersonBot()) { sb.append("Bot"); Loading Loading @@ -318,8 +318,8 @@ public class ConversationInfo { return this; } Builder setVip(boolean value) { return setConversationFlag(FLAG_VIP, value); Builder setImportant(boolean value) { return setConversationFlag(FLAG_IMPORTANT, value); } Builder setNotificationSilenced(boolean value) { Loading services/people/java/com/android/server/people/data/DataManager.java +42 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Person; import android.app.prediction.AppTarget; import android.app.prediction.AppTargetEvent; Loading Loading @@ -157,8 +159,8 @@ public class DataManager { mNotificationListeners.put(userId, notificationListener); try { notificationListener.registerAsSystemService(mContext, new ComponentName(PLATFORM_PACKAGE_NAME, getClass().getSimpleName()), UserHandle.myUserId()); new ComponentName(PLATFORM_PACKAGE_NAME, getClass().getCanonicalName()), userId); } catch (RemoteException e) { // Should never occur for local calls. } Loading Loading @@ -571,6 +573,44 @@ public class DataManager { long currentTime = System.currentTimeMillis(); eventHistory.addEvent(new Event(currentTime, Event.TYPE_NOTIFICATION_OPENED)); } @Override public void onNotificationChannelModified(String pkg, UserHandle user, NotificationChannel channel, int modificationType) { PackageData packageData = getPackage(pkg, user.getIdentifier()); String shortcutId = channel.getConversationId(); if (packageData == null || shortcutId == null) { return; } ConversationStore conversationStore = packageData.getConversationStore(); ConversationInfo conversationInfo = conversationStore.getConversation(shortcutId); if (conversationInfo == null) { return; } ConversationInfo.Builder builder = new ConversationInfo.Builder(conversationInfo); switch (modificationType) { case NOTIFICATION_CHANNEL_OR_GROUP_ADDED: case NOTIFICATION_CHANNEL_OR_GROUP_UPDATED: builder.setNotificationChannelId(channel.getId()); builder.setImportant(channel.isImportantConversation()); builder.setDemoted(channel.isDemoted()); builder.setNotificationSilenced( channel.getImportance() <= NotificationManager.IMPORTANCE_LOW); builder.setBubbled(channel.canBubble()); break; case NOTIFICATION_CHANNEL_OR_GROUP_DELETED: // If the notification channel is deleted, revert all the notification settings // to the default value. builder.setNotificationChannelId(null); builder.setImportant(false); builder.setDemoted(false); builder.setNotificationSilenced(false); builder.setBubbled(false); break; } conversationStore.addOrUpdate(builder.build()); // TODO: Cache the shortcut when a conversation's notification setting is changed. } } /** Loading services/tests/servicestests/src/com/android/server/people/data/ConversationInfoTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ public final class ConversationInfoTest { .setContactPhoneNumber(PHONE_NUMBER) .setNotificationChannelId(NOTIFICATION_CHANNEL_ID) .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED) .setVip(true) .setImportant(true) .setNotificationSilenced(true) .setBubbled(true) .setDemoted(true) Loading @@ -62,7 +62,7 @@ public final class ConversationInfoTest { assertEquals(PHONE_NUMBER, conversationInfo.getContactPhoneNumber()); assertEquals(NOTIFICATION_CHANNEL_ID, conversationInfo.getNotificationChannelId()); assertTrue(conversationInfo.isShortcutLongLived()); assertTrue(conversationInfo.isVip()); assertTrue(conversationInfo.isImportant()); assertTrue(conversationInfo.isNotificationSilenced()); assertTrue(conversationInfo.isBubbled()); assertTrue(conversationInfo.isDemoted()); Loading @@ -83,7 +83,7 @@ public final class ConversationInfoTest { assertNull(conversationInfo.getContactPhoneNumber()); assertNull(conversationInfo.getNotificationChannelId()); assertFalse(conversationInfo.isShortcutLongLived()); assertFalse(conversationInfo.isVip()); assertFalse(conversationInfo.isImportant()); assertFalse(conversationInfo.isNotificationSilenced()); assertFalse(conversationInfo.isBubbled()); assertFalse(conversationInfo.isDemoted()); Loading @@ -101,7 +101,7 @@ public final class ConversationInfoTest { .setContactPhoneNumber(PHONE_NUMBER) .setNotificationChannelId(NOTIFICATION_CHANNEL_ID) .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED) .setVip(true) .setImportant(true) .setNotificationSilenced(true) .setBubbled(true) .setPersonImportant(true) Loading @@ -110,7 +110,7 @@ public final class ConversationInfoTest { .build(); ConversationInfo destination = new ConversationInfo.Builder(source) .setVip(false) .setImportant(false) .setContactStarred(false) .build(); Loading @@ -120,7 +120,7 @@ public final class ConversationInfoTest { assertEquals(PHONE_NUMBER, destination.getContactPhoneNumber()); assertEquals(NOTIFICATION_CHANNEL_ID, destination.getNotificationChannelId()); assertTrue(destination.isShortcutLongLived()); assertFalse(destination.isVip()); assertFalse(destination.isImportant()); assertTrue(destination.isNotificationSilenced()); assertTrue(destination.isBubbled()); assertTrue(destination.isPersonImportant()); Loading services/tests/servicestests/src/com/android/server/people/data/ConversationStoreTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ public final class ConversationStoreTest { .setContactPhoneNumber(phoneNumber) .setNotificationChannelId(notificationChannelId) .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED) .setVip(true) .setImportant(true) .setBubbled(true) .build(); } Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -9256,7 +9256,7 @@ public class NotificationManagerService extends SystemService { } BackgroundThread.getHandler().post(() -> { if (hasCompanionDevice(serviceInfo)) { if (serviceInfo.isSystem || hasCompanionDevice(serviceInfo)) { notifyNotificationChannelChanged( serviceInfo, pkg, user, channel, modificationType); } Loading @@ -9276,7 +9276,7 @@ public class NotificationManagerService extends SystemService { } BackgroundThread.getHandler().post(() -> { if (hasCompanionDevice(serviceInfo)) { if (serviceInfo.isSystem || hasCompanionDevice(serviceInfo)) { notifyNotificationChannelGroupChanged( serviceInfo, pkg, user, group, modificationType); } Loading
services/people/java/com/android/server/people/data/ConversationInfo.java +10 −10 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ import java.util.Objects; */ public class ConversationInfo { private static final int FLAG_VIP = 1; private static final int FLAG_IMPORTANT = 1; private static final int FLAG_NOTIFICATION_SILENCED = 1 << 1; Loading @@ -50,7 +50,7 @@ public class ConversationInfo { private static final int FLAG_DEMOTED = 1 << 6; @IntDef(flag = true, prefix = {"FLAG_"}, value = { FLAG_VIP, FLAG_IMPORTANT, FLAG_NOTIFICATION_SILENCED, FLAG_BUBBLED, FLAG_PERSON_IMPORTANT, Loading Loading @@ -129,9 +129,9 @@ public class ConversationInfo { return hasShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED); } /** Whether this conversation is marked as VIP by the user. */ public boolean isVip() { return hasConversationFlags(FLAG_VIP); /** Whether this conversation is marked as important by the user. */ public boolean isImportant() { return hasConversationFlags(FLAG_IMPORTANT); } /** Whether the notifications for this conversation should be silenced. */ Loading Loading @@ -208,8 +208,8 @@ public class ConversationInfo { sb.append("]"); sb.append(", conversationFlags=0x").append(Integer.toHexString(mConversationFlags)); sb.append(" ["); if (isVip()) { sb.append("Vip"); if (isImportant()) { sb.append("Imp"); } if (isNotificationSilenced()) { sb.append("Sil"); Loading @@ -221,7 +221,7 @@ public class ConversationInfo { sb.append("Dem"); } if (isPersonImportant()) { sb.append("Imp"); sb.append("PIm"); } if (isPersonBot()) { sb.append("Bot"); Loading Loading @@ -318,8 +318,8 @@ public class ConversationInfo { return this; } Builder setVip(boolean value) { return setConversationFlag(FLAG_VIP, value); Builder setImportant(boolean value) { return setConversationFlag(FLAG_IMPORTANT, value); } Builder setNotificationSilenced(boolean value) { Loading
services/people/java/com/android/server/people/data/DataManager.java +42 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.WorkerThread; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Person; import android.app.prediction.AppTarget; import android.app.prediction.AppTargetEvent; Loading Loading @@ -157,8 +159,8 @@ public class DataManager { mNotificationListeners.put(userId, notificationListener); try { notificationListener.registerAsSystemService(mContext, new ComponentName(PLATFORM_PACKAGE_NAME, getClass().getSimpleName()), UserHandle.myUserId()); new ComponentName(PLATFORM_PACKAGE_NAME, getClass().getCanonicalName()), userId); } catch (RemoteException e) { // Should never occur for local calls. } Loading Loading @@ -571,6 +573,44 @@ public class DataManager { long currentTime = System.currentTimeMillis(); eventHistory.addEvent(new Event(currentTime, Event.TYPE_NOTIFICATION_OPENED)); } @Override public void onNotificationChannelModified(String pkg, UserHandle user, NotificationChannel channel, int modificationType) { PackageData packageData = getPackage(pkg, user.getIdentifier()); String shortcutId = channel.getConversationId(); if (packageData == null || shortcutId == null) { return; } ConversationStore conversationStore = packageData.getConversationStore(); ConversationInfo conversationInfo = conversationStore.getConversation(shortcutId); if (conversationInfo == null) { return; } ConversationInfo.Builder builder = new ConversationInfo.Builder(conversationInfo); switch (modificationType) { case NOTIFICATION_CHANNEL_OR_GROUP_ADDED: case NOTIFICATION_CHANNEL_OR_GROUP_UPDATED: builder.setNotificationChannelId(channel.getId()); builder.setImportant(channel.isImportantConversation()); builder.setDemoted(channel.isDemoted()); builder.setNotificationSilenced( channel.getImportance() <= NotificationManager.IMPORTANCE_LOW); builder.setBubbled(channel.canBubble()); break; case NOTIFICATION_CHANNEL_OR_GROUP_DELETED: // If the notification channel is deleted, revert all the notification settings // to the default value. builder.setNotificationChannelId(null); builder.setImportant(false); builder.setDemoted(false); builder.setNotificationSilenced(false); builder.setBubbled(false); break; } conversationStore.addOrUpdate(builder.build()); // TODO: Cache the shortcut when a conversation's notification setting is changed. } } /** Loading
services/tests/servicestests/src/com/android/server/people/data/ConversationInfoTest.java +6 −6 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ public final class ConversationInfoTest { .setContactPhoneNumber(PHONE_NUMBER) .setNotificationChannelId(NOTIFICATION_CHANNEL_ID) .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED) .setVip(true) .setImportant(true) .setNotificationSilenced(true) .setBubbled(true) .setDemoted(true) Loading @@ -62,7 +62,7 @@ public final class ConversationInfoTest { assertEquals(PHONE_NUMBER, conversationInfo.getContactPhoneNumber()); assertEquals(NOTIFICATION_CHANNEL_ID, conversationInfo.getNotificationChannelId()); assertTrue(conversationInfo.isShortcutLongLived()); assertTrue(conversationInfo.isVip()); assertTrue(conversationInfo.isImportant()); assertTrue(conversationInfo.isNotificationSilenced()); assertTrue(conversationInfo.isBubbled()); assertTrue(conversationInfo.isDemoted()); Loading @@ -83,7 +83,7 @@ public final class ConversationInfoTest { assertNull(conversationInfo.getContactPhoneNumber()); assertNull(conversationInfo.getNotificationChannelId()); assertFalse(conversationInfo.isShortcutLongLived()); assertFalse(conversationInfo.isVip()); assertFalse(conversationInfo.isImportant()); assertFalse(conversationInfo.isNotificationSilenced()); assertFalse(conversationInfo.isBubbled()); assertFalse(conversationInfo.isDemoted()); Loading @@ -101,7 +101,7 @@ public final class ConversationInfoTest { .setContactPhoneNumber(PHONE_NUMBER) .setNotificationChannelId(NOTIFICATION_CHANNEL_ID) .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED) .setVip(true) .setImportant(true) .setNotificationSilenced(true) .setBubbled(true) .setPersonImportant(true) Loading @@ -110,7 +110,7 @@ public final class ConversationInfoTest { .build(); ConversationInfo destination = new ConversationInfo.Builder(source) .setVip(false) .setImportant(false) .setContactStarred(false) .build(); Loading @@ -120,7 +120,7 @@ public final class ConversationInfoTest { assertEquals(PHONE_NUMBER, destination.getContactPhoneNumber()); assertEquals(NOTIFICATION_CHANNEL_ID, destination.getNotificationChannelId()); assertTrue(destination.isShortcutLongLived()); assertFalse(destination.isVip()); assertFalse(destination.isImportant()); assertTrue(destination.isNotificationSilenced()); assertTrue(destination.isBubbled()); assertTrue(destination.isPersonImportant()); Loading
services/tests/servicestests/src/com/android/server/people/data/ConversationStoreTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ public final class ConversationStoreTest { .setContactPhoneNumber(phoneNumber) .setNotificationChannelId(notificationChannelId) .setShortcutFlags(ShortcutInfo.FLAG_LONG_LIVED) .setVip(true) .setImportant(true) .setBubbled(true) .build(); } Loading