Improve the logic for mapping target dynamic partitions.

While applying a retrofit update on a dynamic-partitions-enabled build,
it should always use static target partitions. Otherwise reading them
from the updated partition metadata would end up using mismatching info.

This CL improves the logic in detecting and handling such a case.
- It identifies a retrofit or regular update based on the absence of
  DynamicPartitionMetadata field.
- Upon seeing that, it skips updating partition metadata for the target
  slot, and looks up target partitions as static partitions.
- Source partitions will always be loaded according to the actual state.

This CL also removes the re-mapping of the target partitions from
InitPartitionMetadata(). It only needs to unmap those partitions, since
they may become inconsistent with the updated metadata. However, it's
unnecessary to re-map them, which will be done later as part of
GetDynamicPartitionDevice().

Also updated tests to reflect this.

Bug: 120775936
Test: update_engine_unittests
Test: Apply an update with dynamic partitions; abort and resume.
Test: Apply a retrofit update; abort and resume the update.
Change-Id: Ic07bd98847e91a003101266e426c4d23666810f2
6 files changed
tree: 88330634e780ac46f5422d09541c1255c5a1e8d4
  1. binder_bindings/
  2. client_library/
  3. common/
  4. dbus_bindings/
  5. init/
  6. payload_consumer/
  7. payload_generator/
  8. sample_images/
  9. scripts/
  10. update_engine/
  11. update_manager/
  12. update_payload_key/
  13. .clang-format
  14. .gitignore
  15. Android.bp
  16. binder_service_android.cc
  17. binder_service_android.h
  18. binder_service_brillo.cc
  19. binder_service_brillo.h
  20. boot_control_android.cc
  21. boot_control_android.h
  22. boot_control_android_unittest.cc
  23. boot_control_chromeos.cc
  24. boot_control_chromeos.h
  25. boot_control_chromeos_unittest.cc
  26. certificate_checker.cc
  27. certificate_checker.h
  28. certificate_checker_unittest.cc
  29. chrome_browser_proxy_resolver.cc
  30. chrome_browser_proxy_resolver.h
  31. COMMIT-QUEUE.ini
  32. common_service.cc
  33. common_service.h
  34. common_service_unittest.cc
  35. connection_manager.cc
  36. connection_manager.h
  37. connection_manager_android.cc
  38. connection_manager_android.h
  39. connection_manager_interface.h
  40. connection_manager_unittest.cc
  41. connection_utils.cc
  42. connection_utils.h
  43. CPPLINT.cfg
  44. daemon.cc
  45. daemon.h
  46. daemon_state_android.cc
  47. daemon_state_android.h
  48. daemon_state_interface.h
  49. dbus_connection.cc
  50. dbus_connection.h
  51. dbus_service.cc
  52. dbus_service.h
  53. dbus_test_utils.h
  54. dynamic_partition_control_android.cc
  55. dynamic_partition_control_android.h
  56. dynamic_partition_control_interface.h
  57. fake_file_writer.h
  58. fake_p2p_manager.h
  59. fake_p2p_manager_configuration.h
  60. fake_shill_proxy.cc
  61. fake_shill_proxy.h
  62. fake_system_state.cc
  63. fake_system_state.h
  64. generate_pc_file.sh
  65. hardware_android.cc
  66. hardware_android.h
  67. hardware_chromeos.cc
  68. hardware_chromeos.h
  69. hardware_chromeos_unittest.cc
  70. image_properties.h
  71. image_properties_android.cc
  72. image_properties_android_unittest.cc
  73. image_properties_chromeos.cc
  74. image_properties_chromeos_unittest.cc
  75. libcurl_http_fetcher.cc
  76. libcurl_http_fetcher.h
  77. libupdate_engine-client-test.pc.in
  78. libupdate_engine-client.pc.in
  79. local_coverage_rate
  80. main.cc
  81. metrics_constants.h
  82. metrics_reporter_android.cc
  83. metrics_reporter_android.h
  84. metrics_reporter_interface.h
  85. metrics_reporter_omaha.cc
  86. metrics_reporter_omaha.h
  87. metrics_reporter_omaha_unittest.cc
  88. metrics_reporter_stub.cc
  89. metrics_reporter_stub.h
  90. metrics_utils.cc
  91. metrics_utils.h
  92. metrics_utils_unittest.cc
  93. mock_boot_control_hal.h
  94. mock_certificate_checker.h
  95. mock_connection_manager.h
  96. mock_dynamic_partition_control.h
  97. mock_file_writer.h
  98. mock_metrics_reporter.h
  99. mock_omaha_request_params.h
  100. mock_p2p_manager.h
  101. mock_payload_state.h
  102. mock_power_manager.h
  103. mock_service_observer.h
  104. mock_update_attempter.h
  105. MODULE_LICENSE_APACHE2
  106. network_selector.h
  107. network_selector_android.cc
  108. network_selector_android.h
  109. network_selector_interface.h
  110. network_selector_stub.cc
  111. network_selector_stub.h
  112. NOTICE
  113. omaha_request_action.cc
  114. omaha_request_action.h
  115. omaha_request_action_unittest.cc
  116. omaha_request_params.cc
  117. omaha_request_params.h
  118. omaha_request_params_unittest.cc
  119. omaha_response.h
  120. omaha_response_handler_action.cc
  121. omaha_response_handler_action.h
  122. omaha_response_handler_action_unittest.cc
  123. omaha_utils.cc
  124. omaha_utils.h
  125. omaha_utils_unittest.cc
  126. OWNERS
  127. p2p_manager.cc
  128. p2p_manager.h
  129. p2p_manager_unittest.cc
  130. parcelable_update_engine_status.cc
  131. parcelable_update_engine_status.h
  132. parcelable_update_engine_status_unittest.cc
  133. payload_state.cc
  134. payload_state.h
  135. payload_state_interface.h
  136. payload_state_unittest.cc
  137. power_manager_android.cc
  138. power_manager_android.h
  139. power_manager_chromeos.cc
  140. power_manager_chromeos.h
  141. power_manager_interface.h
  142. PRESUBMIT.cfg
  143. PREUPLOAD.cfg
  144. pylintrc
  145. real_system_state.cc
  146. real_system_state.h
  147. run_unittests
  148. sample_omaha_v3_response.xml
  149. service_delegate_android_interface.h
  150. service_observer_interface.h
  151. shill_proxy.cc
  152. shill_proxy.h
  153. shill_proxy_interface.h
  154. sideload_main.cc
  155. system_state.h
  156. tar_bunzip2.gypi
  157. test_http_server.cc
  158. test_subprocess.cc
  159. testrunner.cc
  160. unittest_key.pem
  161. unittest_key2.pem
  162. update_attempter.cc
  163. update_attempter.h
  164. update_attempter_android.cc
  165. update_attempter_android.h
  166. update_attempter_android_unittest.cc
  167. update_attempter_unittest.cc
  168. update_boot_flags_action.cc
  169. update_boot_flags_action.h
  170. update_boot_flags_action_unittest.cc
  171. update_engine-client.gyp
  172. update_engine.conf
  173. update_engine.gyp
  174. update_engine.rc
  175. update_engine_client.cc
  176. update_engine_client_android.cc
  177. update_metadata.proto
  178. update_status_utils.cc
  179. update_status_utils.h
  180. UpdateEngine.conf