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

Commit 01bc9deb authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[RONs] Change tests to only run with the new promotability behavior" into main

parents 9d2bdbd9 94b21b3e
Loading
Loading
Loading
Loading
+36 −29
Original line number Diff line number Diff line
@@ -24,8 +24,11 @@ import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIB
import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.NOT_FOREGROUND_SERVICE;
import static android.app.ActivityManagerInternal.ServiceNotificationPolicy.SHOW_IMMEDIATELY;
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.Flags.FLAG_API_RICH_ONGOING;
import static android.app.Flags.FLAG_NM_SUMMARIZATION;
import static android.app.Flags.FLAG_OPT_IN_RICH_ONGOING;
import static android.app.Flags.FLAG_SORT_SECTION_BY_TIME;
import static android.app.Flags.FLAG_UI_RICH_ONGOING;
import static android.app.Notification.EXTRA_ALLOW_DURING_SETUP;
import static android.app.Notification.EXTRA_PICTURE;
import static android.app.Notification.EXTRA_PICTURE_ICON;
@@ -17724,7 +17727,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING,
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING,
            android.service.notification.Flags.FLAG_NOTIFICATION_CLASSIFICATION,
            android.app.Flags.FLAG_NOTIFICATION_CLASSIFICATION_UI})
    public void testApplyAdjustment_promotedOngoingNotification_doesNotApply() throws Exception {
@@ -17733,7 +17737,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_PROMOTED_ONGOING, true) // add manually since we're skipping post
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
@@ -17777,14 +17781,16 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING})
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    @DisableFlags({FLAG_UI_RICH_ONGOING})
    public void testSetCanBePromoted_granted_noui() throws Exception {
        testSetCanBePromoted_granted();
    }
    @Test
    @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING,
            android.app.Flags.FLAG_UI_RICH_ONGOING })
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING, FLAG_UI_RICH_ONGOING})
    public void testSetCanBePromoted_granted_ui() throws Exception {
        testSetCanBePromoted_granted();
    }
@@ -17795,9 +17801,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
        StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 9, null, mUid, 0,
@@ -17809,9 +17814,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
        StatusBarNotification sbn1 = new StatusBarNotification(mPkg, mPkg, 7, null, mUid, 0,
                n1, UserHandle.getUserHandleForUid(mUid), null, 0);
@@ -17822,9 +17826,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
        StatusBarNotification sbn2 = new StatusBarNotification(PKG_O, PKG_O, 7, null, UID_O, 0,
                n2, UserHandle.getUserHandleForUid(UID_O), null, 0);
@@ -17870,14 +17873,16 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    @DisableFlags({FLAG_UI_RICH_ONGOING})
    public void testSetCanBePromoted_granted_onlyNotifiesOnce_noui() throws Exception {
        testSetCanBePromoted_granted_onlyNotifiesOnce();
    }
    @Test
    @EnableFlags({android.app.Flags.FLAG_API_RICH_ONGOING,
            android.app.Flags.FLAG_UI_RICH_ONGOING})
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING, FLAG_UI_RICH_ONGOING})
    public void testSetCanBePromoted_granted_onlyNotifiesOnce_ui() throws Exception {
        testSetCanBePromoted_granted_onlyNotifiesOnce();
    }
@@ -17888,7 +17893,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
@@ -17915,7 +17920,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    public void testSetCanBePromoted_revoked() throws Exception {
        // start from true state
        mBinderService.setCanBePromoted(mPkg, mUid, true, true);
@@ -17925,10 +17931,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_PROMOTED_ONGOING, true) // add manually since we're skipping post
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
        StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 9, null, mUid, 0,
@@ -17940,10 +17945,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_PROMOTED_ONGOING, true) // add manually since we're skipping post
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
        StatusBarNotification sbn1 = new StatusBarNotification(mPkg, mPkg, 7, null, mUid, 0,
                n1, UserHandle.getUserHandleForUid(mUid), null, 0);
@@ -17980,7 +17984,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    public void testSetCanBePromoted_revoked_onlyNotifiesOnce() throws Exception {
        // start from true state
        mBinderService.setCanBePromoted(mPkg, mUid, true, true);
@@ -17990,10 +17995,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .setFlag(FLAG_PROMOTED_ONGOING, true) // add manually since we're skipping post
                .setFlag(FLAG_CAN_COLORIZE, true) // add manually since we're skipping post
                .build();
        StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 9, null, mUid, 0,
@@ -18014,7 +18018,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    public void testPostPromotableNotification() throws Exception {
        mBinderService.setCanBePromoted(mPkg, mUid, true, true);
        assertThat(mBinderService.appCanBePromoted(mPkg, mUid)).isTrue();
@@ -18023,7 +18028,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .build();
        StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 9, null, mUid, 0,
@@ -18043,7 +18048,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    public void testPostPromotableNotification_noPermission() throws Exception {
        mBinderService.setCanBePromoted(mPkg, mUid, false, true);
        assertThat(mBinderService.appCanBePromoted(mPkg, mUid)).isFalse();
@@ -18052,7 +18058,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .build();
@@ -18073,14 +18079,15 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    }
    @Test
    @EnableFlags(android.app.Flags.FLAG_API_RICH_ONGOING)
    // TODO(b/415070395): remove FLAG_OPT_IN_RICH_ONGOING from EnableFlags when behavior inlined
    @EnableFlags({FLAG_API_RICH_ONGOING, FLAG_OPT_IN_RICH_ONGOING})
    public void testPostPromotableNotification_unimportantNotification() throws Exception {
        mBinderService.setCanBePromoted(mPkg, mUid, true, true);
        Notification n = new Notification.Builder(mContext, mMinChannel.getId())
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG"))
                .setColor(Color.WHITE)
                .setColorized(true)
                .setRequestPromotedOngoing(true)
                .setOngoing(true)
                .build();