Update fingerprint SensorLocation interface for multi-display

Allows the implementation to specify location relative to multiple
displays (instead of just one), from which the sensor is accessible
from.

Fixes: 174868353
Test: make -j android.hardware.biometrics.fingerprint-update-api
Test: make -j android.hardware.biometrics.fingerprint-service.example

Change-Id: I0d1c1d2bdc0ea817656c14b3b79381db994fdd75
diff --git a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorLocation.aidl b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorLocation.aidl
new file mode 100644
index 0000000..a6e8b4d
--- /dev/null
+++ b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorLocation.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2021 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 FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package android.hardware.biometrics.fingerprint;
+@VintfStability
+parcelable SensorLocation {
+  int displayId;
+  int sensorLocationX;
+  int sensorLocationY;
+  int sensorRadius;
+}
diff --git a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorProps.aidl b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorProps.aidl
index c3daacd..53ac6dd 100644
--- a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorProps.aidl
+++ b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SensorProps.aidl
@@ -35,10 +35,7 @@
 parcelable SensorProps {
   android.hardware.biometrics.common.CommonProps commonProps;
   android.hardware.biometrics.fingerprint.FingerprintSensorType sensorType;
+  android.hardware.biometrics.fingerprint.SensorLocation[] sensorLocations;
   boolean supportsNavigationGestures;
-  int sensorLocationX;
-  int sensorLocationY;
-  int sensorRadius;
-  int displayId;
   boolean supportsDetectInteraction;
 }
diff --git a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorLocation.aidl b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorLocation.aidl
new file mode 100644
index 0000000..62a2e8c
--- /dev/null
+++ b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorLocation.aidl
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2021 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 android.hardware.biometrics.fingerprint;
+
+@VintfStability
+parcelable SensorLocation {
+    /**
+     * The display to which the following measurements are relative to. This must correspond to the
+     * android.hardware.DisplayManager#getDisplay Android API.
+     *
+     * A few examples:
+     *   1) A capacitive rear fingerprint sensor would specify the display to which it is behind.
+     *   2) An under-display fingerprint sensor would specify the display on which the sensor is
+     *      located.
+     *   3) A foldable device would specify multiple locations and have a SensorLocation entry
+     *      for each display from which the sensor is accessible from.
+     */
+    int displayId;
+
+    /**
+     * The location of the center of the sensor if applicable. For example, sensors of
+     * FingerprintSensorType::UNDER_DISPLAY_* would report this value as the distance in pixels,
+     * measured from the left edge of the screen.
+     */
+    int sensorLocationX;
+
+    /**
+     * The location of the center of the sensor if applicable. For example, sensors of
+     * FingerprintSensorType::UNDER_DISPLAY_* would report this value as the distance in pixels,
+     * measured from the top edge of the screen.
+     */
+    int sensorLocationY;
+
+    /**
+     * The radius of the sensor if applicable. For example, sensors of
+     * FingerprintSensorType::UNDER_DISPLAY_* would report this value as the radius of the sensor,
+     * in pixels.
+     */
+    int sensorRadius;
+}
\ No newline at end of file
diff --git a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorProps.aidl b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorProps.aidl
index afed175..5222f3e 100644
--- a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorProps.aidl
+++ b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SensorProps.aidl
@@ -18,6 +18,7 @@
 
 import android.hardware.biometrics.common.CommonProps;
 import android.hardware.biometrics.fingerprint.FingerprintSensorType;
+import android.hardware.biometrics.fingerprint.SensorLocation;
 
 @VintfStability
 parcelable SensorProps {
@@ -32,39 +33,18 @@
     FingerprintSensorType sensorType;
 
     /**
+     * A list of display-specific locations from where the sensor is usable from. See SensorLocation
+     * for more details.
+     */
+    SensorLocation[] sensorLocations;
+
+    /**
      * Must be set to true for sensors that support "swipe" gestures via
      * android.view.KeyEvent#KEYCODE_SYSTEM_NAVIGATION_*.
      */
     boolean supportsNavigationGestures;
 
     /**
-     * The location of the center of the sensor if applicable. For example, sensors of
-     * FingerprintSensorType::UNDER_DISPLAY_* would report this value as the distance in pixels,
-     * measured from the left edge of the screen.
-     */
-    int sensorLocationX;
-
-    /**
-     * The location of the center of the sensor if applicable. For example, sensors of
-     * FingerprintSensorType::UNDER_DISPLAY_* would report this value as the distance in pixels,
-     * measured from the top edge of the screen.
-     */
-    int sensorLocationY;
-
-    /**
-     * The radius of the sensor if applicable. For example, sensors of
-     * FingerprintSensorType::UNDER_DISPLAY_* would report this value as the radius of the sensor,
-     * in pixels.
-     */
-    int sensorRadius;
-
-    /**
-     * For sensors of FingerprintSensorType::UNDER_DISPLAY_*, this must correspond to the
-     * android.hardware.DisplayManager#getDisplay Android API.
-     */
-    int displayId;
-
-    /**
      * Specifies whether or not the implementation supports ISession#detectInteraction.
      */
     boolean supportsDetectInteraction;
diff --git a/biometrics/fingerprint/aidl/default/Fingerprint.cpp b/biometrics/fingerprint/aidl/default/Fingerprint.cpp
index 6eb35d9..f27e278 100644
--- a/biometrics/fingerprint/aidl/default/Fingerprint.cpp
+++ b/biometrics/fingerprint/aidl/default/Fingerprint.cpp
@@ -43,13 +43,17 @@
             kSensorStrength,
             kMaxEnrollmentsPerUser,
             hardwareInfos};
-    SensorProps props = {commonProps,
-            kSensorType,
-            kSupportsNavigationGestures,
+    SensorLocation sensorLocation = {
+            0 /* displayId */,
             0 /* sensorLocationX */,
             0 /* sensorLocationY */,
-            0 /* sensorRadius */,
-            0 /* displayId */};
+            0 /* sensorRadius */
+    };
+    SensorProps props = {commonProps,
+            kSensorType,
+            {sensorLocation},
+            kSupportsNavigationGestures,
+            false /* supportsDetectInteraction */};
     return_val->push_back(props);
     return ndk::ScopedAStatus::ok();
 }