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

Commit 75c6d41f authored by Manish Singh's avatar Manish Singh
Browse files

Include injected settings for selected profiles only

Earlier we were getting them for all the profiles (under certain
conditions), which is not correct, as each profile ended up showing
entries from other profiles.

Bug: 330538899
Bug: 333507072
Test: atest LocationInjectedServicesPreferenceControllerTest
Test: manual
Change-Id: I36a49d5b305a380ef64d7e83f06ead3ab2b48248
parent cdf87da8
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -168,17 +168,16 @@ public class SettingsInjector {
    /**
     * Gets a list of preferences that other apps have injected.
     *
     * @param profileId Identifier of the user/profile to obtain the injected settings for or
     *                  UserHandle.USER_CURRENT for all profiles associated with current user.
     * @param profiles UserHandles of the users/profiles for which to obtain the injected settings.
     */
    public Map<Integer, List<Preference>> getInjectedSettings(Context prefContext,
            final int profileId) {
            final Set<UserHandle> profiles) {
        final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        final List<UserHandle> profiles = um.getUserProfiles();
        final List<UserHandle> allProfilesForUser = um.getUserProfiles();
        final ArrayMap<Integer, List<Preference>> result = new ArrayMap<>();
        mSettings.clear();
        for (UserHandle userHandle : profiles) {
            if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) {
        for (UserHandle userHandle : allProfilesForUser) {
            if (profiles.contains(userHandle)) {
                final List<Preference> prefs = new ArrayList<>();
                Iterable<InjectedSetting> settings = getSettings(userHandle);
                for (InjectedSetting setting : settings) {