Commit 027b447f authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

Enable "Turn on/off Do Not Disturb" query on Assistant.

Add API in ash_message_center_controller.mojom to support
DO_NOT_DISTURB setting modification when query comes.

Test: local compile and manually test.
Change-Id: I645cff4aace79038ff8a7a39a498464cfced9979
Reviewed-on: https://chromium-review.googlesource.com/c/1260504Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597363}
parent 2d03edf7
......@@ -4,6 +4,8 @@
#include "ash/message_center/message_center_controller.h"
#include <utility>
#include "ash/message_center/arc_notification_manager_delegate_impl.h"
#include "ash/message_center/ash_message_center_lock_screen_controller.h"
#include "ash/public/cpp/ash_pref_names.h"
......@@ -44,7 +46,7 @@ namespace {
// --suppress-message-center-notifications.
class PopupNotificationBlocker : public message_center::NotificationBlocker {
public:
PopupNotificationBlocker(MessageCenter* message_center)
explicit PopupNotificationBlocker(MessageCenter* message_center)
: NotificationBlocker(message_center) {}
~PopupNotificationBlocker() override = default;
......@@ -240,6 +242,10 @@ void MessageCenterController::GetActiveNotifications(
std::move(callback).Run(notification_vector);
}
void MessageCenterController::SetQuietMode(bool enabled) {
MessageCenter::Get()->SetQuietMode(enabled);
}
void MessageCenterController::GetArcAppIdByPackageName(
const std::string& package_name,
GetAppIdByPackageNameCallback callback) {
......
......@@ -5,6 +5,10 @@
#ifndef ASH_MESSAGE_CENTER_MESSAGE_CENTER_CONTROLLER_H_
#define ASH_MESSAGE_CENTER_MESSAGE_CENTER_CONTROLLER_H_
#include <memory>
#include <string>
#include <vector>
#include "ash/ash_export.h"
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/system/message_center/arc/arc_notification_manager.h"
......@@ -54,6 +58,7 @@ class ASH_EXPORT MessageCenterController
void NotifierEnabledChanged(const message_center::NotifierId& notifier_id,
bool enabled) override;
void GetActiveNotifications(GetActiveNotificationsCallback callback) override;
void SetQuietMode(bool enabled) override;
// Handles get app id calls from ArcNotificationManager.
using GetAppIdByPackageNameCallback =
......
......@@ -55,6 +55,9 @@ interface AshMessageCenterController {
// Gets a list of all the notifications in the message center.
GetActiveNotifications() =>
(array<message_center.mojom.Notification> notifications);
// Changes the quiet mode state in the message center.
SetQuietMode(bool enabled);
};
// The message center client interface mimics
......
......@@ -48,6 +48,7 @@ constexpr char kWiFiDeviceSettingId[] = "WIFI";
constexpr char kBluetoothDeviceSettingId[] = "BLUETOOTH";
constexpr char kVolumeLevelDeviceSettingId[] = "VOLUME_LEVEL";
constexpr char kScreenBrightnessDeviceSettingId[] = "BRIGHTNESS_LEVEL";
constexpr char kDoNotDisturbDeviceSettingId[] = "DO_NOT_DISTURB";
constexpr char kNightLightDeviceSettingId[] = "NIGHT_LIGHT_SWITCH";
constexpr char kTimerFireNotificationGroupId[] = "assistant/timer_fire";
constexpr char kQueryDeeplinkPrefix[] = "googleassistant://send-query?q=";
......@@ -78,6 +79,8 @@ AssistantManagerServiceImpl::AssistantManagerServiceImpl(
background_thread_.task_runner());
connector->BindInterface(ash::mojom::kServiceName,
&voice_interaction_controller_);
connector->BindInterface(ash::mojom::kServiceName,
&ash_message_center_controller_);
// TODO(b/112281490): Combine this observer with the one in service.cc.
ash::mojom::VoiceInteractionObserverPtr ptr;
......@@ -620,6 +623,12 @@ void AssistantManagerServiceImpl::OnModifySettingsAction(
weak_factory_.GetWeakPtr(), modify_setting_args));
}
if (modify_setting_args.setting_id() == kDoNotDisturbDeviceSettingId) {
HandleOnOffChange(modify_setting_args, [&](bool enabled) {
ash_message_center_controller_->SetQuietMode(enabled);
});
}
if (modify_setting_args.setting_id() == kNightLightDeviceSettingId) {
HandleOnOffChange(modify_setting_args, [&](bool enabled) {
this->service_->device_actions()->SetNightLightEnabled(enabled);
......@@ -644,6 +653,7 @@ bool AssistantManagerServiceImpl::IsSettingSupported(
setting_id == kBluetoothDeviceSettingId ||
setting_id == kVolumeLevelDeviceSettingId ||
setting_id == kScreenBrightnessDeviceSettingId ||
setting_id == kDoNotDisturbDeviceSettingId ||
setting_id == kNightLightDeviceSettingId);
}
......
......@@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "ash/public/interfaces/ash_message_center_controller.mojom.h"
#include "ash/public/interfaces/assistant_controller.mojom.h"
#include "ash/public/interfaces/voice_interaction_controller.mojom.h"
#include "base/threading/thread.h"
......@@ -217,7 +218,7 @@ class AssistantManagerServiceImpl
ash::mojom::VoiceInteractionControllerPtr voice_interaction_controller_;
mojo::Binding<ash::mojom::VoiceInteractionObserver>
voice_interaction_observer_binding_;
ash::mojom::AshMessageCenterControllerPtr ash_message_center_controller_;
Service* service_; // unowned.
base::Optional<std::string> arc_version_;
......
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