Update require attention in stats pull service

Bug: 171225367
Test: Verified setting was correctly updated with value from hal.
1. Flash device to QD1A
2. Observe default setting is reported
3. Flash to build including this change
4. Verify that setting gets updated after two pulls to getFeature using
adb shell cmd stats pull-source 10058

Change-Id: Ifa64ea7e08c04b4674b3fd961d2ec11033c0b687
Merged-In: I0187e27b641edf0836fa187530cb2a193082fe5d
diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
index 8979d8c..9795e02 100644
--- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
+++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java
@@ -77,8 +77,10 @@
 import android.content.pm.PackageManager;
 import android.content.pm.PermissionInfo;
 import android.content.pm.UserInfo;
+import android.hardware.biometrics.BiometricFaceConstants;
 import android.hardware.biometrics.BiometricsProtoEnums;
 import android.hardware.face.FaceManager;
+import android.hardware.face.FaceManager.GetFeatureCallback;
 import android.hardware.fingerprint.FingerprintManager;
 import android.hardware.health.V2_0.IHealth;
 import android.net.ConnectivityManager;
@@ -3327,9 +3329,30 @@
         try {
             List<UserInfo> users = mContext.getSystemService(UserManager.class).getUsers();
             int numUsers = users.size();
+            FaceManager faceManager = mContext.getSystemService(FaceManager.class);
+
             for (int userNum = 0; userNum < numUsers; userNum++) {
                 int userId = users.get(userNum).getUserHandle().getIdentifier();
 
+                if (faceManager != null) {
+                    // Store the current setting from the Face HAL, and upon next upload the value
+                    // reported will be correct (given the user did not modify it).
+                    faceManager.getFeature(userId, BiometricFaceConstants.FEATURE_REQUIRE_ATTENTION,
+                            new GetFeatureCallback() {
+                                @Override
+                                public void onCompleted(boolean success, int feature,
+                                        boolean value) {
+                                    if (feature == FaceManager.FEATURE_REQUIRE_ATTENTION
+                                            && success) {
+                                        Settings.Secure.putIntForUser(mContext.getContentResolver(),
+                                                Settings.Secure.FACE_UNLOCK_ATTENTION_REQUIRED,
+                                                value ? 1 : 0, userId);
+                                    }
+                                }
+                            }
+                    );
+                }
+
                 int unlockKeyguardEnabled = Settings.Secure.getIntForUser(
                           mContext.getContentResolver(),
                           Settings.Secure.FACE_UNLOCK_KEYGUARD_ENABLED, 1, userId);