summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2014-06-09 19:22:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-09 19:22:19 +0000
commitc92af83b0c94eaf99f1c4d9675b39b4a73a958cc (patch)
tree2c648d82b763588ef614d6d997895d0aa0a7af75
parent51d898fd0223a4b7c728980ab987dd985c02df5f (diff)
parentee27b9de8f2ab17d50b90dd8c13546aebb4e9fc1 (diff)
downloadpackages_apps_Settings-c92af83b0c94eaf99f1c4d9675b39b4a73a958cc.zip
packages_apps_Settings-c92af83b0c94eaf99f1c4d9675b39b4a73a958cc.tar.gz
packages_apps_Settings-c92af83b0c94eaf99f1c4d9675b39b4a73a958cc.tar.bz2
Merge "Settings user restriction changes: wireless & networks changes."
-rw-r--r--res/layout/apn_disallowed_preference_screen.xml39
-rw-r--r--res/values/strings.xml6
-rw-r--r--src/com/android/settings/ApnSettings.java21
-rw-r--r--src/com/android/settings/DevelopmentSettings.java3
-rw-r--r--src/com/android/settings/TetherSettings.java25
-rw-r--r--src/com/android/settings/WirelessSettings.java24
-rw-r--r--src/com/android/settings/vpn2/VpnSettings.java27
7 files changed, 135 insertions, 10 deletions
diff --git a/res/layout/apn_disallowed_preference_screen.xml b/res/layout/apn_disallowed_preference_screen.xml
new file mode 100644
index 0000000..25f6f37
--- /dev/null
+++ b/res/layout/apn_disallowed_preference_screen.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2014 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.
+ */
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/listContainer"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ListView android:id="@android:id/list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:drawSelectorOnTop="false"
+ android:scrollbarStyle="insideOverlay"
+ android:background="@android:color/white"
+ android:cacheColorHint="@android:color/white"
+ android:fadingEdgeLength="16dip" />
+
+ <TextView android:id="@+android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:text="@string/apn_settings_not_available"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+</FrameLayout> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 72f8408..f8dc7b5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3132,6 +3132,12 @@
<!-- Setting checkbox title for Whether to enable USB debugging support on the phone. -->
<!-- Error message for users that aren't allowed to modify developer options [CHAR LIMIT=none] -->
<string name="development_settings_not_available">Developer options are not available for this user</string>
+ <!-- Error message for users that aren't allowed to modify VPN settings [CHAR LIMIT=none] -->
+ <string name="vpn_settings_not_available">VPN settings are not available for this user</string>
+ <!-- Error message for users that aren't allowed to modify Tethering settings [CHAR LIMIT=none] -->
+ <string name="tethering_settings_not_available">Tethering settings are not available for this user</string>
+ <!-- Error message for users that aren't allowed to modify Access Point Names settings [CHAR LIMIT=none] -->
+ <string name="apn_settings_not_available">Access Point Name settings are not available for this user</string>
<string name="enable_adb">USB debugging</string>
<!-- Setting checkbox summary for Whether to enable USB debugging support on the phone -->
<string name="enable_adb_summary">Debug mode when USB is connected</string>
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java
index 3fbb5e3..ef79f2b 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 fe7a217..2643793 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 4e0933d..d960ce6 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 7aaa0a6..507445f 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 73aae99..ea6325e 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);