Commit 3105519d authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS PhoneHub] Fix issue which causes crash on Linux build

This CL changes FeatureStatusProviderImpl logic to check whether
DeviceSyncClient is ready before continuing. In real-world usage, this
will always be the case, but on the Linux emulator this condition is not
true, causing a crash.

Bug: 1106937
Change-Id: Ie99d4085697867b730b81e52f28b0afdbb7a46f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405901
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Auto-Submit: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarRegan Hsu <hsuregan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806318}
parent 1e328810
......@@ -205,7 +205,11 @@ FeatureStatus FeatureStatusProviderImpl::ComputeStatus() {
FeatureState feature_state =
multidevice_setup_client_->GetFeatureState(Feature::kPhoneHub);
if (!IsEligibleForFeature(device_sync_client_->GetLocalDeviceMetadata(),
// Note: If |device_sync_client_| is not yet ready, it has not initialized
// itself with device metadata, so we assume that we are ineligible for the
// feature until proven otherwise.
if (!device_sync_client_->is_ready() ||
!IsEligibleForFeature(device_sync_client_->GetLocalDeviceMetadata(),
device_sync_client_->GetSyncedDevices(),
feature_state)) {
return FeatureStatus::kNotEligibleForFeature;
......
......@@ -100,6 +100,7 @@ class FeatureStatusProviderImplTest : public testing::Test {
.WillByDefault(
Invoke(this, &FeatureStatusProviderImplTest::is_adapter_powered));
device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter_);
fake_device_sync_client_.NotifyReady();
provider_ = std::make_unique<FeatureStatusProviderImpl>(
&fake_device_sync_client_, &fake_multidevice_setup_client_,
......
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