Continue with an older update if update progress is 30% or more

This feature is desirable in cases where a device is used infrequently
on a network with little or no bandwidth to the update servers. In a
nutshell, the problem is that the device will start downloading an
update but it's so slow that it will see a new update before it's
done. This new update will cause the device to throw away the old
update (and thereby the resources it has already expended downloading
it) and then start over again. Which means downloading an update and
then get interrupted again. Rinse and repeat. With this change, we'll
at least converge against an update (albeit, perhaps an old one)
instead of starting over again and again.

To implement this feature, a new "update-state-overall-progress"
persistent variable (so-called "preference" according to the codebase)
is introduced so we can easily evaluate the progress without having to
parse the manifest again.

This feature is difficult to test with devserver since it's always
using the same URL, e.g.

 http://your-workstation.corp.company.net:8080/static/update.gz

meaning that it's not possible to actually continue an older update
server from deverser. What happens is that update_engine will happily
continue downloading and apply the update, but it will fail with
something like kErrorCodePayloadSizeMismatchError because it's getting
the new payload while expecting the old. This is not a problem per se,
it will just cause us to abandon the update attempt.

Fortunately, to verify that the patch works, it's sufficient to just
check the log files for these messages

 [0612/163553:INFO:delta_performer.cc(1144)] Abandoning current update (at 12% completion) because there is a newer update available.

 [0612/164451:INFO:delta_performer.cc(1139)] Resuming current update (at 51% completion) despite the fact that there's a newer update.

BUG=chromium:244538
TEST=Unit tests pass + Manually tested (see above)

Change-Id: Ibfb2fe10fe1883bfadf132f22b802ca3482c699e
Reviewed-on: https://gerrit.chromium.org/gerrit/58470
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
4 files changed
tree: ea0a33957d085e18dced94aa7208e76ccddd407e
  1. .gitignore
  2. 99-gpio-dutflag.rules
  3. action.h
  4. action_mock.h
  5. action_pipe.h
  6. action_pipe_unittest.cc
  7. action_processor.cc
  8. action_processor.h
  9. action_processor_mock.h
  10. action_processor_unittest.cc
  11. action_unittest.cc
  12. build
  13. bzip.cc
  14. bzip.h
  15. bzip_extent_writer.cc
  16. bzip_extent_writer.h
  17. bzip_extent_writer_unittest.cc
  18. certificate_checker.cc
  19. certificate_checker.h
  20. certificate_checker_mock.h
  21. certificate_checker_unittest.cc
  22. chrome_browser_proxy_resolver.cc
  23. chrome_browser_proxy_resolver.h
  24. chrome_browser_proxy_resolver_unittest.cc
  25. chrome_proxy_resolver.cc
  26. chrome_proxy_resolver.h
  27. chrome_proxy_resolver_unittest.cc
  28. clock.cc
  29. clock.h
  30. clock_interface.h
  31. connection_manager.cc
  32. connection_manager.h
  33. connection_manager_unittest.cc
  34. constants.cc
  35. constants.h
  36. cycle_breaker.cc
  37. cycle_breaker.h
  38. cycle_breaker_unittest.cc
  39. dbus_constants.h
  40. dbus_interface.h
  41. dbus_service.cc
  42. dbus_service.h
  43. delta_diff_generator.cc
  44. delta_diff_generator.h
  45. delta_diff_generator_unittest.cc
  46. delta_performer.cc
  47. delta_performer.h
  48. delta_performer_unittest.cc
  49. download_action.cc
  50. download_action.h
  51. download_action_unittest.cc
  52. error_code.h
  53. extent_mapper.cc
  54. extent_mapper.h
  55. extent_mapper_unittest.cc
  56. extent_ranges.cc
  57. extent_ranges.h
  58. extent_ranges_unittest.cc
  59. extent_writer.cc
  60. extent_writer.h
  61. extent_writer_unittest.cc
  62. fake_clock.h
  63. file_descriptor.cc
  64. file_descriptor.h
  65. file_writer.cc
  66. file_writer.h
  67. file_writer_mock.h
  68. file_writer_unittest.cc
  69. filesystem_copier_action.cc
  70. filesystem_copier_action.h
  71. filesystem_copier_action_unittest.cc
  72. filesystem_iterator.cc
  73. filesystem_iterator.h
  74. filesystem_iterator_unittest.cc
  75. full_update_generator.cc
  76. full_update_generator.h
  77. full_update_generator_unittest.cc
  78. gen_coverage_html
  79. generate_delta_main.cc
  80. gpio_handler.cc
  81. gpio_handler.h
  82. gpio_handler_unittest.cc
  83. gpio_handler_unittest.h
  84. gpio_mock_file_descriptor.cc
  85. gpio_mock_file_descriptor.h
  86. gpio_mock_udev_interface.cc
  87. gpio_mock_udev_interface.h
  88. graph_types.h
  89. graph_utils.cc
  90. graph_utils.h
  91. graph_utils_unittest.cc
  92. http_common.cc
  93. http_common.h
  94. http_fetcher.cc
  95. http_fetcher.h
  96. http_fetcher_unittest.cc
  97. http_fetcher_unittest.h
  98. inherit-review-settings-ok
  99. install_plan.cc
  100. install_plan.h
  101. integration_unittest.cc
  102. libcurl_http_fetcher.cc
  103. libcurl_http_fetcher.h
  104. LICENSE
  105. local_coverage_rate
  106. main.cc
  107. marshal.list
  108. metadata.cc
  109. metadata.h
  110. metadata_unittest.cc
  111. mock_connection_manager.h
  112. mock_dbus_interface.h
  113. mock_file_writer.h
  114. mock_gpio_handler.h
  115. mock_http_fetcher.cc
  116. mock_http_fetcher.h
  117. mock_payload_state.h
  118. mock_system_state.cc
  119. mock_system_state.h
  120. multi_range_http_fetcher.cc
  121. multi_range_http_fetcher.h
  122. omaha_hash_calculator.cc
  123. omaha_hash_calculator.h
  124. omaha_hash_calculator_unittest.cc
  125. omaha_request_action.cc
  126. omaha_request_action.h
  127. omaha_request_action_unittest.cc
  128. omaha_request_params.cc
  129. omaha_request_params.h
  130. omaha_request_params_unittest.cc
  131. omaha_response.h
  132. omaha_response_handler_action.cc
  133. omaha_response_handler_action.h
  134. omaha_response_handler_action_unittest.cc
  135. org.chromium.UpdateEngine.service
  136. payload_signer.cc
  137. payload_signer.h
  138. payload_signer_unittest.cc
  139. payload_state.cc
  140. payload_state.h
  141. payload_state_interface.h
  142. payload_state_unittest.cc
  143. postinstall_runner_action.cc
  144. postinstall_runner_action.h
  145. postinstall_runner_action_unittest.cc
  146. prefs.cc
  147. prefs.h
  148. prefs_interface.h
  149. prefs_mock.h
  150. prefs_unittest.cc
  151. proxy_resolver.cc
  152. proxy_resolver.h
  153. real_system_state.h
  154. run_unittests
  155. sample_omaha_v3_response.xml
  156. SConstruct
  157. setup_dev_packages
  158. simple_key_value_store.cc
  159. simple_key_value_store.h
  160. simple_key_value_store_unittest.cc
  161. subprocess.cc
  162. subprocess.h
  163. subprocess_unittest.cc
  164. system_state.cc
  165. system_state.h
  166. tarjan.cc
  167. tarjan.h
  168. tarjan_unittest.cc
  169. terminator.cc
  170. terminator.h
  171. terminator_unittest.cc
  172. test_http_server.cc
  173. test_utils.cc
  174. test_utils.h
  175. testrunner.cc
  176. topological_sort.cc
  177. topological_sort.h
  178. topological_sort_unittest.cc
  179. udev_interface.h
  180. unittest_key.pem
  181. unittest_key2.pem
  182. update_attempter.cc
  183. update_attempter.h
  184. update_attempter_mock.h
  185. update_attempter_unittest.cc
  186. update_check_scheduler.cc
  187. update_check_scheduler.h
  188. update_check_scheduler_unittest.cc
  189. update_engine.xml
  190. update_engine_client.cc
  191. update_metadata.proto
  192. UpdateEngine.conf
  193. utils.cc
  194. utils.h
  195. utils_unittest.cc
  196. WATCHLISTS
  197. zip_unittest.cc