diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/settings/ApnSettings.java | 21 | ||||
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 3 | ||||
-rw-r--r-- | src/com/android/settings/TetherSettings.java | 25 | ||||
-rw-r--r-- | src/com/android/settings/WirelessSettings.java | 24 | ||||
-rw-r--r-- | src/com/android/settings/vpn2/VpnSettings.java | 27 |
5 files changed, 90 insertions, 10 deletions
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java index 3fbb5e3ab..ef79f2bcb 100644 --- a/src/com/android/settings/ApnSettings.java +++ b/src/com/android/settings/ApnSettings.java @@ -32,6 +32,7 @@ import android.os.Handler; import android.os.HandlerThread; import android.os.Looper; import android.os.Message; +import android.os.UserManager; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceGroup; @@ -83,10 +84,14 @@ public class ApnSettings extends PreferenceActivity implements private RestoreApnProcessHandler mRestoreApnProcessHandler; private HandlerThread mRestoreDefaultApnThread; + private UserManager mUm; + private String mSelectedKey; private IntentFilter mMobileStateFilter; + private boolean mUnavailable; + private final BroadcastReceiver mMobileStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { @@ -119,6 +124,14 @@ public class ApnSettings extends PreferenceActivity implements protected void onCreate(Bundle icicle) { super.onCreate(icicle); + mUm = (UserManager) getSystemService(Context.USER_SERVICE); + + if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { + mUnavailable = true; + setContentView(R.layout.apn_disallowed_preference_screen); + return; + } + addPreferencesFromResource(R.xml.apn_settings); getListView().setItemsCanFocus(true); @@ -130,6 +143,10 @@ public class ApnSettings extends PreferenceActivity implements protected void onResume() { super.onResume(); + if (mUnavailable) { + return; + } + registerReceiver(mMobileStateReceiver, mMobileStateFilter); if (!mRestoreDefaultApnMode) { @@ -143,6 +160,10 @@ public class ApnSettings extends PreferenceActivity implements protected void onPause() { super.onPause(); + if (mUnavailable) { + return; + } + unregisterReceiver(mMobileStateReceiver); } diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index fe7a21731..264379331 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -467,6 +467,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment public void onPause() { super.onPause(); + if (mUnavailable) { + return; + } mSwitchBar.removeOnSwitchChangeListener(this); mSwitchBar.hide(); } diff --git a/src/com/android/settings/TetherSettings.java b/src/com/android/settings/TetherSettings.java index 4e0933d53..d960ce6da 100644 --- a/src/com/android/settings/TetherSettings.java +++ b/src/com/android/settings/TetherSettings.java @@ -47,6 +47,7 @@ import android.text.TextUtils; import android.view.ViewGroup; import android.view.ViewParent; import android.webkit.WebView; +import android.widget.TextView; import java.io.InputStream; import java.util.ArrayList; @@ -92,6 +93,7 @@ public class TetherSettings extends SettingsPreferenceFragment private WifiApDialog mDialog; private WifiManager mWifiManager; private WifiConfiguration mWifiConfig = null; + private UserManager mUm; private boolean mUsbConnected; private boolean mMassStorageActive; @@ -110,11 +112,21 @@ public class TetherSettings extends SettingsPreferenceFragment private String[] mProvisionApp; private static final int PROVISION_REQUEST = 0; + private boolean mUnavailable; + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.tether_prefs); + mUm = (UserManager) getSystemService(Context.USER_SERVICE); + + if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) { + mUnavailable = true; + setPreferenceScreen(new PreferenceScreen(getActivity(), null)); + return; + } + final Activity activity = getActivity(); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { @@ -264,6 +276,15 @@ public class TetherSettings extends SettingsPreferenceFragment public void onStart() { super.onStart(); + if (mUnavailable) { + TextView emptyView = (TextView) getView().findViewById(android.R.id.empty); + getListView().setEmptyView(emptyView); + if (emptyView != null) { + emptyView.setText(R.string.tethering_settings_not_available); + } + return; + } + final Activity activity = getActivity(); mMassStorageActive = Environment.MEDIA_SHARED.equals(Environment.getExternalStorageState()); @@ -297,6 +318,10 @@ public class TetherSettings extends SettingsPreferenceFragment @Override public void onStop() { super.onStop(); + + if (mUnavailable) { + return; + } getActivity().unregisterReceiver(mTetherChangeReceiver); mTetherChangeReceiver = null; if (mWifiApEnabler != null) { diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java index 7aaa0a6a9..507445f31 100644 --- a/src/com/android/settings/WirelessSettings.java +++ b/src/com/android/settings/WirelessSettings.java @@ -34,6 +34,7 @@ import android.nfc.NfcManager; import android.os.Bundle; import android.os.SystemProperties; import android.os.UserHandle; +import android.os.UserManager; import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; @@ -86,6 +87,7 @@ public class WirelessSettings extends RestrictedSettingsFragment private ConnectivityManager mCm; private TelephonyManager mTm; private PackageManager mPm; + private UserManager mUm; private static final int MANAGE_MOBILE_PLAN_DIALOG_ID = 1; private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage"; @@ -251,6 +253,7 @@ public class WirelessSettings extends RestrictedSettingsFragment mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mPm = getPackageManager(); + mUm = (UserManager) getSystemService(Context.USER_SERVICE); addPreferencesFromResource(R.xml.wireless_settings); @@ -296,10 +299,11 @@ public class WirelessSettings extends RestrictedSettingsFragment if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) { findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE); } - if (isSecondaryUser) { // Disable VPN + // Disable VPN. + if (isSecondaryUser || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) { removePreference(KEY_VPN_SETTINGS); } - protectByRestrictions(KEY_VPN_SETTINGS); + // Manually set dependencies for Bluetooth when not toggleable. if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) { // No bluetooth-dependent items in the list. Code kept in case one is added later. @@ -319,8 +323,10 @@ public class WirelessSettings extends RestrictedSettingsFragment mNfcEnabler = null; } - // Remove Mobile Network Settings and Manage Mobile Plan if it's a wifi-only device. - if (isSecondaryUser || Utils.isWifiOnly(getActivity())) { + // Remove Mobile Network Settings and Manage Mobile Plan for secondary users, + // if it's a wifi-only device, or if the settings are restricted. + if (isSecondaryUser || Utils.isWifiOnly(getActivity()) + || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) { removePreference(KEY_MOBILE_NETWORK_SETTINGS); removePreference(KEY_MANAGE_MOBILE_PLAN); } @@ -334,8 +340,6 @@ public class WirelessSettings extends RestrictedSettingsFragment removePreference(KEY_MANAGE_MOBILE_PLAN); } } - protectByRestrictions(KEY_MOBILE_NETWORK_SETTINGS); - protectByRestrictions(KEY_MANAGE_MOBILE_PLAN); // Remove SMS Application if the device does not support SMS if (!isSmsSupported()) { @@ -358,13 +362,13 @@ public class WirelessSettings extends RestrictedSettingsFragment // Disable Tethering if it's not allowed or if it's a wifi-only device final ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE); - if (isSecondaryUser || !cm.isTetheringSupported()) { + if (isSecondaryUser || !cm.isTetheringSupported() + || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING)) { getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS)); } else { Preference p = findPreference(KEY_TETHER_SETTINGS); p.setTitle(Utils.getTetheringLabel(cm)); } - protectByRestrictions(KEY_TETHER_SETTINGS); // Enable link to CMAS app settings depending on the value in config.xml. boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean( @@ -379,12 +383,12 @@ public class WirelessSettings extends RestrictedSettingsFragment } catch (IllegalArgumentException ignored) { isCellBroadcastAppLinkEnabled = false; // CMAS app not installed } - if (isSecondaryUser || !isCellBroadcastAppLinkEnabled) { + if (isSecondaryUser || !isCellBroadcastAppLinkEnabled + || mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_CELL_BROADCASTS)) { PreferenceScreen root = getPreferenceScreen(); Preference ps = findPreference(KEY_CELL_BROADCAST_SETTINGS); if (ps != null) root.removePreference(ps); } - protectByRestrictions(KEY_CELL_BROADCAST_SETTINGS); } @Override diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java index 73aae990b..ea6325e24 100644 --- a/src/com/android/settings/vpn2/VpnSettings.java +++ b/src/com/android/settings/vpn2/VpnSettings.java @@ -29,8 +29,10 @@ import android.os.Handler; import android.os.Message; import android.os.ServiceManager; import android.os.SystemProperties; +import android.os.UserManager; import android.preference.Preference; import android.preference.PreferenceGroup; +import android.preference.PreferenceScreen; import android.security.Credentials; import android.security.KeyStore; import android.text.TextUtils; @@ -45,6 +47,7 @@ import android.view.View; import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.ArrayAdapter; import android.widget.ListView; +import android.widget.TextView; import android.widget.Toast; import com.android.internal.net.LegacyVpnInfo; @@ -80,14 +83,25 @@ public class VpnSettings extends SettingsPreferenceFragment implements private Handler mUpdater; private LegacyVpnInfo mInfo; + private UserManager mUm; // The key of the profile for the current ContextMenu. private String mSelectedKey; + private boolean mUnavailable; + @Override public void onCreate(Bundle savedState) { super.onCreate(savedState); + mUm = (UserManager) getSystemService(Context.USER_SERVICE); + + if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_VPN)) { + mUnavailable = true; + setPreferenceScreen(new PreferenceScreen(getActivity(), null)); + return; + } + setHasOptionsMenu(true); addPreferencesFromResource(R.xml.vpn_settings2); @@ -156,6 +170,15 @@ public class VpnSettings extends SettingsPreferenceFragment implements public void onResume() { super.onResume(); + if (mUnavailable) { + TextView emptyView = (TextView) getView().findViewById(android.R.id.empty); + getListView().setEmptyView(emptyView); + if (emptyView != null) { + emptyView.setText(R.string.vpn_settings_not_available); + } + return; + } + final boolean pickLockdown = getActivity() .getIntent().getBooleanExtra(EXTRA_PICK_LOCKDOWN, false); if (pickLockdown) { @@ -214,6 +237,10 @@ public class VpnSettings extends SettingsPreferenceFragment implements public void onPause() { super.onPause(); + if (mUnavailable) { + return; + } + // Hide the dialog if there is one. if (mDialog != null) { mDialog.setOnDismissListener(null); |