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;
using multidevice_setup::mojom::FeatureState;
using multidevice_setup::mojom::HostStatus;
bool DoesDeviceSupportPhoneHubHost(const RemoteDeviceRef& device) {
return device.GetSoftwareFeatureState(SoftwareFeature::kPhoneHubHost) !=
SoftwareFeatureState::kNotSupported;
bool IsEligiblePhoneHubHost(const RemoteDeviceRef& device) {
// Device must be capable of being a multi-device host.
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(
......@@ -71,27 +83,12 @@ bool IsEligibleForFeature(
// If there is a host device available, check if the device is eligible for
// Phonehub.
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
// eligible for Phonehub.
for (const RemoteDeviceRef& device : remote_devices) {
// Device must be capable of being a multi-device host.
if (device.GetSoftwareFeatureState(SoftwareFeature::kBetterTogetherHost) ==
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;
if (IsEligiblePhoneHubHost(device))
return true;
}
......
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