Loading services/core/java/com/android/server/notification/PreferencesHelper.java +8 −5 Original line number Diff line number Diff line Loading @@ -184,6 +184,7 @@ public class PreferencesHelper implements RankingConfig { private static final boolean DEFAULT_SHOW_BADGE = true; private static final boolean DEFAULT_APP_LOCKED_IMPORTANCE = false; private static final boolean DEFAULT_CAN_HAVE_PROMOTED_NOTIFS = true; static final boolean DEFAULT_BUBBLES_ENABLED = true; @VisibleForTesting Loading Loading @@ -369,8 +370,8 @@ public class PreferencesHelper implements RankingConfig { null, ATT_USER_DEMOTED_INVALID_MSG_APP, false); r.hasSentValidBubble = parser.getAttributeBoolean(null, ATT_SENT_VALID_BUBBLE, false); if (android.app.Flags.uiRichOngoing()) { r.canHavePromotedNotifs = parser.getAttributeBoolean(null, ATT_PROMOTE_NOTIFS, false); r.canHavePromotedNotifs = parser.getAttributeBoolean(null, ATT_PROMOTE_NOTIFS, DEFAULT_CAN_HAVE_PROMOTED_NOTIFS); } final int innerDepth = parser.getDepth(); Loading Loading @@ -748,7 +749,7 @@ public class PreferencesHelper implements RankingConfig { r.userDemotedMsgApp); out.attributeBoolean(null, ATT_SENT_VALID_BUBBLE, r.hasSentValidBubble); if (android.app.Flags.uiRichOngoing()) { if (r.canHavePromotedNotifs) { if (r.canHavePromotedNotifs != DEFAULT_CAN_HAVE_PROMOTED_NOTIFS) { out.attributeBoolean(null, ATT_PROMOTE_NOTIFS, r.canHavePromotedNotifs); } } Loading Loading @@ -2331,7 +2332,8 @@ public class PreferencesHelper implements RankingConfig { pw.print(" fixedImportance="); pw.print(r.fixedImportance); } if (android.app.Flags.uiRichOngoing() && r.canHavePromotedNotifs) { if (android.app.Flags.uiRichOngoing() && r.canHavePromotedNotifs != DEFAULT_CAN_HAVE_PROMOTED_NOTIFS) { pw.print(" promoted="); pw.print(r.canHavePromotedNotifs); } Loading Loading @@ -3184,7 +3186,8 @@ public class PreferencesHelper implements RankingConfig { long creationTime; @FlaggedApi(android.app.Flags.FLAG_API_RICH_ONGOING) boolean canHavePromotedNotifs = false; // Until we enable the UI, we should return false. boolean canHavePromotedNotifs = android.app.Flags.uiRichOngoing(); @UserIdInt int userId; Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -17405,6 +17405,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING) public void testPostPromotableNotification_noPermission() throws Exception { mBinderService.setCanBePromoted(mPkg, mUid, false, true); assertThat(mBinderService.appCanBePromoted(mPkg, mUid)).isFalse(); Notification n = new Notification.Builder(mContext, mTestNotificationChannel.getId()) .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,7 @@ public class PreferencesHelperTest extends UiServiceTestCase { @Parameters(name = "{0}") public static List<FlagsParameterization> getParams() { return FlagsParameterization.allCombinationsOf( android.app.Flags.FLAG_API_RICH_ONGOING, FLAG_NOTIFICATION_CLASSIFICATION, FLAG_MODES_UI); } Loading Loading @@ -6511,11 +6512,20 @@ public class PreferencesHelperTest extends UiServiceTestCase { @Test @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING) @DisableFlags(android.app.Flags.FLAG_UI_RICH_ONGOING) public void testNoAppHasPermissionToPromoteByDefault() { mHelper.setShowBadge(PKG_P, UID_P, true); assertThat(mHelper.canBePromoted(PKG_P, UID_P)).isFalse(); } @Test @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING, android.app.Flags.FLAG_UI_RICH_ONGOING}) public void testAllAppsHavePermissionToPromoteByDefault() { mHelper.setShowBadge(PKG_P, UID_P, true); assertThat(mHelper.canBePromoted(PKG_P, UID_P)).isTrue(); } @Test @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING) public void testSetCanBePromoted() { Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +8 −5 Original line number Diff line number Diff line Loading @@ -184,6 +184,7 @@ public class PreferencesHelper implements RankingConfig { private static final boolean DEFAULT_SHOW_BADGE = true; private static final boolean DEFAULT_APP_LOCKED_IMPORTANCE = false; private static final boolean DEFAULT_CAN_HAVE_PROMOTED_NOTIFS = true; static final boolean DEFAULT_BUBBLES_ENABLED = true; @VisibleForTesting Loading Loading @@ -369,8 +370,8 @@ public class PreferencesHelper implements RankingConfig { null, ATT_USER_DEMOTED_INVALID_MSG_APP, false); r.hasSentValidBubble = parser.getAttributeBoolean(null, ATT_SENT_VALID_BUBBLE, false); if (android.app.Flags.uiRichOngoing()) { r.canHavePromotedNotifs = parser.getAttributeBoolean(null, ATT_PROMOTE_NOTIFS, false); r.canHavePromotedNotifs = parser.getAttributeBoolean(null, ATT_PROMOTE_NOTIFS, DEFAULT_CAN_HAVE_PROMOTED_NOTIFS); } final int innerDepth = parser.getDepth(); Loading Loading @@ -748,7 +749,7 @@ public class PreferencesHelper implements RankingConfig { r.userDemotedMsgApp); out.attributeBoolean(null, ATT_SENT_VALID_BUBBLE, r.hasSentValidBubble); if (android.app.Flags.uiRichOngoing()) { if (r.canHavePromotedNotifs) { if (r.canHavePromotedNotifs != DEFAULT_CAN_HAVE_PROMOTED_NOTIFS) { out.attributeBoolean(null, ATT_PROMOTE_NOTIFS, r.canHavePromotedNotifs); } } Loading Loading @@ -2331,7 +2332,8 @@ public class PreferencesHelper implements RankingConfig { pw.print(" fixedImportance="); pw.print(r.fixedImportance); } if (android.app.Flags.uiRichOngoing() && r.canHavePromotedNotifs) { if (android.app.Flags.uiRichOngoing() && r.canHavePromotedNotifs != DEFAULT_CAN_HAVE_PROMOTED_NOTIFS) { pw.print(" promoted="); pw.print(r.canHavePromotedNotifs); } Loading Loading @@ -3184,7 +3186,8 @@ public class PreferencesHelper implements RankingConfig { long creationTime; @FlaggedApi(android.app.Flags.FLAG_API_RICH_ONGOING) boolean canHavePromotedNotifs = false; // Until we enable the UI, we should return false. boolean canHavePromotedNotifs = android.app.Flags.uiRichOngoing(); @UserIdInt int userId; Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -17405,6 +17405,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING) public void testPostPromotableNotification_noPermission() throws Exception { mBinderService.setCanBePromoted(mPkg, mUid, false, true); assertThat(mBinderService.appCanBePromoted(mPkg, mUid)).isFalse(); Notification n = new Notification.Builder(mContext, mTestNotificationChannel.getId()) .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,7 @@ public class PreferencesHelperTest extends UiServiceTestCase { @Parameters(name = "{0}") public static List<FlagsParameterization> getParams() { return FlagsParameterization.allCombinationsOf( android.app.Flags.FLAG_API_RICH_ONGOING, FLAG_NOTIFICATION_CLASSIFICATION, FLAG_MODES_UI); } Loading Loading @@ -6511,11 +6512,20 @@ public class PreferencesHelperTest extends UiServiceTestCase { @Test @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING) @DisableFlags(android.app.Flags.FLAG_UI_RICH_ONGOING) public void testNoAppHasPermissionToPromoteByDefault() { mHelper.setShowBadge(PKG_P, UID_P, true); assertThat(mHelper.canBePromoted(PKG_P, UID_P)).isFalse(); } @Test @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING, android.app.Flags.FLAG_UI_RICH_ONGOING}) public void testAllAppsHavePermissionToPromoteByDefault() { mHelper.setShowBadge(PKG_P, UID_P, true); assertThat(mHelper.canBePromoted(PKG_P, UID_P)).isTrue(); } @Test @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING) public void testSetCanBePromoted() { Loading