Merge "Don't show SMS app settings for restricted profiles" into lmp-mr1-dev
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 4f92cf6..e9c39d9 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -260,7 +260,9 @@
 
         addPreferencesFromResource(R.xml.wireless_settings);
 
-        final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
+        final int myUserId = UserHandle.myUserId();
+        final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
+        final boolean isRestrictedUser = mUm.getUserInfo(myUserId).isRestricted();
 
         final Activity activity = getActivity();
         mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
@@ -272,8 +274,13 @@
         mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
 
         mSmsApplicationPreference = (AppListPreference) findPreference(KEY_SMS_APPLICATION);
-        mSmsApplicationPreference.setOnPreferenceChangeListener(this);
-        initSmsApplicationSetting();
+        // Restricted users cannot currently read/write SMS.
+        if (isRestrictedUser) {
+            removePreference(KEY_SMS_APPLICATION);
+        } else {
+            mSmsApplicationPreference.setOnPreferenceChangeListener(this);
+            initSmsApplicationSetting();
+        }
 
         // Remove NSD checkbox by default
         getPreferenceScreen().removePreference(nsd);
@@ -485,8 +492,11 @@
                 result.add(KEY_TOGGLE_NSD);
 
                 final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
-                final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
-                final boolean isWimaxEnabled = !isSecondaryUser && context.getResources().getBoolean(
+                final int myUserId = UserHandle.myUserId();
+                final boolean isSecondaryUser = myUserId != UserHandle.USER_OWNER;
+                final boolean isRestrictedUser = um.getUserInfo(myUserId).isRestricted();
+                final boolean isWimaxEnabled = !isSecondaryUser
+                        && context.getResources().getBoolean(
                         com.android.internal.R.bool.config_wimaxEnabled);
                 if (!isWimaxEnabled
                         || um.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
@@ -498,7 +508,8 @@
                 }
 
                 // Remove NFC if not available
-                final NfcManager manager = (NfcManager) context.getSystemService(Context.NFC_SERVICE);
+                final NfcManager manager = (NfcManager)
+                        context.getSystemService(Context.NFC_SERVICE);
                 if (manager != null) {
                     NfcAdapter adapter = manager.getDefaultAdapter();
                     if (adapter == null) {
@@ -524,7 +535,7 @@
                 // Remove SMS Application if the device does not support SMS
                 TelephonyManager tm =
                         (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
-                if (!tm.isSmsCapable()) {
+                if (!tm.isSmsCapable() || isRestrictedUser) {
                     result.add(KEY_SMS_APPLICATION);
                 }
 
@@ -539,8 +550,8 @@
                 result.add(KEY_PROXY_SETTINGS);
 
                 // Disable Tethering if it's not allowed or if it's a wifi-only device
-                ConnectivityManager cm =
-                        (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+                ConnectivityManager cm = (ConnectivityManager)
+                        context.getSystemService(Context.CONNECTIVITY_SERVICE);
                 if (isSecondaryUser || !cm.isTetheringSupported()) {
                     result.add(KEY_TETHER_SETTINGS);
                 }