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 { ...@@ -39,12 +39,10 @@ class MockUpdateView : public UpdateView {
MOCK_METHOD(void, SetUIState, (UpdateView::UIState value)); MOCK_METHOD(void, SetUIState, (UpdateView::UIState value));
MOCK_METHOD(void, MOCK_METHOD(void,
SetUpdateStatusMessagePercent, SetUpdateStatus,
(const base::string16& value)); (int percent,
MOCK_METHOD(void, const base::string16& percent_message,
SetUpdateStatusMessageTimeLeft, const base::string16& timeleft_message));
(const base::string16& value));
MOCK_METHOD(void, SetBetterUpdateProgress, (int value));
MOCK_METHOD(void, SetEstimatedTimeLeft, (int value)); MOCK_METHOD(void, SetEstimatedTimeLeft, (int value));
MOCK_METHOD(void, SetShowEstimatedTimeLeft, (bool value)); MOCK_METHOD(void, SetShowEstimatedTimeLeft, (bool value));
MOCK_METHOD(void, SetUpdateCompleted, (bool value)); MOCK_METHOD(void, SetUpdateCompleted, (bool value));
......
...@@ -443,20 +443,23 @@ void UpdateScreen::SetUpdateStatusMessage(int percent, ...@@ -443,20 +443,23 @@ void UpdateScreen::SetUpdateStatusMessage(int percent,
base::TimeDelta time_left) { base::TimeDelta time_left) {
if (!view_) if (!view_)
return; return;
view_->SetUpdateStatusMessagePercent(l10n_util::GetStringFUTF16( base::string16 time_left_message;
IDS_UPDATE_STATUS_SUBTITLE_PERCENT, base::FormatPercent(percent)));
if (time_left.InMinutes() == 0) { if (time_left.InMinutes() == 0) {
view_->SetUpdateStatusMessageTimeLeft(l10n_util::GetStringFUTF16( time_left_message = l10n_util::GetStringFUTF16(
IDS_UPDATE_STATUS_SUBTITLE_TIME_LEFT, IDS_UPDATE_STATUS_SUBTITLE_TIME_LEFT,
l10n_util::GetPluralStringFUTF16(IDS_TIME_LONG_SECS, l10n_util::GetPluralStringFUTF16(IDS_TIME_LONG_SECS,
time_left.InSeconds()))); time_left.InSeconds()));
} else { } else {
view_->SetUpdateStatusMessageTimeLeft(l10n_util::GetStringFUTF16( time_left_message = l10n_util::GetStringFUTF16(
IDS_UPDATE_STATUS_SUBTITLE_TIME_LEFT, IDS_UPDATE_STATUS_SUBTITLE_TIME_LEFT,
l10n_util::GetPluralStringFUTF16(IDS_TIME_LONG_MINS, 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() { void UpdateScreen::UpdateBatteryWarningVisibility() {
......
...@@ -73,9 +73,11 @@ ...@@ -73,9 +73,11 @@
icon1x="oobe-32:googleg" icon2x="oobe-64:googleg"> icon1x="oobe-32:googleg" icon2x="oobe-64:googleg">
</hd-iron-icon> </hd-iron-icon>
<div slot="subtitle"> <div slot="subtitle">
<span>[[updateStatusMessagePercent]]</span> <span id="better-update-percent">[[updateStatusMessagePercent]]</span>
<span> | </span> <span> | </span>
<span>[[updateStatusMessageTimeLeft]]</span> <span id="better-update-timeleft">
[[updateStatusMessageTimeLeft]]
</span>
</div> </div>
<paper-progress slot="progress" id="update-progress" <paper-progress slot="progress" id="update-progress"
value="[[betterUpdateProgressValue]]"> value="[[betterUpdateProgressValue]]">
......
...@@ -14,6 +14,13 @@ const USER_ACTION_ACCEPT_UPDATE_OVER_CELLUAR = 'update-accept-cellular'; ...@@ -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_REJECT_UPDATE_OVER_CELLUAR = 'update-reject-cellular';
const USER_ACTION_CANCEL_UPDATE_SHORTCUT = 'cancel-update'; 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. * 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. * These values must be kept in sync with UpdateView::UIState in C++ code.
...@@ -43,9 +50,7 @@ Polymer({ ...@@ -43,9 +50,7 @@ Polymer({
'setCancelUpdateShortcutEnabled', 'setCancelUpdateShortcutEnabled',
'showLowBatteryWarningMessage', 'showLowBatteryWarningMessage',
'setUIState', 'setUIState',
'setUpdateStatusMessagePercent', 'setUpdateStatus',
'setUpdateStatusMessageTimeLeft',
'setBetterUpdateProgress',
'setAutoTransition', 'setAutoTransition',
], ],
...@@ -184,6 +189,14 @@ Polymer({ ...@@ -184,6 +189,14 @@ Polymer({
type: Boolean, type: Boolean,
value: true, value: true,
}, },
/**
* Index of threshold that has been already achieved.
*/
thresholdIndex: {
type: Number,
value: 0,
}
}, },
ready() { ready() {
...@@ -288,22 +301,6 @@ Polymer({ ...@@ -288,22 +301,6 @@ Polymer({
this.showLowBatteryWarning = visible; 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. * Sets which dialog should be shown.
* @param {UpdateUIState} value Current UI state. * @param {UpdateUIState} value Current UI state.
...@@ -314,10 +311,27 @@ Polymer({ ...@@ -314,10 +311,27 @@ Polymer({
/** /**
* Sets percent to be shown in progress bar. * 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) { setUpdateStatus(percent, messagePercent, messageTimeLeft) {
this.betterUpdateProgressValue = value; // 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) { ...@@ -71,18 +71,12 @@ void UpdateScreenHandler::SetUIState(UpdateView::UIState value) {
CallJS("login.UpdateScreen.setUIState", static_cast<int>(value)); CallJS("login.UpdateScreen.setUIState", static_cast<int>(value));
} }
void UpdateScreenHandler::SetUpdateStatusMessagePercent( void UpdateScreenHandler::SetUpdateStatus(
const base::string16& value) { int percent,
CallJS("login.UpdateScreen.setUpdateStatusMessagePercent", value); const base::string16& percent_message,
} const base::string16& timeleft_message) {
CallJS("login.UpdateScreen.setUpdateStatus", percent, percent_message,
void UpdateScreenHandler::SetUpdateStatusMessageTimeLeft( timeleft_message);
const base::string16& value) {
CallJS("login.UpdateScreen.setUpdateStatusMessageTimeLeft", value);
}
void UpdateScreenHandler::SetBetterUpdateProgress(int value) {
CallJS("login.UpdateScreen.setBetterUpdateProgress", value);
} }
void UpdateScreenHandler::SetEstimatedTimeLeft(int value) { void UpdateScreenHandler::SetEstimatedTimeLeft(int value) {
......
...@@ -47,9 +47,9 @@ class UpdateView { ...@@ -47,9 +47,9 @@ class UpdateView {
virtual void Unbind() = 0; virtual void Unbind() = 0;
virtual void SetUIState(UIState value) = 0; virtual void SetUIState(UIState value) = 0;
virtual void SetUpdateStatusMessagePercent(const base::string16& value) = 0; virtual void SetUpdateStatus(int percent,
virtual void SetUpdateStatusMessageTimeLeft(const base::string16& value) = 0; const base::string16& percent_message,
virtual void SetBetterUpdateProgress(int value) = 0; const base::string16& timeleft_message) = 0;
// Set the estimated time left, in seconds. // Set the estimated time left, in seconds.
virtual void SetEstimatedTimeLeft(int value) = 0; virtual void SetEstimatedTimeLeft(int value) = 0;
virtual void SetShowEstimatedTimeLeft(bool value) = 0; virtual void SetShowEstimatedTimeLeft(bool value) = 0;
...@@ -77,9 +77,9 @@ class UpdateScreenHandler : public UpdateView, public BaseScreenHandler { ...@@ -77,9 +77,9 @@ class UpdateScreenHandler : public UpdateView, public BaseScreenHandler {
void Unbind() override; void Unbind() override;
void SetUIState(UpdateView::UIState value) override; void SetUIState(UpdateView::UIState value) override;
void SetUpdateStatusMessagePercent(const base::string16& value) override; void SetUpdateStatus(int percent,
void SetUpdateStatusMessageTimeLeft(const base::string16& value) override; const base::string16& percent_message,
void SetBetterUpdateProgress(int value) override; const base::string16& timeleft_message) override;
void SetEstimatedTimeLeft(int value) override; void SetEstimatedTimeLeft(int value) override;
void SetShowEstimatedTimeLeft(bool value) override; void SetShowEstimatedTimeLeft(bool value) override;
void SetUpdateCompleted(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