Merge pi-dev-plus-aosp-without-vendor into stage-dr1-aosp-master

Bug: 111615259
Change-Id: I5fa45da109f19a68a4256098f3e5071bb35a9d7a
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index 9387ad7..7638634 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -28490,12 +28490,26 @@
 the following code snippet can be used:</p>
 <pre><code>//<wbr/> Returns true if the device supports the required hardware level,<wbr/> or better.<wbr/>
 boolean isHardwareLevelSupported(CameraCharacteristics c,<wbr/> int requiredLevel) {
+    final int[] sortedHwLevels = {
+        Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL_<wbr/>LEGACY,<wbr/>
+        Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL_<wbr/>EXTERNAL,<wbr/>
+        Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL_<wbr/>LIMITED,<wbr/>
+        Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL_<wbr/>FULL,<wbr/>
+        Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL_<wbr/>3
+    };
     int deviceLevel = c.<wbr/>get(Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL);
-    if (deviceLevel == Camera<wbr/>Characteristics.<wbr/>INFO_<wbr/>SUPPORTED_<wbr/>HARDWARE_<wbr/>LEVEL_<wbr/>LEGACY) {
-        return requiredLevel == deviceLevel;
+    if (requiredLevel == deviceLevel) {
+        return true;
     }
-    //<wbr/> deviceLevel is not LEGACY,<wbr/> can use numerical sort
-    return requiredLevel &lt;= deviceLevel;
+
+    for (int sortedlevel : sortedHwLevels) {
+        if (sortedlevel == requiredLevel) {
+            return true;
+        } else if (sortedlevel == deviceLevel) {
+            return false;
+        }
+    }
+    return false; //<wbr/> Should never reach here
 }
 </code></pre>
 <p>At a high level,<wbr/> the levels are:</p>
@@ -28509,6 +28523,8 @@
   post-processing settings,<wbr/> and image capture at a high rate.<wbr/></li>
 <li><code>LEVEL_<wbr/>3</code> devices additionally support YUV reprocessing and RAW image capture,<wbr/> along
   with additional output stream configurations.<wbr/></li>
+<li><code>EXTERNAL</code> devices are similar to <code>LIMITED</code> devices with exceptions like some sensor or
+  lens information not reorted or less stable framerates.<wbr/></li>
 </ul>
 <p>See the individual level enums for full descriptions of the supported capabilities.<wbr/>  The
 <a href="#static_android.request.availableCapabilities">android.<wbr/>request.<wbr/>available<wbr/>Capabilities</a> entry describes the device's capabilities at a
diff --git a/camera/docs/metadata_definitions.xml b/camera/docs/metadata_definitions.xml
index e288c57..a177124 100644
--- a/camera/docs/metadata_definitions.xml
+++ b/camera/docs/metadata_definitions.xml
@@ -9234,12 +9234,26 @@
 
               // Returns true if the device supports the required hardware level, or better.
               boolean isHardwareLevelSupported(CameraCharacteristics c, int requiredLevel) {
+                  final int[] sortedHwLevels = {
+                      CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY,
+                      CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL,
+                      CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED,
+                      CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL,
+                      CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_3
+                  };
                   int deviceLevel = c.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
-                  if (deviceLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
-                      return requiredLevel == deviceLevel;
+                  if (requiredLevel == deviceLevel) {
+                      return true;
                   }
-                  // deviceLevel is not LEGACY, can use numerical sort
-                  return requiredLevel &lt;= deviceLevel;
+
+                  for (int sortedlevel : sortedHwLevels) {
+                      if (sortedlevel == requiredLevel) {
+                          return true;
+                      } else if (sortedlevel == deviceLevel) {
+                          return false;
+                      }
+                  }
+                  return false; // Should never reach here
               }
 
           At a high level, the levels are:
@@ -9253,6 +9267,8 @@
             post-processing settings, and image capture at a high rate.
           * `LEVEL_3` devices additionally support YUV reprocessing and RAW image capture, along
             with additional output stream configurations.
+          * `EXTERNAL` devices are similar to `LIMITED` devices with exceptions like some sensor or
+            lens information not reorted or less stable framerates.
 
           See the individual level enums for full descriptions of the supported capabilities.  The
           android.request.availableCapabilities entry describes the device's capabilities at a