Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27a22415 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge "[RONs] Fixes for promoted notification logic" into main

parents b85ab4b7 26db4177
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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
@@ -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();
@@ -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);
            }
        }
@@ -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);
                }
@@ -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;

+3 −0
Original line number Diff line number Diff line
@@ -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"))
+10 −0
Original line number Diff line number Diff line
@@ -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);
    }

@@ -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() {