[PhoneHub] Fix enabling of Phone Hub after host verification

After multi-device setup, we expect Phone Hub to be automatically
enabled after the multi-device host phone is verified. This is currently
not happening due to two issues:

1. The default state of the Phone Hub feature is kNotSupportedByPhone on
   start-up and until multi-device setup is complete. So, after the host
   is verified, we immediately try to change the state from
   kNotSupportedByPhone to kEnabledByUser. This transition is not
   supported by our feature state manager; only transitions
   kDisabledByUser<->kEnabledByUser are allowed. In this CL, we wait
   until the feature state updates to kDisabledByUser before trying to
   enable the feature.

2. The intent to enable Phone Hub after host verification is properly
   persisted in prefs, but that pref is unintentionally reset during
   start-up. When we create the Phone Hub objects we check to see
   if we still need to enable based on the host status. But, on start-up
   the host status is always temporarily kNoEligibleHosts by default.
   In this CL, we do not clear the persisted state until the host is
   verified and the feature is enabled.

Manually verified the following scenarios:
* New account added to Chromebook goes through multi-device setup
  during OOBE --> Phone Hub enabled.
* New account added to Chromebook; phone already multi-device host -->
  Phone Hub *disabled*; user must explicitly set up Phone Hub.
* Existing account goes through multi-device setup via Settings or via
  the Phone Hub tray icon --> Phone Hub enabled.
* Existing account goes through multi-device setup, phone is offline and
  cannot be verified, user logs out and back in, phone is back online,
  and host is verified  --> Phone Hub enabled.
* User disables Phone Hub in Settings then logs out and back in -->
  Phone Hub remains disabled.
* User disables Phone Hub in Settings then disconnects and reconnects
  phone to multi-device suite --> Phone Hub is re-enabled.

Bug: 1187254
Change-Id: Ic976c1d8e300f93bca839ec45eba90fda99220cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2757082
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#862820}
5 files changed
tree: d1f3d3b6c539d16472feffa69f73f059f03cca08
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. cloud_print/
  13. codelabs/
  14. components/
  15. content/
  16. courgette/
  17. crypto/
  18. dbus/
  19. device/
  20. docs/
  21. extensions/
  22. fuchsia/
  23. gin/
  24. google_apis/
  25. google_update/
  26. gpu/
  27. headless/
  28. infra/
  29. ios/
  30. ipc/
  31. jingle/
  32. media/
  33. mojo/
  34. native_client_sdk/
  35. net/
  36. pdf/
  37. ppapi/
  38. printing/
  39. remoting/
  40. rlz/
  41. sandbox/
  42. services/
  43. skia/
  44. sql/
  45. storage/
  46. styleguide/
  47. testing/
  48. third_party/
  49. tools/
  50. ui/
  51. url/
  52. weblayer/
  53. .clang-format
  54. .clang-tidy
  55. .eslintrc.js
  56. .git-blame-ignore-revs
  57. .gitattributes
  58. .gitignore
  59. .gn
  60. .vpython
  61. .vpython3
  62. .yapfignore
  63. AUTHORS
  64. BUILD.gn
  65. CODE_OF_CONDUCT.md
  66. codereview.settings
  67. DEPS
  68. DIR_METADATA
  69. ENG_REVIEW_OWNERS
  70. LICENSE
  71. LICENSE.chromium_os
  72. OWNERS
  73. PRESUBMIT.py
  74. PRESUBMIT_test.py
  75. PRESUBMIT_test_mocks.py
  76. README.md
  77. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure .

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.