Network Reset should have a lockdown like Factory Reset.
bug:20332322
Change-Id: I645ad0d226869042c11225630e4de5968ebb7a0d
(cherry picked from commit 176f512c5ad8d8478db88fad4c14ffca52102ade)
diff --git a/res/layout/network_reset_disallowed_screen.xml b/res/layout/network_reset_disallowed_screen.xml
new file mode 100644
index 0000000..04f6fc2
--- /dev/null
+++ b/res/layout/network_reset_disallowed_screen.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2015 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/network_reset_not_available"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+</FrameLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 700ec0b..efb66bc 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2557,6 +2557,8 @@
<string name="reset_network_final_button_text">Reset settings</string>
<!-- Reset settings confirmation screen title [CHAR LIMIT=30] -->
<string name="reset_network_confirm_title">Reset?</string>
+ <!-- Error message for users that aren't allowed to reset network settings [CHAR LIMIT=none] -->
+ <string name="network_reset_not_available">Network reset is not available for this user</string>
<!-- Reset settings complete toast text [CHAR LIMIT=75] -->
<string name="reset_network_complete_toast">Network settings have been reset</string>
@@ -5860,6 +5862,7 @@
<string name="keywords_voice_input">recognizer input speech speak language hands-free hand free recognition offensive word audio history bluetooth headset</string>
<string name="keywords_text_to_speech_output">rate language default speak speaking tts accessibility reader blind</string>
<string name="keywords_date_and_time">clock military</string>
+ <string name="keywords_network_reset">reset restore factory</string>
<string name="keywords_factory_data_reset">wipe delete restore clear remove</string>
<string name="keywords_printing">printer</string>
<string name="keywords_sounds_and_notifications">speaker beep</string>
diff --git a/res/xml/privacy_settings.xml b/res/xml/privacy_settings.xml
index f9b4fbe..721a3bf 100644
--- a/res/xml/privacy_settings.xml
+++ b/res/xml/privacy_settings.xml
@@ -48,7 +48,9 @@
<!-- Network reset -->
<PreferenceScreen
+ android:key="network_reset"
android:title="@string/reset_network_title"
+ settings:keywords="@string/keywords_network_reset"
android:fragment="com.android.settings.ResetNetwork" />
<!-- Factory reset -->
diff --git a/src/com/android/settings/PrivacySettings.java b/src/com/android/settings/PrivacySettings.java
index 7c911cb..a295759 100644
--- a/src/com/android/settings/PrivacySettings.java
+++ b/src/com/android/settings/PrivacySettings.java
@@ -54,6 +54,7 @@
private static final String AUTO_RESTORE = "auto_restore";
private static final String CONFIGURE_ACCOUNT = "configure_account";
private static final String BACKUP_INACTIVE = "backup_inactive";
+ private static final String NETWORK_RESET = "network_reset";
private static final String FACTORY_RESET = "factory_reset";
private static final String TAG = "PrivacySettings";
private IBackupManager mBackupManager;
@@ -244,5 +245,9 @@
UserManager.DISALLOW_FACTORY_RESET)) {
nonVisibleKeys.add(FACTORY_RESET);
}
+ if (UserManager.get(context).hasUserRestriction(
+ UserManager.DISALLOW_NETWORK_RESET)) {
+ nonVisibleKeys.add(NETWORK_RESET);
+ }
}
}
diff --git a/src/com/android/settings/ResetNetwork.java b/src/com/android/settings/ResetNetwork.java
index 587b8e8..2e57dc3 100644
--- a/src/com/android/settings/ResetNetwork.java
+++ b/src/com/android/settings/ResetNetwork.java
@@ -26,6 +26,7 @@
import android.os.Bundle;
import android.os.Environment;
import android.os.SystemProperties;
+import android.os.Process;
import android.os.UserManager;
import android.preference.Preference;
import android.preference.PreferenceActivity;
@@ -191,6 +192,12 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ if (!Process.myUserHandle().isOwner()
+ || UserManager.get(getActivity()).hasUserRestriction(
+ UserManager.DISALLOW_NETWORK_RESET)) {
+ return inflater.inflate(R.layout.network_reset_disallowed_screen, null);
+ }
+
mContentView = inflater.inflate(R.layout.reset_network, null);
establishInitialState();
diff --git a/src/com/android/settings/ResetNetworkConfirm.java b/src/com/android/settings/ResetNetworkConfirm.java
index f67467b..7762b89 100644
--- a/src/com/android/settings/ResetNetworkConfirm.java
+++ b/src/com/android/settings/ResetNetworkConfirm.java
@@ -22,6 +22,7 @@
import android.net.NetworkPolicyManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.os.UserManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.view.LayoutInflater;
@@ -108,6 +109,10 @@
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
+ if (UserManager.get(getActivity()).hasUserRestriction(
+ UserManager.DISALLOW_NETWORK_RESET)) {
+ return inflater.inflate(R.layout.network_reset_disallowed_screen, null);
+ }
mContentView = inflater.inflate(R.layout.reset_network_confirm, null);
establishFinalConfirmationState();
return mContentView;