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

Commit 26c9d3c2 authored by Danny Baumann's avatar Danny Baumann
Browse files

Fix fallback path for default profile groups.

There was a problem in backwards-compatibility for the default
('wildcard') group. As the wildcard group name now always is localized,
matching by name didn't work. Fix that by also matching for the
'default group' flag.
parent 0a648ad3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -83,10 +83,14 @@ public class Profile implements Parcelable {

    /** @hide */
    public void addProfileGroup(ProfileGroup value) {
        profileGroups.put(value.getUuid(), value);
        if (value.isDefaultGroup()) {
            /* we must not have more than one default group */
            if (mDefaultGroup != null) {
                return;
            }
            mDefaultGroup = value;
        }
        profileGroups.put(value.getUuid(), value);
        mDirty = true;
    }

+18 −7
Original line number Diff line number Diff line
@@ -80,20 +80,31 @@ public class ProfileGroup implements Parcelable {
    }

    /** @hide */
    public boolean matches(NotificationGroup group) {
    public boolean matches(NotificationGroup group, boolean defaultGroup) {
        if (mUuid.equals(group.getUuid())) {
            return true;
        }

        /* second try: match name for backwards compat */
        /* fallback matches for backwards compatibility */
        boolean matches = false;

        /* fallback attempt 1: match name */
        if (mName != null && mName.equals(group.getName())) {
            matches = true;
        /* fallback attempt 2: match for the 'defaultGroup' flag to match the wildcard group */
        } else if (mDefaultGroup && defaultGroup) {
            matches = true;
        }

        if (!matches) {
            return false;
        }

        mName = null;
        mUuid = group.getUuid();
        mDirty = true;
            return true;
        }

        return false;
        return true;
    }

    public UUID getUuid() {
+1 −1
Original line number Diff line number Diff line
@@ -239,7 +239,7 @@ public class ProfileManagerService extends IProfileManager.Stub {
        /* enforce a matchup between profile and notification group, which not only
         * works by UUID, but also by name for backwards compatibility */
        for (ProfileGroup pg : profile.getProfileGroups()) {
            if (pg.matches(group)) {
            if (pg.matches(group, defaultGroup)) {
                return;
            }
        }