Snap for 7642458 from 77a627e6708544ad4dbd657e815a69eaf99e7841 to mainline-os-statsd-release

Change-Id: Iafc5a6038a6912a5393c771529257909b956302b
diff --git a/camera/docs/ACameraMetadata.mako b/camera/docs/ACameraMetadata.mako
index b65efc1..effa5ea 100644
--- a/camera/docs/ACameraMetadata.mako
+++ b/camera/docs/ACameraMetadata.mako
@@ -67,7 +67,7 @@
 // System tags that should be hidden from users
 std::unordered_set<uint32_t> ACameraMetadata::sSystemTags ({
     % for sec in find_all_sections(metadata):
-      % for entry in remove_synthetic(find_unique_entries(sec)):
+      % for entry in remove_synthetic_or_fwk_only(find_unique_entries(sec)):
         % if entry.applied_visibility == "system":
     ${entry.name | csym},
         % endif
diff --git a/camera/docs/CameraMetadataKeys.mako b/camera/docs/CameraMetadataKeys.mako
index c53f5d6..ac3a920 100644
--- a/camera/docs/CameraMetadataKeys.mako
+++ b/camera/docs/CameraMetadataKeys.mako
@@ -54,7 +54,7 @@
      * @deprecated
 ${entry.deprecation_description | javadoc(metadata)}
   % endif
-  % if entry.applied_visibility in ('hidden', 'ndk_public'):
+  % if entry.applied_visibility in ('hidden', 'ndk_public', 'fwk_only'):
      * @hide
   % endif
      */
@@ -77,17 +77,17 @@
 % for outer_namespace in metadata.outer_namespaces: ## assumes single 'android' namespace
   % for section in outer_namespace.sections:
     % if section.find_first(lambda x: isinstance(x, metadata_model.Entry) and x.kind == xml_name) and \
-         any_visible(section, xml_name, ('public','hidden','ndk_public','java_public') ):
+         any_visible(section, xml_name, ('public','hidden','ndk_public','java_public','fwk_only') ):
       % for inner_namespace in get_children_by_filtering_kind(section, xml_name, 'namespaces'):
 ## We only support 1 level of inner namespace, i.e. android.a.b and android.a.b.c works, but not android.a.b.c.d
 ## If we need to support more, we should use a recursive function here instead.. but the indentation gets trickier.
-        % for entry in filter_visibility(inner_namespace.merged_entries, ('hidden','public', 'ndk_public', 'java_public')):
+        % for entry in filter_visibility(inner_namespace.merged_entries, ('hidden','public', 'ndk_public', 'java_public ', 'fwk_only')):
 ${generate_key(entry)}
        % endfor
     % endfor
     % for entry in filter_visibility( \
         get_children_by_filtering_kind(section, xml_name, 'merged_entries'), \
-                                         ('hidden', 'public', 'ndk_public', 'java_public')):
+                                         ('hidden', 'public', 'ndk_public', 'java_public', 'fwk_only')):
 ${generate_key(entry)}
     % endfor
     % endif
diff --git a/camera/docs/HidlMetadata.mako b/camera/docs/HidlMetadata.mako
index 021bc0a..da69588 100644
--- a/camera/docs/HidlMetadata.mako
+++ b/camera/docs/HidlMetadata.mako
@@ -97,7 +97,7 @@
 enum CameraMetadataTag : ${'uint32_t' if first_hal_minor_version(hal_major_version()) == hal_minor_version() else '@%d.%d::CameraMetadataTag' % (hal_major_version(), hal_minor_version()-1)} {
     % for sec in find_all_sections(metadata):
 <%    gotEntries = False %>\
-      % for idx,entry in enumerate(filter_added_in_hal_version(remove_synthetic(find_unique_entries(sec)), hal_major_version(), hal_minor_version())):
+      % for idx,entry in enumerate(filter_added_in_hal_version(remove_synthetic_or_fwk_only(find_unique_entries(sec)), hal_major_version(), hal_minor_version())):
 <%      gotEntries = True %>\
     /** ${entry.name} [${entry.kind}, ${annotated_type(entry)}, ${entry.applied_visibility}]
         % if entry.description:
@@ -128,7 +128,7 @@
  * Enumeration definitions for the various entries that need them
  */
 % for sec in find_all_sections(metadata):
-  % for entry in filter_has_enum_values_added_in_hal_version(remove_synthetic(find_unique_entries(sec)), hal_major_version(), hal_minor_version()):
+  % for entry in filter_has_enum_values_added_in_hal_version(remove_synthetic_or_fwk_only(find_unique_entries(sec)), hal_major_version(), hal_minor_version()):
     % if entry.enum:
 
 <%    isFirstValue = True %>\
diff --git a/camera/docs/camera_metadata_tags.mako b/camera/docs/camera_metadata_tags.mako
index 7e951a2..e7515a8 100644
--- a/camera/docs/camera_metadata_tags.mako
+++ b/camera/docs/camera_metadata_tags.mako
@@ -77,10 +77,10 @@
     % for sec in find_all_sections(metadata):
       % for idx,entry in enumerate(remove_synthetic(find_unique_entries(sec))):
         % if idx == 0:
-    ${entry.name + " = " | csym,ljust(50)}// ${annotated_type(entry) | ljust(12)} | ${entry.applied_visibility | ljust(12)} | HIDL v${entry.hal_major_version}.${entry.hal_minor_version}
+    ${entry.name + " = " | csym,ljust(50)}// ${annotated_type(entry) | ljust(12)} | ${entry.hidl_comment_string}
             ${path_name(find_parent_section(entry)) | csym}_START,
         % else:
-    ${entry.name + "," | csym,ljust(50)}// ${annotated_type(entry) | ljust(12)} | ${entry.applied_visibility | ljust(12)} | HIDL v${entry.hal_major_version}.${entry.hal_minor_version}
+    ${entry.name + "," | csym,ljust(50)}// ${annotated_type(entry) | ljust(12)} | ${entry.hidl_comment_string}
         % endif
       % endfor
     ${path_name(sec) | csym}_END,
@@ -99,9 +99,9 @@
 typedef enum camera_metadata_enum_${csym(entry.name).lower()} {
       % for val in entry.enum.values:
         % if val.id is None:
-    ${entry.name | csym}_${val.name | pad(70)}, // HIDL v${val.hal_major_version}.${val.hal_minor_version}
+    ${entry.name | csym}_${val.name | pad(70)}${val.hidl_comment_string}
         % else:
-    ${'%s_%s'%(csym(entry.name), val.name) | pad(70)} = ${val.id}, // HIDL v${val.hal_major_version}.${val.hal_minor_version}
+    ${'%s_%s'%(csym(entry.name), val.name) | pad(70)} = ${val.id}${val.hidl_comment_string}
         % endif
       % endfor
 } camera_metadata_enum_${csym(entry.name).lower()}_t;
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index fc3f33b..fa707ed 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -197,6 +197,12 @@
             ><a href="#controls_android.control.extendedSceneMode">android.control.extendedSceneMode</a></li>
             <li
             ><a href="#controls_android.control.zoomRatio">android.control.zoomRatio</a></li>
+            <li
+            ><a href="#controls_android.control.afRegionsSet">android.control.afRegionsSet</a></li>
+            <li
+            ><a href="#controls_android.control.aeRegionsSet">android.control.aeRegionsSet</a></li>
+            <li
+            ><a href="#controls_android.control.awbRegionsSet">android.control.awbRegionsSet</a></li>
           </ul>
         </li>
         <li>
@@ -726,6 +732,8 @@
             ><a href="#controls_android.scaler.cropRegion">android.scaler.cropRegion</a></li>
             <li
             ><a href="#controls_android.scaler.rotateAndCrop">android.scaler.rotateAndCrop</a></li>
+            <li
+            ><a href="#controls_android.scaler.cropRegionSet">android.scaler.cropRegionSet</a></li>
           </ul>
         </li>
         <li>
@@ -5027,6 +5035,192 @@
           <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
            <!-- end of entry -->
         
+                
+          <tr class="entry" id="controls_android.control.afRegionsSet">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>control.<wbr/>af<wbr/>Regions<wbr/>Set
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [fwk_only as boolean]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">TRUE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>AF regions (<a href="#controls_android.control.afRegions">android.<wbr/>control.<wbr/>af<wbr/>Regions</a>) have been set by the camera client.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">FALSE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>AF regions (<a href="#controls_android.control.afRegions">android.<wbr/>control.<wbr/>af<wbr/>Regions</a>) have not been set by the camera client.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Framework-only private key which informs camera fwk that the AF regions has been set
+by the client and those regions need not be corrected when <a href="#controls_android.sensor.pixelMode">android.<wbr/>sensor.<wbr/>pixel<wbr/>Mode</a> is
+set to MAXIMUM_<wbr/>RESOLUTION.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>2</p>
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
+<a href="#controls_android.control.afRegions">android.<wbr/>control.<wbr/>af<wbr/>Regions</a>.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
+                
+          <tr class="entry" id="controls_android.control.aeRegionsSet">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>control.<wbr/>ae<wbr/>Regions<wbr/>Set
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [fwk_only as boolean]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">TRUE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>AE regions (<a href="#controls_android.control.aeRegions">android.<wbr/>control.<wbr/>ae<wbr/>Regions</a>) have been set by the camera client.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">FALSE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>AE regions (<a href="#controls_android.control.aeRegions">android.<wbr/>control.<wbr/>ae<wbr/>Regions</a>) have not been set by the camera client.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Framework-only private key which informs camera fwk that the AE regions has been set
+by the client and those regions need not be corrected when <a href="#controls_android.sensor.pixelMode">android.<wbr/>sensor.<wbr/>pixel<wbr/>Mode</a> is
+set to MAXIMUM_<wbr/>RESOLUTION.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>2</p>
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
+<a href="#controls_android.control.aeRegions">android.<wbr/>control.<wbr/>ae<wbr/>Regions</a>.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
+                
+          <tr class="entry" id="controls_android.control.awbRegionsSet">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>control.<wbr/>awb<wbr/>Regions<wbr/>Set
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [fwk_only as boolean]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">TRUE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>AWB regions (<a href="#controls_android.control.awbRegions">android.<wbr/>control.<wbr/>awb<wbr/>Regions</a>) have been set by the camera client.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">FALSE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>AWB regions (<a href="#controls_android.control.awbRegions">android.<wbr/>control.<wbr/>awb<wbr/>Regions</a>) have not been set by the camera client.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Framework-only private key which informs camera fwk that the AF regions has been set
+by the client and those regions need not be corrected when <a href="#controls_android.sensor.pixelMode">android.<wbr/>sensor.<wbr/>pixel<wbr/>Mode</a> is
+set to MAXIMUM_<wbr/>RESOLUTION.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>2</p>
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
+<a href="#controls_android.control.awbRegions">android.<wbr/>control.<wbr/>awb<wbr/>Regions</a>.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
@@ -18736,13 +18930,27 @@
 camera's crop region is set to maximum size,<wbr/> the FOV of the physical streams for the
 ultrawide lens will be the same as the logical stream,<wbr/> by making the crop region
 smaller than its active array size to compensate for the smaller focal length.<wbr/></p>
-<p>Even if the underlying physical cameras have different RAW characteristics (such as
-size or CFA pattern),<wbr/> a logical camera can still advertise RAW capability.<wbr/> In this
-case,<wbr/> when the application configures a RAW stream,<wbr/> the camera device will make sure
-the active physical camera will remain active to ensure consistent RAW output
-behavior,<wbr/> and not switch to other physical cameras.<wbr/></p>
+<p>There are two ways for the application to capture RAW images from a logical camera
+with RAW capability:</p>
+<ul>
+<li>Because the underlying physical cameras may have different RAW capabilities (such
+as resolution or CFA pattern),<wbr/> to maintain backward compatibility,<wbr/> when a RAW stream
+is configured,<wbr/> the camera device makes sure the default active physical camera remains
+active and does not switch to other physical cameras.<wbr/> (One exception is that,<wbr/> if the
+logical camera consists of identical image sensors and advertises multiple focalLength
+due to different lenses,<wbr/> the camera device may generate RAW images from different
+physical cameras based on the focalLength being set by the application.<wbr/>) This
+backward-compatible approach usually results in loss of optical zoom,<wbr/> to telephoto
+lens or to ultrawide lens.<wbr/></li>
+<li>Alternatively,<wbr/> to take advantage of the full zoomRatio range of the logical camera,<wbr/>
+the application should use <a href="https://developer.android.com/reference/android/hardware/camera2/MultiResolutionImageReader.html">MultiResolutionImageReader</a>
+to capture RAW images from the currently active physical camera.<wbr/> Because different
+physical camera may have different RAW characteristics,<wbr/> the application needs to use
+the characteristics and result metadata of the active physical camera for the
+relevant RAW metadata.<wbr/></li>
+</ul>
 <p>The capture request and result metadata tags required for backward compatible camera
-functionalities will be solely based on the logical camera capabiltity.<wbr/> On the other
+functionalities will be solely based on the logical camera capability.<wbr/> On the other
 hand,<wbr/> the use of manual capture controls (sensor or post-processing) with a
 logical camera may result in unexpected behavior when the HAL decides to switch
 between physical cameras with different characteristics under the hood.<wbr/> For example,<wbr/>
@@ -18835,7 +19043,10 @@
 <code><a href="#static_android.scaler.streamConfigurationMap">android.<wbr/>scaler.<wbr/>stream<wbr/>Configuration<wbr/>Map</a></code> describes the streams supported in 'default'
 mode.<wbr/>
 The stream configurations supported in 'max resolution' mode are described by
-<code><a href="#static_android.scaler.streamConfigurationMapMaximumResolution">android.<wbr/>scaler.<wbr/>stream<wbr/>Configuration<wbr/>Map<wbr/>Maximum<wbr/>Resolution</a></code>.<wbr/></p></span>
+<code><a href="#static_android.scaler.streamConfigurationMapMaximumResolution">android.<wbr/>scaler.<wbr/>stream<wbr/>Configuration<wbr/>Map<wbr/>Maximum<wbr/>Resolution</a></code>.<wbr/>
+The maximum resolution mode pixel array size of a camera device
+(<code><a href="#static_android.sensor.info.pixelArraySize">android.<wbr/>sensor.<wbr/>info.<wbr/>pixel<wbr/>Array<wbr/>Size</a></code>) with this capability,<wbr/>
+will be at least 24 megapixels.<wbr/></p></span>
                   </li>
                   <li>
                     <span class="entry_type_enum_name">REMOSAIC_REPROCESSING (v3.6)</span>
@@ -20235,6 +20446,70 @@
           <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
            <!-- end of entry -->
         
+                
+          <tr class="entry" id="controls_android.scaler.cropRegionSet">
+            <td class="entry_name
+             " rowspan="3">
+              android.<wbr/>scaler.<wbr/>crop<wbr/>Region<wbr/>Set
+            </td>
+            <td class="entry_type">
+                <span class="entry_type_name entry_type_name_enum">byte</span>
+
+              <span class="entry_type_visibility"> [fwk_only as boolean]</span>
+
+
+
+
+
+                <ul class="entry_type_enum">
+                  <li>
+                    <span class="entry_type_enum_name">TRUE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>Crop region (<a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>) has been set by the
+camera client.<wbr/></p></span>
+                  </li>
+                  <li>
+                    <span class="entry_type_enum_name">FALSE (v3.2)</span>
+                    <span class="entry_type_enum_notes"><p>Scaler crop regions (<a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>) has not been set by the camera
+client.<wbr/></p></span>
+                  </li>
+                </ul>
+
+            </td> <!-- entry_type -->
+
+            <td class="entry_description">
+              <p>Framework-only private key which informs camera fwk that the scaler crop region
+(<a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>) has been set by the client and it need
+not be corrected when <a href="#controls_android.sensor.pixelMode">android.<wbr/>sensor.<wbr/>pixel<wbr/>Mode</a> is set to MAXIMUM_<wbr/>RESOLUTION.<wbr/></p>
+            </td>
+
+            <td class="entry_units">
+            </td>
+
+            <td class="entry_range">
+            </td>
+
+            <td class="entry_hal_version">
+              <p>3.<wbr/>2</p>
+            </td>
+
+            <td class="entry_tags">
+            </td>
+
+          </tr>
+          <tr class="entries_header">
+            <th class="th_details" colspan="6">Details</th>
+          </tr>
+          <tr class="entry_cont">
+            <td class="entry_details" colspan="6">
+              <p>This must be set to TRUE by the camera2 java fwk when the camera client sets
+<a href="#controls_android.scaler.cropRegion">android.<wbr/>scaler.<wbr/>crop<wbr/>Region</a>.<wbr/></p>
+            </td>
+          </tr>
+
+
+          <tr class="entry_spacer"><td class="entry_spacer" colspan="7"></td></tr>
+           <!-- end of entry -->
+        
         
 
       <!-- end of kind -->
diff --git a/camera/docs/metadata_definitions.xml b/camera/docs/metadata_definitions.xml
index 34d4c1f..c23bd46 100644
--- a/camera/docs/metadata_definitions.xml
+++ b/camera/docs/metadata_definitions.xml
@@ -3402,6 +3402,77 @@
         <tag id="V1" />
       </entry>
     </static>
+    <controls>
+        <entry name="afRegionsSet" type="byte" visibility="fwk_only"
+               enum="true" typedef="boolean">
+          <enum>
+            <value>TRUE
+            <notes>AF regions (android.control.afRegions) have been set by the camera client.
+            </notes>
+            </value>
+            <value>FALSE
+            <notes>
+              AF regions (android.control.afRegions) have not been set by the camera client.
+            </notes>
+            </value>
+          </enum>
+          <description>
+            Framework-only private key which informs camera fwk that the AF regions has been set
+            by the client and those regions need not be corrected when android.sensor.pixelMode is
+            set to MAXIMUM_RESOLUTION.
+          </description>
+          <details>
+            This must be set to TRUE by the camera2 java fwk when the camera client sets
+            android.control.afRegions.
+          </details>
+        </entry>
+        <entry name="aeRegionsSet" type="byte" visibility="fwk_only"
+          enum="true" typedef="boolean">
+          <enum>
+            <value>TRUE
+            <notes> AE regions (android.control.aeRegions) have been set by the camera client.
+            </notes>
+            </value>
+            <value>FALSE
+            <notes>
+              AE regions (android.control.aeRegions) have not been set by the camera client.
+            </notes>
+            </value>
+          </enum>
+          <description>
+            Framework-only private key which informs camera fwk that the AE regions has been set
+            by the client and those regions need not be corrected when android.sensor.pixelMode is
+            set to MAXIMUM_RESOLUTION.
+          </description>
+          <details>
+            This must be set to TRUE by the camera2 java fwk when the camera client sets
+            android.control.aeRegions.
+          </details>
+        </entry>
+        <entry name="awbRegionsSet" type="byte" visibility="fwk_only"
+          enum="true" typedef="boolean">
+          <enum>
+            <value>TRUE
+            <notes> AWB regions (android.control.awbRegions) have been set by the camera client.
+            </notes>
+            </value>
+            <value>FALSE
+            <notes>
+              AWB regions (android.control.awbRegions) have not been set by the camera client.
+            </notes>
+            </value>
+          </enum>
+          <description>
+            Framework-only private key which informs camera fwk that the AF regions has been set
+            by the client and those regions need not be corrected when android.sensor.pixelMode is
+            set to MAXIMUM_RESOLUTION.
+          </description>
+          <details>
+            This must be set to TRUE by the camera2 java fwk when the camera client sets
+            android.control.awbRegions.
+          </details>
+        </entry>
+    </controls>
     </section>
     <section name="demosaic">
       <controls>
@@ -5934,14 +6005,27 @@
               ultrawide lens will be the same as the logical stream, by making the crop region
               smaller than its active array size to compensate for the smaller focal length.
 
-              Even if the underlying physical cameras have different RAW characteristics (such as
-              size or CFA pattern), a logical camera can still advertise RAW capability. In this
-              case, when the application configures a RAW stream, the camera device will make sure
-              the active physical camera will remain active to ensure consistent RAW output
-              behavior, and not switch to other physical cameras.
+              There are two ways for the application to capture RAW images from a logical camera
+              with RAW capability:
+
+              * Because the underlying physical cameras may have different RAW capabilities (such
+              as resolution or CFA pattern), to maintain backward compatibility, when a RAW stream
+              is configured, the camera device makes sure the default active physical camera remains
+              active and does not switch to other physical cameras. (One exception is that, if the
+              logical camera consists of identical image sensors and advertises multiple focalLength
+              due to different lenses, the camera device may generate RAW images from different
+              physical cameras based on the focalLength being set by the application.) This
+              backward-compatible approach usually results in loss of optical zoom, to telephoto
+              lens or to ultrawide lens.
+              * Alternatively, to take advantage of the full zoomRatio range of the logical camera,
+              the application should use {@link android.hardware.camera2.MultiResolutionImageReader}
+              to capture RAW images from the currently active physical camera. Because different
+              physical camera may have different RAW characteristics, the application needs to use
+              the characteristics and result metadata of the active physical camera for the
+              relevant RAW metadata.
 
               The capture request and result metadata tags required for backward compatible camera
-              functionalities will be solely based on the logical camera capabiltity. On the other
+              functionalities will be solely based on the logical camera capability. On the other
               hand, the use of manual capture controls (sensor or post-processing) with a
               logical camera may result in unexpected behavior when the HAL decides to switch
               between physical cameras with different characteristics under the hood. For example,
@@ -6034,6 +6118,9 @@
                 mode.
                 The stream configurations supported in 'max resolution' mode are described by
                 `android.scaler.streamConfigurationMapMaximumResolution`.
+                The maximum resolution mode pixel array size of a camera device
+                (`android.sensor.info.pixelArraySize`) with this capability,
+                will be at least 24 megapixels.
               </notes>
             </value>
             <value optional="true" visibility="java_public" hal_version="3.6">REMOSAIC_REPROCESSING
@@ -8073,6 +8160,33 @@
           </hal_details>
         </entry>
       </static>
+      <controls>
+        <entry name="cropRegionSet" type="byte" visibility="fwk_only"
+               enum="true" typedef="boolean">
+          <enum>
+            <value>TRUE
+            <notes>Crop region (android.scaler.cropRegion) has been set by the
+              camera client.
+            </notes>
+            </value>
+            <value>FALSE
+            <notes>
+              Scaler crop regions (android.scaler.cropRegion) has not been set by the camera
+              client.
+            </notes>
+            </value>
+          </enum>
+          <description>
+            Framework-only private key which informs camera fwk that the scaler crop region
+            (android.scaler.cropRegion) has been set by the client and it need
+            not be corrected when android.sensor.pixelMode is set to MAXIMUM_RESOLUTION.
+          </description>
+          <details>
+            This must be set to TRUE by the camera2 java fwk when the camera client sets
+            android.scaler.cropRegion.
+          </details>
+        </entry>
+      </controls>
     </section>
     <section name="sensor">
       <controls>
diff --git a/camera/docs/metadata_definitions.xsd b/camera/docs/metadata_definitions.xsd
index 262bf06..6df5813 100644
--- a/camera/docs/metadata_definitions.xsd
+++ b/camera/docs/metadata_definitions.xsd
@@ -205,6 +205,7 @@
                     <enumeration value="ndk_public" /> <!-- public in NDK. @hide in java -->
                     <enumeration value="hidden" /> <!-- java as @hide. Not included in NDK -->
                     <enumeration value="public" /> <!-- public to both java and NDK -->
+                    <enumeration value="fwk_only" /> <!-- java as @hide. Not included in NDK. Not included in hal interfaces. -->
                 </restriction>
             </simpleType>
         </attribute>
diff --git a/camera/docs/metadata_helpers.py b/camera/docs/metadata_helpers.py
index 58fad4c..5039828 100644
--- a/camera/docs/metadata_helpers.py
+++ b/camera/docs/metadata_helpers.py
@@ -1347,6 +1347,18 @@
   """
   return (e for e in entries if e.applied_visibility in visibilities)
 
+def remove_synthetic_or_fwk_only(entries):
+  """
+  Filter the given entries by removing those that are synthetic or fwk_only.
+
+  Args:
+    entries: An iterable of Entry nodes
+
+  Yields:
+    An iterable of Entry nodes
+  """
+  return (e for e in entries if not (e.synthetic or e.visibility == 'fwk_only'))
+
 def remove_synthetic(entries):
   """
   Filter the given entries by removing those that are synthetic.
@@ -1400,7 +1412,7 @@
   """
   ret = 0
   for sec in find_all_sections(root):
-      ret += len(list(filter_has_permission_needed(remove_synthetic(find_unique_entries(sec)))))
+      ret += len(list(filter_has_permission_needed(remove_synthetic_or_fwk_only(find_unique_entries(sec)))))
 
   return ret
 
@@ -1522,7 +1534,7 @@
   for section in all_sections:
     min_major_version = None
     min_minor_version = None
-    for entry in remove_synthetic(find_unique_entries(section)):
+    for entry in remove_synthetic_or_fwk_only(find_unique_entries(section)):
       min_major_version = (min_major_version or entry.hal_major_version)
       min_minor_version = (min_minor_version or entry.hal_minor_version)
       if entry.hal_major_version < min_major_version or \
diff --git a/camera/docs/metadata_model.py b/camera/docs/metadata_model.py
index 35e8437..31a8c74 100644
--- a/camera/docs/metadata_model.py
+++ b/camera/docs/metadata_model.py
@@ -1028,6 +1028,15 @@
     return self._visibility or 'public'
 
   @property
+  def hidl_comment_string(self):
+    parent_enum = None
+    if (self.parent is not None and self.parent.parent is not None):
+      parent_enum = self.parent.parent
+    if parent_enum is not None and parent_enum.visibility == 'fwk_only' or self._visibility == 'fwk_only':
+      return ','
+    return ', // HIDL v' + str(self._hal_major_version) + '.' + str(self.hal_minor_version)
+
+  @property
   def hidden(self):
     return self.visibility in {'hidden', 'ndk_public', 'test'}
 
@@ -1239,6 +1248,13 @@
     return self._visibility or 'system'
 
   @property
+  def hidl_comment_string(self):
+    if self._visibility == 'fwk_only':
+      return 'fwk_only'
+    visibility_lj = str(self.applied_visibility).ljust(12)
+    return visibility_lj + ' | HIDL v' + str(self._hal_major_version) + '.' + str(self._hal_minor_version)
+
+  @property
   def applied_ndk_visible(self):
     if self._visibility in ("public", "ndk_public"):
       return "true"
diff --git a/camera/docs/ndk_camera_metadata_tags.mako b/camera/docs/ndk_camera_metadata_tags.mako
index f355773..c079820 100644
--- a/camera/docs/ndk_camera_metadata_tags.mako
+++ b/camera/docs/ndk_camera_metadata_tags.mako
@@ -79,12 +79,12 @@
 typedef enum acamera_metadata_tag {
     % for sec in find_all_sections(metadata):
 <%
-      entries = remove_synthetic(find_unique_entries(sec))
+      entries = remove_synthetic_or_fwk_only(find_unique_entries(sec))
       skip_sec = all(e.applied_ndk_visible == "false" for e in entries)
       if skip_sec:
         continue
 %>\
-      % for idx,entry in enumerate(remove_synthetic(find_unique_entries(sec))):
+      % for idx,entry in enumerate(remove_synthetic_or_fwk_only(find_unique_entries(sec))):
         % if entry.applied_ndk_visible == "true":
           % if entry.deprecated:
     ${ndk(entry.name) + " = " | csym,ljust(60)}// Deprecated! DO NOT USE
@@ -134,7 +134,7 @@
  */
 
 % for sec in find_all_sections(metadata):
-  % for entry in filter_ndk_visible(remove_synthetic(find_unique_entries(sec))):
+  % for entry in filter_ndk_visible(remove_synthetic_or_fwk_only(find_unique_entries(sec))):
     % if entry.enum:
 // ${ndk(entry.name) | csym}
 typedef enum acamera_metadata_enum_${csym(ndk(entry.name)).lower()} {
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
index 9c8b041..2b3dfc2 100644
--- a/camera/include/system/camera_metadata_tags.h
+++ b/camera/include/system/camera_metadata_tags.h
@@ -183,6 +183,9 @@
     ANDROID_CONTROL_ZOOM_RATIO,                       // float        | public       | HIDL v3.5
     ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION,
                                                       // int32[]      | hidden       | HIDL v3.6
+    ANDROID_CONTROL_AF_REGIONS_SET,                   // enum         | fwk_only
+    ANDROID_CONTROL_AE_REGIONS_SET,                   // enum         | fwk_only
+    ANDROID_CONTROL_AWB_REGIONS_SET,                  // enum         | fwk_only
     ANDROID_CONTROL_END,
 
     ANDROID_DEMOSAIC_MODE =                           // enum         | system       | HIDL v3.2
@@ -330,6 +333,7 @@
     ANDROID_SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP_MAXIMUM_RESOLUTION,
                                                       // int32        | hidden       | HIDL v3.6
     ANDROID_SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED, // enum         | ndk_public   | HIDL v3.6
+    ANDROID_SCALER_CROP_REGION_SET,                   // enum         | fwk_only
     ANDROID_SCALER_END,
 
     ANDROID_SENSOR_EXPOSURE_TIME =                    // int64        | public       | HIDL v3.2
@@ -745,6 +749,24 @@
     ANDROID_CONTROL_EXTENDED_SCENE_MODE_VENDOR_START                 = 0x40, // HIDL v3.5
 } camera_metadata_enum_android_control_extended_scene_mode_t;
 
+// ANDROID_CONTROL_AF_REGIONS_SET
+typedef enum camera_metadata_enum_android_control_af_regions_set {
+    ANDROID_CONTROL_AF_REGIONS_SET_TRUE                             ,
+    ANDROID_CONTROL_AF_REGIONS_SET_FALSE                            ,
+} camera_metadata_enum_android_control_af_regions_set_t;
+
+// ANDROID_CONTROL_AE_REGIONS_SET
+typedef enum camera_metadata_enum_android_control_ae_regions_set {
+    ANDROID_CONTROL_AE_REGIONS_SET_TRUE                             ,
+    ANDROID_CONTROL_AE_REGIONS_SET_FALSE                            ,
+} camera_metadata_enum_android_control_ae_regions_set_t;
+
+// ANDROID_CONTROL_AWB_REGIONS_SET
+typedef enum camera_metadata_enum_android_control_awb_regions_set {
+    ANDROID_CONTROL_AWB_REGIONS_SET_TRUE                            ,
+    ANDROID_CONTROL_AWB_REGIONS_SET_FALSE                           ,
+} camera_metadata_enum_android_control_awb_regions_set_t;
+
 
 // ANDROID_DEMOSAIC_MODE
 typedef enum camera_metadata_enum_android_demosaic_mode {
@@ -961,6 +983,12 @@
     ANDROID_SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED_TRUE           , // HIDL v3.6
 } camera_metadata_enum_android_scaler_multi_resolution_stream_supported_t;
 
+// ANDROID_SCALER_CROP_REGION_SET
+typedef enum camera_metadata_enum_android_scaler_crop_region_set {
+    ANDROID_SCALER_CROP_REGION_SET_TRUE                             ,
+    ANDROID_SCALER_CROP_REGION_SET_FALSE                            ,
+} camera_metadata_enum_android_scaler_crop_region_set_t;
+
 
 // ANDROID_SENSOR_REFERENCE_ILLUMINANT1
 typedef enum camera_metadata_enum_android_sensor_reference_illuminant1 {
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
index c81c2cd..94bead3 100644
--- a/camera/src/camera_metadata_tag_info.c
+++ b/camera/src/camera_metadata_tag_info.c
@@ -249,6 +249,12 @@
     [ ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION - ANDROID_CONTROL_START ] =
     { "availableHighSpeedVideoConfigurationsMaximumResolution",
                                         TYPE_INT32  },
+    [ ANDROID_CONTROL_AF_REGIONS_SET - ANDROID_CONTROL_START ] =
+    { "afRegionsSet",                  TYPE_BYTE   },
+    [ ANDROID_CONTROL_AE_REGIONS_SET - ANDROID_CONTROL_START ] =
+    { "aeRegionsSet",                  TYPE_BYTE   },
+    [ ANDROID_CONTROL_AWB_REGIONS_SET - ANDROID_CONTROL_START ] =
+    { "awbRegionsSet",                 TYPE_BYTE   },
 };
 
 static tag_info_t android_demosaic[ANDROID_DEMOSAIC_END -
@@ -510,6 +516,8 @@
     [ ANDROID_SCALER_MULTI_RESOLUTION_STREAM_SUPPORTED - ANDROID_SCALER_START ] =
     { "multiResolutionStreamSupported",
                                         TYPE_BYTE   },
+    [ ANDROID_SCALER_CROP_REGION_SET - ANDROID_SCALER_START ] =
+    { "cropRegionSet",                 TYPE_BYTE   },
 };
 
 static tag_info_t android_sensor[ANDROID_SENSOR_END -
@@ -1645,6 +1653,51 @@
         case ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION: {
             break;
         }
+        case ANDROID_CONTROL_AF_REGIONS_SET: {
+            switch (value) {
+                case ANDROID_CONTROL_AF_REGIONS_SET_TRUE:
+                    msg = "TRUE";
+                    ret = 0;
+                    break;
+                case ANDROID_CONTROL_AF_REGIONS_SET_FALSE:
+                    msg = "FALSE";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
+        case ANDROID_CONTROL_AE_REGIONS_SET: {
+            switch (value) {
+                case ANDROID_CONTROL_AE_REGIONS_SET_TRUE:
+                    msg = "TRUE";
+                    ret = 0;
+                    break;
+                case ANDROID_CONTROL_AE_REGIONS_SET_FALSE:
+                    msg = "FALSE";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
+        case ANDROID_CONTROL_AWB_REGIONS_SET: {
+            switch (value) {
+                case ANDROID_CONTROL_AWB_REGIONS_SET_TRUE:
+                    msg = "TRUE";
+                    ret = 0;
+                    break;
+                case ANDROID_CONTROL_AWB_REGIONS_SET_FALSE:
+                    msg = "FALSE";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
 
         case ANDROID_DEMOSAIC_MODE: {
             switch (value) {
@@ -2433,6 +2486,21 @@
             }
             break;
         }
+        case ANDROID_SCALER_CROP_REGION_SET: {
+            switch (value) {
+                case ANDROID_SCALER_CROP_REGION_SET_TRUE:
+                    msg = "TRUE";
+                    ret = 0;
+                    break;
+                case ANDROID_SCALER_CROP_REGION_SET_FALSE:
+                    msg = "FALSE";
+                    ret = 0;
+                    break;
+                default:
+                    msg = "error: enum value out of range";
+            }
+            break;
+        }
 
         case ANDROID_SENSOR_EXPOSURE_TIME: {
             break;
@@ -4261,6 +4329,51 @@
         case ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS_MAXIMUM_RESOLUTION: {
             break;
         }
+        case ANDROID_CONTROL_AF_REGIONS_SET: {
+                enumName = "TRUE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_CONTROL_AF_REGIONS_SET_TRUE;
+                    ret = 0;
+                    break;
+                }
+                enumName = "FALSE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_CONTROL_AF_REGIONS_SET_FALSE;
+                    ret = 0;
+                    break;
+                }
+            break;
+        }
+        case ANDROID_CONTROL_AE_REGIONS_SET: {
+                enumName = "TRUE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_CONTROL_AE_REGIONS_SET_TRUE;
+                    ret = 0;
+                    break;
+                }
+                enumName = "FALSE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_CONTROL_AE_REGIONS_SET_FALSE;
+                    ret = 0;
+                    break;
+                }
+            break;
+        }
+        case ANDROID_CONTROL_AWB_REGIONS_SET: {
+                enumName = "TRUE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_CONTROL_AWB_REGIONS_SET_TRUE;
+                    ret = 0;
+                    break;
+                }
+                enumName = "FALSE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_CONTROL_AWB_REGIONS_SET_FALSE;
+                    ret = 0;
+                    break;
+                }
+            break;
+        }
 
         case ANDROID_DEMOSAIC_MODE: {
                 enumName = "FAST";
@@ -5143,6 +5256,21 @@
                 }
             break;
         }
+        case ANDROID_SCALER_CROP_REGION_SET: {
+                enumName = "TRUE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_SCALER_CROP_REGION_SET_TRUE;
+                    ret = 0;
+                    break;
+                }
+                enumName = "FALSE";
+                if (strncmp(name, enumName, size) == 0) {
+                    *value = ANDROID_SCALER_CROP_REGION_SET_FALSE;
+                    ret = 0;
+                    break;
+                }
+            break;
+        }
 
         case ANDROID_SENSOR_EXPOSURE_TIME: {
             break;