GPIO test signal safe fallback + refactoring.

This addresses the problem of spurious GPIO signals indicating a test
scenario whereas in fact this isn't one, which may lead to hosts unable
to get an update (ZGB, Lumpy). This is also a partial fix to a problem
with Stumpy, where such spurious signals are inherent to the board
implementation.

* Safe fallback: a GPIO-signaled test scenario will be ignored other
  than on the first time, in both places it is being checked
  (UpdateAttempter::Update() and UpdateCheckScheduler::StaticCheck()).
  This will ensure that we do not (a) override EULA/OOBE-complete flag
  more than once; and (b) we do not attempt to update against a local
  test server more than once.  This generally covers against spurious
  GPIO, as long as a user cannot trigger an update check on
  a non-OOBE-complete system (appears to be a safe assumption).

* The retry timeout after failing an update with the test server is
  shortened to 1 minute (compared to the default 45 minute). This
  substantially increases the chances for a system exhibiting spurious
  GPIO signals to get updates.

* Moved the GPIO functionality into a separate module/class. This makes
  more sense now that it is being used by more than one class
  (UpdateAttempter and UpdateCheckScheduler). The implementation of
  GpioHandler has no instance data members and so behaves like
  a singleton, but otherwise looks and feels like a normal class.

* Also changing the private test server URL to use an unregistered TCP
  port (further reduces the chances of anything responding on the LAN).

* Some minor fixes.

BUG=chromium-os:27077, chromium-os:27109, chromium-os:25397,
chromium-os:27157

TEST=Unittests passed; GPIO reading + fallback work on x86-alex.

Change-Id: Ide1a60a690f1263efd47872360470347e56eeb45
Reviewed-on: https://gerrit.chromium.org/gerrit/17344
Commit-Ready: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
12 files changed
tree: 7ee27aa07426c26f6ff3f02544e90e1ffa2541ac
  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. bzip.cc
  13. bzip.h
  14. bzip_extent_writer.cc
  15. bzip_extent_writer.h
  16. bzip_extent_writer_unittest.cc
  17. certificate_checker.cc
  18. certificate_checker.h
  19. certificate_checker_mock.h
  20. certificate_checker_unittest.cc
  21. chrome_browser_proxy_resolver.cc
  22. chrome_browser_proxy_resolver.h
  23. chrome_browser_proxy_resolver_unittest.cc
  24. chrome_proxy_resolver.cc
  25. chrome_proxy_resolver.h
  26. chrome_proxy_resolver_unittest.cc
  27. cycle_breaker.cc
  28. cycle_breaker.h
  29. cycle_breaker_unittest.cc
  30. dbus_constants.h
  31. dbus_interface.h
  32. dbus_service.cc
  33. dbus_service.h
  34. delta_diff_generator.cc
  35. delta_diff_generator.h
  36. delta_diff_generator_unittest.cc
  37. delta_performer.cc
  38. delta_performer.h
  39. delta_performer_unittest.cc
  40. download_action.cc
  41. download_action.h
  42. download_action_unittest.cc
  43. extent_mapper.cc
  44. extent_mapper.h
  45. extent_mapper_unittest.cc
  46. extent_ranges.cc
  47. extent_ranges.h
  48. extent_ranges_unittest.cc
  49. extent_writer.cc
  50. extent_writer.h
  51. extent_writer_unittest.cc
  52. file_writer.cc
  53. file_writer.h
  54. file_writer_mock.h
  55. file_writer_unittest.cc
  56. filesystem_copier_action.cc
  57. filesystem_copier_action.h
  58. filesystem_copier_action_unittest.cc
  59. filesystem_iterator.cc
  60. filesystem_iterator.h
  61. filesystem_iterator_unittest.cc
  62. flimflam_proxy.cc
  63. flimflam_proxy.h
  64. flimflam_proxy_unittest.cc
  65. full_update_generator.cc
  66. full_update_generator.h
  67. full_update_generator_unittest.cc
  68. gen_coverage_html.sh
  69. generate_delta_main.cc
  70. gpio_handler.cc
  71. gpio_handler.h
  72. graph_types.h
  73. graph_utils.cc
  74. graph_utils.h
  75. graph_utils_unittest.cc
  76. http_common.cc
  77. http_common.h
  78. http_fetcher.cc
  79. http_fetcher.h
  80. http_fetcher_unittest.cc
  81. http_fetcher_unittest.h
  82. inherit-review-settings-ok
  83. install_plan.h
  84. integration_unittest.cc
  85. libcurl_http_fetcher.cc
  86. libcurl_http_fetcher.h
  87. LICENSE
  88. local_coverage_rate.sh
  89. main.cc
  90. marshal.list
  91. metadata.cc
  92. metadata.h
  93. metadata_unittest.cc
  94. mock_dbus_interface.h
  95. mock_file_writer.h
  96. mock_http_fetcher.cc
  97. mock_http_fetcher.h
  98. multi_range_http_fetcher.cc
  99. multi_range_http_fetcher.h
  100. omaha_hash_calculator.cc
  101. omaha_hash_calculator.h
  102. omaha_hash_calculator_unittest.cc
  103. omaha_request_action.cc
  104. omaha_request_action.h
  105. omaha_request_action_unittest.cc
  106. omaha_request_params.cc
  107. omaha_request_params.h
  108. omaha_request_params_unittest.cc
  109. omaha_response_handler_action.cc
  110. omaha_response_handler_action.h
  111. omaha_response_handler_action_unittest.cc
  112. org.chromium.UpdateEngine.service
  113. payload_signer.cc
  114. payload_signer.h
  115. payload_signer_unittest.cc
  116. postinstall_runner_action.cc
  117. postinstall_runner_action.h
  118. postinstall_runner_action_unittest.cc
  119. prefs.cc
  120. prefs.h
  121. prefs_interface.h
  122. prefs_mock.h
  123. prefs_unittest.cc
  124. proxy_resolver.cc
  125. proxy_resolver.h
  126. SConstruct
  127. setup_dev_packages
  128. simple_key_value_store.cc
  129. simple_key_value_store.h
  130. simple_key_value_store_unittest.cc
  131. subprocess.cc
  132. subprocess.h
  133. subprocess_unittest.cc
  134. tarjan.cc
  135. tarjan.h
  136. tarjan_unittest.cc
  137. terminator.cc
  138. terminator.h
  139. terminator_unittest.cc
  140. test_http_server.cc
  141. test_utils.cc
  142. test_utils.h
  143. testrunner.cc
  144. topological_sort.cc
  145. topological_sort.h
  146. topological_sort_unittest.cc
  147. unittest_key.pem
  148. unittest_key2.pem
  149. update_attempter.cc
  150. update_attempter.h
  151. update_attempter_mock.h
  152. update_attempter_unittest.cc
  153. update_check_scheduler.cc
  154. update_check_scheduler.h
  155. update_check_scheduler_unittest.cc
  156. update_engine.xml
  157. update_engine_client.cc
  158. update_metadata.proto
  159. UpdateEngine.conf
  160. utils.cc
  161. utils.h
  162. utils_unittest.cc
  163. WATCHLISTS
  164. zip_unittest.cc