Commit bebe07d2 authored by Renato Silva's avatar Renato Silva Committed by Commit Bot

CrOS OOBE - Fix Assistant message about battery

The Assistant flow in OOBE mentions that it will only listen when
the device is connected to a power source in order to save battery
when no DSP is available. This prevents this message from showing
up on Chromebases, Chromebits and Chromeboxes.

Fixed: 1109363
Bug: 1109363
Change-Id: I188a06d8e7c42064a6daab8f27a2e963930ee1fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416696
Commit-Queue: Renato Silva <rrsilva@google.com>
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Auto-Submit: Renato Silva <rrsilva@google.com>
Cr-Commit-Position: refs/heads/master@{#808911}
parent 768144a6
...@@ -185,7 +185,8 @@ Polymer({ ...@@ -185,7 +185,8 @@ Polymer({
this.$['already-setup-lottie'].setPlay(true); this.$['already-setup-lottie'].setPlay(true);
Polymer.RenderStatus.afterNextRender( Polymer.RenderStatus.afterNextRender(
this, () => this.$['agree-button'].focus()); this, () => this.$['agree-button'].focus());
if (loadTimeData.getBoolean('hotwordDspAvailable')) { if (loadTimeData.getBoolean('hotwordDspAvailable') ||
loadTimeData.getBoolean('deviceHasNoBattery')) {
this.$['no-dsp-message'].hidden = true; this.$['no-dsp-message'].hidden = true;
} }
}, },
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h" #include "chrome/browser/ui/webui/chromeos/assistant_optin/assistant_optin_utils.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/services/assistant/public/cpp/assistant_prefs.h" #include "chromeos/services/assistant/public/cpp/assistant_prefs.h"
#include "chromeos/services/assistant/public/cpp/assistant_service.h" #include "chromeos/services/assistant/public/cpp/assistant_service.h"
#include "chromeos/services/assistant/public/cpp/features.h" #include "chromeos/services/assistant/public/cpp/features.h"
...@@ -147,6 +148,7 @@ void AssistantOptInFlowScreenHandler::RegisterMessages() { ...@@ -147,6 +148,7 @@ void AssistantOptInFlowScreenHandler::RegisterMessages() {
void AssistantOptInFlowScreenHandler::GetAdditionalParameters( void AssistantOptInFlowScreenHandler::GetAdditionalParameters(
base::DictionaryValue* dict) { base::DictionaryValue* dict) {
dict->SetBoolean("hotwordDspAvailable", chromeos::IsHotwordDspAvailable()); dict->SetBoolean("hotwordDspAvailable", chromeos::IsHotwordDspAvailable());
dict->SetBoolean("deviceHasNoBattery", !DeviceHasBattery());
dict->SetBoolean("voiceMatchDisabled", dict->SetBoolean("voiceMatchDisabled",
chromeos::assistant::features::IsVoiceMatchDisabled()); chromeos::assistant::features::IsVoiceMatchDisabled());
BaseScreenHandler::GetAdditionalParameters(dict); BaseScreenHandler::GetAdditionalParameters(dict);
...@@ -603,4 +605,17 @@ void AssistantOptInFlowScreenHandler::HandleFlowInitialized( ...@@ -603,4 +605,17 @@ void AssistantOptInFlowScreenHandler::HandleFlowInitialized(
SendGetSettingsRequest(); SendGetSettingsRequest();
} }
bool AssistantOptInFlowScreenHandler::DeviceHasBattery() {
// Assume that the device has a battery if we can't determine otherwise.
if (!chromeos::PowerManagerClient::Get())
return true;
auto status = PowerManagerClient::Get()->GetLastStatus();
if (!status.has_value() || !status->has_battery_state())
return true;
return status->battery_state() !=
power_manager::PowerSupplyProperties_BatteryState_NOT_PRESENT;
}
} // namespace chromeos } // namespace chromeos
...@@ -128,6 +128,9 @@ class AssistantOptInFlowScreenHandler ...@@ -128,6 +128,9 @@ class AssistantOptInFlowScreenHandler
void HandleFlowFinished(); void HandleFlowFinished();
void HandleFlowInitialized(const int flow_type); void HandleFlowInitialized(const int flow_type);
// Power related
bool DeviceHasBattery();
AssistantOptInFlowScreen* screen_ = nullptr; AssistantOptInFlowScreen* screen_ = nullptr;
base::OnceClosure on_initialized_; base::OnceClosure on_initialized_;
......
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