Merge "Add "eyes open" setting message to face enroll intro" into sc-dev
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index c9c4d23..c1c9ac6 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -107,6 +107,28 @@
                     style="@style/BiometricEnrollIntroMessage" />
             </LinearLayout>
 
+            <LinearLayout
+                android:id="@+id/info_row_require_eyes"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:visibility="gone">
+
+                <ImageView
+                    android:id="@+id/icon_require_eyes"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:background="@drawable/ic_settings_24dp"/>
+                <Space
+                    android:layout_width="16dp"
+                    android:layout_height="wrap_content"/>
+                <TextView
+                    android:id="@+id/info_message_require_eyes"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    style="@style/BiometricEnrollIntroMessage" />
+            </LinearLayout>
+
             <!-- How it works -->
             <TextView
                 android:layout_width="match_parent"
diff --git a/res/values/config.xml b/res/values/config.xml
index 9cf48b1..0a1be65 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -269,6 +269,9 @@
     <!-- ComponentName to launch a vendor-specific enrollment activity if available -->
     <string name="config_face_enroll" translatable="false"></string>
 
+    <!-- Whether to show the "require eyes" info section on the face enroll intro screen -->
+    <bool name="config_face_intro_show_require_eyes">true</bool>
+
     <!-- Whether to use the Lottie animation for the face education enrollment screen -->
     <bool name="config_face_education_use_lottie">false</bool>
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c9e8ae5..6fb8319 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -796,6 +796,11 @@
     <string name="security_settings_face_enroll_introduction_info_looking"></string>
     <!-- Message on the face enrollment introduction page that provides information about what could cause the phone to unlock when asking for parental consent. [CHAR LIMIT=NONE] -->
     <string name="security_settings_face_enroll_introduction_info_consent_looking"></string>
+    <!-- Message on the face enrollment introduction page that provides information about how to require eyes to be open for Face Unlock. [CHAR LIMIT=NONE] -->
+    <string name="security_settings_face_enroll_introduction_info_gaze"></string>
+    <!-- Message on the face enrollment introduction page that provides information about how to require eyes to be open for Face Unlock when asking for parental consent. [CHAR LIMIT=NONE] -->
+    <string name="security_settings_face_enroll_introduction_info_consent_gaze"></string>
+
     <!-- Title of a section on the face enrollment introduction page that explains how face unlock works. [CHAR LIMIT=40] -->
     <string name="security_settings_face_enroll_introduction_how_title"></string>
     <!-- Message on the face enrollment introduction page that explains how face unlock works. [CHAR LIMIT=NONE] -->
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 91cc3a9..bee1aca 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -24,6 +24,7 @@
 import android.os.Bundle;
 import android.view.View;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
@@ -74,11 +75,13 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
+        // Apply extracted theme color to icons.
         final ImageView iconGlasses = findViewById(R.id.icon_glasses);
         final ImageView iconLooking = findViewById(R.id.icon_looking);
         iconGlasses.getBackground().setColorFilter(getIconColorFilter());
         iconLooking.getBackground().setColorFilter(getIconColorFilter());
 
+        // Set text for views with multiple variations.
         final TextView infoMessageGlasses = findViewById(R.id.info_message_glasses);
         final TextView infoMessageLooking = findViewById(R.id.info_message_looking);
         final TextView howMessage = findViewById(R.id.how_message);
@@ -86,10 +89,20 @@
         final TextView inControlMessage = findViewById(R.id.message_in_control);
         infoMessageGlasses.setText(getInfoMessageGlasses());
         infoMessageLooking.setText(getInfoMessageLooking());
-        howMessage.setText(getHowMessage());
         inControlTitle.setText(getInControlTitle());
+        howMessage.setText(getHowMessage());
         inControlMessage.setText(getInControlMessage());
 
+        // Set up and show the "require eyes" info section if necessary.
+        if (getResources().getBoolean(R.bool.config_face_intro_show_require_eyes)) {
+            final LinearLayout infoRowRequireEyes = findViewById(R.id.info_row_require_eyes);
+            final ImageView iconRequireEyes = findViewById(R.id.icon_require_eyes);
+            final TextView infoMessageRequireEyes = findViewById(R.id.info_message_require_eyes);
+            infoRowRequireEyes.setVisibility(View.VISIBLE);
+            iconRequireEyes.getBackground().setColorFilter(getIconColorFilter());
+            infoMessageRequireEyes.setText(getInfoMessageRequireEyes());
+        }
+
         mFaceManager = Utils.getFaceManagerOrNull(this);
         mFaceFeatureProvider = FeatureFactory.getFactory(getApplicationContext())
                 .getFaceFeatureProvider();
@@ -127,6 +140,11 @@
     }
 
     @StringRes
+    protected int getInfoMessageRequireEyes() {
+        return R.string.security_settings_face_enroll_introduction_info_gaze;
+    }
+
+    @StringRes
     protected int getHowMessage() {
         return R.string.security_settings_face_enroll_introduction_how_message;
     }
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
index 7a60a94..81043dc 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollParentalConsent.java
@@ -82,6 +82,12 @@
 
     @Override
     @StringRes
+    protected int getInfoMessageRequireEyes() {
+        return R.string.security_settings_face_enroll_introduction_info_consent_gaze;
+    }
+
+    @Override
+    @StringRes
     protected int getHowMessage() {
         return R.string.security_settings_face_enroll_introduction_how_consent_message;
     }