Commit 274cc243 authored by David Black's avatar David Black Committed by Commit Bot

Use AddTimeToTimer API in Assistant.

Previous versions of LibAssistant did not implement AddTimeToTimer. Now
that they do, we can do away with our previous workaround of cancelling
the timer and scheduling a new one.

Bug: b:149574352
Change-Id: Icea605a009574ec170c1c725deba2008d32458e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2057158
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744364}
parent 8eafe392
......@@ -346,18 +346,12 @@ void AssistantAlarmTimerController::PerformAlarmTimerAction(
<< "duration.";
return;
}
// Verify the timer is ringing.
DCHECK(model_.GetAlarmTimerById(alarm_timer_id.value()));
// LibAssistant doesn't currently support adding time to an ringing timer.
// We'll create a new one with the duration specified. Note that we
// currently only support this deep link for an alarm/timer that is
// ringing.
assistant_->StopAlarmTimerRinging();
assistant_->CreateTimer(duration.value());
assistant_->AddTimeToTimer(alarm_timer_id.value(), duration.value());
break;
case assistant::util::AlarmTimerAction::kStopRinging:
assistant_->StopAlarmTimerRinging();
break;
}
}
} // namespace ash
......@@ -320,11 +320,12 @@ void TestAssistantService::NotifyEntryIntoAssistantUi(
NOTIMPLEMENTED_LOG_ONCE();
}
void TestAssistantService::StopAlarmTimerRinging() {
void TestAssistantService::AddTimeToTimer(const std::string& id,
base::TimeDelta duration) {
NOTIMPLEMENTED_LOG_ONCE();
}
void TestAssistantService::CreateTimer(base::TimeDelta duration) {
void TestAssistantService::StopAlarmTimerRinging() {
NOTIMPLEMENTED_LOG_ONCE();
}
......
......@@ -109,8 +109,8 @@ class TestAssistantService : public chromeos::assistant::mojom::Assistant {
chromeos::assistant::mojom::AssistantFeedbackPtr feedback) override;
void NotifyEntryIntoAssistantUi(
chromeos::assistant::mojom::AssistantEntryPoint entry_point) override;
void AddTimeToTimer(const std::string& id, base::TimeDelta duration) override;
void StopAlarmTimerRinging() override;
void CreateTimer(base::TimeDelta duration) override;
private:
void StartInteraction(
......
......@@ -1526,12 +1526,13 @@ void AssistantManagerServiceImpl::StopAlarmTimerRinging() {
assistant_manager_internal_->GetAlarmTimerManager()->StopRinging();
}
void AssistantManagerServiceImpl::CreateTimer(base::TimeDelta duration) {
void AssistantManagerServiceImpl::AddTimeToTimer(const std::string& id,
base::TimeDelta duration) {
if (!assistant_manager_internal_)
return;
assistant_manager_internal_->GetAlarmTimerManager()->CreateTimer(
duration.InSeconds(), /*label=*/std::string());
assistant_manager_internal_->GetAlarmTimerManager()->AddTimeToTimer(
id, duration.InSeconds());
}
void AssistantManagerServiceImpl::CacheAssistantStructure(
......
......@@ -152,8 +152,8 @@ class COMPONENT_EXPORT(ASSISTANT_SERVICE) AssistantManagerServiceImpl
mojom::AssistantFeedbackPtr assistant_feedback) override;
void NotifyEntryIntoAssistantUi(
mojom::AssistantEntryPoint entry_point) override;
void AddTimeToTimer(const std::string& id, base::TimeDelta duration) override;
void StopAlarmTimerRinging() override;
void CreateTimer(base::TimeDelta duration) override;
// AssistantActionObserver overrides:
void OnScheduleWait(int id, int time_ms) override;
......
......@@ -116,8 +116,11 @@ void FakeAssistantManagerServiceImpl::SendAssistantFeedback(
void FakeAssistantManagerServiceImpl::NotifyEntryIntoAssistantUi(
mojom::AssistantEntryPoint entry_point) {}
void FakeAssistantManagerServiceImpl::AddTimeToTimer(const std::string& id,
base::TimeDelta duration) {
}
void FakeAssistantManagerServiceImpl::StopAlarmTimerRinging() {}
void FakeAssistantManagerServiceImpl::CreateTimer(base::TimeDelta duration) {}
void FakeAssistantManagerServiceImpl::SetStateAndInformObservers(
State new_state) {
......
......@@ -70,8 +70,8 @@ class COMPONENT_EXPORT(ASSISTANT_SERVICE) FakeAssistantManagerServiceImpl
void SendAssistantFeedback(mojom::AssistantFeedbackPtr feedback) override;
void NotifyEntryIntoAssistantUi(
mojom::AssistantEntryPoint entry_point) override;
void AddTimeToTimer(const std::string& id, base::TimeDelta duration) override;
void StopAlarmTimerRinging() override;
void CreateTimer(base::TimeDelta duration) override;
// Update the state to the corresponding value, and inform the
// |AssistantStateObserver| of the change.
......
......@@ -145,12 +145,14 @@ interface Assistant {
// Invoked on entry to Assistant UI.
NotifyEntryIntoAssistantUi(AssistantEntryPoint entry_point);
// ===== Alarm/Timer management methods =====
// Alarm/Timer methods -------------------------------------------------------
// Adds the specified |duration| to the timer identified by |id|. Note that
// this method is a no-op if there is no existing timer identified by |id|.
AddTimeToTimer(string id, mojo_base.mojom.TimeDelta duration);
// Stops timer or alarm ringing.
StopAlarmTimerRinging();
// Create timer with |duration|.
CreateTimer(mojo_base.mojom.TimeDelta duration);
};
// Enumeration of Assistant entry points. These values are persisted to logs.
......
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