Merge "Add or remove WFC setting when Wireless settings activity is resumed" into mnc-dev
diff --git a/res/drawable-hdpi/setup_illustration_lock_screen.jpg b/res/drawable-hdpi/setup_illustration_lock_screen.jpg
index 0bf53fc..263d33e 100644
--- a/res/drawable-hdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-hdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-mdpi/setup_illustration_lock_screen.jpg b/res/drawable-mdpi/setup_illustration_lock_screen.jpg
index 9ab9117..004fa9e 100644
--- a/res/drawable-mdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-mdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-sw600dp-hdpi/setup_illustration_lock_screen.jpg b/res/drawable-sw600dp-hdpi/setup_illustration_lock_screen.jpg
index 26cff1d..933e986 100644
--- a/res/drawable-sw600dp-hdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-sw600dp-hdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-sw600dp-mdpi/setup_illustration_lock_screen.jpg b/res/drawable-sw600dp-mdpi/setup_illustration_lock_screen.jpg
index 386fc8d..57e0385 100644
--- a/res/drawable-sw600dp-mdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-sw600dp-mdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-sw600dp-xhdpi/setup_illustration_lock_screen.jpg b/res/drawable-sw600dp-xhdpi/setup_illustration_lock_screen.jpg
index 54362e7..e329a96 100644
--- a/res/drawable-sw600dp-xhdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-sw600dp-xhdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-sw600dp-xxhdpi/setup_illustration_lock_screen.jpg b/res/drawable-sw600dp-xxhdpi/setup_illustration_lock_screen.jpg
index 4f62b84..7934e8a 100644
--- a/res/drawable-sw600dp-xxhdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-sw600dp-xxhdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-sw600dp-xxxhdpi/setup_illustration_lock_screen.jpg b/res/drawable-sw600dp-xxxhdpi/setup_illustration_lock_screen.jpg
index 2c6b57e..ab61328 100644
--- a/res/drawable-sw600dp-xxxhdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-sw600dp-xxxhdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-xhdpi/setup_illustration_lock_screen.jpg b/res/drawable-xhdpi/setup_illustration_lock_screen.jpg
index ddad6d5..b78a59d 100644
--- a/res/drawable-xhdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-xhdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-xxhdpi/setup_illustration_lock_screen.jpg b/res/drawable-xxhdpi/setup_illustration_lock_screen.jpg
index 5b0a7a7..875e55e 100644
--- a/res/drawable-xxhdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-xxhdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/drawable-xxxhdpi/setup_illustration_lock_screen.jpg b/res/drawable-xxxhdpi/setup_illustration_lock_screen.jpg
index 5be34fd..8ac85a4 100644
--- a/res/drawable-xxxhdpi/setup_illustration_lock_screen.jpg
+++ b/res/drawable-xxxhdpi/setup_illustration_lock_screen.jpg
Binary files differ
diff --git a/res/layout/setup_encryption_interstitial.xml b/res/layout/setup_encryption_interstitial.xml
new file mode 100644
index 0000000..8a36e30
--- /dev/null
+++ b/res/layout/setup_encryption_interstitial.xml
@@ -0,0 +1,63 @@
+<?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
+-->
+
+<com.android.setupwizardlib.SetupWizardLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/setup_wizard_layout"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    settings:suwBackgroundTile="@drawable/setup_illustration_tile"
+    settings:suwHeaderText="@string/encryption_interstitial_header"
+    settings:suwIllustrationHorizontalTile="@drawable/setup_illustration_horizontal_tile"
+    settings:suwIllustrationImage="@drawable/setup_illustration_lock_screen">
+
+    <LinearLayout
+        style="@style/SuwContentFrame"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <TextView
+            android:id="@+id/encryption_message"
+            style="@style/SuwDescription"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content" />
+
+        <RadioGroup
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="16dp"
+            android:checkedButton="@+id/encrypt_require_password">
+
+            <RadioButton
+                android:id="@+id/encrypt_require_password"
+                style="@style/SuwRadioButton"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+            <RadioButton
+                android:id="@+id/encrypt_dont_require_password"
+                style="@style/SuwRadioButton"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
+        </RadioGroup>
+
+    </LinearLayout>
+
+</com.android.setupwizardlib.SetupWizardLayout>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 14c829a..01f3ba5 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -60,11 +60,6 @@
         android:summary="@string/runningservices_settings_summary"
         android:fragment="com.android.settings.applications.RunningServices" />
 
-    <SwitchPreference
-        android:key="tuner_ui"
-        android:persistent="false"
-        android:title="@string/system_ui_settings" />
-
     <PreferenceCategory android:key="debug_debugging_category"
             android:title="@string/debug_debugging_category">
 
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index f20728a..4a4c51d 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -101,9 +101,6 @@
      */
     public static final String PREF_SHOW = "show";
 
-    private static final ComponentName SYSUI_TUNER = new ComponentName("com.android.systemui",
-            "com.android.systemui.tuner.TunerActivity");
-
     private static final String ENABLE_ADB = "enable_adb";
     private static final String CLEAR_ADB_KEYS = "clear_adb_keys";
     private static final String ENABLE_TERMINAL = "enable_terminal";
@@ -270,8 +267,6 @@
     private Dialog mAdbKeysDialog;
     private boolean mUnavailable;
 
-    private SwitchPreference mTunerUiPref;
-
     @Override
     protected int getMetricsCategory() {
         return MetricsLogger.DEVELOPMENT;
@@ -407,8 +402,6 @@
         mAllPrefs.add(mShowAllANRs);
         mResetSwitchPrefs.add(mShowAllANRs);
 
-        mTunerUiPref = findAndInitSwitchPref(TUNER_UI_KEY);
-
         Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
         if (hdcpChecking != null) {
             mAllPrefs.add(hdcpChecking);
@@ -608,7 +601,6 @@
         updateMobileDataAlwaysOnOptions();
         updateSimulateColorSpace();
         updateUSBAudioOptions();
-        updateTweakUi();
     }
 
     private void resetDangerousOptions() {
@@ -1153,21 +1145,6 @@
         }
     }
 
-    private void updateTweakUi() {
-        updateSwitchPreference(mTunerUiPref, getActivity().getPackageManager()
-                .getComponentEnabledSetting(SYSUI_TUNER)
-                == PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
-        mTunerUiPref.setOnPreferenceChangeListener(this);
-    }
-
-    private void writeTweakUi(Object newValue) {
-        Boolean enabled = (Boolean) newValue;
-        getActivity().getPackageManager().setComponentEnabledSetting(SYSUI_TUNER,
-                enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
-                        : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
-                        PackageManager.DONT_KILL_APP);
-    }
-
     private void updateUSBAudioOptions() {
         updateSwitchPreference(mUSBAudio, Settings.Secure.getInt(getContentResolver(),
                 Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, 0) != 0);
@@ -1766,9 +1743,6 @@
         } else if (preference == mSimulateColorSpace) {
             writeSimulateColorSpace(newValue);
             return true;
-        } else if (preference == mTunerUiPref) {
-            writeTweakUi(newValue);
-            return true;
         }
         return false;
     }
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 73d8257..1bef99a 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -87,8 +87,12 @@
         @Override
         public View onCreateView(LayoutInflater inflater, ViewGroup container,
                 Bundle savedInstanceState) {
-            final int layoutId = R.layout.encryption_interstitial;
-            View view = inflater.inflate(layoutId, container, false);
+            return inflater.inflate(R.layout.encryption_interstitial, container, false);
+        }
+
+        @Override
+        public void onViewCreated(View view, Bundle savedInstanceState) {
+            super.onViewCreated(view, savedInstanceState);
             mRequirePasswordToDecryptButton =
                     (RadioButton) view.findViewById(R.id.encrypt_require_password);
             mDontRequirePasswordToDecryptButton =
@@ -135,7 +139,6 @@
 
             setRequirePasswordState(getActivity().getIntent().getBooleanExtra(
                     EXTRA_REQUIRE_PASSWORD, true));
-            return view;
         }
 
         @Override
diff --git a/src/com/android/settings/SetupEncryptionInterstitial.java b/src/com/android/settings/SetupEncryptionInterstitial.java
index 4605ca1..27d7e0c 100644
--- a/src/com/android/settings/SetupEncryptionInterstitial.java
+++ b/src/com/android/settings/SetupEncryptionInterstitial.java
@@ -72,22 +72,24 @@
         @Override
         public View onCreateView(LayoutInflater inflater, ViewGroup container,
                 Bundle savedInstanceState) {
-            final SetupWizardLayout layout = new SetupWizardLayout(inflater.getContext());
-            layout.setIllustration(R.drawable.setup_illustration_lock_screen,
-                    R.drawable.setup_illustration_horizontal_tile);
-            layout.setBackgroundTile(R.drawable.setup_illustration_tile);
-            layout.setHeaderText(R.string.encryption_interstitial_header);
+            return inflater.inflate(R.layout.setup_encryption_interstitial, container, false);
+        }
 
-            View content = super.onCreateView(inflater, layout, savedInstanceState);
-            layout.addView(content);
-            layout.getNavigationBar().setNavigationBarListener(this);
+        @Override
+        public void onViewCreated(View view, Bundle savedInstanceState) {
+            super.onViewCreated(view, savedInstanceState);
+
+            final SetupWizardLayout layout =
+                    (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout);
+
+            final NavigationBar navigationBar = layout.getNavigationBar();
+            navigationBar.setNavigationBarListener(this);
 
             Activity activity = getActivity();
             if (activity != null) {
                 activity.setTitle(R.string.encryption_interstitial_header);
                 SetupWizardUtils.setImmersiveMode(activity);
             }
-            return layout;
         }
 
         @Override
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
index b8ac040..5d4edbd 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
@@ -214,9 +214,9 @@
 
     private void launchFinish(byte[] token) {
         Intent intent = getFinishIntent();
+        intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, token);
         startActivity(intent);
-        setResult(RESULT_FINISHED);
         finish();
     }
 
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java
index 552ed71..1d9d1c5 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollFindSensor.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.fingerprint;
 
+import android.content.Context;
 import android.content.Intent;
 import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
@@ -75,6 +76,14 @@
             if (resultCode == RESULT_FINISHED) {
                 setResult(RESULT_FINISHED);
                 finish();
+            } else {
+                FingerprintManager fpm = getSystemService(FingerprintManager.class);
+                int enrolled = fpm.getEnrolledFingerprints().size();
+                int max = getResources().getInteger(
+                        com.android.internal.R.integer.config_fingerprintMaxTemplatesPerUser);
+                if (enrolled >= max) {
+                    finish();
+                }
             }
         } else {
             super.onActivityResult(requestCode, resultCode, data);
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java
index 7e4d656..7ce340d 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollFinish.java
@@ -55,6 +55,7 @@
 
     @Override
     protected void onNextButtonClick() {
+        setResult(RESULT_FINISHED);
         finish();
     }