Merge "Don't show SMS app settings for restricted profiles" into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c395b9f37a
@@ -260,7 +260,9 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
addPreferencesFromResource(R.xml.wireless_settings);
|
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();
|
final Activity activity = getActivity();
|
||||||
mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
|
mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
|
||||||
@@ -272,8 +274,13 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
|||||||
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
|
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam);
|
||||||
|
|
||||||
mSmsApplicationPreference = (AppListPreference) findPreference(KEY_SMS_APPLICATION);
|
mSmsApplicationPreference = (AppListPreference) findPreference(KEY_SMS_APPLICATION);
|
||||||
mSmsApplicationPreference.setOnPreferenceChangeListener(this);
|
// Restricted users cannot currently read/write SMS.
|
||||||
initSmsApplicationSetting();
|
if (isRestrictedUser) {
|
||||||
|
removePreference(KEY_SMS_APPLICATION);
|
||||||
|
} else {
|
||||||
|
mSmsApplicationPreference.setOnPreferenceChangeListener(this);
|
||||||
|
initSmsApplicationSetting();
|
||||||
|
}
|
||||||
|
|
||||||
// Remove NSD checkbox by default
|
// Remove NSD checkbox by default
|
||||||
getPreferenceScreen().removePreference(nsd);
|
getPreferenceScreen().removePreference(nsd);
|
||||||
@@ -485,8 +492,11 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
|||||||
result.add(KEY_TOGGLE_NSD);
|
result.add(KEY_TOGGLE_NSD);
|
||||||
|
|
||||||
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||||
final boolean isSecondaryUser = UserHandle.myUserId() != UserHandle.USER_OWNER;
|
final int myUserId = UserHandle.myUserId();
|
||||||
final boolean isWimaxEnabled = !isSecondaryUser && context.getResources().getBoolean(
|
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);
|
com.android.internal.R.bool.config_wimaxEnabled);
|
||||||
if (!isWimaxEnabled
|
if (!isWimaxEnabled
|
||||||
|| um.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
|
|| um.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
|
||||||
@@ -498,7 +508,8 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove NFC if not available
|
// 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) {
|
if (manager != null) {
|
||||||
NfcAdapter adapter = manager.getDefaultAdapter();
|
NfcAdapter adapter = manager.getDefaultAdapter();
|
||||||
if (adapter == null) {
|
if (adapter == null) {
|
||||||
@@ -524,7 +535,7 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
|||||||
// Remove SMS Application if the device does not support SMS
|
// Remove SMS Application if the device does not support SMS
|
||||||
TelephonyManager tm =
|
TelephonyManager tm =
|
||||||
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
if (!tm.isSmsCapable()) {
|
if (!tm.isSmsCapable() || isRestrictedUser) {
|
||||||
result.add(KEY_SMS_APPLICATION);
|
result.add(KEY_SMS_APPLICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,8 +550,8 @@ public class WirelessSettings extends SettingsPreferenceFragment
|
|||||||
result.add(KEY_PROXY_SETTINGS);
|
result.add(KEY_PROXY_SETTINGS);
|
||||||
|
|
||||||
// Disable Tethering if it's not allowed or if it's a wifi-only device
|
// Disable Tethering if it's not allowed or if it's a wifi-only device
|
||||||
ConnectivityManager cm =
|
ConnectivityManager cm = (ConnectivityManager)
|
||||||
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
if (isSecondaryUser || !cm.isTetheringSupported()) {
|
if (isSecondaryUser || !cm.isTetheringSupported()) {
|
||||||
result.add(KEY_TETHER_SETTINGS);
|
result.add(KEY_TETHER_SETTINGS);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user