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

Commit 310e1eeb authored by Nicolas Prevot's avatar Nicolas Prevot
Browse files

Notify the profile when cloned settings are changed.

In SettingsProvider, for settings that are cloned from the parent
to the profile:
When the parent value is changed, notify ContentObservers in the
profile as well.

BUG:21414456
Change-Id: Ie0560d1332174499d067db9978553843b640a161
parent e40d7a63
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1774,6 +1774,26 @@ public class SettingsProvider extends ContentProvider {
            Uri uri = getNotificationUriFor(key, name);

            sendNotify(uri, userId);
            if (isSecureSettingsKey(key)) {
                maybeNotifyProfiles(userId, uri, name, sSecureCloneToManagedSettings);
            } else if (isSystemSettingsKey(key)) {
                maybeNotifyProfiles(userId, uri, name, sSystemCloneToManagedSettings);
            }
        }

        private void maybeNotifyProfiles(int userId, Uri uri, String name,
                Set<String> keysCloned) {
            if (keysCloned.contains(name)) {
                List<UserInfo> profiles = mUserManager.getProfiles(userId);
                int size = profiles.size();
                for (int i = 0; i < size; i++) {
                    UserInfo profile = profiles.get(i);
                    // the notification for userId has already been sent.
                    if (profile.id != userId) {
                        sendNotify(uri, profile.id);
                    }
                }
            }
        }

        private int makeKey(int type, int userId) {