Camera: add new EXTERNAL hardware level

Bug: 64874137 63873538
Change-Id: Ida7c14d045c6e9f13c638e2314c76178f8bdecf4
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index 5b07e4d..5d4a12f 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -27438,6 +27438,27 @@
   <code>RAW</code>)</li>
 </ul></span>
                   </li>
+                  <li>
+                    <span class="entry_type_enum_name">EXTERNAL (v3.3)</span>
+                    <span class="entry_type_enum_notes"><p>This camera device is backed by an external camera connected to this Android device.<wbr/></p>
+<p>The device has capability identical to a LIMITED level device,<wbr/> with the following
+exceptions:</p>
+<ul>
+<li>The device may not report lens/<wbr/>sensor related information such as<ul>
+<li><a href="#controls_android.lens.focalLength">android.<wbr/>lens.<wbr/>focal<wbr/>Length</a></li>
+<li><a href="#static_android.lens.info.hyperfocalDistance">android.<wbr/>lens.<wbr/>info.<wbr/>hyperfocal<wbr/>Distance</a></li>
+<li><a href="#static_android.sensor.info.physicalSize">android.<wbr/>sensor.<wbr/>info.<wbr/>physical<wbr/>Size</a></li>
+<li><a href="#static_android.sensor.info.whiteLevel">android.<wbr/>sensor.<wbr/>info.<wbr/>white<wbr/>Level</a></li>
+<li><a href="#static_android.sensor.blackLevelPattern">android.<wbr/>sensor.<wbr/>black<wbr/>Level<wbr/>Pattern</a></li>
+<li><a href="#static_android.sensor.info.colorFilterArrangement">android.<wbr/>sensor.<wbr/>info.<wbr/>color<wbr/>Filter<wbr/>Arrangement</a></li>
+<li><a href="#dynamic_android.sensor.rollingShutterSkew">android.<wbr/>sensor.<wbr/>rolling<wbr/>Shutter<wbr/>Skew</a></li>
+</ul>
+</li>
+<li>The device will report 0 for <a href="#static_android.sensor.orientation">android.<wbr/>sensor.<wbr/>orientation</a></li>
+<li>The device has less guarantee on stable framerate,<wbr/> as the framerate partly depends
+  on the external camera being used.<wbr/></li>
+</ul></span>
+                  </li>
                 </ul>
 
             </td> <!-- entry_type -->
@@ -27526,6 +27547,9 @@
 <p>Camera HAL3+ must not implement LEGACY mode.<wbr/> It is there for backwards compatibility in
 the <code>android.<wbr/>hardware.<wbr/>camera2</code> user-facing API only on legacy HALv1 devices,<wbr/> and is
 implemented by the camera framework code.<wbr/></p>
+<p>EXTERNAL level devices have lower peformance bar in CTS since the peformance might depend
+on the external camera being used and is not fully controlled by the device manufacturer.<wbr/>
+The ITS test suite is exempted for the same reason.<wbr/></p>
             </td>
           </tr>
 
diff --git a/camera/docs/metadata-check-dependencies b/camera/docs/metadata-check-dependencies
index 56f2e27..3ad7b1b 100755
--- a/camera/docs/metadata-check-dependencies
+++ b/camera/docs/metadata-check-dependencies
@@ -109,6 +109,7 @@
 binary_check python python27 python2.7
 python_check bs4 py27-beautifulsoup4 python-bs4
 python_check mako py27-mako python-mako
+python_check markdown py27-markdown python-markdown
 
 exit $retcode
 
diff --git a/camera/docs/metadata_definitions.xml b/camera/docs/metadata_definitions.xml
index 877b5fb..978171e 100644
--- a/camera/docs/metadata_definitions.xml
+++ b/camera/docs/metadata_definitions.xml
@@ -8738,6 +8738,27 @@
                 `RAW`)
               </notes>
             </value>
+            <value hal_version="3.3">
+              EXTERNAL
+              <notes>
+              This camera device is backed by an external camera connected to this Android device.
+
+              The device has capability identical to a LIMITED level device, with the following
+              exceptions:
+
+              * The device may not report lens/sensor related information such as
+                  - android.lens.focalLength
+                  - android.lens.info.hyperfocalDistance
+                  - android.sensor.info.physicalSize
+                  - android.sensor.info.whiteLevel
+                  - android.sensor.blackLevelPattern
+                  - android.sensor.info.colorFilterArrangement
+                  - android.sensor.rollingShutterSkew
+              * The device will report 0 for android.sensor.orientation
+              * The device has less guarantee on stable framerate, as the framerate partly depends
+                on the external camera being used.
+              </notes>
+            </value>
           </enum>
           <description>
           Generally classifies the overall set of the camera device functionality.
@@ -8805,6 +8826,10 @@
           Camera HAL3+ must not implement LEGACY mode. It is there for backwards compatibility in
           the `android.hardware.camera2` user-facing API only on legacy HALv1 devices, and is
           implemented by the camera framework code.
+
+          EXTERNAL level devices have lower peformance bar in CTS since the peformance might depend
+          on the external camera being used and is not fully controlled by the device manufacturer.
+          The ITS test suite is exempted for the same reason.
           </hal_details>
         </entry>
         <entry name="version" type="byte" visibility="public" typedef="string" hal_version="3.3">
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
index 80d500e..7d974c3 100644
--- a/camera/include/system/camera_metadata_tags.h
+++ b/camera/include/system/camera_metadata_tags.h
@@ -916,6 +916,7 @@
     ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL                      , // HIDL v3.2
     ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY                    , // HIDL v3.2
     ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3                         , // HIDL v3.2
+    ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL                  , // HIDL v3.3
 } camera_metadata_enum_android_info_supported_hardware_level_t;
 
 
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
index fe60b98..421544e 100644
--- a/camera/src/camera_metadata_tag_info.c
+++ b/camera/src/camera_metadata_tag_info.c
@@ -2568,6 +2568,10 @@
                     msg = "3";
                     ret = 0;
                     break;
+                case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL:
+                    msg = "EXTERNAL";
+                    ret = 0;
+                    break;
                 default:
                     msg = "error: enum value out of range";
             }