Commit 2adaee40 authored by Roman Aleksandrov's avatar Roman Aleksandrov Committed by Commit Bot

UpdateScreen: Notify status updates only after reaching thresholds.

Add thresholds to announce by spoken feedback timeleft and percent
progress only after reaching them.

Bug: 1124252
Change-Id: I0374fdb9e3ffdf9e16d1cbb664cb6025d8208fb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391151Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Commit-Queue: Roman Aleksandrov <raleksandrov@google.com>
Cr-Commit-Position: refs/heads/master@{#807029}
parent c4dfaf4d
......@@ -39,12 +39,10 @@ class MockUpdateView : public UpdateView {
MOCK_METHOD(void, SetUIState, (UpdateView::UIState value));
MOCK_METHOD(void,
SetUpdateStatusMessagePercent,
(const base::string16& value));
MOCK_METHOD(void,
SetUpdateStatusMessageTimeLeft,
(const base::string16& value));
MOCK_METHOD(void, SetBetterUpdateProgress, (int value));
SetUpdateStatus,
(int percent,
const base::string16& percent_message,
const base::string16& timeleft_message));
MOCK_METHOD(void, SetEstimatedTimeLeft, (int value));
MOCK_METHOD(void, SetShowEstimatedTimeLeft, (bool value));
MOCK_METHOD(void, SetUpdateCompleted, (bool value));
......
......@@ -443,20 +443,23 @@ void UpdateScreen::SetUpdateStatusMessage(int percent,
base::TimeDelta time_left) {
if (!view_)
return;
view_->SetUpdateStatusMessagePercent(l10n_util::GetStringFUTF16(
IDS_UPDATE_STATUS_SUBTITLE_PERCENT, base::FormatPercent(percent)));
base::string16 time_left_message;
if (time_left.InMinutes() == 0) {
view_->SetUpdateStatusMessageTimeLeft(l10n_util::GetStringFUTF16(
time_left_message = l10n_util::GetStringFUTF16(
IDS_UPDATE_STATUS_SUBTITLE_TIME_LEFT,
l10n_util::GetPluralStringFUTF16(IDS_TIME_LONG_SECS,
time_left.InSeconds())));
time_left.InSeconds()));
} else {
view_->SetUpdateStatusMessageTimeLeft(l10n_util::GetStringFUTF16(
time_left_message = l10n_util::GetStringFUTF16(
IDS_UPDATE_STATUS_SUBTITLE_TIME_LEFT,
l10n_util::GetPluralStringFUTF16(IDS_TIME_LONG_MINS,
time_left.InMinutes())));
time_left.InMinutes()));
}
view_->SetBetterUpdateProgress(percent);
view_->SetUpdateStatus(
percent,
l10n_util::GetStringFUTF16(IDS_UPDATE_STATUS_SUBTITLE_PERCENT,
base::FormatPercent(percent)),
time_left_message);
}
void UpdateScreen::UpdateBatteryWarningVisibility() {
......
......@@ -73,9 +73,11 @@
icon1x="oobe-32:googleg" icon2x="oobe-64:googleg">
</hd-iron-icon>
<div slot="subtitle">
<span>[[updateStatusMessagePercent]]</span>
<span id="better-update-percent">[[updateStatusMessagePercent]]</span>
<span> | </span>
<span>[[updateStatusMessageTimeLeft]]</span>
<span id="better-update-timeleft">
[[updateStatusMessageTimeLeft]]
</span>
</div>
<paper-progress slot="progress" id="update-progress"
value="[[betterUpdateProgressValue]]">
......
......@@ -14,6 +14,13 @@ const USER_ACTION_ACCEPT_UPDATE_OVER_CELLUAR = 'update-accept-cellular';
const USER_ACTION_REJECT_UPDATE_OVER_CELLUAR = 'update-reject-cellular';
const USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update';
const UNREACHABLE_PERCENT = 1000;
// Thresholds which are used to determine when update status announcement should
// take place. Last element is not reachable to simplify implementation.
const PERCENT_THRESHOLDS = [
0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 99, 100, UNREACHABLE_PERCENT
];
/**
* Enum for the UI states corresponding to sub steps inside update screen.
* These values must be kept in sync with UpdateView::UIState in C++ code.
......@@ -43,9 +50,7 @@ Polymer({
'setCancelUpdateShortcutEnabled',
'showLowBatteryWarningMessage',
'setUIState',
'setUpdateStatusMessagePercent',
'setUpdateStatusMessageTimeLeft',
'setBetterUpdateProgress',
'setUpdateStatus',
'setAutoTransition',
],
......@@ -184,6 +189,14 @@ Polymer({
type: Boolean,
value: true,
},
/**
* Index of threshold that has been already achieved.
*/
thresholdIndex: {
type: Number,
value: 0,
}
},
ready() {
......@@ -288,22 +301,6 @@ Polymer({
this.showLowBatteryWarning = visible;
},
/**
* Sets message above the progress bar.
* @param {string} message Message that should be set.
*/
setUpdateStatusMessagePercent(message) {
this.updateStatusMessagePercent = message;
},
/**
* Sets message above the progress bar.
* @param {string} message Message that should be set.
*/
setUpdateStatusMessageTimeLeft(message) {
this.updateStatusMessageTimeLeft = message;
},
/**
* Sets which dialog should be shown.
* @param {UpdateUIState} value Current UI state.
......@@ -314,10 +311,27 @@ Polymer({
/**
* Sets percent to be shown in progress bar.
* @param {number} value Current progress
* @param {number} percent Current progress
* @param {string} messagePercent Message describing current progress.
* @param {string} messageTimeLeft Message describing time left.
*/
setBetterUpdateProgress(value) {
this.betterUpdateProgressValue = value;
setUpdateStatus(percent, messagePercent, messageTimeLeft) {
// Sets aria-live polite on percent and timeleft container every time new
// threshold has been achieved otherwise do not initiate spoken feedback
// update by setting aria-live off.
if (percent >= PERCENT_THRESHOLDS[this.thresholdIndex]) {
while (percent >= PERCENT_THRESHOLDS[this.thresholdIndex]) {
this.thresholdIndex = this.thresholdIndex + 1;
}
this.$['better-update-percent'].setAttribute('aria-live', 'polite');
this.$['better-update-timeleft'].setAttribute('aria-live', 'polite');
} else {
this.$['better-update-timeleft'].setAttribute('aria-live', 'off');
this.$['better-update-percent'].setAttribute('aria-live', 'off');
}
this.betterUpdateProgressValue = percent;
this.updateStatusMessagePercent = messagePercent;
this.updateStatusMessageTimeLeft = messageTimeLeft;
},
/**
......
......@@ -71,18 +71,12 @@ void UpdateScreenHandler::SetUIState(UpdateView::UIState value) {
CallJS("login.UpdateScreen.setUIState", static_cast<int>(value));
}
void UpdateScreenHandler::SetUpdateStatusMessagePercent(
const base::string16& value) {
CallJS("login.UpdateScreen.setUpdateStatusMessagePercent", value);
}
void UpdateScreenHandler::SetUpdateStatusMessageTimeLeft(
const base::string16& value) {
CallJS("login.UpdateScreen.setUpdateStatusMessageTimeLeft", value);
}
void UpdateScreenHandler::SetBetterUpdateProgress(int value) {
CallJS("login.UpdateScreen.setBetterUpdateProgress", value);
void UpdateScreenHandler::SetUpdateStatus(
int percent,
const base::string16& percent_message,
const base::string16& timeleft_message) {
CallJS("login.UpdateScreen.setUpdateStatus", percent, percent_message,
timeleft_message);
}
void UpdateScreenHandler::SetEstimatedTimeLeft(int value) {
......
......@@ -47,9 +47,9 @@ class UpdateView {
virtual void Unbind() = 0;
virtual void SetUIState(UIState value) = 0;
virtual void SetUpdateStatusMessagePercent(const base::string16& value) = 0;
virtual void SetUpdateStatusMessageTimeLeft(const base::string16& value) = 0;
virtual void SetBetterUpdateProgress(int value) = 0;
virtual void SetUpdateStatus(int percent,
const base::string16& percent_message,
const base::string16& timeleft_message) = 0;
// Set the estimated time left, in seconds.
virtual void SetEstimatedTimeLeft(int value) = 0;
virtual void SetShowEstimatedTimeLeft(bool value) = 0;
......@@ -77,9 +77,9 @@ class UpdateScreenHandler : public UpdateView, public BaseScreenHandler {
void Unbind() override;
void SetUIState(UpdateView::UIState value) override;
void SetUpdateStatusMessagePercent(const base::string16& value) override;
void SetUpdateStatusMessageTimeLeft(const base::string16& value) override;
void SetBetterUpdateProgress(int value) override;
void SetUpdateStatus(int percent,
const base::string16& percent_message,
const base::string16& timeleft_message) override;
void SetEstimatedTimeLeft(int value) override;
void SetShowEstimatedTimeLeft(bool value) override;
void SetUpdateCompleted(bool value) override;
......
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