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

Commit efc7f083 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Don't reset NAS if not needed

Test: NotificationManagerServiceTest
Fixes: 416523366
Flag: EXEMPT bug fix
Change-Id: I2453bf43b336d3834e6af21201e6d56b6440732b
parent 52cdbf70
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -7497,15 +7497,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(),
@@ -13049,7 +13053,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<>();