Commit f155b5f9 authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Phonehub: Add additional eligibility checks to host phone

Previously only checked if the host phone is a PhoneHub host but
did not verify whether if it was a BetterTogether host and has a
valid Bluetooth address. This CL adds those checks.

Bug: 1106937
Fixed: 1147290
Test: chromeos_components_unittest
Change-Id: I8c2e7a596655a3a9904268873c8514f1332ae234
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538694
Commit-Queue: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827927}
parent 35e32dc1
...@@ -29,9 +29,21 @@ using multidevice_setup::mojom::Feature; ...@@ -29,9 +29,21 @@ using multidevice_setup::mojom::Feature;
using multidevice_setup::mojom::FeatureState; using multidevice_setup::mojom::FeatureState;
using multidevice_setup::mojom::HostStatus; using multidevice_setup::mojom::HostStatus;
bool DoesDeviceSupportPhoneHubHost(const RemoteDeviceRef& device) { bool IsEligiblePhoneHubHost(const RemoteDeviceRef& device) {
return device.GetSoftwareFeatureState(SoftwareFeature::kPhoneHubHost) != // Device must be capable of being a multi-device host.
SoftwareFeatureState::kNotSupported; if (device.GetSoftwareFeatureState(SoftwareFeature::kBetterTogetherHost) ==
SoftwareFeatureState::kNotSupported) {
return false;
}
if (device.GetSoftwareFeatureState(SoftwareFeature::kPhoneHubHost) ==
SoftwareFeatureState::kNotSupported) {
return false;
}
// Device must have a synced Bluetooth public address, which is used to
// bootstrap Phone Hub connections.
return !device.bluetooth_public_address().empty();
} }
bool IsEligibleForFeature( bool IsEligibleForFeature(
...@@ -71,28 +83,13 @@ bool IsEligibleForFeature( ...@@ -71,28 +83,13 @@ bool IsEligibleForFeature(
// If there is a host device available, check if the device is eligible for // If there is a host device available, check if the device is eligible for
// Phonehub. // Phonehub.
if (host_status.second.has_value()) if (host_status.second.has_value())
return DoesDeviceSupportPhoneHubHost(*(host_status.second)); return IsEligiblePhoneHubHost(*(host_status.second));
// Otherwise, check if there is any available remote device that is // Otherwise, check if there is any available remote device that is
// eligible for Phonehub. // eligible for Phonehub.
for (const RemoteDeviceRef& device : remote_devices) { for (const RemoteDeviceRef& device : remote_devices) {
// Device must be capable of being a multi-device host. if (IsEligiblePhoneHubHost(device))
if (device.GetSoftwareFeatureState(SoftwareFeature::kBetterTogetherHost) == return true;
SoftwareFeatureState::kNotSupported) {
continue;
}
// Device must be capable of being a Phone Hub host.
if (!DoesDeviceSupportPhoneHubHost(device)) {
continue;
}
// Device must have a synced Bluetooth public address, which is used to
// bootstrap Phone Hub connections.
if (device.bluetooth_public_address().empty())
continue;
return true;
} }
// If none of the devices return true above, there are no phones capable of // If none of the devices return true above, there are no phones capable of
......
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