Camera2 Legacy: Set a default thumbnail size

Generally, JPEGs are better with thumbnails, and the default parameters
typically set a basic thumbnail size. In legacy, include a default size in the
templates.

This also works around issues with some devices not producing valid images with no
thumbnail.

Bug: 17724701
Change-Id: I2ad1449fc8c6d1fdec609af55f53db7491abbb92
diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
index 618195a..03540e1 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
@@ -1350,6 +1350,14 @@
         m.set(CaptureRequest.LENS_FOCAL_LENGTH,
                 c.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS)[0]);
 
+        /*
+         * jpeg.*
+         */
+
+        // jpeg.thumbnailSize - set smallest non-zero size if possible
+        Size[] sizes = c.get(CameraCharacteristics.JPEG_AVAILABLE_THUMBNAIL_SIZES);
+        m.set(CaptureRequest.JPEG_THUMBNAIL_SIZE, (sizes.length > 1) ? sizes[1] : sizes[0]);
+
         // TODO: map other request template values
         return m;
     }