mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1189336 - (Part 4) Migrate old restrictions if needed. r=ally
--HG-- extra : commitid : 15Piph0WLl1 extra : rebase_source : 7eb6a1a455a6f3736de1f17181f76fb2d9cd18fc
This commit is contained in:
parent
db5aae07ef
commit
1780a4912d
@ -61,10 +61,11 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
|
||||
StrictMode.ThreadPolicy policy = StrictMode.allowThreadDiskReads();
|
||||
|
||||
try {
|
||||
cachedAppRestrictions = mgr.getApplicationRestrictions(context.getPackageName());
|
||||
Bundle appRestrictions = mgr.getApplicationRestrictions(context.getPackageName());
|
||||
migrateRestrictionsIfNeeded(appRestrictions);
|
||||
|
||||
cachedAppRestrictions = appRestrictions;
|
||||
cachedUserRestrictions = mgr.getUserRestrictions();
|
||||
|
||||
|
||||
} finally {
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
}
|
||||
@ -97,4 +98,37 @@ public class RestrictedProfileConfiguration implements RestrictionConfiguration
|
||||
public synchronized void update() {
|
||||
isCacheInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method migrates the old set of DISALLOW_ restrictions to the new restrictable feature ones (Bug 1189336).
|
||||
*/
|
||||
public static void migrateRestrictionsIfNeeded(Bundle bundle) {
|
||||
if (!bundle.containsKey(Restrictable.INSTALL_EXTENSION.name) && bundle.containsKey("no_install_extensions")) {
|
||||
bundle.putBoolean(Restrictable.INSTALL_EXTENSION.name, !bundle.getBoolean("no_install_extensions"));
|
||||
}
|
||||
|
||||
if (!bundle.containsKey(Restrictable.PRIVATE_BROWSING.name) && bundle.containsKey("no_private_browsing")) {
|
||||
bundle.putBoolean(Restrictable.PRIVATE_BROWSING.name, !bundle.getBoolean("no_private_browsing"));
|
||||
}
|
||||
|
||||
if (!bundle.containsKey(Restrictable.LOCATION_SERVICE.name) && bundle.containsKey("no_location_service")) {
|
||||
bundle.putBoolean(Restrictable.LOCATION_SERVICE.name, !bundle.getBoolean("no_location_service"));
|
||||
}
|
||||
|
||||
if (!bundle.containsKey(Restrictable.CLEAR_HISTORY.name) && bundle.containsKey("no_clear_history")) {
|
||||
bundle.putBoolean(Restrictable.CLEAR_HISTORY.name, !bundle.getBoolean("no_clear_history"));
|
||||
}
|
||||
|
||||
if (!bundle.containsKey(Restrictable.MASTER_PASSWORD.name) && bundle.containsKey("no_master_password")) {
|
||||
bundle.putBoolean(Restrictable.MASTER_PASSWORD.name, !bundle.getBoolean("no_master_password"));
|
||||
}
|
||||
|
||||
if (!bundle.containsKey(Restrictable.GUEST_BROWSING.name) && bundle.containsKey("no_guest_browsing")) {
|
||||
bundle.putBoolean(Restrictable.GUEST_BROWSING.name, !bundle.getBoolean("no_guest_browsing"));
|
||||
}
|
||||
|
||||
if (!bundle.containsKey(Restrictable.ADVANCED_SETTINGS.name) && bundle.containsKey("no_advanced_settings")) {
|
||||
bundle.putBoolean(Restrictable.ADVANCED_SETTINGS.name, !bundle.getBoolean("no_advanced_settings"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ public class RestrictionProvider extends BroadcastReceiver {
|
||||
@Override
|
||||
public void run() {
|
||||
final Bundle oldRestrictions = intent.getBundleExtra(Intent.EXTRA_RESTRICTIONS_BUNDLE);
|
||||
RestrictedProfileConfiguration.migrateRestrictionsIfNeeded(oldRestrictions);
|
||||
|
||||
final Bundle extras = new Bundle();
|
||||
|
||||
ArrayList<RestrictionEntry> entries = initRestrictions(context, oldRestrictions);
|
||||
|
Loading…
Reference in New Issue
Block a user