keymaster restore: warn when pin, password or pattern is enabled

Starting in Android 10, zygote relies on stored inodes in order
to find packages in the user's CE directories. Since TWRP cannot
force inode creation on restore, we warn the user to remove their
pin before restoring their backup. Otherwise zygote may not load
properly in Android. This will force the system to update the
inode cache.

The user can then re-add their security settings to android.

Change-Id: I8f07962d07304dee54c08318efc500dca424b6c0
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index 646bc2c..0b81987 100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -2710,6 +2710,75 @@
 			</button>
 
 			<action>
+				<condition var1="tw_crypto_pwtype" op="!=" var2="0"/>
+				<actions>
+					<action function="page">restore_pin</action>
+				</actions>
+			</action>
+
+			<action>
+				<condition var1="tw_restore" op="modified"/>
+				<actions>
+					<action function="readBackup"/>
+					<action function="set">tw_back=restore</action>
+					<action function="page">restore_read</action>
+				</actions>
+			</action>
+
+			<action>
+				<touch key="home"/>
+				<action function="page">main</action>
+			</action>
+
+			<action>
+				<touch key="back"/>
+				<action function="page">main</action>
+			</action>
+		</page>
+
+		<page name="restore_force">
+			<template name="page"/>
+
+			<action>
+				<conditions>
+					<condition var1="tw_is_fbe" var2="1"/>
+					<condition var1="tw_all_users_decrypted" var2="0"/>
+					<condition var1="tw_multiuser_warning_accepted" op="!=" var2="1"/>
+				</conditions>
+				<actions>
+					<action function="set">tw_multiuser_warning_destination=restore</action>
+					<action function="page">multiuser_warning</action>
+				</actions>
+			</action>
+
+			<template name="statusbar"/>
+
+			<text style="text_m">
+				<placement x="%col1_x_left%" y="%row1_header_y%"/>
+				<text>{@restore_hdr=Restore} &gt; {@sel_backup_hdr=Select Backup}</text>
+			</text>
+
+			<fileselector>
+				<placement x="%indent%" y="%row2_header_y%" w="%content_width%" h="%fileselector_install_height%"/>
+				<text>%tw_storage_display_name%</text>
+				<filter folders="1" files="1" nav="0" extn=".ab"/>
+				<path name="tw_backups_folder"/>
+				<data name="tw_restore" default=""/>
+				<selection name="tw_restore_name"/>
+			</fileselector>
+
+			<button>
+				<placement x="%btn4_col4_x%" y="%row11_y%"/>
+				<highlight color="%highlight_color%"/>
+				<image resource="q_btn_storage"/>
+				<actions>
+					<action function="set">tw_storagetext={@restore_btn=Restore} &gt; {@select_storage_btn=Select Storage}</action>
+					<action function="set">tw_back=restore</action>
+					<action function="page">select_storage</action>
+				</actions>
+			</button>
+
+			<action>
 				<condition var1="tw_restore" op="modified"/>
 				<actions>
 					<action function="readBackup"/>
@@ -6143,5 +6212,74 @@
 				</actions>
 			</action>
 		</page>
+
+		<page name="restore_pin">
+			<template name="page"/>
+			<text style="text_m_accent">
+				<condition var1="tw_crypto_pwtype" var2="1"/>
+				<placement x="%center_x%" y="%row1_y%" placement="5"/>
+				<text>{@restore_with_pin1=PIN/Password is enabled}</text>
+			</text>
+			<text style="text_m_accent">
+				<condition var1="tw_crypto_pwtype" var2="1"/>
+				<placement x="%center_x%" y="%row2_y%" placement="5"/>
+				<text>{@restore_with_pin2=PIN/Password should be disabled before restore}</text>
+			</text>
+			<text style="text_l">
+				<condition var1="tw_crypto_pwtype" var2="1"/>
+				<placement x="%center_x%" y="%row3_y%" placement="5"/>
+				<text>{@restore_pin=Restore While PIN/Password Enabled?}</text>
+			</text>
+			<text style="text_m_accent">
+				<condition var1="tw_crypto_pwtype" var2="2"/>
+				<placement x="%center_x%" y="%row1_y%" placement="5"/>
+				<text>{@restore_with_pattern1=Pattern is enabled}</text>
+			</text>
+			<text style="text_m_accent">
+				<condition var1="tw_crypto_pwtype" var2="2"/>
+				<placement x="%center_x%" y="%row2_y%" placement="5"/>
+				<text>{@restore_with_pattern2=Pattern should be disabled before restore}</text>
+			</text>
+			<text style="text_l">
+				<condition var1="tw_crypto_pwtype" var2="2"/>
+				<placement x="%center_x%" y="%row3_y%" placement="5"/>
+				<text>{@restore_pattern=Restore While Pattern Enabled?}</text>
+			</text>
+
+			<text style="text_m_accent">
+				<condition var1="tw_crypto_pwtype" var2="2"/>
+				<placement x="%center_x%" y="%row2_y%" placement="5"/>
+				<text>{@restore_with_pin1=PIN is enabled}</text>
+			</text>
+
+			<text style="text_m_accent">
+				<condition var1="tw_crypto_pwtype" var2="3"/>
+				<placement x="%center_x%" y="%row2_y%" placement="5"/>
+				<text>{@restore_with_pin2=PIN should be disabled before restore}</text>
+			</text>
+
+			<text style="text_l">
+				<condition var1="tw_crypto_pwtype" var2="3"/>
+				<placement x="%center_x%" y="%row3_y%" placement="5"/>
+				<text>{@restore_pin=Restore While PIN Enabled?}</text>
+			</text>
+
+			<slider>
+				<text>{@continue_restore_encrypted=Continue Restore?}</text>
+				<actions>
+					<action function="page">restore_force</action>
+				</actions>
+			</slider>
+			<action>
+				<touch key="home"/>
+				<action function="page">main</action>
+			</action>
+			<action>
+				<touch key="back"/>
+				<actions>
+					<action function="page">main</action>
+				</actions>
+			</action>
+		</page>
 	</pages>
 </recovery>