Don't show SMS app settings for restricted profiles

Restricted profiles might not have an SMS app and there is
currently no UI to enable/disable SMS for restricted profiles. SMS
is disabled by default in this case. So hide the SMS app picker
option in restricted profiles.

Bug: 17521457
Change-Id: Id2bb3e4690a4afba75ebcec8531727ec150c5632
This commit is contained in:
Amith Yamasani
2014-11-12 13:46:43 -08:00
parent 64cb79bb69
commit 32505ac699

View File

@@ -260,7 +260,9 @@ public class WirelessSettings extends SettingsPreferenceFragment
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 @@ public class WirelessSettings extends SettingsPreferenceFragment
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
mSmsApplicationPreference = (AppListPreference) findPreference(KEY_SMS_APPLICATION);
// 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 @@ public class WirelessSettings extends SettingsPreferenceFragment
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 @@ public class WirelessSettings extends SettingsPreferenceFragment
}
// 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 @@ public class WirelessSettings extends SettingsPreferenceFragment
// 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 @@ public class WirelessSettings extends SettingsPreferenceFragment
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);
}