ITS: Request focus distance based on camera capability

Following test cases fails on camera devices with minimumFocusDistance
larger than requested focus distance.
 -sensor_fusion/test_multi_camera_frame_sync
 -sensor_fusion/test_sensor_fusion

bug: 129896159

Merged-In: I71eb7f80fd6c962ccd86f6cbe6872c7aa0ca6dfc

Change-Id: I0670d1e0f3359b87b2cd93c9af390dff1665bc36
diff --git a/apps/CameraITS/tests/sensor_fusion/test_multi_camera_frame_sync.py b/apps/CameraITS/tests/sensor_fusion/test_multi_camera_frame_sync.py
index 5a6c77b..b16f7ed 100644
--- a/apps/CameraITS/tests/sensor_fusion/test_multi_camera_frame_sync.py
+++ b/apps/CameraITS/tests/sensor_fusion/test_multi_camera_frame_sync.py
@@ -115,7 +115,12 @@
         # Define capture request
         s, e, _, _, _ = cam.do_3a(get_results=True, do_af=False)
         req = its.objects.manual_capture_request(s, e)
-        req["android.lens.focusDistance"] = 1 / (CHART_DISTANCE * CM_TO_M)
+        fd_min = props["android.lens.info.minimumFocusDistance"]
+        fd_chart = 1 / (CHART_DISTANCE * CM_TO_M)
+        if fd_min < fd_chart:
+            req["android.lens.focusDistance"] = fd_min
+        else:
+            req["android.lens.focusDistance"] = fd_chart
 
         # capture YUVs
         out_surfaces = [{"format": "yuv", "width": W, "height": H,
diff --git a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
index c5e2d1b..f814e9a 100644
--- a/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
+++ b/apps/CameraITS/tests/sensor_fusion/test_sensor_fusion.py
@@ -449,7 +449,12 @@
         fmt = {"format": "yuv", "width": w, "height": h}
         s, e, _, _, _ = cam.do_3a(get_results=True, do_af=False)
         req = its.objects.manual_capture_request(s, e)
-        req["android.lens.focusDistance"] = 1 / (CHART_DISTANCE * CM_TO_M)
+        fd_min = props["android.lens.info.minimumFocusDistance"]
+        fd_chart = 1 / (CHART_DISTANCE * CM_TO_M)
+        if fd_min < fd_chart:
+            req["android.lens.focusDistance"] = fd_min
+        else:
+            req["android.lens.focusDistance"] = fd_chart
         req["android.control.aeTargetFpsRange"] = [fps, fps]
         req["android.sensor.frameDuration"] = int(1000.0/fps * MSEC_TO_NSEC)
         print "Capturing %dx%d with sens. %d, exp. time %.1fms at %dfps" % (