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

Commit 256cdd30 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Don't reset NAS if not needed" into main

parents f31bedc4 efc7f083
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -7496,15 +7496,19 @@ public class NotificationManagerService extends SystemService {
        if (users != null) {
            for (UserInfo user : users) {
                int userId = user.id;
                if (assistant == null) {
                ComponentName allowedAssistant = CollectionUtils.firstOrNull(
                        mAssistants.getAllowedComponents(userId));
                if (assistant == null) {
                    if (allowedAssistant != null) {
                        setNotificationAssistantAccessGrantedForUserInternal(
                                allowedAssistant, userId, false, userSet);
                    }
                    continue;
                }
                if (granted && assistant.equals(allowedAssistant)) {
                    continue;
                }
                if (!granted || mAllowedManagedServicePackages.test(assistant.getPackageName(),
                        userId, mAssistants.getRequiredPermission())) {
                    mConditionProviders.setPackageOrComponentEnabled(assistant.flattenToString(),
@@ -13048,7 +13052,7 @@ public class NotificationManagerService extends SystemService {
            return mNasUnsupported.getOrDefault(userId, new HashSet<>());
        }
        private void setNasUnsupportedDefaults(@UserIdInt int userId) {
        void setNasUnsupportedDefaults(@UserIdInt int userId) {
            if (mNasUnsupported != null) {
                mNasUnsupported.put(userId, new HashSet(List.of(mDefaultUnsupportedAdjustments)));
                handleSavePolicyFile();
+24 −0
Original line number Diff line number Diff line
@@ -6163,6 +6163,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                any(), anyInt(), anyBoolean(), anyBoolean(), anyBoolean());
    }
    @Test
    public void testSetAssistantAccess() throws Exception {
        List<UserInfo> uis = new ArrayList<>();
@@ -6209,6 +6210,29 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                any(), anyInt(), anyBoolean(), anyBoolean());
    }
    @Test
    public void testSetAssistantAccess_sameAsCurrentNas() throws Exception {
        List<UserInfo> uis = new ArrayList<>();
        UserInfo ui = new UserInfo();
        ui.id = mContext.getUserId();
        uis.add(ui);
        when(mUm.getEnabledProfiles(ui.id)).thenReturn(uis);
        ComponentName c = ComponentName.unflattenFromString("package/Component");
        ArrayList<ComponentName> componentList = new ArrayList<>();
        componentList.add(c);
        when(mAssistants.getAllowedComponents(anyInt())).thenReturn(componentList);
        mBinderService.setNotificationAssistantAccessGranted(c, true);
        mBinderService.setNotificationAssistantAccessGranted(c, true);
        verify(mAssistants, never()).setPackageOrComponentEnabled(
                c.flattenToString(), ui.id, true, true, true);
        verify(mConditionProviders, never()).setPackageOrComponentEnabled(
                c.flattenToString(), ui.id, false, true);
        verify(mListeners, never()).setPackageOrComponentEnabled(
                any(), anyInt(), anyBoolean(), anyBoolean());
    }
    @Test
    public void testSetAssistantAccess_nullWithAllowedAssistant() throws Exception {
        ArrayList<ComponentName> componentList = new ArrayList<>();