Merge "Update data usage UX"
diff --git a/res/drawable/ic_signal_workmode_enable.xml b/res/drawable/ic_signal_workmode_enable.xml
new file mode 100644
index 0000000..49af897
--- /dev/null
+++ b/res/drawable/ic_signal_workmode_enable.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+     Copyright (C) 2016 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:name="root"
+    android:height="42dp"
+    android:width="42dp"
+    android:viewportHeight="42"
+    android:viewportWidth="42" >
+    <group
+        android:name="ic_signal_briefcase"
+        android:translateX="21.9995"
+        android:translateY="25.73401" >
+        <group
+            android:name="ic_signal_briefcase_pivot"
+            android:translateX="-23.21545"
+            android:translateY="-18.86649" >
+            <clip-path
+                android:name="mask"
+                android:pathData="M 37.8337860107,-40.3974914551 c 0.0,0.0 -35.8077850342,31.5523681641 -35.8077850342,31.5523681641 c 0.0,0.0 40.9884796143,40.9278411865 40.9884796143,40.9278411865 c 0.0,0.0 -2.61700439453,2.0938873291 -2.61700439453,2.0938873291 c 0.0,0.0 -41.1884460449,-40.9392852783 -41.1884460449,-40.9392852783 c 0.0,0.0 -34.6200408936,25.4699249268 -34.6200408936,25.4699249268 c 0.0,0.0 55.9664764404,69.742401123 55.9664764404,69.742401123 c 0.0,0.0 73.2448120117,-59.1047973633 73.2448120117,-59.1047973633 c 0.0,0.0 -55.9664916992,-69.7423400879 -55.9664916992,-69.7423400879 Z" />
+            <group
+                android:name="cross" >
+                <path
+                    android:name="cross_1"
+                    android:pathData="M 7.54049682617,3.9430847168 c 0.0,0.0 31.5749816895,31.4499664307 31.5749816895,31.4499664307 "
+                    android:strokeColor="#FFFFFFFF"
+                    android:strokeAlpha="1"
+                    android:strokeWidth="3.5"
+                    android:fillColor="#00000000" />
+            </group>
+            <group
+                android:name="briefcase"
+                android:translateX="23.481"
+                android:translateY="18.71151" >
+                <path
+                    android:fillColor="#FFFFFFFF"
+                    android:fillAlpha="1"
+                    android:pathData="M-4.83333,-14.3333 L-7.16667,-11.8333 L-7.16667,-9.5 L-4.83333,-9.5 L-4.83333,-11.8333 L4.83333,-11.8333 L4.83333,-9.5 L7.16667,-9.5 L7.16667,-11.8333 L4.83333,-14.3333 Z" />
+                <path
+                    android:fillColor="#FFFFFFFF"
+                    android:fillAlpha="1"
+                    android:pathData="M13.1667,-9.5 L-13.1667,-9.5 C-14.5,-9.5,-15.5,-8.5,-15.5,-7.16666 L-15.5,0.00000286102 C-15.5,1.33334,-14.5,2.33334,-13.1667,2.33334 L-3.66667,2.33334 L-3.66667,0.00000286102 L3.5,0.00000286102 L3.5,2.33334 L13,2.33334 C14.3333,2.33334,15.3333,1.33334,15.3333,0 L15.3333,-7.16666 C15.5,-8.5,14.3333,-9.5,13.1667,-9.5 Z" />
+                <path
+                    android:fillColor="#FFFFFFFF"
+                    android:fillAlpha="1"
+                    android:pathData="M-3.5,7.16667 L-3.5,4.83334 L-14.3333,4.83334 L-14.3333,10.8333 C-14.3333,12.1667,-13.3333,13.1667,-12,13.1667 L11.8333,13.1667 C13.1667,13.1667,14.1667,12.1667,14.1667,10.8333 L14.1667,4.83334 L3.5,4.83334 L3.5,7.16667 L-3.5,7.16667 Z" />
+            </group>
+        </group>
+    </group>
+</vector>
diff --git a/res/layout/redaction_interstitial.xml b/res/layout/redaction_interstitial.xml
index 14e57f8..73a9e5c 100644
--- a/res/layout/redaction_interstitial.xml
+++ b/res/layout/redaction_interstitial.xml
@@ -24,7 +24,7 @@
         android:paddingEnd="?attr/side_margin">
 
     <TextView
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="@dimen/redaction_vertical_margins"
             android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
diff --git a/res/layout/setup_redaction_interstitial.xml b/res/layout/setup_redaction_interstitial.xml
index f5954a1..6eef9ce 100644
--- a/res/layout/setup_redaction_interstitial.xml
+++ b/res/layout/setup_redaction_interstitial.xml
@@ -36,7 +36,7 @@
 
         <TextView
             style="@style/SuwDescription"
-            android:layout_width="wrap_content"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
             android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd"
diff --git a/res/values/config.xml b/res/values/config.xml
index f96662c..3f25fc6 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -35,4 +35,7 @@
     <!-- Carrier_enabled editable -->
     <bool name="config_allow_edit_carrier_enabled" translatable="false">false</bool>
 
+    <!-- When true enable color temperature setting. -->
+    <bool name="config_enableColorTemperature">false</bool>
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f0f75e4..dea1620 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4621,6 +4621,10 @@
     <string name="add_account_label">Add account</string>
     <!-- Label for the state of the work profile [CHAR LIMIT=80] -->
     <string name="managed_profile_not_available_label">Work profile isn\u2019t available yet</string>
+    <!-- Account Settings. The preference title for enabling work mode -->
+    <string name="work_mode_label">Work mode</string>
+    <!-- Account Settings. The preference summary for enabling work mode -->
+    <string name="work_mode_summary">Allow work profile to function, including apps, background sync, and related features</string>
     <!-- Button label to remove the work profile [CHAR LIMIT=35] -->
     <string name="remove_managed_profile_label">Remove work profile</string>
     <!-- Data synchronization settings screen, title of setting that controls whether background data should be used [CHAR LIMIT=30] -->
@@ -6798,6 +6802,12 @@
     <!-- Summary of condition that background data is off [CHAR LIMIT=NONE] -->
     <string name="condition_bg_data_summary">Background data is only available via Wi-Fi. This may affect some apps or services when Wi-Fi is not available.</string>
 
+    <!-- Title of condition that work mode is off [CHAR LIMIT=30] -->
+    <string name="condition_work_title">Work profile is off</string>
+
+    <!-- Summary of condition that work mode is off [CHAR LIMIT=NONE] -->
+    <string name="condition_work_summary">Apps, background sync, and other features related to your work profile are turned off.</string>
+
     <!-- Title for the suggestions section on the dashboard [CHAR LIMIT=30] -->
     <string name="suggestions_title">Suggestions (<xliff:g name="count" example="3">%1$d</xliff:g>)</string>
 
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index d359d84..0aec43f 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -19,7 +19,7 @@
         android:title="@string/date_and_time"
         settings:keywords="@string/keywords_date_and_time">
 
-    <SwitchPreference android:key="auto_time"
+    <com.android.settingslib.RestrictedSwitchPreference android:key="auto_time"
         android:title="@string/date_time_auto"
         android:summaryOn="@string/date_time_auto_summaryOn"
         android:summaryOff="@string/date_time_auto_summaryOff"
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index ea4750e..6335c4e 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -86,6 +86,12 @@
         android:dialogTitle="@string/select_webview_provider_dialog_title"
         android:summary="%s" />
 
+    <SwitchPreference
+        android:key="color_temperature"
+        android:title="@string/color_temperature"
+        android:summary="@string/color_temperature_desc"
+        android:persistent="false" />
+
     <PreferenceCategory android:key="debug_debugging_category"
             android:title="@string/debug_debugging_category">
 
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index e0828e5..a437547 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -64,10 +64,8 @@
             android:title="@string/credentials_title"
             android:persistent="false">
 
-        <Preference android:key="credential_storage_type"
+        <com.android.settingslib.RestrictedPreference android:key="credential_storage_type"
                 android:title="@string/credential_storage_type"
-                android:enabled="false"
-                android:shouldDisableView="false"
                 android:persistent="false" />
 
         <Preference android:key="trusted_credentials"
@@ -82,7 +80,7 @@
                 android:persistent="false"
                 android:fragment="com.android.settings.UserCredentialsSettings"/>
 
-        <Preference android:key="credentials_install"
+        <com.android.settingslib.RestrictedPreference android:key="credentials_install"
                 android:title="@string/credentials_install"
                 android:summary="@string/credentials_install_summary"
                 android:persistent="false">
@@ -91,9 +89,9 @@
                     android:targetPackage="com.android.certinstaller"
                     android:targetClass="com.android.certinstaller.CertInstallerMain"/>
 
-        </Preference>
+        </com.android.settingslib.RestrictedPreference>
 
-        <Preference android:key="credentials_reset"
+        <com.android.settingslib.RestrictedPreference android:key="credentials_reset"
                 android:title="@string/credentials_reset"
                 android:summary="@string/credentials_reset_summary"
                 android:persistent="false">
@@ -102,7 +100,7 @@
                     android:targetPackage="com.android.settings"
                     android:targetClass="com.android.settings.CredentialStorage"/>
 
-        </Preference>
+        </com.android.settingslib.RestrictedPreference>
 
     </PreferenceCategory>
 
diff --git a/res/xml/security_settings_picker.xml b/res/xml/security_settings_picker.xml
index e0c5185..3a45697 100644
--- a/res/xml/security_settings_picker.xml
+++ b/res/xml/security_settings_picker.xml
@@ -18,27 +18,27 @@
         android:title="@string/lock_settings_picker_title"
         android:key="lock_settings_picker">
 
-    <PreferenceScreen
+    <com.android.settingslib.RestrictedPreference
             android:key="unlock_set_off"
             android:title="@string/unlock_set_unlock_off_title"
             android:persistent="false"/>
 
-    <PreferenceScreen
+    <com.android.settingslib.RestrictedPreference
             android:key="unlock_set_none"
             android:title="@string/unlock_set_unlock_none_title"
             android:persistent="false"/>
 
-    <PreferenceScreen
+    <com.android.settingslib.RestrictedPreference
             android:key="unlock_set_pattern"
             android:title="@string/unlock_set_unlock_pattern_title"
             android:persistent="false"/>
 
-    <PreferenceScreen
+    <com.android.settingslib.RestrictedPreference
             android:key="unlock_set_pin"
             android:title="@string/unlock_set_unlock_pin_title"
             android:persistent="false"/>
 
-    <PreferenceScreen
+    <com.android.settingslib.RestrictedPreference
             android:key="unlock_set_password"
             android:title="@string/unlock_set_unlock_password_title"
             android:persistent="false"/>
diff --git a/src/com/android/settings/ChooseLockGeneric.java b/src/com/android/settings/ChooseLockGeneric.java
index bd46456..3d35bc8 100644
--- a/src/com/android/settings/ChooseLockGeneric.java
+++ b/src/com/android/settings/ChooseLockGeneric.java
@@ -45,6 +45,10 @@
 
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.widget.LockPatternUtils;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedPreference;
+
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
 public class ChooseLockGeneric extends SettingsActivity {
     public static final String CONFIRM_CREDENTIALS = "confirm_credentials";
@@ -367,39 +371,60 @@
                 boolean hideDisabled) {
             final PreferenceScreen entries = getPreferenceScreen();
 
+            int adminEnforcedQuality = mDPM.getPasswordQuality(null);
+            EnforcedAdmin enforcedAdmin = RestrictedLockUtils.checkIfPasswordQualityIsSet(
+                    getActivity());
             for (int i = entries.getPreferenceCount() - 1; i >= 0; --i) {
                 Preference pref = entries.getPreference(i);
-                if (pref instanceof PreferenceScreen) {
+                if (pref instanceof RestrictedPreference) {
                     final String key = pref.getKey();
                     boolean enabled = true;
                     boolean visible = true;
+                    boolean disabledByAdmin = false;
                     if (KEY_UNLOCK_SET_OFF.equals(key)) {
                         enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
                         if (getResources().getBoolean(R.bool.config_hide_none_security_option)) {
                             enabled = false;
                             visible = false;
                         }
+                        disabledByAdmin = adminEnforcedQuality
+                                > DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
                     } else if (KEY_UNLOCK_SET_NONE.equals(key)) {
                         if (mUserId != UserHandle.myUserId()) {
                             // Swipe doesn't make sense for profiles.
                             visible = false;
                         }
                         enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
+                        disabledByAdmin = adminEnforcedQuality
+                                > DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
                     } else if (KEY_UNLOCK_SET_PATTERN.equals(key)) {
                         enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
+                        disabledByAdmin = adminEnforcedQuality
+                                > DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
                     } else if (KEY_UNLOCK_SET_PIN.equals(key)) {
                         enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX;
+                        disabledByAdmin = adminEnforcedQuality
+                                > DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX;
                     } else if (KEY_UNLOCK_SET_PASSWORD.equals(key)) {
                         enabled = quality <= DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
+                        disabledByAdmin = adminEnforcedQuality
+                                > DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
                     }
                     if (hideDisabled) {
                         visible = enabled;
                     }
                     if (!visible) {
                         entries.removePreference(pref);
+                    } else if (disabledByAdmin && enforcedAdmin != null) {
+                        ((RestrictedPreference) pref).setDisabledByAdmin(enforcedAdmin);
                     } else if (!enabled) {
+                        // we need to setDisabledByAdmin to null first to disable the padlock
+                        // in case it was set earlier.
+                        ((RestrictedPreference) pref).setDisabledByAdmin(null);
                         pref.setSummary(R.string.unlock_set_unlock_disabled_summary);
                         pref.setEnabled(false);
+                    } else {
+                        ((RestrictedPreference) pref).setDisabledByAdmin(null);
                     }
                 }
             }
diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java
index d92d610..6602c3e 100644
--- a/src/com/android/settings/DateTimeSettings.java
+++ b/src/com/android/settings/DateTimeSettings.java
@@ -39,11 +39,15 @@
 
 import com.android.internal.logging.MetricsLogger;
 import com.android.settings.dashboard.SummaryLoader;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
 import com.android.settingslib.datetime.ZoneGetter;
 
 import java.util.Calendar;
 import java.util.Date;
 
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 public class DateTimeSettings extends SettingsPreferenceFragment
         implements OnSharedPreferenceChangeListener,
                 TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
@@ -64,7 +68,7 @@
     // have we been launched from the setup wizard?
     protected static final String EXTRA_IS_FIRST_RUN = "firstRun";
 
-    private SwitchPreference mAutoTimePref;
+    private RestrictedSwitchPreference mAutoTimePref;
     private Preference mTimePref;
     private Preference mTime24Pref;
     private SwitchPreference mAutoTimeZonePref;
@@ -89,23 +93,17 @@
         boolean autoTimeEnabled = getAutoState(Settings.Global.AUTO_TIME);
         boolean autoTimeZoneEnabled = getAutoState(Settings.Global.AUTO_TIME_ZONE);
 
-        mAutoTimePref = (SwitchPreference) findPreference(KEY_AUTO_TIME);
-
-        DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context
-                .DEVICE_POLICY_SERVICE);
-        if (dpm.getAutoTimeRequired()) {
-            mAutoTimePref.setEnabled(false);
-
-            // If Settings.Global.AUTO_TIME is false it will be set to true
-            // by the device policy manager very soon.
-            // Note that this app listens to that change.
-        }
+        mAutoTimePref = (RestrictedSwitchPreference) findPreference(KEY_AUTO_TIME);
+        EnforcedAdmin admin = RestrictedLockUtils.checkIfAutoTimeRequired(getActivity());
+        mAutoTimePref.setDisabledByAdmin(admin);
 
         Intent intent = getActivity().getIntent();
         boolean isFirstRun = intent.getBooleanExtra(EXTRA_IS_FIRST_RUN, false);
 
         mDummyDate = Calendar.getInstance();
 
+        // If device admin requires auto time device policy manager will set
+        // Settings.Global.AUTO_TIME to true. Note that this app listens to that change.
         mAutoTimePref.setChecked(autoTimeEnabled);
         mAutoTimeZonePref = (SwitchPreference) findPreference(KEY_AUTO_TIME_ZONE);
         // Override auto-timezone if it's a wifi-only device or if we're still in setup wizard.
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 34bf00e..a1d9750 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -124,6 +124,7 @@
     private static final String BUGREPORT_IN_POWER_KEY = "bugreport_in_power";
     private static final String OPENGL_TRACES_PROPERTY = "debug.egl.trace";
     private static final String TUNER_UI_KEY = "tuner_ui";
+    private static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp";
 
     private static final String DEBUG_APP_KEY = "debug_app";
     private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
@@ -177,6 +178,7 @@
     private static final String KEY_COLOR_MODE = "color_mode";
     private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
     private static final String ENABLE_FREEFORM_SUPPORT_KEY = "enable_freeform_support";
+    private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
 
     private static final String INACTIVE_APPS_KEY = "inactive_apps";
 
@@ -285,6 +287,8 @@
 
     private SwitchPreference mEnableFreeformSupport;
 
+    private SwitchPreference mColorTemperaturePreference;
+
     private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
 
     private final ArrayList<SwitchPreference> mResetSwitchPrefs
@@ -480,6 +484,15 @@
             mColorModePreference = null;
         }
         updateWebViewProviderOptions();
+
+        mColorTemperaturePreference = (SwitchPreference) findPreference(COLOR_TEMPERATURE_KEY);
+        if (getResources().getBoolean(R.bool.config_enableColorTemperature)) {
+            mAllPrefs.add(mColorTemperaturePreference);
+            mResetSwitchPrefs.add(mColorTemperaturePreference);
+        } else {
+            removePreference(COLOR_TEMPERATURE_KEY);
+            mColorTemperaturePreference = null;
+        }
     }
 
     private ListPreference addListPreference(String prefKey) {
@@ -690,6 +703,9 @@
         updateForceResizableOptions();
         updateEnableFreeformWindowsSupportOptions();
         updateWebViewProviderOptions();
+        if (mColorTemperaturePreference != null) {
+            updateColorTemperature();
+        }
     }
 
     private void resetDangerousOptions() {
@@ -1257,6 +1273,17 @@
         }
     }
 
+    private void updateColorTemperature() {
+        updateSwitchPreference(mColorTemperaturePreference,
+                SystemProperties.getBoolean(COLOR_TEMPERATURE_PROPERTY, false));
+    }
+
+    private void writeColorTemperature() {
+        SystemProperties.set(COLOR_TEMPERATURE_PROPERTY,
+                mColorTemperaturePreference.isChecked() ? "1" : "0");
+        pokeSystemProperties();
+    }
+
     private void updateUSBAudioOptions() {
         updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
                 Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
@@ -1762,12 +1789,12 @@
         } else if (preference == mBtHciSnoopLog) {
             writeBtHciSnoopLogOptions();
         } else if (preference == mEnableOemUnlock) {
-            if (!showKeyguardConfirmation(getResources(), REQUEST_CODE_ENABLE_OEM_UNLOCK)) {
-                if (mEnableOemUnlock.isChecked()) {
+            if (mEnableOemUnlock.isChecked()) {
+                if (!showKeyguardConfirmation(getResources(), REQUEST_CODE_ENABLE_OEM_UNLOCK)) {
                     confirmEnableOemUnlock();
-                } else {
-                    Utils.setOemUnlockEnabled(getActivity(), false);
                 }
+            } else {
+                Utils.setOemUnlockEnabled(getActivity(), false);
             }
         } else if (preference == mMockLocationAppPref) {
             Intent intent = new Intent(getActivity(), AppPicker.class);
@@ -1830,6 +1857,8 @@
             writeLegacyDhcpClientOptions();
         } else if (preference == mMobileDataAlwaysOn) {
             writeMobileDataAlwaysOnOptions();
+        } else if (preference == mColorTemperaturePreference) {
+            writeColorTemperature();
         } else if (preference == mUSBAudio) {
             writeUSBAudioOptions();
         } else if (preference == mForceResizable) {
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 1221624..d39203d 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -61,6 +61,7 @@
 import com.android.settings.search.Index;
 import com.android.settings.search.Indexable;
 import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.RestrictedPreference;
 import com.android.settingslib.RestrictedSwitchPreference;
 
 import java.util.ArrayList;
@@ -130,7 +131,7 @@
     private SwitchPreference mShowPassword;
 
     private KeyStore mKeyStore;
-    private Preference mResetCredentials;
+    private RestrictedPreference mResetCredentials;
 
     private RestrictedSwitchPreference mToggleAppInstallation;
     private DialogInterface mWarnInstallApps;
@@ -310,25 +311,26 @@
 
         // Show password
         mShowPassword = (SwitchPreference) root.findPreference(KEY_SHOW_PASSWORD);
-        mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
+        mResetCredentials = (RestrictedPreference) root.findPreference(KEY_RESET_CREDENTIALS);
 
         // Credential storage
         final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE);
         mKeyStore = KeyStore.getInstance(); // needs to be initialized for onResume()
-        if (!um.hasUserRestriction(UserManager.DISALLOW_CONFIG_CREDENTIALS)) {
-            Preference credentialStorageType = root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE);
 
-            final int storageSummaryRes =
+        RestrictedPreference credentialStorageType = (RestrictedPreference) root.findPreference(
+                KEY_CREDENTIAL_STORAGE_TYPE);
+        credentialStorageType.checkRestrictionAndSetDisabled(
+                UserManager.DISALLOW_CONFIG_CREDENTIALS);
+        RestrictedPreference installCredentials = (RestrictedPreference) root.findPreference(
+                KEY_CREDENTIALS_INSTALL);
+        installCredentials.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_CREDENTIALS);
+        mResetCredentials.checkRestrictionAndSetDisabled(UserManager.DISALLOW_CONFIG_CREDENTIALS);
+
+        final int storageSummaryRes =
                 mKeyStore.isHardwareBacked() ? R.string.credential_storage_type_hardware
                         : R.string.credential_storage_type_software;
-            credentialStorageType.setSummary(storageSummaryRes);
-        } else {
-            PreferenceGroup credentialsManager = (PreferenceGroup)
-                    root.findPreference(KEY_CREDENTIALS_MANAGER);
-            credentialsManager.removePreference(root.findPreference(KEY_RESET_CREDENTIALS));
-            credentialsManager.removePreference(root.findPreference(KEY_CREDENTIALS_INSTALL));
-            credentialsManager.removePreference(root.findPreference(KEY_CREDENTIAL_STORAGE_TYPE));
-        }
+        credentialStorageType.setSummary(storageSummaryRes);
+
 
         // Application install
         PreferenceGroup deviceAdminCategory = (PreferenceGroup)
@@ -649,7 +651,7 @@
                     Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
         }
 
-        if (mResetCredentials != null) {
+        if (mResetCredentials != null && !mResetCredentials.isDisabledByAdmin()) {
             mResetCredentials.setEnabled(!mKeyStore.isEmpty());
         }
 
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 7aa5a76..f56ebe0 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -52,6 +52,8 @@
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.search.Indexable;
 import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.RestrictedPreference;
+import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
 import java.util.ArrayList;
@@ -61,6 +63,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 /**
  * Activity with the accessibility settings.
  */
@@ -476,8 +480,7 @@
         for (int i = 0, count = installedServices.size(); i < count; ++i) {
             AccessibilityServiceInfo info = installedServices.get(i);
 
-            PreferenceScreen preference = getPreferenceManager().createPreferenceScreen(
-                    getActivity());
+            RestrictedPreference preference = new RestrictedPreference(getActivity());
             String title = info.getResolveInfo().loadLabel(getPackageManager()).toString();
 
             ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
@@ -500,7 +503,17 @@
             String packageName = serviceInfo.packageName;
             boolean serviceAllowed =
                     permittedServices == null || permittedServices.contains(packageName);
-            preference.setEnabled(serviceAllowed || serviceEnabled);
+            if (!serviceAllowed && !serviceEnabled) {
+                EnforcedAdmin admin =
+                        RestrictedLockUtils.getProfileOrDeviceOwnerOnCallingUser(getActivity());
+                if (admin != null) {
+                    preference.setDisabledByAdmin(admin);
+                } else {
+                    preference.setEnabled(false);
+                }
+            } else {
+                preference.setEnabled(true);
+            }
 
             String summaryString;
             if (serviceAllowed) {
diff --git a/src/com/android/settings/accounts/AccountSettings.java b/src/com/android/settings/accounts/AccountSettings.java
index 3942fbb..4296689 100644
--- a/src/com/android/settings/accounts/AccountSettings.java
+++ b/src/com/android/settings/accounts/AccountSettings.java
@@ -39,8 +39,10 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.provider.SearchIndexableResource;
+import android.support.v14.preference.SwitchPreference;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.Preference.OnPreferenceClickListener;
+import android.support.v7.preference.Preference.OnPreferenceChangeListener;
 import android.support.v7.preference.PreferenceGroup;
 import android.support.v7.preference.PreferenceScreen;
 import android.util.Log;
@@ -80,7 +82,7 @@
  */
 public class AccountSettings extends SettingsPreferenceFragment
         implements AuthenticatorHelper.OnAccountsUpdateListener,
-        OnPreferenceClickListener, Indexable {
+        OnPreferenceClickListener, OnPreferenceChangeListener, Indexable {
     public static final String TAG = "AccountSettings";
 
     private static final String KEY_ACCOUNT = "account";
@@ -88,8 +90,9 @@
     private static final String ADD_ACCOUNT_ACTION = "android.settings.ADD_ACCOUNT_SETTINGS";
     private static final String TAG_CONFIRM_AUTO_SYNC_CHANGE = "confirmAutoSyncChange";
 
-    private static final int ORDER_LAST = 1001;
-    private static final int ORDER_NEXT_TO_LAST = 1000;
+    private static final int ORDER_LAST = 1002;
+    private static final int ORDER_NEXT_TO_LAST = 1001;
+    private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
 
     private UserManager mUm;
     private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
@@ -112,6 +115,10 @@
          */
         public Preference addAccountPreference;
         /**
+         * The preference that displays the button to toggle work profile.
+         */
+        public SwitchPreference workModeSwitch;
+        /**
          * The preference that displays the button to remove the managed profile
          */
         public Preference removeWorkProfilePreference;
@@ -234,6 +241,21 @@
         return false;
     }
 
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        // Check the preference
+        final int count = mProfiles.size();
+        for (int i = 0; i < count; i++) {
+            ProfileData profileData = mProfiles.valueAt(i);
+            if (preference == profileData.workModeSwitch) {
+                final int userId = profileData.userInfo.id;
+                mUm.setQuietModeEnabled(userId, !((boolean) newValue));
+                return true;
+            }
+        }
+        return false;
+    }
+
     void updateUi() {
         // Load the preferences from an XML resource
         addPreferencesFromResource(R.xml.account_settings);
@@ -286,6 +308,9 @@
                 profileData.preferenceGroup.setSummary(workGroupSummary);
                 ((AccessiblePreferenceCategory) profileData.preferenceGroup).setContentDescription(
                         getString(R.string.accessibility_category_work, workGroupSummary));
+                profileData.workModeSwitch = newWorkModeSwitchPreference(context);
+                final UserHandle userHandle = profileData.userInfo.getUserHandle();
+                profileData.workModeSwitch.setChecked(!mUm.isQuietModeEnabled(userHandle));
                 profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
             } else {
                 profileData.preferenceGroup.setTitle(R.string.category_personal);
@@ -313,6 +338,15 @@
         preference.setTitle(R.string.add_account_label);
         preference.setIcon(R.drawable.ic_menu_add);
         preference.setOnPreferenceClickListener(this);
+        preference.setOrder(ORDER_NEXT_TO_NEXT_TO_LAST);
+        return preference;
+    }
+
+    private SwitchPreference newWorkModeSwitchPreference(Context context) {
+        SwitchPreference preference = new SwitchPreference(getPrefContext());
+        preference.setTitle(R.string.work_mode_label);
+        preference.setSummary(R.string.work_mode_summary);
+        preference.setOnPreferenceChangeListener(this);
         preference.setOrder(ORDER_NEXT_TO_LAST);
         return preference;
     }
@@ -385,6 +419,9 @@
                     R.string.managed_profile_not_available_label);
             profileData.preferenceGroup.addPreference(mProfileNotAvailablePreference);
         }
+        if (profileData.workModeSwitch != null) {
+            profileData.preferenceGroup.addPreference(profileData.workModeSwitch);
+        }
         if (profileData.removeWorkProfilePreference != null) {
             profileData.preferenceGroup.addPreference(profileData.removeWorkProfilePreference);
         }
@@ -533,9 +570,9 @@
 
         @Override
         public void onReceive(Context context, Intent intent) {
+            Log.v(TAG, "Received broadcast: " + intent.getAction());
             if (intent.getAction().equals(Intent.ACTION_MANAGED_PROFILE_REMOVED)
                     || intent.getAction().equals(Intent.ACTION_MANAGED_PROFILE_ADDED)) {
-                Log.v(TAG, "Received broadcast: " + intent.getAction());
                 // Clean old state
                 stopListeningToAccountUpdates();
                 cleanUpPreferences();
@@ -547,6 +584,17 @@
                 getActivity().invalidateOptionsMenu();
                 return;
             }
+
+            if (intent.getAction().equals(Intent.ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED)) {
+                // We assume there's only one managed profile, otherwise this needs to change.
+                ProfileData profileData = mProfiles.valueAt(1);
+                if (intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
+                        UserHandle.USER_NULL) == profileData.userInfo.id) {
+                    profileData.workModeSwitch.setChecked(
+                            !mUm.isQuietModeEnabled(profileData.userInfo.getUserHandle()));
+                }
+                return;
+            }
             Log.w(TAG, "Cannot handle received broadcast: " + intent.getAction());
         }
 
@@ -555,6 +603,7 @@
                 IntentFilter intentFilter = new IntentFilter();
                 intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
                 intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED);
+                intentFilter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED);
                 context.registerReceiver(this, intentFilter);
                 listeningToManagedProfileEvents = true;
             }
diff --git a/src/com/android/settings/accounts/ChooseAccountActivity.java b/src/com/android/settings/accounts/ChooseAccountActivity.java
index f2f1f86..489a165 100644
--- a/src/com/android/settings/accounts/ChooseAccountActivity.java
+++ b/src/com/android/settings/accounts/ChooseAccountActivity.java
@@ -169,6 +169,7 @@
                 Drawable drawable = getDrawableForType(pref.type);
                 ProviderPreference p = new ProviderPreference(getPreferenceScreen().getContext(),
                         pref.type, drawable, pref.name);
+                p.checkAccountManagementAndSetDisabled();
                 mAddAccountGroup.addPreference(p);
             }
         } else {
diff --git a/src/com/android/settings/accounts/ProviderPreference.java b/src/com/android/settings/accounts/ProviderPreference.java
index 9a63062..863fef4 100644
--- a/src/com/android/settings/accounts/ProviderPreference.java
+++ b/src/com/android/settings/accounts/ProviderPreference.java
@@ -20,11 +20,16 @@
 import android.graphics.drawable.Drawable;
 import android.support.v7.preference.Preference;
 
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedPreference;
+
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 /**
  * ProviderPreference is used to display an image to the left of a provider name.
  * The preference ultimately calls AccountManager.addAccount() for the account type.
  */
-public class ProviderPreference extends Preference {
+public class ProviderPreference extends RestrictedPreference {
     private String mAccountType;
 
     public ProviderPreference(
@@ -39,4 +44,10 @@
     public String getAccountType() {
         return mAccountType;
     }
+
+    public void checkAccountManagementAndSetDisabled() {
+        EnforcedAdmin admin = RestrictedLockUtils.checkIfAccountManagementDisabled(
+                getContext(), getAccountType());
+        setDisabledByAdmin(admin);
+    }
 }
diff --git a/src/com/android/settings/dashboard/conditional/ConditionManager.java b/src/com/android/settings/dashboard/conditional/ConditionManager.java
index a245222..cd044ac 100644
--- a/src/com/android/settings/dashboard/conditional/ConditionManager.java
+++ b/src/com/android/settings/dashboard/conditional/ConditionManager.java
@@ -132,6 +132,7 @@
         addIfMissing(BatterySaverCondition.class);
         addIfMissing(CellularDataCondition.class);
         addIfMissing(BackgroundDataCondition.class);
+        addIfMissing(WorkModeCondition.class);
     }
 
     private void addIfMissing(Class<? extends Condition> clz) {
@@ -154,6 +155,8 @@
             return new CellularDataCondition(this);
         } else if (BackgroundDataCondition.class == clz) {
             return new BackgroundDataCondition(this);
+        } else if (WorkModeCondition.class == clz) {
+            return new WorkModeCondition(this);
         }
         throw new RuntimeException("Unexpected Condition " + clz);
     }
diff --git a/src/com/android/settings/dashboard/conditional/WorkModeCondition.java b/src/com/android/settings/dashboard/conditional/WorkModeCondition.java
new file mode 100644
index 0000000..be333ea
--- /dev/null
+++ b/src/com/android/settings/dashboard/conditional/WorkModeCondition.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.settings.dashboard.conditional;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.UserInfo;
+import android.graphics.drawable.Icon;
+import android.os.UserHandle;
+import android.os.UserManager;
+
+import com.android.settings.R;
+import com.android.settings.Settings;
+
+import java.util.List;
+
+public class WorkModeCondition extends Condition {
+
+    private UserManager mUm;
+    private UserHandle mUserHandle;
+
+    public WorkModeCondition(ConditionManager conditionManager) {
+        super(conditionManager);
+        mUm = (UserManager) mManager.getContext().getSystemService(Context.USER_SERVICE);
+    }
+
+    private void updateUserHandle() {
+        List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
+        final int profilesCount = profiles.size();
+        mUserHandle = null;
+        for (int i = 0; i < profilesCount; i++) {
+            UserInfo userInfo = profiles.get(i);
+            if (userInfo.isManagedProfile()) {
+                // We assume there's only one managed profile, otherwise UI needs to change.
+                mUserHandle = userInfo.getUserHandle();
+                break;
+            }
+        }
+    }
+
+    @Override
+    public void refreshState() {
+        updateUserHandle();
+        setActive(mUserHandle != null && mUm.isQuietModeEnabled(mUserHandle));
+    }
+
+    @Override
+    public Icon getIcon() {
+        return Icon.createWithResource(mManager.getContext(),
+                R.drawable.ic_signal_workmode_enable);
+    }
+
+    @Override
+    public CharSequence getTitle() {
+        return mManager.getContext().getString(R.string.condition_work_title);
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        return mManager.getContext().getString(R.string.condition_work_summary);
+    }
+
+    @Override
+    public CharSequence[] getActions() {
+        return new CharSequence[] {
+                mManager.getContext().getString(R.string.condition_turn_on)
+        };
+    }
+
+    @Override
+    public void onPrimaryClick() {
+        mManager.getContext().startActivity(new Intent(mManager.getContext(),
+                Settings.AccountSettingsActivity.class));
+    }
+
+    @Override
+    public void onActionClick(int index) {
+        if (index == 0) {
+            mUm.setQuietModeEnabled(mUserHandle.getIdentifier(), false);
+            setActive(false);
+        } else {
+            throw new IllegalArgumentException("Unexpected index " + index);
+        }
+    }
+}
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java
index 0d812e5..8c87080 100755
--- a/src/com/android/settings/inputmethod/InputMethodPreference.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreference.java
@@ -34,11 +34,15 @@
 
 import com.android.internal.inputmethod.InputMethodUtils;
 import com.android.settings.R;
+import com.android.settingslib.RestrictedLockUtils;
+import com.android.settingslib.RestrictedSwitchPreference;
 
 import java.text.Collator;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 /**
  * Input method preference.
  *
@@ -46,7 +50,7 @@
  * is used to enable or disable the IME. 2) An instance without a switch is used to invoke the
  * setting activity of the IME.
  */
-class InputMethodPreference extends SwitchPreference implements OnPreferenceClickListener,
+class InputMethodPreference extends RestrictedSwitchPreference implements OnPreferenceClickListener,
         OnPreferenceChangeListener {
     private static final String TAG = InputMethodPreference.class.getSimpleName();
     private static final String EMPTY_TEXT = "";
@@ -80,7 +84,7 @@
      * @param isImeEnabler true if this preference is the IME enabler that has enable/disable
      *     switches for all available IMEs, not the list of enabled IMEs.
      * @param isAllowedByOrganization false if the IME has been disabled by a device or profile
-           owner.
+     *     owner.
      * @param onSaveListener The listener called when this preference has been changed and needs
      *     to save the state to shared preference.
      */
@@ -115,6 +119,11 @@
                 && mInputMethodSettingValues.isValidSystemNonAuxAsciiCapableIme(imi, context);
         setOnPreferenceClickListener(this);
         setOnPreferenceChangeListener(this);
+        if (!isAllowedByOrganization) {
+            EnforcedAdmin admin =
+                    RestrictedLockUtils.getProfileOrDeviceOwnerOnCallingUser(context);
+            setDisabledByAdmin(admin);
+        }
     }
 
     public InputMethodInfo getInputMethodInfo() {
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 9974e89..047fcbb 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -46,6 +46,7 @@
 import com.android.settings.applications.InstalledAppDetails;
 import com.android.settings.dashboard.SummaryLoader;
 import com.android.settings.widget.SwitchBar;
+import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.location.RecentLocationApps;
 
 import java.util.ArrayList;
@@ -53,6 +54,8 @@
 import java.util.Comparator;
 import java.util.List;
 
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+
 /**
  * System location settings (Settings &gt; Location). The screen has three parts:
  * <ul>
@@ -373,9 +376,15 @@
         // corner cases, the location might still be enabled. In such case the master switch should
         // be disabled but checked.
         final boolean enabled = (mode != android.provider.Settings.Secure.LOCATION_MODE_OFF);
+        EnforcedAdmin admin = RestrictedLockUtils.checkIfRestrictionEnforced(getActivity(),
+                UserManager.DISALLOW_SHARE_LOCATION, UserHandle.myUserId());
         // Disable the whole switch bar instead of the switch itself. If we disabled the switch
         // only, it would be re-enabled again if the switch bar is not disabled.
-        mSwitchBar.setEnabled(!restricted);
+        if (admin != null) {
+            mSwitchBar.setDisabledByAdmin(admin);
+        } else {
+            mSwitchBar.setEnabled(!restricted);
+        }
         mLocationMode.setEnabled(enabled && !restricted);
         mCategoryRecentLocationRequests.setEnabled(enabled);
 
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index d5f469c..b096cc4 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -35,6 +35,9 @@
 import android.widget.TextView;
 
 import com.android.settings.R;
+import com.android.settingslib.RestrictedLockUtils;
+
+import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
 import java.util.ArrayList;
 
@@ -58,6 +61,9 @@
     private String mLabel;
     private String mSummary;
 
+    private boolean mDisabledByAdmin = false;
+    private EnforcedAdmin mEnforcedAdmin = null;
+
     private ArrayList<OnSwitchChangeListener> mSwitchChangeListeners =
             new ArrayList<OnSwitchChangeListener>();
 
@@ -153,11 +159,35 @@
     }
 
     public void setEnabled(boolean enabled) {
+        if (enabled && mDisabledByAdmin) {
+            setDisabledByAdmin(null);
+            return;
+        }
         super.setEnabled(enabled);
         mTextView.setEnabled(enabled);
         mSwitch.setEnabled(enabled);
     }
 
+    /**
+     * If admin is not null, disables the text and switch but keeps the view clickable.
+     * Otherwise, calls setEnabled which will enables the entire view including
+     * the text and switch.
+     */
+    public void setDisabledByAdmin(EnforcedAdmin admin) {
+        mEnforcedAdmin = admin;
+        if (admin != null) {
+            super.setEnabled(true);
+            mDisabledByAdmin = true;
+            RestrictedLockUtils.setTextViewPadlock(mContext, mTextView, true);
+            mTextView.setEnabled(false);
+            mSwitch.setEnabled(false);
+        } else {
+            mDisabledByAdmin = false;
+            RestrictedLockUtils.setTextViewPadlock(mContext, mTextView, false);
+            setEnabled(true);
+        }
+    }
+
     public final ToggleSwitch getSwitch() {
         return mSwitch;
     }
@@ -182,8 +212,12 @@
 
     @Override
     public void onClick(View v) {
-        final boolean isChecked = !mSwitch.isChecked();
-        setChecked(isChecked);
+        if (mDisabledByAdmin) {
+            RestrictedLockUtils.sendShowAdminSupportDetailsIntent(mContext, mEnforcedAdmin);
+        } else {
+            final boolean isChecked = !mSwitch.isChecked();
+            setChecked(isChecked);
+        }
     }
 
     public void propagateChecked(boolean isChecked) {
diff --git a/src/com/android/settings/wifi/WifiDialogActivity.java b/src/com/android/settings/wifi/WifiDialogActivity.java
index b15a6e4..af723c3 100644
--- a/src/com/android/settings/wifi/WifiDialogActivity.java
+++ b/src/com/android/settings/wifi/WifiDialogActivity.java
@@ -61,6 +61,12 @@
     }
 
     @Override
+    public void finish() {
+        super.finish();
+        overridePendingTransition(0, 0);
+    }
+
+    @Override
     public void onForget(WifiDialog dialog) {
         final WifiManager wifiManager = getSystemService(WifiManager.class);
         final AccessPoint accessPoint = dialog.getController().getAccessPoint();