Loading services/core/java/com/android/server/notification/NotificationManagerService.java +11 −9 Original line number Original line Diff line number Diff line Loading @@ -166,7 +166,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static android.view.contentprotection.flags.Flags.rapidClearNotificationsByListenerAppOpEnabled; import static android.view.contentprotection.flags.Flags.rapidClearNotificationsByListenerAppOpEnabled; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.FrameworkStatsLog.NOTIFICATION_BUNDLE_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.NOTIFICATION_ADJUSTMENT_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES; Loading Loading @@ -2992,7 +2992,7 @@ public class NotificationManagerService extends SystemService { mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES); mStatsManager.clearPullAtomCallback(NOTIFICATION_BUNDLE_PREFERENCES); mStatsManager.clearPullAtomCallback(NOTIFICATION_ADJUSTMENT_PREFERENCES); mStatsManager.clearPullAtomCallback(DND_MODE_RULE); mStatsManager.clearPullAtomCallback(DND_MODE_RULE); } } if (mAppOps != null) { if (mAppOps != null) { Loading Loading @@ -3116,7 +3116,7 @@ public class NotificationManagerService extends SystemService { mPullAtomCallback mPullAtomCallback ); ); mStatsManager.setPullAtomCallback( mStatsManager.setPullAtomCallback( NOTIFICATION_BUNDLE_PREFERENCES, NOTIFICATION_ADJUSTMENT_PREFERENCES, null, // use default PullAtomMetadata values null, // use default PullAtomMetadata values ConcurrentUtils.DIRECT_EXECUTOR, ConcurrentUtils.DIRECT_EXECUTOR, mPullAtomCallback mPullAtomCallback Loading Loading @@ -3155,7 +3155,7 @@ public class NotificationManagerService extends SystemService { case PACKAGE_NOTIFICATION_PREFERENCES: case PACKAGE_NOTIFICATION_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: case NOTIFICATION_BUNDLE_PREFERENCES: case NOTIFICATION_ADJUSTMENT_PREFERENCES: case DND_MODE_RULE: case DND_MODE_RULE: return pullNotificationStates(atomTag, data); return pullNotificationStates(atomTag, data); default: default: Loading @@ -3182,9 +3182,9 @@ public class NotificationManagerService extends SystemService { case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: mPreferencesHelper.pullPackageChannelGroupPreferencesStats(data); mPreferencesHelper.pullPackageChannelGroupPreferencesStats(data); break; break; case NOTIFICATION_BUNDLE_PREFERENCES: case NOTIFICATION_ADJUSTMENT_PREFERENCES: if (notificationClassification() && notificationClassificationUi()) { if (notificationClassification() && notificationClassificationUi()) { mAssistants.pullBundlePreferencesStats(data); mAssistants.pullAdjustmentPreferencesStats(data); } } break; break; case DND_MODE_RULE: case DND_MODE_RULE: Loading Loading @@ -13046,7 +13046,7 @@ public class NotificationManagerService extends SystemService { * Fills out {@link BundlePreferences} proto and wraps it in a {@link StatsEvent}. * Fills out {@link BundlePreferences} proto and wraps it in a {@link StatsEvent}. */ */ @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION) @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION) protected void pullBundlePreferencesStats(List<StatsEvent> events) { protected void pullAdjustmentPreferencesStats(List<StatsEvent> events) { boolean bundlesAllowed = true; boolean bundlesAllowed = true; synchronized (mLock) { synchronized (mLock) { List<String> unsupportedAdjustments = new ArrayList( List<String> unsupportedAdjustments = new ArrayList( Loading @@ -13061,12 +13061,14 @@ public class NotificationManagerService extends SystemService { int[] allowedBundleTypes = getAllowedClassificationTypes(UserHandle.getCallingUserId()); int[] allowedBundleTypes = getAllowedClassificationTypes(UserHandle.getCallingUserId()); events.add(FrameworkStatsLog.buildStatsEvent( events.add(FrameworkStatsLog.buildStatsEvent( NOTIFICATION_BUNDLE_PREFERENCES, NOTIFICATION_ADJUSTMENT_PREFERENCES, /* optional int32 event_id = 1 */ /* optional int32 event_id = 1 */ NotificationPullStatsEvent.NOTIFICATION_BUNDLE_PREFERENCES_PULLED.getId(), NotificationPullStatsEvent.NOTIFICATION_BUNDLE_PREFERENCES_PULLED.getId(), /* optional bool bundles_allowed = 2 */ bundlesAllowed, /* optional bool bundles_allowed = 2 */ bundlesAllowed, /* repeated android.stats.notification.BundleTypes allowed_bundle_types = 3 */ /* repeated android.stats.notification.BundleTypes allowed_bundle_types = 3 */ allowedBundleTypes)); allowedBundleTypes, /* optional android.stats.notification.AdjustmentKey key = 4 */ NotificationPullStatsEvent.adjustmentKeyEnum(KEY_TYPE))); } } } } services/core/java/com/android/server/notification/NotificationRecordLogger.java +13 −0 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannel; import android.app.Person; import android.app.Person; import android.os.Bundle; import android.os.Bundle; import android.service.notification.Adjustment; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationStats; import android.service.notification.NotificationStats; import android.util.Log; import android.util.Log; Loading @@ -36,6 +37,7 @@ import com.android.internal.logging.InstanceId; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLogger; import com.android.internal.util.FrameworkStatsLog; import com.android.internal.util.FrameworkStatsLog; import com.android.os.notification.NotificationProtoEnums; import java.time.Duration; import java.time.Duration; import java.util.ArrayList; import java.util.ArrayList; Loading Loading @@ -377,6 +379,17 @@ interface NotificationRecordLogger { @Override public int getId() { @Override public int getId() { return mId; return mId; } } /** * Maps an adjustment key string to its corresponding logging enum. */ public static int adjustmentKeyEnum(String adjustmentKey) { return switch (adjustmentKey) { case Adjustment.KEY_TYPE -> NotificationProtoEnums.KEY_TYPE; case Adjustment.KEY_SUMMARIZATION -> NotificationProtoEnums.KEY_SUMMARIZATION; default -> NotificationProtoEnums.KEY_UNKNOWN; }; } } } /** /** Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java +12 −12 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,7 @@ import com.android.internal.util.CollectionUtils; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.modules.utils.TypedXmlSerializer; import com.android.os.AtomsProto; import com.android.os.AtomsProto; import com.android.os.notification.NotificationBundlePreferences; import com.android.os.notification.NotificationAdjustmentPreferences; import com.android.os.notification.NotificationExtensionAtoms; import com.android.os.notification.NotificationExtensionAtoms; import com.android.os.notification.NotificationProtoEnums; import com.android.os.notification.NotificationProtoEnums; import com.android.server.LocalServices; import com.android.server.LocalServices; Loading Loading @@ -979,7 +979,7 @@ public class NotificationAssistantsTest extends UiServiceTestCase { @SuppressWarnings("GuardedBy") @SuppressWarnings("GuardedBy") @EnableFlags({android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION, @EnableFlags({android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION, android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI}) android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI}) public void testPullBundlePreferencesStats_fillsOutStatsEvent() public void testPullAdjustmentPreferencesStats_fillsOutStatsEvent() throws Exception { throws Exception { // Create the current user and enable the package // Create the current user and enable the package int userId = ActivityManager.getCurrentUser(); int userId = ActivityManager.getCurrentUser(); Loading @@ -1000,9 +1000,9 @@ public class NotificationAssistantsTest extends UiServiceTestCase { // When pullBundlePreferencesStats is run with the given preferences // When pullBundlePreferencesStats is run with the given preferences ArrayList<StatsEvent> events = new ArrayList<>(); ArrayList<StatsEvent> events = new ArrayList<>(); mAssistants.pullBundlePreferencesStats(events); mAssistants.pullAdjustmentPreferencesStats(events); // The StatsEvent is filled out with the expected NotificationBundlePreferences values. // The StatsEvent is filled out with the expected NotificationAdjustmentPreferences values. assertThat(events.size()).isEqualTo(1); assertThat(events.size()).isEqualTo(1); AtomsProto.Atom atom = StatsEventTestUtils.convertToAtom(events.get(0)); AtomsProto.Atom atom = StatsEventTestUtils.convertToAtom(events.get(0)); Loading @@ -1016,9 +1016,9 @@ public class NotificationAssistantsTest extends UiServiceTestCase { ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); CodedInputStream codedis = CodedInputStream.newInstance(inputStream); CodedInputStream codedis = CodedInputStream.newInstance(inputStream); atom = AtomsProto.Atom.parseFrom(codedis, mRegistry); atom = AtomsProto.Atom.parseFrom(codedis, mRegistry); assertTrue(atom.hasExtension(NotificationExtensionAtoms.notificationBundlePreferences)); assertTrue(atom.hasExtension(NotificationExtensionAtoms.notificationAdjustmentPreferences)); NotificationBundlePreferences p = NotificationAdjustmentPreferences p = atom.getExtension(NotificationExtensionAtoms.notificationBundlePreferences); atom.getExtension(NotificationExtensionAtoms.notificationAdjustmentPreferences); assertThat(p.getBundlesAllowed()).isTrue(); assertThat(p.getBundlesAllowed()).isTrue(); assertThat(p.getAllowedBundleTypes(0).getNumber()) assertThat(p.getAllowedBundleTypes(0).getNumber()) .isEqualTo(NotificationProtoEnums.TYPE_NEWS); .isEqualTo(NotificationProtoEnums.TYPE_NEWS); Loading @@ -1034,9 +1034,9 @@ public class NotificationAssistantsTest extends UiServiceTestCase { true); true); ArrayList<StatsEvent> eventsDisabled = new ArrayList<>(); ArrayList<StatsEvent> eventsDisabled = new ArrayList<>(); mAssistants.pullBundlePreferencesStats(eventsDisabled); mAssistants.pullAdjustmentPreferencesStats(eventsDisabled); // The StatsEvent is filled out with the expected NotificationBundlePreferences values. // The StatsEvent is filled out with the expected NotificationAdjustmentPreferences values. assertThat(eventsDisabled.size()).isEqualTo(1); assertThat(eventsDisabled.size()).isEqualTo(1); AtomsProto.Atom atomDisabled = StatsEventTestUtils.convertToAtom(eventsDisabled.get(0)); AtomsProto.Atom atomDisabled = StatsEventTestUtils.convertToAtom(eventsDisabled.get(0)); Loading @@ -1051,10 +1051,10 @@ public class NotificationAssistantsTest extends UiServiceTestCase { codedis = CodedInputStream.newInstance(inputStream); codedis = CodedInputStream.newInstance(inputStream); atomDisabled = AtomsProto.Atom.parseFrom(codedis, mRegistry); atomDisabled = AtomsProto.Atom.parseFrom(codedis, mRegistry); assertTrue(atomDisabled.hasExtension(NotificationExtensionAtoms assertTrue(atomDisabled.hasExtension(NotificationExtensionAtoms .notificationBundlePreferences)); .notificationAdjustmentPreferences)); NotificationBundlePreferences p2 = NotificationAdjustmentPreferences p2 = atomDisabled.getExtension( atomDisabled.getExtension(NotificationExtensionAtoms.notificationBundlePreferences); NotificationExtensionAtoms.notificationAdjustmentPreferences); assertThat(p2.getBundlesAllowed()).isFalse(); assertThat(p2.getBundlesAllowed()).isFalse(); assertThat(p2.getAllowedBundleTypes(0).getNumber()) assertThat(p2.getAllowedBundleTypes(0).getNumber()) .isEqualTo(NotificationProtoEnums.TYPE_PROMOTION); .isEqualTo(NotificationProtoEnums.TYPE_PROMOTION); Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +11 −9 Original line number Original line Diff line number Diff line Loading @@ -166,7 +166,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static android.view.contentprotection.flags.Flags.rapidClearNotificationsByListenerAppOpEnabled; import static android.view.contentprotection.flags.Flags.rapidClearNotificationsByListenerAppOpEnabled; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.FrameworkStatsLog.NOTIFICATION_BUNDLE_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.NOTIFICATION_ADJUSTMENT_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES; Loading Loading @@ -2992,7 +2992,7 @@ public class NotificationManagerService extends SystemService { mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES); mStatsManager.clearPullAtomCallback(PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES); mStatsManager.clearPullAtomCallback(NOTIFICATION_BUNDLE_PREFERENCES); mStatsManager.clearPullAtomCallback(NOTIFICATION_ADJUSTMENT_PREFERENCES); mStatsManager.clearPullAtomCallback(DND_MODE_RULE); mStatsManager.clearPullAtomCallback(DND_MODE_RULE); } } if (mAppOps != null) { if (mAppOps != null) { Loading Loading @@ -3116,7 +3116,7 @@ public class NotificationManagerService extends SystemService { mPullAtomCallback mPullAtomCallback ); ); mStatsManager.setPullAtomCallback( mStatsManager.setPullAtomCallback( NOTIFICATION_BUNDLE_PREFERENCES, NOTIFICATION_ADJUSTMENT_PREFERENCES, null, // use default PullAtomMetadata values null, // use default PullAtomMetadata values ConcurrentUtils.DIRECT_EXECUTOR, ConcurrentUtils.DIRECT_EXECUTOR, mPullAtomCallback mPullAtomCallback Loading Loading @@ -3155,7 +3155,7 @@ public class NotificationManagerService extends SystemService { case PACKAGE_NOTIFICATION_PREFERENCES: case PACKAGE_NOTIFICATION_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: case NOTIFICATION_BUNDLE_PREFERENCES: case NOTIFICATION_ADJUSTMENT_PREFERENCES: case DND_MODE_RULE: case DND_MODE_RULE: return pullNotificationStates(atomTag, data); return pullNotificationStates(atomTag, data); default: default: Loading @@ -3182,9 +3182,9 @@ public class NotificationManagerService extends SystemService { case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: case PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES: mPreferencesHelper.pullPackageChannelGroupPreferencesStats(data); mPreferencesHelper.pullPackageChannelGroupPreferencesStats(data); break; break; case NOTIFICATION_BUNDLE_PREFERENCES: case NOTIFICATION_ADJUSTMENT_PREFERENCES: if (notificationClassification() && notificationClassificationUi()) { if (notificationClassification() && notificationClassificationUi()) { mAssistants.pullBundlePreferencesStats(data); mAssistants.pullAdjustmentPreferencesStats(data); } } break; break; case DND_MODE_RULE: case DND_MODE_RULE: Loading Loading @@ -13046,7 +13046,7 @@ public class NotificationManagerService extends SystemService { * Fills out {@link BundlePreferences} proto and wraps it in a {@link StatsEvent}. * Fills out {@link BundlePreferences} proto and wraps it in a {@link StatsEvent}. */ */ @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION) @FlaggedApi(android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION) protected void pullBundlePreferencesStats(List<StatsEvent> events) { protected void pullAdjustmentPreferencesStats(List<StatsEvent> events) { boolean bundlesAllowed = true; boolean bundlesAllowed = true; synchronized (mLock) { synchronized (mLock) { List<String> unsupportedAdjustments = new ArrayList( List<String> unsupportedAdjustments = new ArrayList( Loading @@ -13061,12 +13061,14 @@ public class NotificationManagerService extends SystemService { int[] allowedBundleTypes = getAllowedClassificationTypes(UserHandle.getCallingUserId()); int[] allowedBundleTypes = getAllowedClassificationTypes(UserHandle.getCallingUserId()); events.add(FrameworkStatsLog.buildStatsEvent( events.add(FrameworkStatsLog.buildStatsEvent( NOTIFICATION_BUNDLE_PREFERENCES, NOTIFICATION_ADJUSTMENT_PREFERENCES, /* optional int32 event_id = 1 */ /* optional int32 event_id = 1 */ NotificationPullStatsEvent.NOTIFICATION_BUNDLE_PREFERENCES_PULLED.getId(), NotificationPullStatsEvent.NOTIFICATION_BUNDLE_PREFERENCES_PULLED.getId(), /* optional bool bundles_allowed = 2 */ bundlesAllowed, /* optional bool bundles_allowed = 2 */ bundlesAllowed, /* repeated android.stats.notification.BundleTypes allowed_bundle_types = 3 */ /* repeated android.stats.notification.BundleTypes allowed_bundle_types = 3 */ allowedBundleTypes)); allowedBundleTypes, /* optional android.stats.notification.AdjustmentKey key = 4 */ NotificationPullStatsEvent.adjustmentKeyEnum(KEY_TYPE))); } } } }
services/core/java/com/android/server/notification/NotificationRecordLogger.java +13 −0 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannel; import android.app.Person; import android.app.Person; import android.os.Bundle; import android.os.Bundle; import android.service.notification.Adjustment; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationStats; import android.service.notification.NotificationStats; import android.util.Log; import android.util.Log; Loading @@ -36,6 +37,7 @@ import com.android.internal.logging.InstanceId; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLogger; import com.android.internal.util.FrameworkStatsLog; import com.android.internal.util.FrameworkStatsLog; import com.android.os.notification.NotificationProtoEnums; import java.time.Duration; import java.time.Duration; import java.util.ArrayList; import java.util.ArrayList; Loading Loading @@ -377,6 +379,17 @@ interface NotificationRecordLogger { @Override public int getId() { @Override public int getId() { return mId; return mId; } } /** * Maps an adjustment key string to its corresponding logging enum. */ public static int adjustmentKeyEnum(String adjustmentKey) { return switch (adjustmentKey) { case Adjustment.KEY_TYPE -> NotificationProtoEnums.KEY_TYPE; case Adjustment.KEY_SUMMARIZATION -> NotificationProtoEnums.KEY_SUMMARIZATION; default -> NotificationProtoEnums.KEY_UNKNOWN; }; } } } /** /** Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java +12 −12 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,7 @@ import com.android.internal.util.CollectionUtils; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlPullParser; import com.android.modules.utils.TypedXmlSerializer; import com.android.modules.utils.TypedXmlSerializer; import com.android.os.AtomsProto; import com.android.os.AtomsProto; import com.android.os.notification.NotificationBundlePreferences; import com.android.os.notification.NotificationAdjustmentPreferences; import com.android.os.notification.NotificationExtensionAtoms; import com.android.os.notification.NotificationExtensionAtoms; import com.android.os.notification.NotificationProtoEnums; import com.android.os.notification.NotificationProtoEnums; import com.android.server.LocalServices; import com.android.server.LocalServices; Loading Loading @@ -979,7 +979,7 @@ public class NotificationAssistantsTest extends UiServiceTestCase { @SuppressWarnings("GuardedBy") @SuppressWarnings("GuardedBy") @EnableFlags({android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION, @EnableFlags({android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION, android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI}) android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI}) public void testPullBundlePreferencesStats_fillsOutStatsEvent() public void testPullAdjustmentPreferencesStats_fillsOutStatsEvent() throws Exception { throws Exception { // Create the current user and enable the package // Create the current user and enable the package int userId = ActivityManager.getCurrentUser(); int userId = ActivityManager.getCurrentUser(); Loading @@ -1000,9 +1000,9 @@ public class NotificationAssistantsTest extends UiServiceTestCase { // When pullBundlePreferencesStats is run with the given preferences // When pullBundlePreferencesStats is run with the given preferences ArrayList<StatsEvent> events = new ArrayList<>(); ArrayList<StatsEvent> events = new ArrayList<>(); mAssistants.pullBundlePreferencesStats(events); mAssistants.pullAdjustmentPreferencesStats(events); // The StatsEvent is filled out with the expected NotificationBundlePreferences values. // The StatsEvent is filled out with the expected NotificationAdjustmentPreferences values. assertThat(events.size()).isEqualTo(1); assertThat(events.size()).isEqualTo(1); AtomsProto.Atom atom = StatsEventTestUtils.convertToAtom(events.get(0)); AtomsProto.Atom atom = StatsEventTestUtils.convertToAtom(events.get(0)); Loading @@ -1016,9 +1016,9 @@ public class NotificationAssistantsTest extends UiServiceTestCase { ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); CodedInputStream codedis = CodedInputStream.newInstance(inputStream); CodedInputStream codedis = CodedInputStream.newInstance(inputStream); atom = AtomsProto.Atom.parseFrom(codedis, mRegistry); atom = AtomsProto.Atom.parseFrom(codedis, mRegistry); assertTrue(atom.hasExtension(NotificationExtensionAtoms.notificationBundlePreferences)); assertTrue(atom.hasExtension(NotificationExtensionAtoms.notificationAdjustmentPreferences)); NotificationBundlePreferences p = NotificationAdjustmentPreferences p = atom.getExtension(NotificationExtensionAtoms.notificationBundlePreferences); atom.getExtension(NotificationExtensionAtoms.notificationAdjustmentPreferences); assertThat(p.getBundlesAllowed()).isTrue(); assertThat(p.getBundlesAllowed()).isTrue(); assertThat(p.getAllowedBundleTypes(0).getNumber()) assertThat(p.getAllowedBundleTypes(0).getNumber()) .isEqualTo(NotificationProtoEnums.TYPE_NEWS); .isEqualTo(NotificationProtoEnums.TYPE_NEWS); Loading @@ -1034,9 +1034,9 @@ public class NotificationAssistantsTest extends UiServiceTestCase { true); true); ArrayList<StatsEvent> eventsDisabled = new ArrayList<>(); ArrayList<StatsEvent> eventsDisabled = new ArrayList<>(); mAssistants.pullBundlePreferencesStats(eventsDisabled); mAssistants.pullAdjustmentPreferencesStats(eventsDisabled); // The StatsEvent is filled out with the expected NotificationBundlePreferences values. // The StatsEvent is filled out with the expected NotificationAdjustmentPreferences values. assertThat(eventsDisabled.size()).isEqualTo(1); assertThat(eventsDisabled.size()).isEqualTo(1); AtomsProto.Atom atomDisabled = StatsEventTestUtils.convertToAtom(eventsDisabled.get(0)); AtomsProto.Atom atomDisabled = StatsEventTestUtils.convertToAtom(eventsDisabled.get(0)); Loading @@ -1051,10 +1051,10 @@ public class NotificationAssistantsTest extends UiServiceTestCase { codedis = CodedInputStream.newInstance(inputStream); codedis = CodedInputStream.newInstance(inputStream); atomDisabled = AtomsProto.Atom.parseFrom(codedis, mRegistry); atomDisabled = AtomsProto.Atom.parseFrom(codedis, mRegistry); assertTrue(atomDisabled.hasExtension(NotificationExtensionAtoms assertTrue(atomDisabled.hasExtension(NotificationExtensionAtoms .notificationBundlePreferences)); .notificationAdjustmentPreferences)); NotificationBundlePreferences p2 = NotificationAdjustmentPreferences p2 = atomDisabled.getExtension( atomDisabled.getExtension(NotificationExtensionAtoms.notificationBundlePreferences); NotificationExtensionAtoms.notificationAdjustmentPreferences); assertThat(p2.getBundlesAllowed()).isFalse(); assertThat(p2.getBundlesAllowed()).isFalse(); assertThat(p2.getAllowedBundleTypes(0).getNumber()) assertThat(p2.getAllowedBundleTypes(0).getNumber()) .isEqualTo(NotificationProtoEnums.TYPE_PROMOTION); .isEqualTo(NotificationProtoEnums.TYPE_PROMOTION); Loading