Add functions to allow update over cellular (including tethered connection)

- Add an update state NEED_PERMISSION_TO_UPDATE which is broadcasted along
with the update info (version and size) when |OmahaRequestAction| aborts
update due to cellular connection. So the state transition will be:
IDLE->CHECKING_FOR_UPDATE->NEED_PERMISSION_TO_UPDATE->REPORTING_ERROR_EVENT
->IDLE
(The Chrome UI prompts an alert window showing update size and asks user
whether to proceed upon receiving this state.)

- Add a dbus interface to set update over cellular target
(kPrefsUpdateOverCellularTargetVersion and kPrefsUpdateOverCellularTargetSize).
The target is the one received by Chrome UI in NEED_PERMISSION_TO_UPDATE
broadcast. By sending the target back with the dbus call, update engine can
double check the target with the server to make sure there's no new server
push after NEED_PERMISSION_TO_UPDATE is broadcasted to Chrome UI.
(This dbus call is invoked when the user chooses to proceed to update at the
alert window. The dbus call is followed by another dbus call |AttemptUpdate|)

- So, the the decision tree as to whether to allow update over cellular
connection has changed to:
IF (device policy DeviceUpdateAllowedConnectionTypes set)
  follow device policy's decision
ELSE IF (kPrefsUpdateOverCellularPermission set to true)
  allow update
ELSE IF (Either kPrefsUpdateOverCellularTargetVersion or
    kPrefsUpdateOverCellularTargetSize is not set, or they are set but do not
    match the version and size in |OmahaResponse| retrieved by
    |OmahaRequestAction|)
  disallow update, and broadcast NEED_PERMISSION_TO_UPDATE
ELSE
  allow update
ENDIF

- This decision making happens at |OmahaRequestAction| after |OmahaResponse| is
retrieved. Since we want to separate the device policy check with the user
preferences check which depends on |OmahaResponse| during checking for update,
we modify ConnectionManager::IsUpdateAllowedOver by moving the user preferences
check to |OmahaRequestAction|. Thus, the function by default returns true for
cellular connection if device policy is not set.

- Corner case:
Adding kPrefsUpdateOverCellularPermission and
kPrefsUpdateOverCellularTargetSize seems to complicate the logic here. But
they could effectively solve a corner case where the target does not match
|OmahaResponse| due to new server push after broadcasting
NEED_PERMISSION_TO_UPDATE. In that case, we simply broadcast
NEED_PERMISSION_TO_UPDATE again along with new update info.

CQ-DEPEND=CL:481102
BUG=chromium:691108
TEST='FEATURES=test emerge-link update_engine'

Change-Id: I91b07e6030f202f7d0d48fb50787115695f228e3
Reviewed-on: https://chromium-review.googlesource.com/479467
Commit-Ready: Weidong Guo <weidongg@chromium.org>
Tested-by: Weidong Guo <weidongg@chromium.org>
Reviewed-by: Weidong Guo <weidongg@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
25 files changed
tree: 93bdc667ed4f6422be9b559d48b38217e0fd820f
  1. binder_bindings/
  2. client_library/
  3. common/
  4. dbus_bindings/
  5. include/
  6. init/
  7. payload_consumer/
  8. payload_generator/
  9. sample_images/
  10. scripts/
  11. update_manager/
  12. update_payload_key/
  13. weaved/
  14. .gitignore
  15. Android.mk
  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_chromeos.cc
  23. boot_control_chromeos.h
  24. boot_control_chromeos_unittest.cc
  25. chrome_browser_proxy_resolver.cc
  26. chrome_browser_proxy_resolver.h
  27. chrome_browser_proxy_resolver_unittest.cc
  28. common_service.cc
  29. common_service.h
  30. common_service_unittest.cc
  31. connection_manager.cc
  32. connection_manager.h
  33. connection_manager_interface.h
  34. connection_manager_unittest.cc
  35. daemon.cc
  36. daemon.h
  37. daemon_state_android.cc
  38. daemon_state_android.h
  39. daemon_state_interface.h
  40. dbus_service.cc
  41. dbus_service.h
  42. dbus_test_utils.h
  43. fake_file_writer.h
  44. fake_p2p_manager.h
  45. fake_p2p_manager_configuration.h
  46. fake_shill_proxy.cc
  47. fake_shill_proxy.h
  48. fake_system_state.cc
  49. fake_system_state.h
  50. generate_pc_file.sh
  51. hardware_android.cc
  52. hardware_android.h
  53. hardware_chromeos.cc
  54. hardware_chromeos.h
  55. hardware_chromeos_unittest.cc
  56. image_properties.h
  57. image_properties_android.cc
  58. image_properties_chromeos.cc
  59. image_properties_chromeos_unittest.cc
  60. libcros_proxy.cc
  61. libcros_proxy.h
  62. libupdate_engine-client-test.pc.in
  63. libupdate_engine-client.pc.in
  64. local_coverage_rate
  65. main.cc
  66. metrics.cc
  67. metrics.h
  68. metrics_utils.cc
  69. metrics_utils.h
  70. metrics_utils_unittest.cc
  71. mock_connection_manager.h
  72. mock_file_writer.h
  73. mock_omaha_request_params.h
  74. mock_p2p_manager.h
  75. mock_payload_state.h
  76. mock_proxy_resolver.h
  77. mock_update_attempter.h
  78. MODULE_LICENSE_APACHE2
  79. NOTICE
  80. omaha_request_action.cc
  81. omaha_request_action.h
  82. omaha_request_action_unittest.cc
  83. omaha_request_params.cc
  84. omaha_request_params.h
  85. omaha_request_params_unittest.cc
  86. omaha_response.h
  87. omaha_response_handler_action.cc
  88. omaha_response_handler_action.h
  89. omaha_response_handler_action_unittest.cc
  90. omaha_utils.cc
  91. omaha_utils.h
  92. omaha_utils_unittest.cc
  93. OWNERS
  94. p2p_manager.cc
  95. p2p_manager.h
  96. p2p_manager_unittest.cc
  97. parcelable_update_engine_status.cc
  98. parcelable_update_engine_status.h
  99. payload_state.cc
  100. payload_state.h
  101. payload_state_interface.h
  102. payload_state_unittest.cc
  103. PRESUBMIT.cfg
  104. proxy_resolver.cc
  105. proxy_resolver.h
  106. real_system_state.cc
  107. real_system_state.h
  108. run_unittests
  109. sample_omaha_v3_response.xml
  110. service_delegate_android_interface.h
  111. service_observer_interface.h
  112. shill_proxy.cc
  113. shill_proxy.h
  114. shill_proxy_interface.h
  115. system_state.h
  116. tar_bunzip2.gypi
  117. test_http_server.cc
  118. test_subprocess.cc
  119. testrunner.cc
  120. unittest_key.pem
  121. unittest_key2.pem
  122. update_attempter.cc
  123. update_attempter.h
  124. update_attempter_android.cc
  125. update_attempter_android.h
  126. update_attempter_unittest.cc
  127. update_engine-client.gyp
  128. update_engine.conf
  129. update_engine.gyp
  130. update_engine.rc
  131. update_engine_client.cc
  132. update_engine_client_android.cc
  133. update_metadata.proto
  134. update_status_utils.cc
  135. update_status_utils.h
  136. UpdateEngine.conf
  137. WATCHLISTS
  138. weave_service.cc
  139. weave_service.h
  140. weave_service_factory.cc
  141. weave_service_factory.h
  142. weave_service_interface.h