Fix 2332563: Add password-lock support to lockscreen
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f4b1181..2cb7772 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -406,6 +406,9 @@
         <!-- Second and third-level settings -->
 
         <activity android:name="ConfirmLockPattern"/>
+        <activity android:name="ConfirmLockPassword"
+            android:theme="@android:style/Theme.NoTitleBar">
+        </activity>
 
         <activity android:name="ChooseLockPattern" android:label="@string/lockpattern_change_lock_pattern_label">
             <intent-filter>
@@ -413,9 +416,15 @@
             </intent-filter>
         </activity>
 
+        <activity android:name="ChooseLockPassword" android:label="@string/lockpattern_change_lock_pin_label"
+            android:theme="@android:style/Theme.NoTitleBar">
+            <intent-filter>
+                <action android:name="android.intent.action.DEFAULT" />
+            </intent-filter>
+        </activity>
+
         <activity android:name="ChooseLockPatternTutorial"
-            android:label="@string/lockpattern_change_lock_pattern_label"
-            >
+            android:label="@string/lockpattern_change_lock_pattern_label">
             <intent-filter>
                 <action android:name="android.intent.action.DEFAULT" />
             </intent-filter>
diff --git a/res/layout-land/choose_lock_pin.xml b/res/layout-land/choose_lock_pin.xml
new file mode 100644
index 0000000..cdc75d3
--- /dev/null
+++ b/res/layout-land/choose_lock_pin.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2008, 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.
+*/
+-->
+
+<!-- TODO: think about moving to frameworks/base/res -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="horizontal"
+    android:background="@android:color/background_dark">
+
+    <LinearLayout android:id="@+id/topDisplayGroup"
+        android:layout_width="0dip"
+        android:layout_weight="1"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <!-- password entry -->
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_marginRight="6dip"
+            android:layout_marginLeft="6dip"
+            android:gravity="center_vertical"
+            android:background="@android:drawable/edit_text">
+
+            <!-- displays dots as user enters pin -->
+            <TextView android:id="@+id/pinDisplay"
+                android:layout_width="0dip"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:maxLines="1"
+                android:textAppearance="?android:attr/textAppearanceLargeInverse"
+                android:textStyle="bold"
+                android:inputType="textPassword"
+            />
+
+            <ImageButton android:id="@+id/backspace"
+                android:src="@android:drawable/ic_input_delete"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="-3dip"
+                android:layout_marginBottom="-3dip"
+            />
+        </LinearLayout>
+
+        <!-- header text ('Enter Pin') -->
+        <TextView android:id="@+id/headerText"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:lines="2"
+            android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+    </LinearLayout>
+
+    <include
+        android:id="@+id/keyPad"
+        layout="@layout/twelve_key_entry"
+        android:layout_width="0dip"
+        android:layout_weight="1"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/topDisplayGroup"
+        android:layout_marginTop="10dip"
+    />
+
+</LinearLayout>
diff --git a/res/layout-land/confirm_lock_pin.xml b/res/layout-land/confirm_lock_pin.xml
new file mode 100644
index 0000000..beff4a1
--- /dev/null
+++ b/res/layout-land/confirm_lock_pin.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2008, 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.
+*/
+-->
+
+<!-- TODO: think about moving to frameworks/base/res -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical"
+    android:background="@android:color/background_dark"
+    android:gravity="center_horizontal">
+
+    <LinearLayout android:id="@+id/topDisplayGroup"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <!-- header text ('Enter Pin') -->
+        <TextView android:id="@+id/headerText"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:lines="2"
+            android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+        <!-- password entry -->
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_marginRight="6dip"
+            android:layout_marginLeft="6dip"
+            android:gravity="center_vertical"
+            android:background="@android:drawable/edit_text">
+
+            <!-- displays dots as user enters pin -->
+            <TextView android:id="@+id/pinDisplay"
+                android:layout_width="0dip"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:maxLines="1"
+                android:textAppearance="?android:attr/textAppearanceLargeInverse"
+                android:textStyle="bold"
+                android:inputType="textPassword"
+            />
+
+            <ImageButton android:id="@+id/backspace"
+                android:src="@android:drawable/ic_input_delete"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="-3dip"
+                android:layout_marginBottom="-3dip"
+            />
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <include
+        android:id="@+id/keyPad"
+        layout="@layout/twelve_key_entry"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/topDisplayGroup"
+        android:layout_marginTop="10dip"
+    />
+
+</LinearLayout>
diff --git a/res/layout/choose_lock_password.xml b/res/layout/choose_lock_password.xml
new file mode 100644
index 0000000..213f9a4
--- /dev/null
+++ b/res/layout/choose_lock_password.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2008, 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.
+*/
+-->
+
+<!-- TODO: think about moving to frameworks/base/res -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical"
+    android:background="@android:color/background_dark"
+    android:gravity="center_horizontal">
+
+    <LinearLayout android:id="@+id/topDisplayGroup"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <!-- header text ('Enter Pin') -->
+        <TextView android:id="@+id/headerText"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:lines="2"
+            android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+        <!-- password entry -->
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_marginRight="6dip"
+            android:layout_marginLeft="6dip"
+            android:gravity="center_vertical"
+            android:background="@android:drawable/edit_text">
+
+            <!-- displays dots as user enters pin -->
+            <TextView android:id="@+id/pinDisplay"
+                android:layout_width="0dip"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:maxLines="1"
+                android:textAppearance="?android:attr/textAppearanceLargeInverse"
+                android:textStyle="bold"
+                android:inputType="textPassword"
+            />
+
+            <ImageButton android:id="@+id/backspace"
+                android:src="@android:drawable/ic_input_delete"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="-3dip"
+                android:layout_marginBottom="-3dip"
+            />
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <View
+        android:layout_width="fill_parent"
+        android:layout_height="0dip"
+        android:layout_weight="1"
+    />
+
+</LinearLayout>
diff --git a/res/layout/choose_lock_pin.xml b/res/layout/choose_lock_pin.xml
new file mode 100644
index 0000000..beff4a1
--- /dev/null
+++ b/res/layout/choose_lock_pin.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2008, 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.
+*/
+-->
+
+<!-- TODO: think about moving to frameworks/base/res -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical"
+    android:background="@android:color/background_dark"
+    android:gravity="center_horizontal">
+
+    <LinearLayout android:id="@+id/topDisplayGroup"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <!-- header text ('Enter Pin') -->
+        <TextView android:id="@+id/headerText"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:lines="2"
+            android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+        <!-- password entry -->
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_marginRight="6dip"
+            android:layout_marginLeft="6dip"
+            android:gravity="center_vertical"
+            android:background="@android:drawable/edit_text">
+
+            <!-- displays dots as user enters pin -->
+            <TextView android:id="@+id/pinDisplay"
+                android:layout_width="0dip"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:maxLines="1"
+                android:textAppearance="?android:attr/textAppearanceLargeInverse"
+                android:textStyle="bold"
+                android:inputType="textPassword"
+            />
+
+            <ImageButton android:id="@+id/backspace"
+                android:src="@android:drawable/ic_input_delete"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="-3dip"
+                android:layout_marginBottom="-3dip"
+            />
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <include
+        android:id="@+id/keyPad"
+        layout="@layout/twelve_key_entry"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/topDisplayGroup"
+        android:layout_marginTop="10dip"
+    />
+
+</LinearLayout>
diff --git a/res/layout/confirm_lock_pin.xml b/res/layout/confirm_lock_pin.xml
new file mode 100644
index 0000000..beff4a1
--- /dev/null
+++ b/res/layout/confirm_lock_pin.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2008, 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.
+*/
+-->
+
+<!-- TODO: think about moving to frameworks/base/res -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical"
+    android:background="@android:color/background_dark"
+    android:gravity="center_horizontal">
+
+    <LinearLayout android:id="@+id/topDisplayGroup"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical">
+
+        <!-- header text ('Enter Pin') -->
+        <TextView android:id="@+id/headerText"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center"
+            android:lines="2"
+            android:textAppearance="?android:attr/textAppearanceLarge"/>
+
+        <!-- password entry -->
+        <LinearLayout
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal"
+            android:layout_marginRight="6dip"
+            android:layout_marginLeft="6dip"
+            android:gravity="center_vertical"
+            android:background="@android:drawable/edit_text">
+
+            <!-- displays dots as user enters pin -->
+            <TextView android:id="@+id/pinDisplay"
+                android:layout_width="0dip"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:maxLines="1"
+                android:textAppearance="?android:attr/textAppearanceLargeInverse"
+                android:textStyle="bold"
+                android:inputType="textPassword"
+            />
+
+            <ImageButton android:id="@+id/backspace"
+                android:src="@android:drawable/ic_input_delete"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="-3dip"
+                android:layout_marginBottom="-3dip"
+            />
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <include
+        android:id="@+id/keyPad"
+        layout="@layout/twelve_key_entry"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/topDisplayGroup"
+        android:layout_marginTop="10dip"
+    />
+
+</LinearLayout>
diff --git a/res/layout/twelve_key_entry.xml b/res/layout/twelve_key_entry.xml
new file mode 100644
index 0000000..81ead98
--- /dev/null
+++ b/res/layout/twelve_key_entry.xml
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2008, 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.
+*/
+-->
+
+<!-- This is not a standalone element it can be included into apps that need 12-key input -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical">
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="64dip"
+        android:layout_marginLeft="2dip"
+        android:layout_marginRight="2dip"
+        android:orientation="horizontal">
+
+        <Button android:id="@+id/one"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/two"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/three"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+        
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="64dip"
+        android:layout_marginLeft="2dip"
+        android:layout_marginRight="2dip"
+        android:orientation="horizontal">
+
+        <Button android:id="@+id/four"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/five"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/six"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="64dip"
+        android:layout_marginLeft="2dip"
+        android:layout_marginRight="2dip"
+        android:orientation="horizontal">
+
+        <Button android:id="@+id/seven"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/eight"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/nine"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+        
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="64dip"
+        android:layout_marginLeft="2dip"
+        android:layout_marginRight="2dip"
+        android:orientation="horizontal">
+
+        <Button android:id="@+id/ok"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:textStyle="bold"
+            android:text="@android:string/ok"
+        />
+
+        <Button android:id="@+id/zero"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceLarge"
+            android:textStyle="bold"
+        />
+
+        <Button android:id="@+id/cancel"
+            android:layout_width="0sp"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"
+            android:layout_marginLeft="2dip"
+            android:layout_marginRight="2dip"
+            android:textAppearance="?android:attr/textAppearanceMedium"
+            android:textStyle="bold"
+            android:text="@android:string/cancel"
+        />
+        
+    </LinearLayout>
+    
+</LinearLayout>
\ No newline at end of file
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 2981b12..eec1ffc 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -23,19 +23,19 @@
          strings. --> <skip />
     <!-- The time zone picker screen has two levels.  The first level allows the user to choose a region. -->
     <string-array name="timezone_filters">
-	<!-- The next level of the time zoner picker should show time zones from the Americas. -->
+    <!-- The next level of the time zoner picker should show time zones from the Americas. -->
         <item>America</item>
-	<!-- The next level of the time zoner picker should show time zones from Europe. -->
+    <!-- The next level of the time zoner picker should show time zones from Europe. -->
         <item>Europe</item>
-	<!-- The next level of the time zoner picker should show time zones from Africa. -->
+    <!-- The next level of the time zoner picker should show time zones from Africa. -->
         <item>Africa</item>
-	<!-- The next level of the time zoner picker should show time zones from Asia. -->
+    <!-- The next level of the time zoner picker should show time zones from Asia. -->
         <item>Asia</item>
-	<!-- The next level of the time zoner picker should show time zones from Australia. -->
+    <!-- The next level of the time zoner picker should show time zones from Australia. -->
         <item>Australia</item>
-	<!-- The next level of the time zoner picker should show time zones from Pacific. -->
+    <!-- The next level of the time zoner picker should show time zones from Pacific. -->
         <item>Pacific</item>
-	<!-- The next level of the time zoner picker should show time zones from ALL regions. -->
+    <!-- The next level of the time zoner picker should show time zones from ALL regions. -->
         <item>All</item>
     </string-array>
 
@@ -98,6 +98,22 @@
         <item>1800000</item>
     </string-array>
 
+    <!-- Unlock method in SecuritySettings --><skip/>
+    <string-array name="unlock_method_entries">
+        <item>Password</item>
+        <item>PIN</item>
+        <item>Pattern</item>
+        <item>None</item>
+    </string-array>
+
+    <!-- Do not translate. -->
+    <string-array name="unlock_method_values" translatable="false">
+        <item>password</item>
+        <item>pin</item>
+        <item>pattern</item>
+        <item>none</item>
+    </string-array>
+
     <!-- TTS settings -->
 
     <!-- Default speech rate choices -->
@@ -133,7 +149,7 @@
         <item>120</item>
         <item>150</item>
     </string-array>
-    
+
     <!-- Default language choices -->
     <string-array name="tts_lang_entries">
         <item>American English</item>
@@ -202,7 +218,7 @@
         <!-- WEP key that is in hexadecimal. -->
         <item>WEP hexadecimal</item>
     </string-array>
-    
+
     <!-- Wi-Fi settings. Presented as a list dialog to the user to choose the Wi-Fi sleep policy. -->
     <string-array name="wifi_sleep_policy_entries">
         <!-- Wi-Fi should go to sleep when the screen turns off. -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6152ecc..83fda4d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4,9 +4,9 @@
      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.
@@ -135,7 +135,7 @@
     <string name="battery_info_awake_plugged">Awake time when charging:</string>
     <!-- Battery Info screen. Label for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
     <string name="battery_info_screen_on">Screen ON time:</string>
-    
+
 
     <!-- Battery Info screen. Value for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
     <string name="battery_info_status_unknown">Unknown</string>
@@ -158,7 +158,7 @@
     <string name="battery_info_power_usb">USB</string>
     <string name="battery_info_power_ac_usb">AC+USB</string>
     <string name="battery_info_power_unknown">Unknown</string>
-    
+
     <!-- Battery Info screen. Value for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
     <string name="battery_info_health_unknown">Unknown</string>
     <!-- Battery Info screen. Value for a status item.  Used for diagnostic info screens, precise translation isn't needed -->
@@ -516,6 +516,18 @@
     <string name="cdma_security_settings_summary">Set My Location, screen unlock, credential storage lock</string>
     <!-- In the security screen, the header title for settings related to  Passwords-->
     <string name="security_passwords_title">Passwords</string>
+    <!-- Name shown for changing the unlock method -->
+    <string name="unlock_method_title">Unlock Method</string>
+    <!-- Summary shown for changing the unlock method -->
+    <string name="unlock_method_summary">Change the method used to unlock your phone</string>
+    <!-- Error shown in popup when PIN is too short -->
+    <string name="pin_password_too_short">Password must be at least %d digits</string>
+    <!-- Error shown in popup when PIN is too long -->
+    <string name="pin_password_too_long">Password can be no longer than %d digits</string>
+    <!-- Error shown when in PIN mode and user enters a non-digit -->
+    <string name="pin_password_illegal_character">PIN must contain only digits 0-9</string>
+    <!-- Error shown when in PASSWORD mode and user enters an invalid character -->
+    <string name="pin_password_contains_non_digits">Password contains an illegal character</string>
 
     <!-- Bluetooth settings -->
     <!-- Bluetooth settings check box title on Main Settings screen -->
@@ -553,7 +565,7 @@
     <!-- Title for BT error dialogs. -->
     <string name="bluetooth_error_title">Attention</string>
     <!-- Message for the error dialog when BT pairing fails generically. -->
-    <string name="bluetooth_pairing_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g>.</string> 
+    <string name="bluetooth_pairing_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g>.</string>
     <!-- Message for the error dialog when BT pairing fails because the PIN /
     Passkey entered is incorrect. -->
     <string name="bluetooth_pairing_pin_error_message">There was a problem pairing with <xliff:g id="device_name">%1$s</xliff:g> because the PIN or Passkey is incorrect.</string>
@@ -563,7 +575,7 @@
     <string name="bluetooth_pairing_rejected_error_message">Pairing rejected by <xliff:g id="device_name">%1$s</xliff:g>.</string>
 
     <!-- Message for the error dialog when BT connecting operation fails generically. -->
-    <string name="bluetooth_connecting_error_message">There was a problem connecting to <xliff:g id="device_name">%1$s</xliff:g>.</string> 
+    <string name="bluetooth_connecting_error_message">There was a problem connecting to <xliff:g id="device_name">%1$s</xliff:g>.</string>
 
     <!-- Do not translate -->
     <string name="bluetooth_device_info_alias">Device alias</string>
@@ -576,7 +588,7 @@
 
     <!-- Bluetooth settings: The title of the preference (list item) that initiates a scan for devices -->
     <string name="bluetooth_preference_scan_title">Scan for devices</string>
-    
+
     <!-- Bluetooth settings.  Context menu item for a device.  Action will connect to all profiles on the device. -->
     <string name="bluetooth_device_context_connect">Connect</string>
     <!-- Bluetooth settings.  Context menu item for a device.  Action will disconnect from all profiles on the device. -->
@@ -588,8 +600,8 @@
     <!-- Bluetooth settings.  Context menu item for a device.  Action will disconnect and remove pairing with the device. -->
     <string name="bluetooth_device_context_disconnect_unpair">Disconnect &amp; unpair</string>
     <!-- Bluetooth settings.  Context menu item for a device.  Action will take the user to another screen where they can choose exactly which profiles to connect to. -->
-    <string name="bluetooth_device_context_connect_advanced">Options\u2026</string>    
-    
+    <string name="bluetooth_device_context_connect_advanced">Options\u2026</string>
+
     <!-- Bluetooth settings.  The title of the screen to pick which profiles to connect to on the device.  For example, headphones may have both A2DP and headset, this allows the user to choose which one he wants to connect to. -->
     <string name="bluetooth_connect_specific_profiles_title">Connect to\u2026</string>
 
@@ -807,7 +819,7 @@
     <string name="wifi_setting_sleep_policy_summary">Specify when to switch from Wi-Fi to mobile data</string>
     <!-- Wi-Fi settings screen, generic error message when the sleep policy could not be set. -->
     <string name="wifi_setting_sleep_policy_error">There was a problem setting the sleep policy.</string>
-    
+
     <!-- Wi-Fi settings screen, advanced, title of the item to show the Wi-Fi device's MAC address. -->
     <string name="wifi_advanced_mac_address_title">MAC address</string>
 
@@ -1253,10 +1265,10 @@
     <string name="error_mnc_not23">MNC field must be 2 or 3 digits.</string>
     <!-- The message of dialog indicated restoring default APN settings in progress -->
     <string name="restore_default_apn">Restoring default APN settings</string>
-    <!-- APNs screen menu option to reset default APN settings --> 
-    <string name="menu_restore">Reset to default</string>    
-    <!-- APNs screen toast message to inform reset default APN settings is completed -->     
-    <string name="restore_default_apn_completed">Reset default APN settings completed</string>    
+    <!-- APNs screen menu option to reset default APN settings -->
+    <string name="menu_restore">Reset to default</string>
+    <!-- APNs screen toast message to inform reset default APN settings is completed -->
+    <string name="restore_default_apn_completed">Reset default APN settings completed</string>
 
     <!-- Master Clear -->
     <!-- SD card & phone storage settings screen, setting option name under Internal phone storage heading -->
@@ -1379,11 +1391,23 @@
     <string name="settings_safetylegal_activity_loading">Loading\u2026</string>
 
     <!-- Lock Pattern settings -->
+    <!-- Header on first screen of choose password/PIN flow -->
+    <string name="lockpassword_choose_your_password_header">Choose your password</string>
+    <!-- Header on password confirm screen -->
+    <string name="lockpassword_confirm_your_password_header">Confirm password</string>
+    <!-- Header on password confirm screen if second password doesn't match the first. -->
+    <string name="lockpassword_confirm_passwords_dont_match">Passwords don\'t match</string>
+    <!-- Header shown if passwords match -->
+    <string name="lockpassword_password_confirmed_header">Password confirmed</string>
+
+    <!-- Lock Pattern settings -->
     <!-- Security & location settings screen, header -->
     <string name="lock_settings_title">Screen unlock pattern</string>
     <!-- Security & location settings screen, setting option name -->
     <string name="lockpattern_change_lock_pattern_label">Change unlock pattern</string>
     <!-- Security & location settings screen, change unlock pattern screen instruction when the user chooses "Change unlock pattern".  We first ask the user toe nter the current pattern, and this is the message seen -->
+    <string name="lockpattern_change_lock_pin_label">Change unlock PIN</string>
+    <!-- Security & location settings screen, change unlock pattern screen instruction when the user chooses "Change unlock pattern".  We first ask the user toe nter the current pattern, and this is the message seen -->
     <string name="lockpattern_need_to_unlock">Confirm saved pattern</string>
     <!-- Do not translate. -->
     <string name="lockpattern_need_to_unlock_footer"></string>
@@ -1447,8 +1471,8 @@
         \n<font height="17">\n</font><b>3</b>\u00A0 Redraw your pattern to confirm.
         \n<font height="17">\n</font><b>Ready to start? Touch \u201CNext\u201D</b>.
         \n<font height="3">\n</font>To leave your phone unprotected, touch \u201CCancel\u201D.</font>
-    </string>    
-        
+    </string>
+
     <!-- ChooseLockPatternExample --> <skip />
     <!-- ChooseLockPatternExample, screen title that shows an example pattern -->
     <string name="lock_example_title">Example pattern</string>
@@ -1528,7 +1552,7 @@
     <!-- Text for filter option in ManageApps screen to display all installed
     applications -->
     <string name="filter_apps_all">All</string>
-    <!-- Text for filter option in ManageApps screen to display third party 
+    <!-- Text for filter option in ManageApps screen to display third party
     applications only -->
     <string name="filter_apps_third_party">Downloaded</string>
     <!-- Text for filter option in ManageApps screen to display list of running
@@ -1598,7 +1622,7 @@
     <string name="service_foreground_processes">Other: <xliff:g id="memory">%2$s</xliff:g> in <xliff:g id="count">%1$d</xliff:g></string>
     <!-- Text to label a process entry with the process name. -->
     <string name="service_process_name">Process: <xliff:g id="process">%1$s</xliff:g></string>
-    
+
     <!-- Language Settings --> <skip />
     <!-- Title of setting on main settings screen.  This item will take the user to the screen to tweak settings realted to locale and text -->
     <string name="language_settings">Language &amp; keyboard</string>
@@ -1639,7 +1663,7 @@
     card numbers.  It comes from the application
     <xliff:g id="ime_application_name">%1$s</xliff:g>.
     Use this input method?</string>
-    
+
     <!-- User dictionary settings --><skip />
     <!-- User dictionary settings, The titlebar text of the User dictionary settings screen. -->
     <string name="user_dict_settings_titlebar">User dictionary</string>
@@ -1731,7 +1755,7 @@
          (or other screens that can host gadgets).  Note to translators: we're still determining
          the final name for Gadgets/Widgets, so please translate both for now. -->
     <string name="gadget_picker_title">Choose gadget</string>
-    
+
     <!-- Title for the screen that lets the user choose a widget to add to the home screen
          (or other screens that can host widgets).  Note to translators: we're still determining
          the final name for Gadgets/Widgets, so please translate both for now. -->
@@ -1784,52 +1808,52 @@
 
     <!-- Used to head a list of packages that share a given user id BatteryHistory -->
     <string name="battery_history_packages_sharing_this_uid">Packages sharing this UID:</string>
-    
+
     <!-- Used when no battery data available in BatteryHistory -->
     <string name="battery_history_no_data">No battery usage data available</string>
-        
+
     <!-- Used for Sensor detail screen in BatteryHistory -->
     <string name="battery_history_sensor">Sensor:</string>
-    
+
     <!-- Used for Wakelock detail screen in BatteryHistory -->
     <string name="battery_history_wakelock">Partial Wakelock:</string>
-    
+
     <!-- Used for Sensor detail screen in BatteryHistory -->
     <string name="battery_history_used_by_packages">Sensor used by packages:</string>
-    
+
     <!-- Used for Sensor detail screen in BatteryHistory -->
     <string name="battery_history_sensor_usage">Used <xliff:g id="count">%1$d</xliff:g> times by <xliff:g id="package">%2$s</xliff:g></string>
-    
+
     <!-- Used for Sensor detail screen in BatteryHistory -->
     <string name="battery_history_sensor_usage_multi">Used <xliff:g id="count">%1$d</xliff:g> times by one of:</string>
-    
+
     <!-- Used for label of awake bar in BatteryHistory -->
     <string name="battery_history_awake_label">Running</string>
-    
+
     <!-- Used for label of screen on bar in BatteryHistory -->
     <string name="battery_history_screen_on_label">Screen on</string>
-    
+
     <!-- Used for label of phone on bar in BatteryHistory -->
     <string name="battery_history_phone_on_label">Phone on</string>
-    
+
     <!-- Used for awake time message in BatteryHistory -->
     <string name="battery_history_awake">Time spent without sleeping:</string>
-    
+
     <!-- Used for Screen on time message in BatteryHistory -->
     <string name="battery_history_screen_on">Time spent with screen on:</string>
-    
+
     <!-- Used for Phone on time message in BatteryHistory -->
     <string name="battery_history_phone_on">Time spent with phone on:</string>
-    
+
     <!-- Used for Screen on time message in BatteryHistory -->
     <string name="battery_history_screen_on_battery">On battery:</string>
-    
+
     <!-- XXX remove? Used for Screen on time message in BatteryHistory -->
     <string name="battery_history_screen_on_plugged">Plugged in:</string>
 
     <!-- XXX remove? Strings used for displaying usage statistics -->
     <string name="usage_stats_label">Usage statistics</string>
-    
+
     <!-- In the Testing screen. The item title of the activity that shows usage statistics.  -->
     <string name="testing_usage_stats">Usage statistics</string>
     <!-- label for text to indicate sort options -->
@@ -2263,7 +2287,7 @@
     <string name="emergency_tone_title">Emergency tone</string>
     <!-- Sound settings screen, setting option summary text -->
     <string name="emergency_tone_summary">Set behavior when an emergency call is placed</string>
-    
+
     <!-- Privacy Settings screen --><skip/>
     <!-- Privacy settings menu title -->
     <string name="privacy_settings">Privacy</string>
diff --git a/res/xml/security_settings.xml b/res/xml/security_settings.xml
index 1b73584..d1f896a 100644
--- a/res/xml/security_settings.xml
+++ b/res/xml/security_settings.xml
@@ -4,9 +4,9 @@
      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.
@@ -19,15 +19,15 @@
     <PreferenceCategory
         android:key="location_category"
         android:title="@string/location_title">
-        
-        <CheckBoxPreference 
-            android:key="location_network" 
+
+        <CheckBoxPreference
+            android:key="location_network"
             android:title="@string/location_network_based"
             android:summaryOn="@string/location_neighborhood_level"
             android:summaryOff="@string/location_networks_disabled"/>
-        
-        <CheckBoxPreference 
-            android:key="location_gps" 
+
+        <CheckBoxPreference
+            android:key="location_gps"
             android:title="@string/location_gps"
             android:summaryOn="@string/location_street_level"
             android:summaryOff="@string/location_gps_disabled"/>
@@ -42,5 +42,27 @@
 -->
 
     </PreferenceCategory>
-            
+
+    <PreferenceCategory
+        android:key="security_category"
+        android:title="@string/lock_settings_title">
+
+        <ListPreference
+            android:key="unlock_method"
+            android:title="@string/unlock_method_title"
+            android:summary="@string/unlock_method_summary"
+            android:persistent="false"
+            android:entries="@array/unlock_method_entries"
+            android:entryValues="@array/unlock_method_values"/>
+
+        <CheckBoxPreference
+            android:key="visiblepattern"
+            android:title="@string/lockpattern_settings_enable_visible_pattern_title"/>
+
+        <CheckBoxPreference
+            android:key="tactilefeedback"
+            android:title="@string/lockpattern_settings_enable_tactile_feedback_title"/>
+
+    </PreferenceCategory>
+
 </PreferenceScreen>
diff --git a/src/com/android/settings/ChooseLockPassword.java b/src/com/android/settings/ChooseLockPassword.java
new file mode 100644
index 0000000..4a8b543
--- /dev/null
+++ b/src/com/android/settings/ChooseLockPassword.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2010 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;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.ChooseLockPattern.LeftButtonMode;
+import com.android.settings.ChooseLockPattern.RightButtonMode;
+import com.android.settings.ChooseLockPattern.Stage;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+
+
+public class ChooseLockPassword extends Activity implements OnClickListener {
+    private final int digitIds[] = new int[] { R.id.zero, R.id.one, R.id.two, R.id.three,
+            R.id.four, R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine };
+    private TextView mPasswordTextView;
+    private int mPasswordMinLength = 4;
+    private int mPasswordMaxLength = 8;
+    private LockPatternUtils mLockPatternUtils;
+    private int mRequestedMode = LockPatternUtils.MODE_PIN;
+    private ChooseLockSettingsHelper mChooseLockSettingsHelper;
+    private com.android.settings.ChooseLockPassword.Stage mUiStage = Stage.Introduction;
+    private TextView mHeaderText;
+    private String mFirstPin;
+    public static final String PASSWORD_MIN_KEY = "lockscreen.password_min";
+    public static final String PASSWORD_MAX_KEY = "lockscreen.password_max";
+    private static Handler mHandler = new Handler();
+    private static final int CONFIRM_EXISTING_REQUEST = 58;
+    static final int RESULT_FINISHED = RESULT_FIRST_USER;
+    private static final long ERROR_MESSAGE_TIMEOUT = 3000;
+
+    /**
+     * Keep track internally of where the user is in choosing a pattern.
+     */
+    protected enum Stage {
+
+        Introduction(R.string.lockpassword_choose_your_password_header),
+        NeedToConfirm(R.string.lockpassword_confirm_your_password_header),
+        ConfirmWrong(R.string.lockpassword_confirm_passwords_dont_match),
+        ChoiceConfirmed(R.string.lockpassword_password_confirmed_header);
+
+        /**
+         * @param headerMessage The message displayed at the top.
+         */
+        Stage(int headerMessage) {
+            this.headerMessage = headerMessage;
+        }
+
+        final int headerMessage;
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mLockPatternUtils = new LockPatternUtils(getContentResolver());
+        mRequestedMode = getIntent().getIntExtra("password_mode", mRequestedMode);
+        mPasswordMinLength = getIntent().getIntExtra("password_min_length", mPasswordMinLength);
+        mPasswordMaxLength = getIntent().getIntExtra("password_max_length", mPasswordMaxLength);
+        initViews();
+        mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
+        if (savedInstanceState == null) {
+            updateStage(Stage.Introduction);
+            mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
+        }
+    }
+
+    private void initViews() {
+        if (LockPatternUtils.MODE_PIN == mRequestedMode
+                || LockPatternUtils.MODE_PASSWORD == mRequestedMode) {
+            setContentView(R.layout.choose_lock_pin);
+            // TODO: alphanumeric layout
+            // setContentView(R.layout.choose_lock_password);
+            for (int i = 0; i < digitIds.length; i++) {
+                Button button = (Button) findViewById(digitIds[i]);
+                button.setOnClickListener(this);
+                button.setText(Integer.toString(i));
+            }
+            findViewById(R.id.ok).setOnClickListener(this);
+            findViewById(R.id.cancel).setOnClickListener(this);
+        }
+        findViewById(R.id.backspace).setOnClickListener(this);
+        mPasswordTextView = (TextView) findViewById(R.id.pinDisplay);
+        mHeaderText = (TextView) findViewById(R.id.headerText);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode,
+            Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        switch (requestCode) {
+            case CONFIRM_EXISTING_REQUEST:
+                if (resultCode != Activity.RESULT_OK) {
+                    setResult(RESULT_FINISHED);
+                    finish();
+                }
+                break;
+        }
+    }
+
+    protected void updateStage(Stage stage) {
+        mHeaderText.setText(stage.headerMessage);
+        mPasswordTextView.setText("");
+        mUiStage = stage;
+    }
+
+    /**
+     * Validates PIN and returns a message to display if PIN fails test.
+     * @param pin
+     * @return message id to display to user
+     */
+    private String validatePassword(String pin) {
+        if (pin.length() < mPasswordMinLength) {
+            return getString(R.string.pin_password_too_short, mPasswordMinLength);
+        }
+        if (pin.length() > mPasswordMaxLength) {
+            return getString(R.string.pin_password_too_long, mPasswordMaxLength);
+        }
+        if (LockPatternUtils.MODE_PIN == mRequestedMode) {
+            Pattern p = Pattern.compile("[0-9]+");
+            Matcher m = p.matcher(pin);
+            if (!m.find()) {
+                return getString(R.string.pin_password_contains_non_digits);
+            }
+        } else if (LockPatternUtils.MODE_PASSWORD == mRequestedMode) {
+            // allow Latin-1 characters only
+            for (int i = 0; i < pin.length(); i++) {
+                char c = pin.charAt(i);
+                if (c <= 32 || c > 127) {
+                    return getString(R.string.pin_password_illegal_character);
+                }
+            }
+        }
+        return null;
+    }
+
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.ok:
+                {
+                    final String pin = mPasswordTextView.getText().toString();
+                    if (TextUtils.isEmpty(pin)) {
+                        break;
+                    }
+                    String errorMsg = null;
+                    if (mUiStage == Stage.Introduction) {
+                        errorMsg = validatePassword(pin);
+                        if (errorMsg == null) {
+                            mFirstPin = pin;
+                            updateStage(Stage.NeedToConfirm);
+                        }
+                    } else if (mUiStage == Stage.NeedToConfirm) {
+                        if (mFirstPin.equals(pin)) {
+                            // TODO: move these to LockPatternUtils
+                            mLockPatternUtils.setLockPatternEnabled(false);
+                            mLockPatternUtils.saveLockPattern(null);
+
+
+                            mLockPatternUtils.saveLockPassword(pin);
+                            finish();
+                        } else {
+                            int msg = R.string.lockpassword_confirm_passwords_dont_match;
+                            errorMsg = getString(msg);
+                        }
+                    }
+                    if (errorMsg != null) {
+                        showError(errorMsg, Stage.Introduction);
+                    }
+                }
+                break;
+
+            case R.id.backspace:
+                {
+                    final Editable digits = mPasswordTextView.getEditableText();
+                    final int len = digits.length();
+                    if (len > 0) {
+                        digits.delete(len-1, len);
+                    }
+                }
+                break;
+
+            case R.id.cancel:
+                finish();
+                break;
+
+            default:
+                // Digits
+                for (int i = 0; i < digitIds.length; i++) {
+                    if (v.getId() == digitIds[i]) {
+                        mPasswordTextView.append(Integer.toString(i));
+                        return;
+                    }
+                }
+                break;
+        }
+    }
+
+    private void showError(String msg, final Stage next) {
+        mHeaderText.setText(msg);
+        mPasswordTextView.setText("");
+        mHandler.postDelayed(new Runnable() {
+            public void run() {
+                updateStage(next);
+            }
+        }, ERROR_MESSAGE_TIMEOUT);
+    }
+}
diff --git a/src/com/android/settings/ChooseLockPattern.java b/src/com/android/settings/ChooseLockPattern.java
index f103c6b..859d96b 100644
--- a/src/com/android/settings/ChooseLockPattern.java
+++ b/src/com/android/settings/ChooseLockPattern.java
@@ -45,7 +45,6 @@
  * - saves chosen password when confirmed
  */
 public class ChooseLockPattern extends Activity implements View.OnClickListener{
-
     /**
      * Used by the choose lock pattern wizard to indicate the wizard is
      * finished, and each activity in the wizard should finish.
@@ -56,7 +55,9 @@
      * result.
      */
     static final int RESULT_FINISHED = RESULT_FIRST_USER;
-    
+
+    public static final int CONFIRM_EXISTING_REQUEST = 55;
+
     // how long after a confirmation message is shown before moving on
     static final int INFORMATION_MSG_TIMEOUT_MS = 3000;
 
@@ -65,29 +66,38 @@
 
     private static final int ID_EMPTY_MESSAGE = -1;
 
-
     protected TextView mHeaderText;
     protected LockPatternView mLockPatternView;
     protected TextView mFooterText;
     private TextView mFooterLeftButton;
     private TextView mFooterRightButton;
-
     protected List<LockPatternView.Cell> mChosenPattern = null;
 
-    protected LockPatternUtils mLockPatternUtils;
-
     /**
      * The patten used during the help screen to show how to draw a pattern.
      */
     private final List<LockPatternView.Cell> mAnimatePattern =
-            Collections.unmodifiableList(
-                Lists.newArrayList(
-                        LockPatternView.Cell.of(0, 0),
-                        LockPatternView.Cell.of(0, 1),
-                        LockPatternView.Cell.of(1, 1),
-                        LockPatternView.Cell.of(2, 1)
-                    ));
+            Collections.unmodifiableList(Lists.newArrayList(
+                    LockPatternView.Cell.of(0, 0),
+                    LockPatternView.Cell.of(0, 1),
+                    LockPatternView.Cell.of(1, 1),
+                    LockPatternView.Cell.of(2, 1)
+            ));
 
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode,
+            Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        switch (requestCode) {
+            case CONFIRM_EXISTING_REQUEST:
+                if (resultCode != Activity.RESULT_OK) {
+                    setResult(RESULT_FINISHED);
+                    finish();
+                }
+                updateStage(Stage.Introduction);
+                break;
+        }
+    }
 
     /**
      * The pattern listener that responds according to a user choosing a new
@@ -125,7 +135,7 @@
                 }
             }
 
-            public void onPatternCellAdded(List<Cell> pattern) { 
+            public void onPatternCellAdded(List<Cell> pattern) {
 
             }
 
@@ -250,19 +260,19 @@
         }
     };
 
+    private ChooseLockSettingsHelper mChooseLockSettingsHelper;
+
     private static final String KEY_UI_STAGE = "uiStage";
     private static final String KEY_PATTERN_CHOICE = "chosenPattern";
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-
-        mLockPatternUtils = new LockPatternUtils(getContentResolver());
-
+        mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
 
         setupViews();
-        
+
         // make it so unhandled touch events within the unlock screen go to the
         // lock pattern view.
         final LinearLayoutWithDefaultTouchRecepient topLayout
@@ -271,11 +281,12 @@
         topLayout.setDefaultTouchRecepient(mLockPatternView);
 
         if (savedInstanceState == null) {
-            // first launch
-            updateStage(Stage.Introduction);
-            if (mLockPatternUtils.savedPatternExists()) {
-                confirmPattern();
-            } 
+            // first launch. As a security measure, we're in NeedToConfirm mode until we know
+            // there isn't an existing password or the user confirms their password.
+            updateStage(Stage.NeedToConfirm);
+            if (!mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST)) {
+                updateStage(Stage.Introduction);
+            }
         } else {
             // restore from previous state
             final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE);
@@ -285,19 +296,20 @@
             updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
         }
     }
-    
+
     /**
      * Keep all "find view" related stuff confined to this function since in
      * case someone needs to subclass and customize.
      */
     protected void setupViews() {
         setContentView(R.layout.choose_lock_pattern);
-        
+
         mHeaderText = (TextView) findViewById(R.id.headerText);
 
         mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern);
         mLockPatternView.setOnPatternListener(mChooseNewLockPatternListener);
-        mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());        
+        mLockPatternView.setTactileFeedbackEnabled(
+                mChooseLockSettingsHelper.utils().isTactileFeedbackEnabled());
 
         mFooterText = (TextView) findViewById(R.id.footerText);
 
@@ -364,35 +376,6 @@
         return super.onKeyDown(keyCode, event);
     }
 
-    /**
-     * Launch screen to confirm the existing lock pattern.
-     * @see #onActivityResult(int, int, android.content.Intent)
-     */
-    protected void confirmPattern() {
-        final Intent intent = new Intent();
-        intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
-        startActivityForResult(intent, 55);
-    }
-
-    /**
-     * @see #confirmPattern
-     */
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode,
-            Intent data) {
-        super.onActivityResult(requestCode, resultCode, data);
-
-        if (requestCode != 55) {
-            return;
-        }
-
-        if (resultCode != Activity.RESULT_OK) {
-            setResult(RESULT_FINISHED);
-            finish();
-        }
-        updateStage(Stage.Introduction);
-    }
-
     @Override
     protected void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
@@ -414,7 +397,7 @@
 
         mUiStage = stage;
 
-        // header text, footer text, visibility and 
+        // header text, footer text, visibility and
         // enabled state all known from the stage
         if (stage == Stage.ChoiceTooShort) {
             mHeaderText.setText(
@@ -486,16 +469,17 @@
     }
 
     private void saveChosenPatternAndFinish() {
-        final boolean lockVirgin = !mLockPatternUtils.isPatternEverChosen();
+        LockPatternUtils utils = mChooseLockSettingsHelper.utils();
+        final boolean lockVirgin = !utils.isPatternEverChosen();
 
-        mLockPatternUtils.saveLockPattern(mChosenPattern);
-        mLockPatternUtils.setLockPatternEnabled(true);
+        utils.saveLockPattern(mChosenPattern);
+        utils.setLockPatternEnabled(true);
 
         if (lockVirgin) {
-            mLockPatternUtils.setVisiblePatternEnabled(true);
-            mLockPatternUtils.setTactileFeedbackEnabled(false);
+            utils.setVisiblePatternEnabled(true);
+            utils.setTactileFeedbackEnabled(false);
         }
-        
+
         setResult(RESULT_FINISHED);
         finish();
     }
diff --git a/src/com/android/settings/ChooseLockSettingsHelper.java b/src/com/android/settings/ChooseLockSettingsHelper.java
new file mode 100644
index 0000000..ab2f8c0
--- /dev/null
+++ b/src/com/android/settings/ChooseLockSettingsHelper.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 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;
+
+import android.app.Activity;
+import android.content.Intent;
+
+import com.android.internal.widget.LockPatternUtils;
+
+public class ChooseLockSettingsHelper {
+    private LockPatternUtils mLockPatternUtils;
+    private Activity mActivity;
+
+    public ChooseLockSettingsHelper(Activity activity) {
+        mActivity = activity;
+        mLockPatternUtils = new LockPatternUtils(activity.getContentResolver());
+    }
+
+    public LockPatternUtils utils() {
+        return mLockPatternUtils;
+    }
+
+    /**
+     * If a pattern, password or PIN exists, prompt the user before allowing them to change it.
+     * @return true if one exists and we launched an activity to confirm it
+     * @see #onActivityResult(int, int, android.content.Intent)
+     */
+    protected boolean launchConfirmationActivity(int request) {
+        boolean launched = false;
+        switch (mLockPatternUtils.getPasswordMode()) {
+            case LockPatternUtils.MODE_PATTERN:
+                launched = confirmPattern(request);
+                break;
+            case LockPatternUtils.MODE_PIN:
+            case LockPatternUtils.MODE_PASSWORD:
+                launched = confirmPassword(request);
+                break;
+        }
+        return launched;
+    }
+
+    /**
+     * Launch screen to confirm the existing lock pattern.
+     * @see #onActivityResult(int, int, android.content.Intent)
+     * @return true if we launched an activity to confirm pattern
+     */
+    private boolean confirmPattern(int request) {
+        if (!mLockPatternUtils.isLockPatternEnabled() || !mLockPatternUtils.savedPatternExists()) {
+            return false;
+        }
+        final Intent intent = new Intent();
+        intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
+        mActivity.startActivityForResult(intent, request);
+        return true;
+    }
+
+    /**
+     * Launch screen to confirm the existing lock password.
+     * @see #onActivityResult(int, int, android.content.Intent)
+     * @return true if we launched an activity to confirm password
+     */
+    private boolean confirmPassword(int request) {
+        if (!mLockPatternUtils.isLockPasswordEnabled()) return false;
+        final Intent intent = new Intent();
+        intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPassword");
+        mActivity.startActivityForResult(intent, request);
+        return true;
+    }
+
+
+}
diff --git a/src/com/android/settings/ConfirmLockPassword.java b/src/com/android/settings/ConfirmLockPassword.java
new file mode 100644
index 0000000..0cbc158
--- /dev/null
+++ b/src/com/android/settings/ConfirmLockPassword.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2010 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;
+
+import com.android.internal.widget.LockPatternUtils;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.text.Editable;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class ConfirmLockPassword extends Activity implements OnClickListener {
+    private static final long ERROR_MESSAGE_TIMEOUT = 3000;
+    private final int digitIds[] = new int[] { R.id.zero, R.id.one, R.id.two, R.id.three,
+            R.id.four, R.id.five, R.id.six, R.id.seven, R.id.eight, R.id.nine };
+    private TextView mPasswordTextView;
+    private LockPatternUtils mLockPatternUtils;
+    private TextView mHeaderText;
+    private Handler mHandler = new Handler();
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mLockPatternUtils = new LockPatternUtils(getContentResolver());
+        initViews();
+    }
+
+    private void initViews() {
+        int mode = mLockPatternUtils.getPasswordMode();
+        if (LockPatternUtils.MODE_PIN == mode || LockPatternUtils.MODE_PASSWORD == mode) {
+            setContentView(R.layout.confirm_lock_pin);
+            for (int i = 0; i < digitIds.length; i++) {
+                Button button = (Button) findViewById(digitIds[i]);
+                button.setOnClickListener(this);
+                button.setText(Integer.toString(i));
+            }
+            findViewById(R.id.ok).setOnClickListener(this);
+            findViewById(R.id.cancel).setOnClickListener(this);
+        }
+        findViewById(R.id.backspace).setOnClickListener(this);
+        mPasswordTextView = (TextView) findViewById(R.id.pinDisplay);
+        mHeaderText = (TextView) findViewById(R.id.headerText);
+        mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);
+    }
+
+    public void onClick(View v) {
+        switch (v.getId()) {
+            case R.id.ok:
+                {
+                    final String pin = mPasswordTextView.getText().toString();
+                    if (mLockPatternUtils.checkPassword(pin)) {
+                        setResult(RESULT_OK);
+                        finish();
+                    } else {
+                        showError(R.string.lockpattern_need_to_unlock_wrong);
+                    }
+                }
+                break;
+
+            case R.id.backspace:
+                {
+                    final Editable digits = mPasswordTextView.getEditableText();
+                    final int len = digits.length();
+                    if (len > 0) {
+                        digits.delete(len-1, len);
+                    }
+                }
+                break;
+
+            case R.id.cancel:
+                setResult(RESULT_CANCELED);
+                finish();
+                break;
+
+            default:
+                // Digits
+                for (int i = 0; i < digitIds.length; i++) {
+                    if (v.getId() == digitIds[i]) {
+                        mPasswordTextView.append(Integer.toString(i));
+                        return;
+                    }
+                }
+                break;
+        }
+    }
+
+    private void showError(int msg) {
+        mHeaderText.setText(msg);
+        mPasswordTextView.setText(null);
+        mHandler.postDelayed(new Runnable() {
+            public void run() {
+                mHeaderText.setText(R.string.lockpassword_confirm_your_password_header);
+            }
+        }, ERROR_MESSAGE_TIMEOUT);
+    }
+}
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 0202f4c..fb284fd 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -25,7 +25,6 @@
 import android.app.Dialog;
 import android.content.ContentQueryMap;
 import android.content.ContentResolver;
-import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.database.Cursor;
@@ -35,10 +34,13 @@
 import android.os.ServiceManager;
 import android.os.SystemProperties;
 import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
 import android.preference.PreferenceCategory;
+import android.preference.PreferenceManager;
 import android.preference.PreferenceScreen;
+import android.preference.Preference.OnPreferenceChangeListener;
 import android.provider.Settings;
 import android.security.Credentials;
 import android.security.KeyStore;
@@ -56,11 +58,18 @@
 public class SecuritySettings extends PreferenceActivity {
 
     // Lock Settings
+    private static final String PACKAGE = "com.android.settings";
+    private static final String LOCK_PATTERN_TUTORIAL = PACKAGE + ".ChooseLockPatternTutorial";
+    private static final String ICC_LOCK_SETTINGS = PACKAGE + ".IccLockSettings";
+    private static final String CHOOSE_LOCK_PATTERN = PACKAGE + ".ChooseLockPattern";
+    private static final String CHOOSE_LOCK_PIN = PACKAGE + ".ChooseLockPassword";
 
     private static final String KEY_LOCK_ENABLED = "lockenabled";
     private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
     private static final String KEY_TACTILE_FEEDBACK_ENABLED = "tactilefeedback";
-    private static final int CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE = 55;
+    private static final String KEY_UNLOCK_METHOD = "unlock_method";
+    private static final int UPDATE_PASSWORD_REQUEST = 56;
+    private static final int CONFIRM_EXISTING_REQUEST = 57;
 
     // Encrypted File Systems constants
     private static final String PROPERTY_EFS_ENABLED = "persist.security.efs.enabled";
@@ -69,11 +78,8 @@
     private static final String PREFS_NAME = "location_prefs";
     private static final String PREFS_USE_LOCATION = "use_location";
 
-    private LockPatternUtils mLockPatternUtils;
-    private CheckBoxPreference mLockEnabled;
     private CheckBoxPreference mVisiblePattern;
     private CheckBoxPreference mTactileFeedback;
-    private Preference mChoosePattern;
 
     private CheckBoxPreference mShowPassword;
 
@@ -97,6 +103,8 @@
     // This is necessary because the Network Location Provider can change settings
     // if the user does not confirm enabling the provider.
     private ContentQueryMap mContentQueryMap;
+    private ListPreference mUnlockMethod;
+    private ChooseLockSettingsHelper mChooseLockSettingsHelper;
     private final class SettingsObserver implements Observer {
         public void update(Observable o, Object arg) {
             updateToggles();
@@ -108,7 +116,7 @@
         super.onCreate(savedInstanceState);
         addPreferencesFromResource(R.xml.security_settings);
 
-        mLockPatternUtils = new LockPatternUtils(getContentResolver());
+        mChooseLockSettingsHelper = new ChooseLockSettingsHelper(this);
 
         createPreferenceHierarchy();
 
@@ -131,37 +139,22 @@
         // Root
         PreferenceScreen root = this.getPreferenceScreen();
 
-        // Inline preferences
-        PreferenceCategory inlinePrefCat = new PreferenceCategory(this);
-        inlinePrefCat.setTitle(R.string.lock_settings_title);
-        root.addPreference(inlinePrefCat);
+        PreferenceManager pm = getPreferenceManager();
 
-        // change pattern lock
-        Intent intent = new Intent();
-        intent.setClassName("com.android.settings",
-                    "com.android.settings.ChooseLockPatternTutorial");
-        mChoosePattern = getPreferenceManager().createPreferenceScreen(this);
-        mChoosePattern.setIntent(intent);
-        inlinePrefCat.addPreference(mChoosePattern);
-
-        // autolock toggle
-        mLockEnabled = new LockEnabledPref(this);
-        mLockEnabled.setTitle(R.string.lockpattern_settings_enable_title);
-        mLockEnabled.setSummary(R.string.lockpattern_settings_enable_summary);
-        mLockEnabled.setKey(KEY_LOCK_ENABLED);
-        inlinePrefCat.addPreference(mLockEnabled);
+        mUnlockMethod = (ListPreference) pm.findPreference(KEY_UNLOCK_METHOD);
+        mUnlockMethod.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
+            public boolean onPreferenceChange(Preference preference, Object newValue) {
+                String value = (String) newValue;
+                handleUpdateUnlockMethod(value);
+                return false;
+            }
+        });
 
         // visible pattern
-        mVisiblePattern = new CheckBoxPreference(this);
-        mVisiblePattern.setKey(KEY_VISIBLE_PATTERN);
-        mVisiblePattern.setTitle(R.string.lockpattern_settings_enable_visible_pattern_title);
-        inlinePrefCat.addPreference(mVisiblePattern);
+        mVisiblePattern = (CheckBoxPreference) pm.findPreference(KEY_VISIBLE_PATTERN);
 
         // tactile feedback
-        mTactileFeedback = new CheckBoxPreference(this);
-        mTactileFeedback.setKey(KEY_TACTILE_FEEDBACK_ENABLED);
-        mTactileFeedback.setTitle(R.string.lockpattern_settings_enable_tactile_feedback_title);
-        inlinePrefCat.addPreference(mTactileFeedback);
+        mTactileFeedback = (CheckBoxPreference) pm.findPreference(KEY_TACTILE_FEEDBACK_ENABLED);
 
         int activePhoneType = TelephonyManager.getDefault().getPhoneType();
 
@@ -172,10 +165,7 @@
                     .createPreferenceScreen(this);
             simLockPreferences.setTitle(R.string.sim_lock_settings_category);
             // Intent to launch SIM lock settings
-            intent = new Intent();
-            intent.setClassName("com.android.settings", "com.android.settings.IccLockSettings");
-            simLockPreferences.setIntent(intent);
-
+            simLockPreferences.setIntent(new Intent().setClassName(PACKAGE, ICC_LOCK_SETTINGS));
             PreferenceCategory simLockCat = new PreferenceCategory(this);
             simLockCat.setTitle(R.string.sim_lock_settings_title);
             root.addPreference(simLockCat);
@@ -209,23 +199,41 @@
         return root;
     }
 
+    protected void handleUpdateUnlockMethod(final String value) {
+        final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
+        if ("none".equals(value)) {
+            mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST);
+        } else if ("password".equals(value) || "pin".equals(value)) {
+            final int minLength = 4; // TODO: get from policy store.
+            final int maxLength = 16;
+            final int mode = "password".equals(value)
+                    ? LockPatternUtils.MODE_PASSWORD : LockPatternUtils.MODE_PIN;
+            Intent intent = new Intent().setClassName(PACKAGE, CHOOSE_LOCK_PIN);
+            intent.putExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mode);
+            intent.putExtra(ChooseLockPassword.PASSWORD_MIN_KEY, minLength);
+            intent.putExtra(ChooseLockPassword.PASSWORD_MAX_KEY, maxLength);
+            startActivityForResult(intent, UPDATE_PASSWORD_REQUEST);
+        } else if ("pattern".equals(value)) {
+            boolean showTutorial = !lockPatternUtils.isPatternEverChosen();
+            Intent intent = new Intent();
+            intent.setClassName(PACKAGE, showTutorial ?
+                    LOCK_PATTERN_TUTORIAL : CHOOSE_LOCK_PATTERN);
+            intent.putExtra("key_lock_method", value);
+            startActivityForResult(intent, UPDATE_PASSWORD_REQUEST);
+        }
+    }
+
     @Override
     protected void onResume() {
         super.onResume();
 
-        boolean patternExists = mLockPatternUtils.savedPatternExists();
-        mLockEnabled.setEnabled(patternExists);
+        final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
+        boolean patternExists = lockPatternUtils.savedPatternExists();
         mVisiblePattern.setEnabled(patternExists);
         mTactileFeedback.setEnabled(patternExists);
 
-        mLockEnabled.setChecked(mLockPatternUtils.isLockPatternEnabled());
-        mVisiblePattern.setChecked(mLockPatternUtils.isVisiblePatternEnabled());
-        mTactileFeedback.setChecked(mLockPatternUtils.isTactileFeedbackEnabled());
-
-        int chooseStringRes = mLockPatternUtils.savedPatternExists() ?
-                R.string.lockpattern_settings_change_lock_pattern :
-                R.string.lockpattern_settings_choose_lock_pattern;
-        mChoosePattern.setTitle(chooseStringRes);
+        mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
+        mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
 
         mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),
                 Settings.System.TEXT_SHOW_PASSWORD, 1) != 0);
@@ -238,12 +246,13 @@
             Preference preference) {
         final String key = preference.getKey();
 
+        final LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
         if (KEY_LOCK_ENABLED.equals(key)) {
-            mLockPatternUtils.setLockPatternEnabled(isToggled(preference));
+            lockPatternUtils.setLockPatternEnabled(isToggled(preference));
         } else if (KEY_VISIBLE_PATTERN.equals(key)) {
-            mLockPatternUtils.setVisiblePatternEnabled(isToggled(preference));
+            lockPatternUtils.setVisiblePatternEnabled(isToggled(preference));
         } else if (KEY_TACTILE_FEEDBACK_ENABLED.equals(key)) {
-            mLockPatternUtils.setTactileFeedbackEnabled(isToggled(preference));
+            lockPatternUtils.setTactileFeedbackEnabled(isToggled(preference));
         } else if (preference == mShowPassword) {
             Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
                     mShowPassword.isChecked() ? 1 : 0);
@@ -265,11 +274,6 @@
         return false;
     }
 
-    private void showPrivacyPolicy() {
-        Intent intent = new Intent("android.settings.TERMS");
-        startActivity(intent);
-    }
-
     /*
      * Creates toggles for each available location provider
      */
@@ -292,36 +296,6 @@
     }
 
     /**
-     * For the user to disable keyguard, we first make them verify their
-     * existing pattern.
-     */
-    private class LockEnabledPref extends CheckBoxPreference {
-
-        public LockEnabledPref(Context context) {
-            super(context);
-        }
-
-        @Override
-        protected void onClick() {
-            if (mLockPatternUtils.savedPatternExists() && isChecked()) {
-                confirmPatternThenDisableAndClear();
-            } else {
-                super.onClick();
-            }
-        }
-    }
-
-    /**
-     * Launch screen to confirm the existing lock pattern.
-     * @see #onActivityResult(int, int, android.content.Intent)
-     */
-    private void confirmPatternThenDisableAndClear() {
-        final Intent intent = new Intent();
-        intent.setClassName("com.android.settings", "com.android.settings.ConfirmLockPattern");
-        startActivityForResult(intent, CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE);
-    }
-
-    /**
      * @see #confirmPatternThenDisableAndClear
      */
     @Override
@@ -330,10 +304,11 @@
 
         final boolean resultOk = resultCode == Activity.RESULT_OK;
 
-        if ((requestCode == CONFIRM_PATTERN_THEN_DISABLE_AND_CLEAR_REQUEST_CODE)
-                && resultOk) {
-            mLockPatternUtils.setLockPatternEnabled(false);
-            mLockPatternUtils.saveLockPattern(null);
+        LockPatternUtils lockPatternUtils = mChooseLockSettingsHelper.utils();
+        if ((requestCode == CONFIRM_EXISTING_REQUEST) && resultOk) {
+            lockPatternUtils.saveLockPassword(null);
+            lockPatternUtils.setLockPatternEnabled(false);
+            lockPatternUtils.saveLockPattern(null);
         }
     }