mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Integrate Dart UX with windows_admin_plugin
PiperOrigin-RevId: 551316220
This commit is contained in:
committed by
Copybara-Service
parent
7e1f286d93
commit
040ed31341
@@ -130,7 +130,7 @@ void Mediator::OnDiscoveryAction(FastPairDevice& device,
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kDismissedByUser";
|
||||
foreground_currently_showing_notification_ = false;
|
||||
// TODO(b/285453663): update discovery block list
|
||||
[[fallthrough]];
|
||||
break;
|
||||
case DiscoveryAction::kDismissedByTimeout:
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kDismissedByTimeout";
|
||||
foreground_currently_showing_notification_ = false;
|
||||
|
||||
@@ -22,13 +22,45 @@ namespace fastpair {
|
||||
void WindowsAdminPlugin::PluginState::DiscoveryClicked(DiscoveryAction action) {
|
||||
NEARBY_LOGS(INFO) << __func__;
|
||||
if (device == nullptr || fast_pair_service == nullptr) return;
|
||||
absl::Status status = fast_pair_service->GetSeeker()->StartInitialPairing(
|
||||
*device, InitialPairingParam{},
|
||||
{.on_pairing_result = [](const FastPairDevice& device,
|
||||
absl::Status status) {
|
||||
NEARBY_LOGS(INFO) << "Pairing result: " << status;
|
||||
}});
|
||||
NEARBY_LOGS(INFO) << "StartInitialPairing: " << status;
|
||||
switch (action) {
|
||||
case DiscoveryAction::kPairToDevice: {
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kPairToDevice";
|
||||
absl::Status status = fast_pair_service->GetSeeker()->StartInitialPairing(
|
||||
*device, InitialPairingParam{},
|
||||
{.on_pairing_result = [this](const FastPairDevice& device,
|
||||
absl::Status status) {
|
||||
NEARBY_LOGS(INFO) << "Pairing result: " << status;
|
||||
for (auto* observer : observers.GetObservers()) {
|
||||
observer->OnPairingResult(device.GetMetadata().value(),
|
||||
status.ok());
|
||||
}
|
||||
}});
|
||||
NEARBY_LOGS(INFO) << "StartInitialPairing: " << status;
|
||||
} break;
|
||||
case DiscoveryAction::kDismissedByOs:
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kDismissedByOs";
|
||||
break;
|
||||
case DiscoveryAction::kDismissedByUser:
|
||||
// When the user explicitly dismisses the discovery notification, update
|
||||
// the device's block-list value accordingly.
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kDismissedByUser";
|
||||
foreground_currently_showing_notification = false;
|
||||
break;
|
||||
case DiscoveryAction::kDismissedByTimeout:
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kDismissedByTimeout";
|
||||
foreground_currently_showing_notification = false;
|
||||
break;
|
||||
case DiscoveryAction::kLearnMore:
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kLearnMore";
|
||||
break;
|
||||
case DiscoveryAction::kDone:
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = kDone";
|
||||
foreground_currently_showing_notification = false;
|
||||
break;
|
||||
default:
|
||||
NEARBY_LOGS(INFO) << __func__ << ": Action = Unknown";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsAdminPlugin::PluginState::SetIsScreenLocked(bool is_locked) {
|
||||
@@ -48,6 +80,14 @@ void WindowsAdminPlugin::OnInitialDiscoveryEvent(
|
||||
<< "Ignoring initial discovery event because metadata is missing";
|
||||
return;
|
||||
}
|
||||
if (state_->foreground_currently_showing_notification) {
|
||||
NEARBY_LOGS(VERBOSE) << __func__
|
||||
<< ": Already showing a notification for a device";
|
||||
return;
|
||||
}
|
||||
// Show discovery notification
|
||||
state_->foreground_currently_showing_notification = true;
|
||||
|
||||
state_->device = device_;
|
||||
for (auto* observer : state_->observers.GetObservers()) {
|
||||
observer->OnUpdateDevice(*metadata);
|
||||
@@ -61,7 +101,7 @@ void WindowsAdminPlugin::OnPairEvent(const PairEvent& event) {
|
||||
{.on_pairing_result = [](const FastPairDevice& device,
|
||||
absl::Status status) {
|
||||
NEARBY_LOGS(INFO) << "Pairing result: " << status;
|
||||
// TODO(jsobczak): Ask for user constent and save the Account Key to
|
||||
// TODO(jsobczak): Ask for user consent and save the Account Key to
|
||||
// user's account.
|
||||
}});
|
||||
NEARBY_LOGS(INFO) << "StartRetroactivePairing: " << status;
|
||||
|
||||
@@ -37,7 +37,9 @@ class WindowsAdminPlugin : public FastPairPlugin {
|
||||
ObserverList<FastPairNotificationController::Observer> observers;
|
||||
const FastPairDevice* device = nullptr;
|
||||
std::unique_ptr<FastPairService> fast_pair_service;
|
||||
bool foreground_currently_showing_notification = false;
|
||||
};
|
||||
|
||||
class Provider : public FastPairPluginProvider {
|
||||
public:
|
||||
explicit Provider(PluginState* state) : state_(state) {}
|
||||
|
||||
Reference in New Issue
Block a user