Merge "Settings user restriction changes: mobile network settings."
diff --git a/res/layout/telephony_disallowed_preference_screen.xml b/res/layout/telephony_disallowed_preference_screen.xml
new file mode 100644
index 0000000..18b4d94
--- /dev/null
+++ b/res/layout/telephony_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/mobile_network_settings_not_available"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f08ce8b..f09f428 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -114,6 +114,8 @@
<!-- settings strings -->
+ <!-- Error message for users that aren't allowed to modify Mobile Network settings [CHAR LIMIT=none] -->
+ <string name="mobile_network_settings_not_available">Mobile network settings are not available for this user</string>
<!-- GSM Call settings screen, setting option name -->
<string name="labelGSMMore">GSM call settings</string>
<!-- CDM Call settings screen, setting option name -->
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 9d0a2d5..0d466ed 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -33,6 +33,7 @@
import android.os.Handler;
import android.os.Message;
import android.os.SystemProperties;
+import android.os.UserManager;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -87,6 +88,7 @@
private static final String iface = "rmnet0"; //TODO: this will go away
+ private UserManager mUm;
private Phone mPhone;
private MyHandler mHandler;
private boolean mOkClicked;
@@ -98,6 +100,7 @@
private Preference mClickedPreference;
private boolean mShow4GForLTE;
private boolean mIsGlobalCdma;
+ private boolean mUnavailable;
//This is a method implemented for DialogInterface.OnClickListener.
// Used to dismiss the dialogs when they come up.
@@ -211,10 +214,17 @@
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
- addPreferencesFromResource(R.xml.network_setting);
-
mPhone = PhoneGlobals.getPhone();
mHandler = new MyHandler();
+ mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
+ if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
+ mUnavailable = true;
+ setContentView(R.layout.telephony_disallowed_preference_screen);
+ return;
+ }
+
+ addPreferencesFromResource(R.xml.network_setting);
try {
Context con = createPackageContext("com.android.systemui", 0);
@@ -338,6 +348,10 @@
protected void onResume() {
super.onResume();
+ if (mUnavailable) {
+ return;
+ }
+
// upon resumption from the sub-activity, make sure we re-enable the
// preferences.
getPreferenceScreen().setEnabled(true);
diff --git a/src/com/android/phone/NetworkSetting.java b/src/com/android/phone/NetworkSetting.java
index 5917795..874be30 100644
--- a/src/com/android/phone/NetworkSetting.java
+++ b/src/com/android/phone/NetworkSetting.java
@@ -29,6 +29,7 @@
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
+import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
@@ -72,6 +73,8 @@
Phone mPhone;
protected boolean mIsForeground = false;
+ private UserManager mUm;
+
/** message for network selection */
String mNetworkSelectMsg;
@@ -224,6 +227,13 @@
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
+ mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+
+ if (mUm.hasUserRestriction(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
+ setContentView(R.layout.telephony_disallowed_preference_screen);
+ return;
+ }
+
addPreferencesFromResource(R.xml.carrier_select);
mPhone = PhoneGlobals.getPhone();