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

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

Merge "Fix notification tests in multi-user environment" into main

parents 8e1d3884 154a40d4
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -6884,10 +6884,16 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    public void testReadPolicyXml_backupRestoreLogging() throws Exception {
    public void testReadPolicyXml_backupRestoreLogging() throws Exception {
        BackupRestoreEventLogger logger = mock(BackupRestoreEventLogger.class);
        BackupRestoreEventLogger logger = mock(BackupRestoreEventLogger.class);
        if (ActivityManager.getCurrentUser() != UserHandle.USER_SYSTEM) {
            // By default, the ZenModeHelper only has a configuration for the system user.
            // If the current user is not the system user, the user must be updated.
            mService.mZenModeHelper.onUserSwitched(ActivityManager.getCurrentUser());
        }
        UserInfo ui = new UserInfo(ActivityManager.getCurrentUser(), "Clone", UserInfo.FLAG_FULL);
        UserInfo ui = new UserInfo(ActivityManager.getCurrentUser(), "Clone", UserInfo.FLAG_FULL);
        ui.userType = USER_TYPE_FULL_SYSTEM;
        ui.userType = USER_TYPE_FULL_SYSTEM;
        when(mUmInternal.getUserInfo(ActivityManager.getCurrentUser())).thenReturn(ui);
        when(mUmInternal.getUserInfo(ActivityManager.getCurrentUser())).thenReturn(ui);
        when(mPermissionHelper.getNotificationPermissionValues(0)).thenReturn(new ArrayMap<>());
        when(mPermissionHelper.getNotificationPermissionValues(ActivityManager.getCurrentUser()))
                .thenReturn(new ArrayMap<>());
        TypedXmlSerializer serializer = Xml.newFastSerializer();
        TypedXmlSerializer serializer = Xml.newFastSerializer();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        serializer.setOutput(new BufferedOutputStream(baos), "utf-8");
        serializer.setOutput(new BufferedOutputStream(baos), "utf-8");
@@ -8931,8 +8937,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    @Test
    @Test
    public void testAreBubblesEnabled_false() throws Exception {
    public void testAreBubblesEnabled_false() throws Exception {
        Settings.Secure.putInt(mContext.getContentResolver(),
        Settings.Secure.putIntForUser(mContext.getContentResolver(),
                Settings.Secure.NOTIFICATION_BUBBLES, 0);
                Settings.Secure.NOTIFICATION_BUBBLES, 0, UserHandle.getUserId(mUid));
        mService.mPreferencesHelper.updateBubblesEnabled();
        mService.mPreferencesHelper.updateBubblesEnabled();
        assertFalse(mBinderService.areBubblesEnabled(UserHandle.getUserHandleForUid(mUid)));
        assertFalse(mBinderService.areBubblesEnabled(UserHandle.getUserHandleForUid(mUid)));
    }
    }
@@ -13310,6 +13316,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        when(mPermissionHelper.hasPermission(UID_N_MR1)).thenReturn(false);
        when(mPermissionHelper.hasPermission(UID_N_MR1)).thenReturn(false);
        when(mPermissionHelper.hasPermission(UID_P)).thenReturn(true);
        when(mPermissionHelper.hasPermission(UID_P)).thenReturn(true);
        enableInteractAcrossUsers();
        assertThat(mBinderService.getPackagesBypassingDnd(UserHandle.getUserId(UID_P)).getList())
        assertThat(mBinderService.getPackagesBypassingDnd(UserHandle.getUserId(UID_P)).getList())
                .containsExactly(new ZenBypassingApp(PKG_P, false));
                .containsExactly(new ZenBypassingApp(PKG_P, false));
    }
    }