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

Commit 84d83cdc authored by Matías Hernández's avatar Matías Hernández
Browse files

Don't switch DND configs in ZenModeHelper upon reception of USER_UNLOCKED

This broadcast just means that the user's storage is accessible, not that it has become the "current" user.

The bug caused ZenModeHelper's configuration to point to the wrong user when secondary users are created and unlocked but never switched to (as some CTS tests do). In turn this caused the broadcasts expected by NotificationManagerZenTest to be sent to the wrong (and actually removed!) user.

Fixes: 322843652
Test: atest PackageInstallerArchiveMultiUserTest NotificationManagerZenTest
Change-Id: I962ab8f18573631fc040314fe186489b199fcb9e
parent b97eff1d
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -2049,10 +2049,12 @@ public class NotificationManagerService extends SystemService {
                if (!mUserProfiles.isProfileUser(userId)) {
                if (!mUserProfiles.isProfileUser(userId)) {
                    mConditionProviders.onUserUnlocked(userId);
                    mConditionProviders.onUserUnlocked(userId);
                    mListeners.onUserUnlocked(userId);
                    mListeners.onUserUnlocked(userId);
                    if (!android.app.Flags.modesApi()) {
                        mZenModeHelper.onUserUnlocked(userId);
                        mZenModeHelper.onUserUnlocked(userId);
                    }
                    }
                }
                }
            }
            }
        }
        private boolean isProfileUnavailable(String action) {
        private boolean isProfileUnavailable(String action) {
            return allowPrivateProfile() ?
            return allowPrivateProfile() ?
+1 −0
Original line number Original line Diff line number Diff line
@@ -325,6 +325,7 @@ public class ZenModeHelper {
        }
        }
    }
    }


    // TODO: b/310620812 - Remove when MODES_API is inlined (no more callers).
    public void onUserUnlocked(int user) {
    public void onUserUnlocked(int user) {
        loadConfigForUser(user, "onUserUnlocked");
        loadConfigForUser(user, "onUserUnlocked");
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -5183,7 +5183,7 @@ public class ZenModeHelperTest extends UiServiceTestCase {
        // rules for a missing package, created a long time ago and deleted a long time ago
        // rules for a missing package, created a long time ago and deleted a long time ago
        config.deletedRules.put("del6", newZenRule("bad_pkg", twoMonthsAgo, twoMonthsAgo));
        config.deletedRules.put("del6", newZenRule("bad_pkg", twoMonthsAgo, twoMonthsAgo));


        mZenModeHelper.onUserUnlocked(42); // copies config and cleans it up.
        mZenModeHelper.onUserSwitched(42); // copies config and cleans it up.


        assertThat(mZenModeHelper.mConfig.automaticRules.keySet())
        assertThat(mZenModeHelper.mConfig.automaticRules.keySet())
                .containsExactly("ar1", "ar2", "ar3", "ar4");
                .containsExactly("ar1", "ar2", "ar3", "ar4");