diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f4b4bc6..143a394 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1602,11 +1602,5 @@
             </intent-filter>
         </receiver>
 
-        <receiver android:name=".users.RestrictionsReceiver">
-            <intent-filter>
-                <action android:name="android.intent.action.GET_RESTRICTION_ENTRIES"/>
-            </intent-filter>
-        </receiver>
-
     </application>
 </manifest>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 11827be..573f4a0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4422,6 +4422,27 @@
     <string name="user_restrictions_title">Allow apps and content</string>
     <!-- User limits screen, user name rename text [CHAR LIMIT=15] -->
     <string name="user_rename">RENAME</string>
+    <!-- Preference label for custom restrictions [CHAR LIMIT=35] -->
+    <string name="app_restrictions_custom_label">Set application limits</string>
+
+    <!-- Restrictions title for configuring wifi and mobile [CHAR LIMIT=35] -->
+    <string name="restriction_wifi_config_title">Wi\u2011Fi and Mobile</string>
+    <!-- Restrictions summary for configuring wifi and mobile [CHAR LIMIT=100] -->
+    <string name="restriction_wifi_config_summary">Allow modification of Wi\u2011Fi and Mobile settings</string>
+    <!-- Restrictions title for changing bluetooth configuration [CHAR LIMIT=35] -->
+    <string name="restriction_bluetooth_config_title">Bluetooth</string>
+    <!-- Restrictions summary for changing bluetooth configuration [CHAR LIMIT=100] -->
+    <string name="restriction_bluetooth_config_summary">Allow modification of Bluetooth pairings and settings</string>
+    <!-- Restrictions title for allowing NFC transfers [CHAR LIMIT=35] -->
+    <string name="restriction_nfc_enable_title">NFC</string>
+    <!-- Restrictions summary for allowing NFC transfers (tablet) [CHAR LIMIT=100] -->
+    <string name="restriction_nfc_enable_summary" product="tablet">Allow data exchange when the tablet touches another device</string>
+    <!-- Restrictions summary for allowing NFC transfers (phone) [CHAR LIMIT=100] -->
+    <string name="restriction_nfc_enable_summary" product="default">Allow data exchange when the phone touches another device</string>
+    <!-- Restrictions title for allowing location sharing [CHAR LIMIT=35] -->
+    <string name="restriction_location_enable_title">Location access</string>
+    <!-- Restrictions summary for allowing location sharing [CHAR LIMIT=100] -->
+    <string name="restriction_location_enable_summary" >Let apps use your location information</string>
 
     <!-- Wizard back button label [CHAR LIMIT=25] -->
     <string name="wizard_back">Back</string>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index 64a7d7f..e29874b 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -57,7 +57,6 @@
 import com.android.settings.accounts.ManageAccountsSettings;
 import com.android.settings.bluetooth.BluetoothEnabler;
 import com.android.settings.bluetooth.BluetoothSettings;
-import com.android.settings.users.RestrictionsReceiver;
 import com.android.settings.wfd.WifiDisplaySettings;
 import com.android.settings.wifi.WifiEnabler;
 import com.android.settings.wifi.WifiSettings;
@@ -457,15 +456,6 @@
                 if (!showDev) {
                     target.remove(i);
                 }
-            } else if (id == R.id.application_settings) {
-                if (mAppRestrictions != null) {
-                    for (RestrictionEntry entry : mAppRestrictions) {
-                        if (entry.key.equals(RestrictionsReceiver.KEY_ENABLE_APPS)
-                                && !entry.getBooleanValue()) {
-                            target.remove(i);
-                        }
-                    }
-                }
             } else if (id == R.id.account_add) {
                 if (um.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)) {
                     target.remove(i);
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java
index b669bac..d03f6dc 100644
--- a/src/com/android/settings/deviceinfo/Memory.java
+++ b/src/com/android/settings/deviceinfo/Memory.java
@@ -33,6 +33,7 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.os.ServiceManager;
+import android.os.UserManager;
 import android.os.storage.IMountService;
 import android.os.storage.StorageEventListener;
 import android.os.storage.StorageManager;
@@ -174,7 +175,10 @@
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         final MenuItem usb = menu.findItem(R.id.storage_usb);
-        usb.setVisible(!isMassStorageEnabled());
+        UserManager um = (UserManager)getActivity().getSystemService(Context.USER_SERVICE);
+        boolean usbItemVisible = !isMassStorageEnabled()
+                && !um.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
+        usb.setVisible(usbItemVisible);
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/UsbSettings.java b/src/com/android/settings/deviceinfo/UsbSettings.java
index a836fb3..42de2fd 100644
--- a/src/com/android/settings/deviceinfo/UsbSettings.java
+++ b/src/com/android/settings/deviceinfo/UsbSettings.java
@@ -16,20 +16,16 @@
 
 package com.android.settings.deviceinfo;
 
-import android.app.AlertDialog;
-import android.app.Dialog;
 import android.content.BroadcastReceiver;
-import android.content.ContentQueryMap;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.hardware.usb.UsbManager;
 import android.os.Bundle;
+import android.os.UserManager;
 import android.preference.CheckBoxPreference;
 import android.preference.Preference;
 import android.preference.PreferenceScreen;
-import android.provider.Settings;
 import android.util.Log;
 
 import com.android.settings.R;
@@ -73,6 +69,12 @@
         mMtp = (CheckBoxPreference)root.findPreference(KEY_MTP);
         mPtp = (CheckBoxPreference)root.findPreference(KEY_PTP);
 
+        UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
+        if (um.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER)) {
+            mMtp.setEnabled(false);
+            mPtp.setEnabled(false);
+        }
+
         return root;
     }
 
@@ -112,8 +114,12 @@
             mMtp.setChecked(false);
             mPtp.setChecked(false);
         }
-
-        if (!mUsbAccessoryMode) {
+        UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
+        if (um.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER)) {
+            Log.e(TAG, "USB is locked down");
+            mMtp.setEnabled(false);
+            mPtp.setEnabled(false);
+        } else if (!mUsbAccessoryMode) {
             //Enable MTP and PTP switch while USB is not in Accessory Mode, otherwise disable it
             Log.e(TAG, "USB Normal Mode");
             mMtp.setEnabled(true);
@@ -133,6 +139,12 @@
         if (Utils.isMonkeyRunning()) {
             return true;
         }
+        // If this user is disallowed from using USB, don't handle their attempts to change the
+        // setting.
+        UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
+        if (um.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER)) {
+            return true;
+        }
 
         String function = "none";
         if (preference == mMtp && mMtp.isChecked()) {
diff --git a/src/com/android/settings/users/AppRestrictionsFragment.java b/src/com/android/settings/users/AppRestrictionsFragment.java
index b610025..6154bdf 100644
--- a/src/com/android/settings/users/AppRestrictionsFragment.java
+++ b/src/com/android/settings/users/AppRestrictionsFragment.java
@@ -16,10 +16,12 @@
 
 package com.android.settings.users;
 
+import android.appwidget.AppWidgetManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.RestrictionEntry;
+import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
@@ -31,6 +33,7 @@
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.os.Parcelable;
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.preference.CheckBoxPreference;
@@ -85,11 +88,14 @@
     private static final int MAX_APP_RESTRICTIONS = 100;
 
     private static final String DELIMITER = ";";
-    private List<ResolveInfo> mApps;
     HashMap<String,Boolean> mSelectedPackages = new HashMap<String,Boolean>();
     private boolean mFirstTime = true;
     private boolean mNewUser;
 
+    private int mCustomRequestCode;
+    private HashMap<Integer, AppRestrictionsPreference> mCustomRequestMap =
+            new HashMap<Integer,AppRestrictionsPreference>();
+
     public static class Activity extends PreferenceActivity {
         @Override
         public Intent getIntent() {
@@ -133,7 +139,7 @@
         RestrictionEntry getRestriction(String key) {
             if (restrictions == null) return null;
             for (RestrictionEntry entry : restrictions) {
-                if (entry.key.equals(key)) {
+                if (entry.getKey().equals(key)) {
                     return entry;
                 }
             }
@@ -207,33 +213,70 @@
         mUserPreference.setText(info.name);
     }
 
+    private void addSystemApps(List<ApplicationInfo> visibleApps, Intent intent) {
+        final PackageManager pm = getActivity().getPackageManager();
+        List<ResolveInfo> launchableApps = pm.queryIntentActivities(intent, 0);
+        for (ResolveInfo app : launchableApps) {
+            if (app.activityInfo != null && app.activityInfo.applicationInfo != null) {
+                int flags = app.activityInfo.applicationInfo.flags;
+                if ((flags & ApplicationInfo.FLAG_SYSTEM) != 0
+                        || (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
+                    // System app
+                    visibleApps.add(app.activityInfo.applicationInfo);
+                }
+            }
+        }
+    }
+
     private void populateApps() {
         mAppList.setOrderingAsAdded(false);
-
+        List<ApplicationInfo> visibleApps = new ArrayList<ApplicationInfo>();
         // TODO: Do this asynchronously since it can be a long operation
         final Context context = getActivity();
         PackageManager pm = context.getPackageManager();
+
+        // Add launchers
         Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
         launcherIntent.addCategory(Intent.CATEGORY_LAUNCHER);
-        mApps = pm.queryIntentActivities(launcherIntent, 0);
-        Collections.sort(mApps, new AppLabelComparator(pm));
+        addSystemApps(visibleApps, launcherIntent);
 
+        // Add widgets
+        Intent widgetIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
+        addSystemApps(visibleApps, widgetIntent);
+
+        List<ApplicationInfo> installedApps = pm.getInstalledApplications(0);
+        for (ApplicationInfo app : installedApps) {
+            if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 0
+                    && (app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 0) {
+                // Downloaded app
+                visibleApps.add(app);
+            }
+        }
+        Collections.sort(visibleApps, new AppLabelComparator(pm));
+
+        for (int i = visibleApps.size() - 1; i > 1; i--) {
+            ApplicationInfo appInfo = visibleApps.get(i);
+            if (appInfo.packageName.equals(visibleApps.get(i-1).packageName)) {
+                visibleApps.remove(i);
+            }
+        }
         Intent restrictionsIntent = new Intent(Intent.ACTION_GET_RESTRICTION_ENTRIES);
         final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(restrictionsIntent, 0);
         final List<ResolveInfo> existingApps = pm.queryIntentActivitiesAsUser(launcherIntent,
                 0, mUser.getIdentifier());
         int i = 0;
-        if (receivers != null && receivers.size() > 0) {
-            for (ResolveInfo app : mApps) {
-                if (app.activityInfo == null || app.activityInfo.packageName == null) continue;
-                String packageName = app.activityInfo.packageName;
+        if (visibleApps.size() > 0) {
+            for (ApplicationInfo app : visibleApps) {
+                if (app.packageName == null) continue;
+                String packageName = app.packageName;
                 Drawable icon = app.loadIcon(pm);
                 CharSequence label = app.loadLabel(pm);
                 AppRestrictionsPreference p = new AppRestrictionsPreference(context, this);
                 p.setIcon(icon);
                 p.setTitle(label);
                 p.setKey(PKG_PREFIX + packageName);
-                p.setSettingsEnabled(hasPackage(receivers, packageName));
+                p.setSettingsEnabled(hasPackage(receivers, packageName)
+                        || packageName.equals(getActivity().getPackageName()));
                 p.setPersistent(false);
                 p.setOnPreferenceChangeListener(this);
                 p.setOnPreferenceClickListener(this);
@@ -261,7 +304,7 @@
         }
     }
 
-    private class AppLabelComparator implements Comparator<ResolveInfo> {
+    private class AppLabelComparator implements Comparator<ApplicationInfo> {
 
         PackageManager pm;
 
@@ -269,13 +312,13 @@
             this.pm = pm;
         }
 
-        private CharSequence getLabel(ResolveInfo info) {
+        private CharSequence getLabel(ApplicationInfo info) {
             // TODO: Optimize this with a cache
-            return info.activityInfo.loadLabel(pm);
+            return info.loadLabel(pm);
         }
 
         @Override
-        public int compare(ResolveInfo lhs, ResolveInfo rhs) {
+        public int compare(ApplicationInfo lhs, ApplicationInfo rhs) {
             String lhsLabel = getLabel(lhs).toString();
             String rhsLabel = getLabel(rhs).toString();
             return lhsLabel.compareTo(rhsLabel);
@@ -296,7 +339,7 @@
         if (v.getTag() instanceof AppRestrictionsPreference) {
             AppRestrictionsPreference pref = (AppRestrictionsPreference) v.getTag();
             if (v.getId() == R.id.app_restrictions_settings) {
-                handleSettingsClick(pref);
+                toggleAppPanel(pref);
             } else if (!pref.isRequired()) {
                 pref.setChecked(!pref.isChecked());
                 mSelectedPackages.put(pref.getKey().substring(PKG_PREFIX.length()),
@@ -317,21 +360,18 @@
             ArrayList<RestrictionEntry> restrictions = appPref.getRestrictions();
             if (restrictions != null) {
                 for (RestrictionEntry entry : restrictions) {
-                    if (entry.key.equals(restrictionKey)) {
-                        switch (entry.type) {
+                    if (entry.getKey().equals(restrictionKey)) {
+                        switch (entry.getType()) {
                         case RestrictionEntry.TYPE_BOOLEAN:
-                            entry.setValue((Boolean) newValue);
+                            entry.setSelectedState((Boolean) newValue);
                             break;
                         case RestrictionEntry.TYPE_CHOICE:
                         case RestrictionEntry.TYPE_CHOICE_LEVEL:
                             ListPreference listPref = (ListPreference) preference;
-                            entry.setValue((String) newValue);
-                            for (int i = 0; i < listPref.getEntryValues().length; i++) {
-                                if (entry.values[i].equals(newValue)) {
-                                    listPref.setSummary(entry.choices[i]);
-                                    break;
-                                }
-                            }
+                            entry.setSelectedString((String) newValue);
+                            String readable = findInArray(entry.getChoiceEntries(),
+                                    entry.getChoiceValues(), (String) newValue);
+                            listPref.setSummary(readable);
                             break;
                         case RestrictionEntry.TYPE_MULTI_SELECT:
                             MultiSelectListPreference msListPref =
@@ -339,13 +379,17 @@
                             Set<String> set = (Set<String>) newValue;
                             String [] selectedValues = new String[set.size()];
                             set.toArray(selectedValues);
-                            entry.setMultipleValues(selectedValues);
+                            entry.setAllSelectedStrings(selectedValues);
                             break;
                         default:
                             continue;
                         }
-                        mUserManager.setApplicationRestrictions(packageName, restrictions,
-                                mUser);
+                        if (packageName.equals(getActivity().getPackageName())) {
+                            RestrictionUtils.setRestrictions(getActivity(), restrictions, mUser);
+                        } else {
+                            mUserManager.setApplicationRestrictions(packageName, restrictions,
+                                    mUser);
+                        }
                         break;
                     }
                 }
@@ -360,7 +404,7 @@
         return true;
     }
 
-    private void handleSettingsClick(AppRestrictionsPreference preference) {
+    private void toggleAppPanel(AppRestrictionsPreference preference) {
         if (preference.getKey().startsWith(PKG_PREFIX)) {
             if (preference.panelOpen) {
                 for (Preference p : preference.childPreferences) {
@@ -369,14 +413,22 @@
                 preference.childPreferences.clear();
             } else {
                 String packageName = preference.getKey().substring(PKG_PREFIX.length());
-                List<RestrictionEntry> oldEntries =
-                        mUserManager.getApplicationRestrictions(packageName, mUser);
-                Intent intent = new Intent(Intent.ACTION_GET_RESTRICTION_ENTRIES);
-                intent.putParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS,
-                        new ArrayList<RestrictionEntry>(oldEntries));
-                getActivity().sendOrderedBroadcast(intent, null,
-                        new RestrictionsResultReceiver(packageName, preference),
-                        null, Activity.RESULT_OK, null, null);
+                if (packageName.equals(getActivity().getPackageName())) {
+                    // Settings, fake it by using user restrictions
+                    ArrayList<RestrictionEntry> restrictions = RestrictionUtils.getRestrictions(
+                            getActivity(), mUser);
+                    onRestrictionsReceived(preference, packageName, restrictions);
+                } else {
+                    List<RestrictionEntry> oldEntries =
+                            mUserManager.getApplicationRestrictions(packageName, mUser);
+                    Intent intent = new Intent(Intent.ACTION_GET_RESTRICTION_ENTRIES);
+                    intent.setPackage(packageName);
+                    intent.putParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS,
+                            new ArrayList<RestrictionEntry>(oldEntries));
+                    getActivity().sendOrderedBroadcast(intent, null,
+                            new RestrictionsResultReceiver(packageName, preference),
+                            null, Activity.RESULT_OK, null, null);
+                }
             }
             preference.panelOpen = !preference.panelOpen;
         }
@@ -384,6 +436,7 @@
 
     class RestrictionsResultReceiver extends BroadcastReceiver {
 
+        private static final String CUSTOM_RESTRICTIONS_INTENT = Intent.EXTRA_RESTRICTIONS_INTENT;
         String packageName;
         AppRestrictionsPreference preference;
 
@@ -395,64 +448,144 @@
 
         @Override
         public void onReceive(Context context, Intent intent) {
-            ArrayList<RestrictionEntry> restrictions = getResultExtras(true).getParcelableArrayList(
+            Bundle results = getResultExtras(true);
+            final ArrayList<RestrictionEntry> restrictions = results.getParcelableArrayList(
                     Intent.EXTRA_RESTRICTIONS);
-            if (restrictions != null) {
-                int count = 1;
-                for (RestrictionEntry entry : restrictions) {
-                    Preference p = null;
-                    switch (entry.type) {
-                    case RestrictionEntry.TYPE_BOOLEAN:
-                        p = new CheckBoxPreference(context);
-                        p.setTitle(entry.title);
-                        p.setSummary(entry.description);
-                        ((CheckBoxPreference)p).setChecked(entry.getBooleanValue());
-                        break;
-                    case RestrictionEntry.TYPE_CHOICE:
-                    case RestrictionEntry.TYPE_CHOICE_LEVEL:
-                        p = new ListPreference(context);
-                        p.setTitle(entry.title);
-                        String value = entry.getStringValue();
-                        if (value == null) {
-                            value = entry.description;
-                        }
-                        p.setSummary(value);
-                        ((ListPreference)p).setEntryValues(entry.values);
-                        ((ListPreference)p).setEntries(entry.choices);
-                        ((ListPreference)p).setValue(entry.getStringValue());
-                        break;
-                    case RestrictionEntry.TYPE_MULTI_SELECT:
-                        p = new MultiSelectListPreference(context);
-                        p.setTitle(entry.title);
-                        ((MultiSelectListPreference)p).setEntryValues(entry.values);
-                        ((MultiSelectListPreference)p).setEntries(entry.choices);
-                        HashSet<String> set = new HashSet<String>();
-                        for (String s : entry.getMultipleValues()) {
-                            set.add(s);
-                        }
-                        ((MultiSelectListPreference)p).setValues(set);
-                        break;
-                    case RestrictionEntry.TYPE_NULL:
-                    default:
+            Intent restrictionsIntent = (Intent) results.getParcelable(CUSTOM_RESTRICTIONS_INTENT);
+            if (restrictions != null && restrictionsIntent == null) {
+                onRestrictionsReceived(preference, packageName, restrictions);
+                mUserManager.setApplicationRestrictions(packageName, restrictions, mUser);
+            } else if (restrictionsIntent != null) {
+                final Intent customIntent = restrictionsIntent;
+                customIntent.putParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS, restrictions);
+                Preference p = new Preference(context);
+                p.setTitle(R.string.app_restrictions_custom_label);
+                p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+                    @Override
+                    public boolean onPreferenceClick(Preference preference) {
+                        int requestCode = generateCustomActivityRequestCode(
+                                RestrictionsResultReceiver.this.preference);
+                        AppRestrictionsFragment.this.startActivityForResult(
+                                customIntent, requestCode);
+                        return false;
                     }
-                    if (p != null) {
-                        p.setPersistent(false);
-                        p.setOrder(preference.getOrder() + count);
-                        // Store the restrictions key string as a key for the preference
-                        p.setKey(preference.getKey().substring(PKG_PREFIX.length()) + DELIMITER
-                                + entry.key);
-                        mAppList.addPreference(p);
-                        p.setOnPreferenceChangeListener(AppRestrictionsFragment.this);
-                        preference.childPreferences.add(p);
-                        count++;
-                    }
-                }
+                });
+                p.setPersistent(false);
+                p.setOrder(preference.getOrder() + 1);
+                preference.childPreferences.add(p);
+                mAppList.addPreference(p);
                 preference.setRestrictions(restrictions);
             }
-            mUserManager.setApplicationRestrictions(packageName, restrictions, mUser);
         }
     }
 
+    private void onRestrictionsReceived(AppRestrictionsPreference preference, String packageName,
+            ArrayList<RestrictionEntry> restrictions) {
+        // Non-custom-activity case - expand the restrictions in-place
+        final Context context = preference.getContext();
+        int count = 1;
+        for (RestrictionEntry entry : restrictions) {
+            Preference p = null;
+            switch (entry.getType()) {
+            case RestrictionEntry.TYPE_BOOLEAN:
+                p = new CheckBoxPreference(context);
+                p.setTitle(entry.getTitle());
+                p.setSummary(entry.getDescription());
+                ((CheckBoxPreference)p).setChecked(entry.getSelectedState());
+                break;
+            case RestrictionEntry.TYPE_CHOICE:
+            case RestrictionEntry.TYPE_CHOICE_LEVEL:
+                p = new ListPreference(context);
+                p.setTitle(entry.getTitle());
+                String value = entry.getSelectedString();
+                if (value == null) {
+                    value = entry.getDescription();
+                }
+                p.setSummary(findInArray(entry.getChoiceEntries(), entry.getChoiceValues(),
+                        value));
+                ((ListPreference)p).setEntryValues(entry.getChoiceValues());
+                ((ListPreference)p).setEntries(entry.getChoiceEntries());
+                ((ListPreference)p).setValue(value);
+                break;
+            case RestrictionEntry.TYPE_MULTI_SELECT:
+                p = new MultiSelectListPreference(context);
+                p.setTitle(entry.getTitle());
+                ((MultiSelectListPreference)p).setEntryValues(entry.getChoiceValues());
+                ((MultiSelectListPreference)p).setEntries(entry.getChoiceEntries());
+                HashSet<String> set = new HashSet<String>();
+                for (String s : entry.getAllSelectedStrings()) {
+                    set.add(s);
+                }
+                ((MultiSelectListPreference)p).setValues(set);
+                break;
+            case RestrictionEntry.TYPE_NULL:
+            default:
+            }
+            if (p != null) {
+                p.setPersistent(false);
+                p.setOrder(preference.getOrder() + count);
+                // Store the restrictions key string as a key for the preference
+                p.setKey(preference.getKey().substring(PKG_PREFIX.length()) + DELIMITER
+                        + entry.getKey());
+                mAppList.addPreference(p);
+                p.setOnPreferenceChangeListener(AppRestrictionsFragment.this);
+                preference.childPreferences.add(p);
+                count++;
+            }
+        }
+        preference.setRestrictions(restrictions);
+    }
+
+    /**
+     * Generates a request code that is stored in a map to retrieve the associated
+     * AppRestrictionsPreference.
+     * @param preference
+     * @return
+     */
+    private int generateCustomActivityRequestCode(AppRestrictionsPreference preference) {
+        mCustomRequestCode++;
+        mCustomRequestMap.put(mCustomRequestCode, preference);
+        return mCustomRequestCode;
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+
+        Log.i(TAG, "Got activity resultCode=" + resultCode + ", requestCode="
+                + requestCode + ", data=" + data);
+
+        AppRestrictionsPreference pref = mCustomRequestMap.get(requestCode);
+        if (pref == null) {
+            Log.w(TAG, "Unknown requestCode " + requestCode);
+            return;
+        }
+
+        if (resultCode == Activity.RESULT_OK) {
+            ArrayList<RestrictionEntry> list =
+                    data.getParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS);
+            if (list != null) {
+                // If there's a valid result, persist it to the user manager.
+                String packageName = pref.getKey().substring(PKG_PREFIX.length());
+                pref.setRestrictions(list);
+                mUserManager.setApplicationRestrictions(packageName, list, mUser);
+            }
+            toggleAppPanel(pref);
+        }
+        // Remove request from the map
+        mCustomRequestMap.remove(requestCode);
+    }
+
+    private String findInArray(String[] choiceEntries, String[] choiceValues,
+            String selectedString) {
+        for (int i = 0; i < choiceValues.length; i++) {
+            if (choiceValues[i].equals(selectedString)) {
+                return choiceEntries[i];
+            }
+        }
+        return selectedString;
+    }
+
     @Override
     public boolean onPreferenceClick(Preference preference) {
         if (preference.getKey().startsWith(PKG_PREFIX)) {
diff --git a/src/com/android/settings/users/RestrictionUtils.java b/src/com/android/settings/users/RestrictionUtils.java
new file mode 100644
index 0000000..8b675a5
--- /dev/null
+++ b/src/com/android/settings/users/RestrictionUtils.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.users;
+
+import android.content.Context;
+import android.content.RestrictionEntry;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.provider.Settings.Secure;
+
+import com.android.settings.R;
+
+import java.util.ArrayList;
+
+public class RestrictionUtils {
+
+    public static final String [] sRestrictionKeys = {
+        UserManager.DISALLOW_CONFIG_WIFI,
+        UserManager.DISALLOW_CONFIG_BLUETOOTH,
+        UserManager.DISALLOW_SHARE_LOCATION,
+        UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES
+    };
+
+    public static final int [] sRestrictionTitles = {
+        R.string.restriction_wifi_config_title,
+        R.string.restriction_bluetooth_config_title,
+        R.string.restriction_location_enable_title,
+        R.string.install_applications
+    };
+
+    public static final int [] sRestrictionDescriptions = {
+        R.string.restriction_wifi_config_summary,
+        R.string.restriction_bluetooth_config_summary,
+        R.string.restriction_location_enable_summary,
+        R.string.install_unknown_applications
+    };
+
+    /**
+     * Returns the current user restrictions in the form of application
+     * restriction entries.
+     * @return list of RestrictionEntry objects with user-visible text.
+     */
+    public static ArrayList<RestrictionEntry> getRestrictions(Context context, UserHandle user) {
+        Resources res = context.getResources();
+        ArrayList<RestrictionEntry> entries = new ArrayList<RestrictionEntry>();
+        UserManager um = UserManager.get(context);
+        Bundle userRestrictions = um.getUserRestrictions(user);
+
+        for (int i = 0; i < sRestrictionKeys.length; i++) {
+            RestrictionEntry entry = new RestrictionEntry(
+                    sRestrictionKeys[i],
+                    !userRestrictions.getBoolean(sRestrictionKeys[i], false));
+            entry.setTitle(res.getString(sRestrictionTitles[i]));
+            entry.setDescription(res.getString(sRestrictionDescriptions[i]));
+            entry.setType(RestrictionEntry.TYPE_BOOLEAN);
+            entries.add(entry);
+        }
+
+        return entries;
+    }
+
+    public static void setRestrictions(Context context, ArrayList<RestrictionEntry> entries,
+            UserHandle user) {
+        UserManager um = UserManager.get(context);
+        Bundle userRestrictions = um.getUserRestrictions(user);
+
+        for (RestrictionEntry entry : entries) {
+            userRestrictions.putBoolean(entry.getKey(), !entry.getSelectedState());
+            if (entry.getKey().equals(UserManager.DISALLOW_SHARE_LOCATION)
+                    && !entry.getSelectedState()) {
+                Secure.putStringForUser(context.getContentResolver(),
+                        Secure.LOCATION_PROVIDERS_ALLOWED, "", user.getIdentifier());
+            }
+        }
+        um.setUserRestrictions(userRestrictions, user);
+    }
+}
diff --git a/src/com/android/settings/users/RestrictionsReceiver.java b/src/com/android/settings/users/RestrictionsReceiver.java
deleted file mode 100644
index 0eeb7cd..0000000
--- a/src/com/android/settings/users/RestrictionsReceiver.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.users;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.RestrictionEntry;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.android.settings.R;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** Test class, to demonstrate the features. TODO: Remove or modify with real restrictions */
-public class RestrictionsReceiver extends BroadcastReceiver {
-
-    private static final String TAG = RestrictionsReceiver.class.getSimpleName();
-
-    public static final String KEY_VERSION = "version";
-    public static final String KEY_ENABLE_APPS = "enable_apps";
-    public static final String KEY_SECTIONS_TO_SHOW = "enable_sections";
-    public static final String KEY_CONTENT_RATING = "content_rating";
-
-    private static final int[] SECTION_IDS = {
-        R.id.wifi_settings,
-        R.id.bluetooth_settings,
-        R.id.data_usage_settings,
-        R.id.app_settings,
-        R.id.date_time_settings,
-        R.id.about_settings
-    };
-
-    private static final int[] SECTION_TITLE_IDS = {
-        R.string.wifi_settings,
-        R.string.bluetooth_settings,
-        R.string.data_usage_summary_title,
-        R.string.manageapplications_settings_title,
-        R.string.date_and_time,
-        R.string.about_settings
-    };
-
-    @Override
-    public void onReceive(final Context context, Intent intent) {
-        final PendingResult result = goAsync();
-        final ArrayList<RestrictionEntry> oldRestrictions =
-                intent.getParcelableArrayListExtra(Intent.EXTRA_RESTRICTIONS);
-        Log.i(TAG, "oldRestrictions = " + oldRestrictions);
-        new Thread() {
-            public void run() {
-                createRestrictions(context, result, oldRestrictions);
-            }
-        }.start();
-    }
-
-    private void createRestrictions(Context context,
-            PendingResult result, List<RestrictionEntry> old) {
-        ArrayList<RestrictionEntry> newRestrictions = new ArrayList<RestrictionEntry>();
-        boolean oldEnableApps = false;
-        String oldContentRating = "";
-        String[] oldEnabledSections = new String[0];
-        if (old != null) {
-            for (RestrictionEntry r : old) {
-                if (r.key.equals(KEY_ENABLE_APPS)) {
-                    oldEnableApps = r.getBooleanValue();
-                } else if (r.key.equals(KEY_CONTENT_RATING)) {
-                    oldContentRating = r.getStringValue();
-                } else if (r.key.equals(KEY_SECTIONS_TO_SHOW)) {
-                    oldEnabledSections = r.getMultipleValues();
-                }
-            }
-        }
-
-        RestrictionEntry r0 = new RestrictionEntry(KEY_VERSION, "1");
-        newRestrictions.add(r0);
-
-        RestrictionEntry r1 = new RestrictionEntry(KEY_ENABLE_APPS,
-                Boolean.toString(oldEnableApps));
-        r1.title = "Enable apps";
-        r1.description = "Show the Apps section in Settings";
-        r1.type = RestrictionEntry.TYPE_BOOLEAN;
-        newRestrictions.add(r1);
-
-        RestrictionEntry r2 = new RestrictionEntry(KEY_CONTENT_RATING, oldContentRating);
-        r2.title = "Test: Content rating";
-        r2.description = "Limit content to chosen rating and lower";
-        r2.type = RestrictionEntry.TYPE_CHOICE_LEVEL;
-        r2.values = new String[] { "G", "PG", "PG13", "R", "NR" };
-        r2.choices = new String[] { "G", "PG", "PG-13", "Restricted", "Not Rated" };
-        newRestrictions.add(r2);
-
-        String [] values = new String[SECTION_IDS.length];
-        String [] choices = new String[SECTION_IDS.length];
-        int i = 0;
-        for (int sectionId : SECTION_IDS) {
-            values[i] = Integer.toString(sectionId);
-            choices[i] = context.getString(SECTION_TITLE_IDS[i]);
-            i++;
-        }
-        RestrictionEntry r3 = new RestrictionEntry(KEY_SECTIONS_TO_SHOW, oldEnabledSections);
-        r3.type = RestrictionEntry.TYPE_MULTI_SELECT;
-        r3.choices = choices;
-        r3.values = values;
-        r3.title = "Test: Sections to show";
-        newRestrictions.add(r3);
-
-        Bundle extras = new Bundle();
-        extras.putParcelableArrayList(Intent.EXTRA_RESTRICTIONS, newRestrictions);
-        result.setResult(0, null, extras);
-        result.finish();
-    }
-}
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 872d144..5830184 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -501,6 +501,12 @@
         boolean moreUsers = mUserManager.getMaxSupportedUsers() > users.size();
         mAddRestrictedUser.setEnabled(moreUsers);
         mAddTrustedUser.setEnabled(moreUsers);
+        // Remove the limited users category if there aren't other limited users.
+        if (!mIsOwner) {
+            if (mLimitedUserListCategory.getPreferenceCount() == 0) {
+                removePreference(KEY_LIMITED_USER_LIST);
+            }
+        }
     }
 
     private void loadIconsAsync(List<Integer> missingIcons) {
