Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +23 −13 Original line number Diff line number Diff line Loading @@ -84,6 +84,8 @@ import com.android.providers.settings.SettingsState.Setting; import com.android.server.LocalServices; import com.android.server.SystemConfig; import com.google.android.collect.Sets; import java.io.File; import java.io.FileDescriptor; import java.io.FileNotFoundException; Loading Loading @@ -957,12 +959,12 @@ public class SettingsProvider extends ContentProvider { UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class); userManager.addUserRestrictionsListener((int userId, Bundle newRestrictions, Bundle prevRestrictions) -> { Set<String> changedRestrictions = getRestrictionDiff(prevRestrictions, newRestrictions); // We are changing the settings affected by restrictions to their current // value with a forced update to ensure that all cross profile dependencies // are taken into account. Also make sure the settings update to.. the same // value passes the security checks, so clear binder calling id. if (newRestrictions.getBoolean(UserManager.DISALLOW_SHARE_LOCATION) != prevRestrictions.getBoolean(UserManager.DISALLOW_SHARE_LOCATION)) { if (changedRestrictions.contains(UserManager.DISALLOW_SHARE_LOCATION)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -976,11 +978,8 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) != prevRestrictions.getBoolean(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) || newRestrictions.getBoolean( UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY) != prevRestrictions.getBoolean( if (changedRestrictions.contains(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) || changedRestrictions.contains( UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY)) { final long identity = Binder.clearCallingIdentity(); try { Loading @@ -994,8 +993,7 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.DISALLOW_DEBUGGING_FEATURES) != prevRestrictions.getBoolean(UserManager.DISALLOW_DEBUGGING_FEATURES)) { if (changedRestrictions.contains(UserManager.DISALLOW_DEBUGGING_FEATURES)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -1008,8 +1006,7 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.ENSURE_VERIFY_APPS) != prevRestrictions.getBoolean(UserManager.ENSURE_VERIFY_APPS)) { if (changedRestrictions.contains(UserManager.ENSURE_VERIFY_APPS)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -1028,8 +1025,7 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS) != prevRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { if (changedRestrictions.contains(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -1046,6 +1042,20 @@ public class SettingsProvider extends ContentProvider { }); } private static Set<String> getRestrictionDiff(Bundle prevRestrictions, Bundle newRestrictions) { Set<String> restrictionNames = Sets.newArraySet(); restrictionNames.addAll(prevRestrictions.keySet()); restrictionNames.addAll(newRestrictions.keySet()); Set<String> diff = Sets.newArraySet(); for (String restrictionName : restrictionNames) { if (prevRestrictions.getBoolean(restrictionName) != newRestrictions.getBoolean( restrictionName)) { diff.add(restrictionName); } } return diff; } private Setting getConfigSetting(String name) { if (DEBUG) { Slog.v(LOG_TAG, "getConfigSetting(" + name + ")"); Loading Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +23 −13 Original line number Diff line number Diff line Loading @@ -84,6 +84,8 @@ import com.android.providers.settings.SettingsState.Setting; import com.android.server.LocalServices; import com.android.server.SystemConfig; import com.google.android.collect.Sets; import java.io.File; import java.io.FileDescriptor; import java.io.FileNotFoundException; Loading Loading @@ -957,12 +959,12 @@ public class SettingsProvider extends ContentProvider { UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class); userManager.addUserRestrictionsListener((int userId, Bundle newRestrictions, Bundle prevRestrictions) -> { Set<String> changedRestrictions = getRestrictionDiff(prevRestrictions, newRestrictions); // We are changing the settings affected by restrictions to their current // value with a forced update to ensure that all cross profile dependencies // are taken into account. Also make sure the settings update to.. the same // value passes the security checks, so clear binder calling id. if (newRestrictions.getBoolean(UserManager.DISALLOW_SHARE_LOCATION) != prevRestrictions.getBoolean(UserManager.DISALLOW_SHARE_LOCATION)) { if (changedRestrictions.contains(UserManager.DISALLOW_SHARE_LOCATION)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -976,11 +978,8 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) != prevRestrictions.getBoolean(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) || newRestrictions.getBoolean( UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY) != prevRestrictions.getBoolean( if (changedRestrictions.contains(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) || changedRestrictions.contains( UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES_GLOBALLY)) { final long identity = Binder.clearCallingIdentity(); try { Loading @@ -994,8 +993,7 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.DISALLOW_DEBUGGING_FEATURES) != prevRestrictions.getBoolean(UserManager.DISALLOW_DEBUGGING_FEATURES)) { if (changedRestrictions.contains(UserManager.DISALLOW_DEBUGGING_FEATURES)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -1008,8 +1006,7 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.ENSURE_VERIFY_APPS) != prevRestrictions.getBoolean(UserManager.ENSURE_VERIFY_APPS)) { if (changedRestrictions.contains(UserManager.ENSURE_VERIFY_APPS)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -1028,8 +1025,7 @@ public class SettingsProvider extends ContentProvider { Binder.restoreCallingIdentity(identity); } } if (newRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS) != prevRestrictions.getBoolean(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { if (changedRestrictions.contains(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { final long identity = Binder.clearCallingIdentity(); try { synchronized (mLock) { Loading @@ -1046,6 +1042,20 @@ public class SettingsProvider extends ContentProvider { }); } private static Set<String> getRestrictionDiff(Bundle prevRestrictions, Bundle newRestrictions) { Set<String> restrictionNames = Sets.newArraySet(); restrictionNames.addAll(prevRestrictions.keySet()); restrictionNames.addAll(newRestrictions.keySet()); Set<String> diff = Sets.newArraySet(); for (String restrictionName : restrictionNames) { if (prevRestrictions.getBoolean(restrictionName) != newRestrictions.getBoolean( restrictionName)) { diff.add(restrictionName); } } return diff; } private Setting getConfigSetting(String name) { if (DEBUG) { Slog.v(LOG_TAG, "getConfigSetting(" + name + ")"); Loading