Merge "camera_metadata: Add OFF_KEEP_STATE flag mode"
diff --git a/camera/docs/docs.html b/camera/docs/docs.html
index 3801fb3..951ff66 100644
--- a/camera/docs/docs.html
+++ b/camera/docs/docs.html
@@ -1900,8 +1900,8 @@
                   <li>
                     <span class="entry_type_enum_name">ON</span>
                     <span class="entry_type_enum_notes"><p>Auto-whitebalance lock is enabled; the AWB
-algorithm must not update the exposure and sensitivity
-parameters while the lock is active</p></span>
+algorithm must not update its parameters while the lock
+is active.<wbr/></p></span>
                   </li>
                 </ul>
 
@@ -1909,7 +1909,7 @@
 
             <td class="entry_description">
               <p>Whether AWB is currently locked to its
-latest calculated values</p>
+latest calculated values.<wbr/></p>
             </td>
 
             <td class="entry_units">
@@ -1932,7 +1932,7 @@
             <td class="entry_details" colspan="5">
               <p>Note that AWB lock is only meaningful for AUTO
 mode; in other modes,<wbr/> AWB is already fixed to a specific
-setting</p>
+setting.<wbr/></p>
             </td>
           </tr>
 
@@ -2351,6 +2351,12 @@
 This setting can only be used if availableSceneModes !=
 UNSUPPORTED</p></span>
                   </li>
+                  <li>
+                    <span class="entry_type_enum_name">OFF_KEEP_STATE</span>
+                    <span class="entry_type_enum_notes"><p>Same as OFF mode,<wbr/> except that this capture will not be
+used by camera device background auto-exposure,<wbr/> auto-white balance and
+auto-focus algorithms to update their statistics.<wbr/></p></span>
+                  </li>
                 </ul>
 
             </td> <!-- entry_type -->
@@ -2389,6 +2395,11 @@
 one of the scene mode settings (such as ACTION,<wbr/> SUNSET,<wbr/> or PARTY)
 as it wishes.<wbr/> The camera device scene mode 3A settings are provided by
 <a href="#static_android.control.sceneModeOverrides">android.<wbr/>control.<wbr/>scene<wbr/>Mode<wbr/>Overrides</a>.<wbr/></p>
+<p>When set to OFF_<wbr/>KEEP_<wbr/>STATE,<wbr/> it is similar to OFF mode,<wbr/> the only difference
+is that this frame will not be used by camera device background 3A statistics
+update,<wbr/> as if this frame is never captured.<wbr/> This mode can be used in the scenario
+where the application doesn't want a 3A manual control capture to affect
+the subsequent auto 3A capture results.<wbr/></p>
             </td>
           </tr>
 
@@ -4700,6 +4711,12 @@
 This setting can only be used if availableSceneModes !=
 UNSUPPORTED</p></span>
                   </li>
+                  <li>
+                    <span class="entry_type_enum_name">OFF_KEEP_STATE</span>
+                    <span class="entry_type_enum_notes"><p>Same as OFF mode,<wbr/> except that this capture will not be
+used by camera device background auto-exposure,<wbr/> auto-white balance and
+auto-focus algorithms to update their statistics.<wbr/></p></span>
+                  </li>
                 </ul>
 
             </td> <!-- entry_type -->
@@ -4738,6 +4755,11 @@
 one of the scene mode settings (such as ACTION,<wbr/> SUNSET,<wbr/> or PARTY)
 as it wishes.<wbr/> The camera device scene mode 3A settings are provided by
 <a href="#static_android.control.sceneModeOverrides">android.<wbr/>control.<wbr/>scene<wbr/>Mode<wbr/>Overrides</a>.<wbr/></p>
+<p>When set to OFF_<wbr/>KEEP_<wbr/>STATE,<wbr/> it is similar to OFF mode,<wbr/> the only difference
+is that this frame will not be used by camera device background 3A statistics
+update,<wbr/> as if this frame is never captured.<wbr/> This mode can be used in the scenario
+where the application doesn't want a 3A manual control capture to affect
+the subsequent auto 3A capture results.<wbr/></p>
             </td>
           </tr>
 
diff --git a/camera/docs/metadata_properties.xml b/camera/docs/metadata_properties.xml
index 942cf0b..3b4051e 100644
--- a/camera/docs/metadata_properties.xml
+++ b/camera/docs/metadata_properties.xml
@@ -635,14 +635,14 @@
             mode.</notes></value>
             <value>ON
             <notes>Auto-whitebalance lock is enabled; the AWB
-            algorithm must not update the exposure and sensitivity
-            parameters while the lock is active</notes></value>
+            algorithm must not update its parameters while the lock
+            is active.</notes></value>
           </enum>
           <description>Whether AWB is currently locked to its
-          latest calculated values</description>
+          latest calculated values.</description>
           <details>Note that AWB lock is only meaningful for AUTO
           mode; in other modes, AWB is already fixed to a specific
-          setting</details>
+          setting.</details>
           <tag id="BC" />
         </entry>
         <entry name="awbMode" type="byte" visibility="public" enum="true">
@@ -900,6 +900,10 @@
             scene mode). Other control entries are still active.
             This setting can only be used if availableSceneModes !=
             UNSUPPORTED</notes></value>
+            <value>OFF_KEEP_STATE
+            <notes>Same as OFF mode, except that this capture will not be
+            used by camera device background auto-exposure, auto-white balance and
+            auto-focus algorithms to update their statistics.</notes></value>
           </enum>
           <description>Overall mode of 3A control
           routines</description>
@@ -915,7 +919,14 @@
           android.control.* are mostly disabled, and the camera device implements
           one of the scene mode settings (such as ACTION, SUNSET, or PARTY)
           as it wishes. The camera device scene mode 3A settings are provided by
-          android.control.sceneModeOverrides.</details>
+          android.control.sceneModeOverrides.
+
+          When set to OFF_KEEP_STATE, it is similar to OFF mode, the only difference
+          is that this frame will not be used by camera device background 3A statistics
+          update, as if this frame is never captured. This mode can be used in the scenario
+          where the application doesn't want a 3A manual control capture to affect
+          the subsequent auto 3A capture results.
+          </details>
           <tag id="BC" />
         </entry>
         <entry name="sceneMode" type="byte" visibility="public" enum="true">
diff --git a/camera/include/system/camera_metadata_tags.h b/camera/include/system/camera_metadata_tags.h
index 7fe6baf..a924edc 100644
--- a/camera/include/system/camera_metadata_tags.h
+++ b/camera/include/system/camera_metadata_tags.h
@@ -468,6 +468,7 @@
     ANDROID_CONTROL_MODE_OFF,
     ANDROID_CONTROL_MODE_AUTO,
     ANDROID_CONTROL_MODE_USE_SCENE_MODE,
+    ANDROID_CONTROL_MODE_OFF_KEEP_STATE,
 } camera_metadata_enum_android_control_mode_t;
 
 // ANDROID_CONTROL_SCENE_MODE
diff --git a/camera/src/camera_metadata_tag_info.c b/camera/src/camera_metadata_tag_info.c
index dd215b4..ffc3403 100644
--- a/camera/src/camera_metadata_tag_info.c
+++ b/camera/src/camera_metadata_tag_info.c
@@ -934,6 +934,10 @@
                     msg = "USE_SCENE_MODE";
                     ret = 0;
                     break;
+                case ANDROID_CONTROL_MODE_OFF_KEEP_STATE:
+                    msg = "OFF_KEEP_STATE";
+                    ret = 0;
+                    break;
                 default:
                     msg = "error: enum value out of range";
             }