Commit 8756d16e authored by li's avatar li Committed by Commit Bot

Skip setting ARC++ status until libassistant is ready.

When ARC++ is ready before libassistant is fully ready, sending display
request will cause a crash.

Ignore setting ARC++ state if libassistant is not fully ready and defer
setting the state.

CQ_INCLUDE_TRYBOTS=luci.chrome.try:linux-chromeos-chrome

Bug: 949797
Test: Manual
Change-Id: Ia5df8e266b217c758f9f225f2a5c25787ae19208
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1559250
Commit-Queue: Li Lin <llin@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652814}
parent a6043f15
......@@ -198,6 +198,7 @@ void AssistantManagerServiceImpl::Stop() {
DCHECK_NE(state_, State::STARTED);
state_ = State::STOPPED;
start_finished_ = false;
// When user disables the feature, we also deletes all data.
if (!service_->assistant_state()->settings_enabled().value() &&
......@@ -309,6 +310,11 @@ void AssistantManagerServiceImpl::EnableHotword(bool enable) {
}
void AssistantManagerServiceImpl::SetArcPlayStoreEnabled(bool enable) {
if (!start_finished_) {
// Skip setting play store status if libassistant is not ready. The status
// will be set when it is ready.
return;
}
// Both LibAssistant and Chrome threads may access |display_connection_|.
// |display_connection_| is thread safe.
display_connection_->SetArcPlayStoreEnabled(enable);
......@@ -1066,9 +1072,14 @@ void AssistantManagerServiceImpl::HandleVerifyAndroidAppResponse(
// assistant_client::DeviceStateListener overrides
// Run on LibAssistant threads
// This method currently only triggered as the callback of libassistant bootup
// checkin. For example, it won't get triggered for opted-out users.
void AssistantManagerServiceImpl::OnStartFinished() {
ENSURE_MAIN_THREAD(&AssistantManagerServiceImpl::OnStartFinished);
// TODO(b/129896357): find a better place for additional setups.
start_finished_ = true;
RegisterFallbackMediaHandler();
AddMediaControllerObserver();
......
......@@ -333,6 +333,8 @@ class AssistantManagerServiceImpl
// the media that was being played has been stopped.
base::Optional<media_session::MediaMetadata> media_metadata_ = base::nullopt;
bool start_finished_ = false;
base::WeakPtrFactory<AssistantManagerServiceImpl> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AssistantManagerServiceImpl);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment