0

Add in accessibility strings for System Info Answer Cards

Based on accessibility greenlines here: go/sys-ans-cards

Bug: b/263994165
Change-Id: I1cbf0c9931009705b2fb6ff5dc6ce735dd417771
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4744824
Commit-Queue: Lauren Commeignes <laurencom@chromium.org>
Reviewed-by: Dmitry Grebenyuk <dgrebenyuk@google.com>
Cr-Commit-Position: refs/heads/main@{#1179375}
This commit is contained in:
Lauren Commeignes
2023-08-04 01:02:20 +00:00
committed by Chromium LUCI CQ
parent d4890fb830
commit 9953a477e5
32 changed files with 257 additions and 70 deletions

@ -2071,15 +2071,24 @@ Style notes:
<message name="IDS_ASH_VERSION_IN_LAUNCHER_DESCRIPTION" desc="Message content for the description of the answer card with the current version in the launcher.">
Click to check for details
</message>
<message name="IDS_ASH_VERSION_IN_LAUNCHER_ACCESSIBILITY_LABEL" desc="Message content for the accessibility label of the answer card with the current version in the launcher.">
Current version <ph name="VERSION_NAME">$1<ex>109.0.5414.125</ex></ph> (<ph name="OFFICIAL_STATUS">$2<ex>Official Build</ex></ph>) <ph name="CHANNEL_NAME">$3<ex>Beta</ex></ph> <ph name="PROCESSOR_VARIATION">$4<ex>(64-bit)</ex></ph>
</message>
<message name="IDS_ASH_CPU_IN_LAUNCHER_TITLE" desc="Message content for the title of the answer card with the current CPU system information in the launcher.">
CPU usage snapshot: <ph name="CPU_USEAGE">$1<ex>89</ex></ph>%
</message>
<message name="IDS_ASH_CPU_IN_LAUNCHER_DESCRIPTION" desc="Message content for the description of the answer card with the current CPU system information in the launcher.">
Temperature: <ph name="TEMPERATURE">$1<ex>34</ex></ph>°C - Current speed: <ph name="CPU_AVERAGE_CURRENT_FREQUENCY_GHZ">$2<ex>1.52</ex></ph>GHz
</message>
<message name="IDS_ASH_CPU_IN_LAUNCHER_ACCESSIBILITY_LABEL" desc="Message content for the accessibility label of the answer card with the current CPU system information in the launcher.">
CPU usage snapshot, <ph name="CPU_USEAGE">$1<ex>89</ex></ph>%. Temperature <ph name="TEMPERATURE">$2<ex>34</ex></ph> degrees celsius, current speed: <ph name="CPU_AVERAGE_CURRENT_FREQUENCY_GHZ">$3<ex>1.52</ex></ph>GHz
</message>
<message name="IDS_ASH_MEMORY_USAGE_IN_LAUNCHER_DESCRIPTION" desc="Message content for the description of the answer card with the current memory usage information in the launcher.">
Memory <ph name="USED_MEMORY">$1<ex>2.4 GB</ex></ph> | <ph name="TOTAL_MEMORY">$2<ex>7.6 GB</ex></ph> total
</message>
<message name="IDS_ASH_MEMORY_USAGE_IN_LAUNCHER_ACCESSIBILITY_LABEL" desc="Message content for the accessibility label of the answer card with the current memory usage information in the launcher.">
Memory <ph name="USED_MEMORY">$1<ex>2.4 GB</ex></ph> available out of <ph name="TOTAL_MEMORY">$2<ex>7.6 GB</ex></ph> total
</message>
<message name="IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_DESCRIPTION_LEFT_SHORT" desc="Message content for the short description on the left of the battery answer card.">
Battery <ph name="BATTERY_PERCENTAGE">$1<ex>56</ex></ph>%
</message>
@ -2092,9 +2101,51 @@ Style notes:
<message name="IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_DESCRIPTION_RIGHT" desc="Message content for the description on the right of the battery answer card, showing the battery health percentage and the cycle count.">
Battery health <ph name="BATTERY_HEALTH_PERCENTAGE">$1<ex>97</ex></ph>% | Cycle count <ph name="CYCLE_COUNT">$2<ex>15</ex></ph>
</message>
<message name="IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_ACCESSIBILITY_LABEL_SHORT" desc="Message content for the accessbility label of the battery answer card while the battery is discharging, showing the battery power as a percentage and the time left until the battery is empty.">
Current battery level <ph name="BATTERY_PERCENTAGE">$1<ex>56</ex></ph>%
</message>
<message name="IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_ACCESSIBILITY_LABEL" desc="Message content for the accessbility label of the battery answer card while the battery is discharging, showing the battery power as a percentage and the time left until the battery is empty.">
Current battery level <ph name="BATTERY_PERCENTAGE">$1<ex>56</ex></ph>%, <ph name="TIME">$2<ex>2 hours and 20 minutes</ex></ph> left
</message>
<message name="IDS_ASH_BATTERY_STATUS_CHARGING_IN_LAUNCHER_ACCESSIBILITY_LABEL" desc="Message content for the accessbility label of the battery answer card while the battery is discharging, showing the battery power as a percentage and the time left until the battery is empty.">
Current battery level <ph name="BATTERY_PERCENTAGE">$1<ex>56</ex></ph>%, <ph name="TIME">$2<ex>2 hours and 20 minutes</ex></ph> until full
</message>
<message name="IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_EXTRA_DETAILS_ACCESSIBILITY_LABEL" desc="Message content for the accessbility label of the battery answer card while the battery is discharging, showing the battery power as a percentage and the time left until the battery is empty.">
Battery health <ph name="BATTERY_HEALTH_PERCENTAGE">$1<ex>97</ex></ph>%, cycle count <ph name="CYCLE_COUNT">$2<ex>15</ex></ph>
</message>
<message name="IDS_ASH_STORAGE_STATUS_IN_LAUNCHER_DESCRIPTION" desc="Message content for the description of the storage answer card, showing the amount of storage currently in use and the total storage size.">
Storage <ph name="STORAGE_IN_USE_SIZE">$1<ex>65 GB</ex></ph> in use | <ph name="STORAGE_TOTAL_SIZE">$2<ex>124 GB</ex></ph> total
</message>
<message name="IDS_ASH_STORAGE_STATUS_IN_LAUNCHER_ACCESSIBILITY_LABEL" desc="Message content for the accessibility label of the storage answer card, showing the amount of storage currently in use and the total storage size.">
Storage <ph name="STORAGE_IN_USE_SIZE">$1<ex>65 GB</ex></ph> in use out of <ph name="STORAGE_TOTAL_SIZE">$2<ex>124 GB</ex></ph> total
</message>
<message name="IDS_ASH_ACCESSIBILITY_ANSWER_TYPE_IN_LAUNCHER" desc="Beginning of accessibility label for System Info Answer cards.">
Showing <ph name="ANSWER_TYPE">$1<ex>Battery</ex></ph> information
</message>
<message name="IDS_ASH_ACCESSIBILITY_OPEN_LABEL_IN_LAUNCHER" desc="Section to specify which app opens in the accessibility label for System Info Answer cards.">
Select to open <ph name="APP_TO_OPEN">$1<ex>Settings page</ex></ph>.
</message>
<message name="IDS_ASH_ACCESSIBILITY_OS_VERSION_LABEL_IN_LAUNCHER" desc="Accessibility string for OS version in System Info Answer cards.">
OS version
</message>
<message name="IDS_ASH_ACCESSIBILITY_BATTERY_LABEL_IN_LAUNCHER" desc="Accessibility string for battery in System Info Answer cards.">
battery
</message>
<message name="IDS_ASH_ACCESSIBILITY_MEMORY_LABEL_IN_LAUNCHER" desc="Accessibility string for memory in System Info Answer cards.">
memory
</message>
<message name="IDS_ASH_ACCESSIBILITY_STORAGE_LABEL_IN_LAUNCHER" desc="Accessibility string for storage in System Info Answer cards.">
storage space
</message>
<message name="IDS_ASH_ACCESSIBILITY_CPU_LABEL_IN_LAUNCHER" desc="Accessibility string for CPU in System Info Answer cards.">
CPU
</message>
<message name="IDS_ASH_ACCESSIBILITY_LABEL_DIAGNOSTICS_APP_IN_LAUNCHER" desc="Accessibility string for diagnostics app in System Info Answer cards.">
Diagnostics app
</message>
<message name="IDS_ASH_ACCESSIBILITY_LABEL_SETTINGS_PAGE_IN_LAUNCHER" desc="Accessibility string for settings page in System Info Answer cards.">
Settings page
</message>
<message name="IDS_ASH_STORAGE_MANAGEMENT_KEYWORD_FOR_LAUNCHER" desc="Keyword of storage management in launcher search that should trigger a storage answer card result.">
storage management
</message>

@ -0,0 +1 @@
18855491afd0aec2c4fc966ba71632d7841495a2

@ -0,0 +1 @@
afdd9b7e680cd154c57386990c36868ff4781136

@ -0,0 +1 @@
f9396e3bf686de19f06ba39b047cffb15f4fab02

@ -0,0 +1 @@
afcb5fa195e2ed9bd50e048578a4048064d08fe5

@ -0,0 +1 @@
be0e204a959fa1c371eb7717fd3b9ef1196b7bf7

@ -0,0 +1 @@
afcb5fa195e2ed9bd50e048578a4048064d08fe5

@ -0,0 +1 @@
18855491afd0aec2c4fc966ba71632d7841495a2

@ -0,0 +1 @@
18855491afd0aec2c4fc966ba71632d7841495a2

@ -0,0 +1 @@
be0e204a959fa1c371eb7717fd3b9ef1196b7bf7

@ -0,0 +1 @@
c2e69c0982372d9890b0a56e1a8ae346d5c81523

@ -0,0 +1 @@
afdd9b7e680cd154c57386990c36868ff4781136

@ -0,0 +1 @@
ece7dcee93dc0d04c0265e938b547039017a58dd

@ -0,0 +1 @@
ece7dcee93dc0d04c0265e938b547039017a58dd

@ -0,0 +1 @@
f9396e3bf686de19f06ba39b047cffb15f4fab02

@ -0,0 +1 @@
afcb5fa195e2ed9bd50e048578a4048064d08fe5

@ -0,0 +1 @@
be0e204a959fa1c371eb7717fd3b9ef1196b7bf7

@ -0,0 +1 @@
18855491afd0aec2c4fc966ba71632d7841495a2

@ -5,7 +5,6 @@
#include "chrome/browser/ash/app_list/search/system_info/battery_answer_result.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/power_utils.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_util.h"
@ -24,7 +23,9 @@ BatteryAnswerResult::BatteryAnswerResult(
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const AnswerCardInfo& answer_card_info)
: SystemInfoAnswerResult(profile,
query,
@ -33,7 +34,9 @@ BatteryAnswerResult::BatteryAnswerResult(
relevance_score,
title,
description,
accessibility_label,
system_info_category,
system_info_card_type,
answer_card_info) {
chromeos::PowerManagerClient::Get()->AddObserver(this);
}
@ -51,11 +54,12 @@ void BatteryAnswerResult::PowerChanged(
if (calculating) {
return;
}
std::u16string power_time = CalculatePowerTime(power_supply_properties);
int percent = ash::power_utils::GetRoundedBatteryPercent(
power_supply_properties.battery_percent());
DCHECK(percent <= 100 && percent >= 0);
UpdateTitleAndDetails(/*title=*/base::EmptyString16(), power_time);
UpdateBarChartPercentage(percent);
std::unique_ptr<BatteryHealth> new_battery_health =
std::make_unique<BatteryHealth>();
PopulatePowerStatus(power_supply_properties, *new_battery_health.get());
UpdateTitleAndDetails(/*title=*/base::EmptyString16(),
new_battery_health->GetPowerTime(),
new_battery_health->GetAccessibilityLabel());
UpdateBarChartPercentage(new_battery_health->GetBatteryPercentage());
}
} // namespace app_list

@ -21,7 +21,9 @@ class BatteryAnswerResult : public SystemInfoAnswerResult,
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const ash::SystemInfoAnswerCardData& answer_card_info);
~BatteryAnswerResult() override;

@ -22,6 +22,10 @@ class BatteryHealth {
void SetPowerTime(const std::u16string& power_time) {
power_time_ = power_time;
}
void SetAccessibilityLabel(const std::u16string& accessibility_label) {
accessibility_label_ = accessibility_label;
}
void SetBatteryPercentage(int battery_percentage) {
battery_percentage_ = battery_percentage;
}
@ -29,12 +33,14 @@ class BatteryHealth {
int GetCycleCount() const { return cycle_count_; }
int GetBatteryWearPercentage() const { return battery_wear_percentage_; }
std::u16string GetPowerTime() const { return power_time_; }
std::u16string GetAccessibilityLabel() const { return accessibility_label_; }
int GetBatteryPercentage() const { return battery_percentage_; }
private:
int cycle_count_ = 0;
int battery_wear_percentage_ = 0;
std::u16string power_time_ = u"";
std::u16string accessibility_label_ = u"";
int battery_percentage_ = 0;
};

@ -5,11 +5,7 @@
#include "chrome/browser/ash/app_list/search/system_info/cpu_answer_result.h"
#include "ash/public/cpp/app_list/app_list_types.h"
#include "ash/public/cpp/power_utils.h"
#include "base/functional/callback.h"
#include "chrome/browser/ash/app_list/search/system_info/cpu_data.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_util.h"
namespace app_list {
namespace {
@ -27,7 +23,9 @@ CpuAnswerResult::CpuAnswerResult(
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const AnswerCardInfo& answer_card_info,
SystemInfoCardProvider::UpdateCpuResultCallback callback,
std::unique_ptr<base::RepeatingTimer> timer,
@ -39,7 +37,9 @@ CpuAnswerResult::CpuAnswerResult(
relevance_score,
title,
description,
accessibility_label,
system_info_category,
system_info_card_type,
answer_card_info),
callback_(std::move(callback)),
timer_(std::move(timer)),
@ -57,9 +57,11 @@ CpuAnswerResult::~CpuAnswerResult() {
}
}
void CpuAnswerResult::OnCpuDataUpdated(const std::u16string& title,
const std::u16string& description) {
UpdateTitleAndDetails(title, description);
void CpuAnswerResult::OnCpuDataUpdated(
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label) {
UpdateTitleAndDetails(title, description, accessibility_label);
}
void CpuAnswerResult::UpdateResult() {

@ -6,10 +6,8 @@
#define CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_CPU_ANSWER_RESULT_H_
#include "ash/public/cpp/app_list/app_list_types.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"
#include "chrome/browser/ash/app_list/search/system_info/cpu_data.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_card_provider.h"
@ -25,7 +23,9 @@ class CpuAnswerResult : public SystemInfoAnswerResult,
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const ash::SystemInfoAnswerCardData& answer_card_info,
SystemInfoCardProvider::UpdateCpuResultCallback callback,
std::unique_ptr<base::RepeatingTimer> timer,
@ -37,7 +37,8 @@ class CpuAnswerResult : public SystemInfoAnswerResult,
CpuAnswerResult& operator=(const CpuAnswerResult& other) = delete;
void OnCpuDataUpdated(const std::u16string& title,
const std::u16string& description) override;
const std::u16string& description,
const std::u16string& accessibility_label) override;
void UpdateResult();
private:

@ -23,7 +23,9 @@ MemoryAnswerResult::MemoryAnswerResult(
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const AnswerCardInfo& answer_card_info,
SystemInfoCardProvider::UpdateMemoryResultCallback callback,
std::unique_ptr<base::RepeatingTimer> timer,
@ -35,7 +37,9 @@ MemoryAnswerResult::MemoryAnswerResult(
relevance_score,
title,
description,
accessibility_label,
system_info_category,
system_info_card_type,
answer_card_info),
callback_(std::move(callback)),
timer_(std::move(timer)),
@ -53,9 +57,11 @@ MemoryAnswerResult::~MemoryAnswerResult() {
}
}
void MemoryAnswerResult::OnMemoryUpdated(const double memory_usage_percentage,
const std::u16string& description) {
UpdateTitleAndDetails(u"", description);
void MemoryAnswerResult::OnMemoryUpdated(
const double memory_usage_percentage,
const std::u16string& description,
const std::u16string& accessibility_label) {
UpdateTitleAndDetails(u"", description, accessibility_label);
UpdateBarChartPercentage(memory_usage_percentage);
}

@ -6,7 +6,6 @@
#define CHROME_BROWSER_ASH_APP_LIST_SEARCH_SYSTEM_INFO_MEMORY_ANSWER_RESULT_H_
#include "ash/public/cpp/app_list/app_list_types.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"
#include "chrome/browser/ash/app_list/search/system_info/system_info_answer_result.h"
@ -25,7 +24,9 @@ class MemoryAnswerResult : public SystemInfoAnswerResult,
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const ash::SystemInfoAnswerCardData& answer_card_info,
SystemInfoCardProvider::UpdateMemoryResultCallback callback,
std::unique_ptr<base::RepeatingTimer> timer,
@ -37,7 +38,8 @@ class MemoryAnswerResult : public SystemInfoAnswerResult,
MemoryAnswerResult& operator=(const MemoryAnswerResult& other) = delete;
void OnMemoryUpdated(const double memory_usage_percentage,
const std::u16string& description) override;
const std::u16string& description,
const std::u16string& accessibility_label) override;
void UpdateResult();
private:

@ -7,6 +7,7 @@
#include <string>
#include "ash/public/cpp/app_list/app_list_metrics.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/webui/diagnostics_ui/url_constants.h"
#include "base/strings/strcat.h"
#include "chrome/browser/ash/app_list/search/common/icon_constants.h"
@ -14,6 +15,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/system_web_apps/system_web_app_ui_utils.h"
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
namespace app_list {
@ -22,6 +24,39 @@ namespace {
constexpr char kOsSettingsResultPrefix[] = "os-settings://";
using AnswerCardInfo = ::ash::SystemInfoAnswerCardData;
const std::u16string CardTypeString(
SystemInfoAnswerResult::SystemInfoCardType system_info_card_type) {
switch (system_info_card_type) {
case SystemInfoAnswerResult::SystemInfoCardType::kVersion:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_OS_VERSION_LABEL_IN_LAUNCHER);
case SystemInfoAnswerResult::SystemInfoCardType::kMemory:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_MEMORY_LABEL_IN_LAUNCHER);
case SystemInfoAnswerResult::SystemInfoCardType::kStorage:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_STORAGE_LABEL_IN_LAUNCHER);
case SystemInfoAnswerResult::SystemInfoCardType::kCPU:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_CPU_LABEL_IN_LAUNCHER);
case SystemInfoAnswerResult::SystemInfoCardType::kBattery:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_BATTERY_LABEL_IN_LAUNCHER);
}
}
const std::u16string CategoryString(
SystemInfoAnswerResult::SystemInfoCategory system_info_category) {
switch (system_info_category) {
case SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_LABEL_DIAGNOSTICS_APP_IN_LAUNCHER);
case SystemInfoAnswerResult::SystemInfoCategory::kSettings:
return l10n_util::GetStringUTF16(
IDS_ASH_ACCESSIBILITY_LABEL_SETTINGS_PAGE_IN_LAUNCHER);
}
}
} // namespace
SystemInfoAnswerResult::SystemInfoAnswerResult(
@ -32,9 +67,12 @@ SystemInfoAnswerResult::SystemInfoAnswerResult(
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const ash::SystemInfoAnswerCardData& answer_card_info)
: system_info_category_(system_info_category),
system_info_card_type_(system_info_card_type),
answer_card_info_(answer_card_info),
profile_(profile),
query_(query),
@ -46,7 +84,7 @@ SystemInfoAnswerResult::SystemInfoAnswerResult(
SetIcon(IconInfo(ui::ImageModel::FromImageSkia(icon), kAppIconDimension));
SetCategory(Category::kSettings);
SetResultType(ResultType::kSystemInfo);
UpdateTitleAndDetails(title, description);
UpdateTitleAndDetails(title, description, accessibility_label);
SetMetricsType(ash::SYSTEM_INFO);
std::string id =
system_info_category_ == SystemInfoCategory::kSettings
@ -60,7 +98,8 @@ SystemInfoAnswerResult::~SystemInfoAnswerResult() = default;
void SystemInfoAnswerResult::UpdateTitleAndDetails(
const std::u16string& title,
const std::u16string& description) {
const std::u16string& description,
const std::u16string& accessibility_label) {
std::vector<TextItem> title_vector;
title_vector.push_back(CreateStringTextItem(title));
SetTitleTextVector(title_vector);
@ -69,13 +108,24 @@ void SystemInfoAnswerResult::UpdateTitleAndDetails(
details_vector.push_back(CreateStringTextItem(description));
SetDetailsTextVector(details_vector);
std::u16string accessibility_label_answer_type_details =
l10n_util::GetStringFUTF16(IDS_ASH_ACCESSIBILITY_ANSWER_TYPE_IN_LAUNCHER,
CardTypeString(system_info_card_type_));
std::u16string accessibility_label_open_page =
l10n_util::GetStringFUTF16(IDS_ASH_ACCESSIBILITY_OPEN_LABEL_IN_LAUNCHER,
CategoryString(system_info_category_));
std::vector<std::u16string> accessibility_vector;
for (const std::u16string& text : {title, description}) {
for (const std::u16string& text :
{accessibility_label_answer_type_details, accessibility_label,
accessibility_label_open_page}) {
if (!text.empty()) {
accessibility_vector.emplace_back(text);
}
}
SetAccessibleName(base::JoinString(accessibility_vector, u", "));
SetAccessibleName(base::JoinString(accessibility_vector, u". "));
}
void SystemInfoAnswerResult::Open(int event_flags) {

@ -16,6 +16,7 @@ namespace app_list {
class SystemInfoAnswerResult : public ChromeSearchResult {
public:
enum class SystemInfoCategory { kSettings, kDiagnostics };
enum class SystemInfoCardType { kVersion, kMemory, kStorage, kCPU, kBattery };
SystemInfoAnswerResult(Profile* profile,
const std::u16string& query,
@ -24,7 +25,9 @@ class SystemInfoAnswerResult : public ChromeSearchResult {
double relevance_score,
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label,
SystemInfoCategory system_info_category,
SystemInfoCardType system_info_card_type,
const ash::SystemInfoAnswerCardData& answer_card_info);
SystemInfoAnswerResult(const SystemInfoAnswerResult&) = delete;
SystemInfoAnswerResult& operator=(const SystemInfoAnswerResult&) = delete;
@ -34,12 +37,14 @@ class SystemInfoAnswerResult : public ChromeSearchResult {
void Open(int event_flags) override;
void UpdateTitleAndDetails(const std::u16string& title,
const std::u16string& description);
const std::u16string& description,
const std::u16string& accessibility_label);
void UpdateBarChartPercentage(const double bar_chart_percentage);
private:
SystemInfoCategory const system_info_category_;
SystemInfoCardType const system_info_card_type_;
ash::SystemInfoAnswerCardData answer_card_info_;
const raw_ptr<Profile, ExperimentalAsh> profile_;
const std::u16string query_;

@ -50,7 +50,10 @@ TEST_F(SystemInfoAnswerResultTest, version) {
profile_.get(), u"query", "path", GetTestIcon(), 0.8,
u"Version 108.0.5359.37 (Official Build) beta (64-bit)",
u"Click here to check for updates",
SystemInfoAnswerResult::SystemInfoCategory::kSettings, answer_card_info);
u"Current version 108.0.5359.37 (Official Build) beta (64-bit). Click "
u"to check for details",
SystemInfoAnswerResult::SystemInfoCategory::kSettings,
SystemInfoAnswerResult::SystemInfoCardType::kVersion, answer_card_info);
EXPECT_EQ(result.id(), "os-settings://path");
EXPECT_EQ(result.display_type(), DisplayType::kAnswerCard);
EXPECT_EQ(result.category(), Category::kSettings);
@ -64,8 +67,10 @@ TEST_F(SystemInfoAnswerResultTest, version) {
EXPECT_EQ(result.system_info_answer_card_data()->display_type,
ash::SystemInfoAnswerCardDisplayType::kTextCard);
EXPECT_EQ(result.accessible_name(),
u"Version 108.0.5359.37 (Official Build) beta (64-bit), Click here "
u"to check for updates");
u"Showing OS version information. Current version 108.0.5359.37 "
u"(Official "
u"Build) beta (64-bit). Click "
u"to check for details. Select to open Settings page.");
ASSERT_EQ(result.title_text_vector().size(), 1u);
const auto& title = result.title_text_vector()[0];
@ -86,8 +91,9 @@ TEST_F(SystemInfoAnswerResultTest, memory) {
SystemInfoAnswerResult result(
profile_.get(), u"query", "", GetTestIcon(), 0.8, u"",
u"5.16 GB of 15.52 GB available",
u"Memory 5.16 GB available out of 15.52 GB total",
SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics,
answer_card_info);
SystemInfoAnswerResult::SystemInfoCardType::kMemory, answer_card_info);
EXPECT_EQ(result.id(), kChromeUIDiagnosticsAppUrl);
EXPECT_EQ(result.display_type(), DisplayType::kAnswerCard);
EXPECT_EQ(result.category(), Category::kSettings);
@ -101,7 +107,9 @@ TEST_F(SystemInfoAnswerResultTest, memory) {
EXPECT_EQ(result.system_info_answer_card_data()->display_type,
ash::SystemInfoAnswerCardDisplayType::kBarChart);
EXPECT_EQ(result.system_info_answer_card_data()->bar_chart_percentage, 54.8);
EXPECT_EQ(result.accessible_name(), u"5.16 GB of 15.52 GB available");
EXPECT_EQ(result.accessible_name(),
u"Showing memory information. Memory 5.16 GB available out of "
u"15.52 GB total. Select to open Diagnostics app.");
ASSERT_EQ(result.title_text_vector().size(), 1u);
const auto& title = result.title_text_vector()[0];

@ -11,8 +11,6 @@
#include "ash/strings/grit/ash_strings.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/ash/app_list/search/common/icon_constants.h"
@ -206,6 +204,10 @@ void SystemInfoCardProvider::OnMemoryUsageUpdated(bool create_result,
l10n_util::GetStringFUTF16(IDS_ASH_MEMORY_USAGE_IN_LAUNCHER_DESCRIPTION,
available_memory_gb, total_memory_gb);
std::u16string accessibility_label_details = l10n_util::GetStringFUTF16(
IDS_ASH_MEMORY_USAGE_IN_LAUNCHER_ACCESSIBILITY_LABEL, available_memory_gb,
total_memory_gb);
if (create_result) {
AnswerCardInfo answer_card_info(memory_usage_percentage);
// The bar chart will turn red if there is less than 10% of memory free.
@ -216,8 +218,9 @@ void SystemInfoCardProvider::OnMemoryUsageUpdated(bool create_result,
profile_, last_query_, /*url_path=*/base::EmptyString(),
diagnostics_icon_, relevance_,
/*title=*/base::EmptyString16(), description,
accessibility_label_details,
SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics,
answer_card_info,
SystemInfoAnswerResult::SystemInfoCardType::kMemory, answer_card_info,
base::BindRepeating(&SystemInfoCardProvider::UpdateMemoryUsage,
weak_factory_.GetWeakPtr()),
std::move(memory_timer_), this));
@ -225,7 +228,8 @@ void SystemInfoCardProvider::OnMemoryUsageUpdated(bool create_result,
memory_timer_ = std::make_unique<base::RepeatingTimer>();
} else {
for (auto& observer : memory_observers_) {
observer.OnMemoryUpdated(memory_usage_percentage, description);
observer.OnMemoryUpdated(memory_usage_percentage, description,
accessibility_label_details);
}
}
}
@ -280,17 +284,21 @@ void SystemInfoCardProvider::OnCpuUsageUpdated(bool create_result,
PopulateAverageScaledClockSpeed(*cpu_info, *new_cpu_usage.get());
previous_cpu_usage_data_ = new_cpu_usage_data;
std::u16string cpu_temp =
base::NumberToString16(new_cpu_usage->GetAverageCpuTempCelsius());
// Provide the frequency in GHz and round the value to 2 decimal places.
std::u16string cpu_speed = base::NumberToString16(
static_cast<double>(
new_cpu_usage->GetScalingAverageCurrentFrequencyKhz() / 10000) /
100);
std::u16string title =
l10n_util::GetStringFUTF16(IDS_ASH_CPU_IN_LAUNCHER_TITLE,
new_cpu_usage->GetPercentUsageTotalString());
std::u16string description = l10n_util::GetStringFUTF16(
IDS_ASH_CPU_IN_LAUNCHER_DESCRIPTION,
base::NumberToString16(new_cpu_usage->GetAverageCpuTempCelsius()),
// Provide the frequency in GHz and round the value to 2 decimal places.
base::NumberToString16(
static_cast<double>(
new_cpu_usage->GetScalingAverageCurrentFrequencyKhz() / 10000) /
100));
IDS_ASH_CPU_IN_LAUNCHER_DESCRIPTION, cpu_temp, cpu_speed);
std::u16string accessibility_label_details = l10n_util::GetStringFUTF16(
IDS_ASH_CPU_IN_LAUNCHER_ACCESSIBILITY_LABEL,
new_cpu_usage->GetPercentUsageTotalString(), cpu_temp, cpu_speed);
if (create_result) {
AnswerCardInfo answer_card_info(
@ -300,8 +308,9 @@ void SystemInfoCardProvider::OnCpuUsageUpdated(bool create_result,
new_results.emplace_back(std::make_unique<CpuAnswerResult>(
profile_, last_query_, /*url_path=*/base::EmptyString(),
diagnostics_icon_, relevance_, title, description,
accessibility_label_details,
SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics,
answer_card_info,
SystemInfoAnswerResult::SystemInfoCardType::kCPU, answer_card_info,
base::BindRepeating(&SystemInfoCardProvider::UpdateCpuUsage,
weak_factory_.GetWeakPtr()),
std::move(cpu_usage_timer_), this));
@ -309,7 +318,8 @@ void SystemInfoCardProvider::OnCpuUsageUpdated(bool create_result,
cpu_usage_timer_ = std::make_unique<base::RepeatingTimer>();
} else {
for (auto& observer : cpu_observers_) {
observer.OnCpuDataUpdated(title, description);
observer.OnCpuDataUpdated(title, description,
accessibility_label_details);
}
}
}
@ -364,6 +374,16 @@ void SystemInfoCardProvider::OnBatteryInfoUpdated(
base::NumberToString16(new_battery_health->GetBatteryWearPercentage()),
base::NumberToString16(new_battery_health->GetCycleCount()));
std::u16string accessibility_extra_details = l10n_util::GetStringFUTF16(
IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_EXTRA_DETAILS_ACCESSIBILITY_LABEL,
base::NumberToString16(new_battery_health->GetBatteryWearPercentage()),
base::NumberToString16(new_battery_health->GetCycleCount()));
std::u16string accessibility_label_details =
base::JoinString({new_battery_health->GetAccessibilityLabel(),
accessibility_extra_details},
u". ");
AnswerCardInfo answer_card_info(new_battery_health->GetBatteryPercentage());
// The bar chart will turn red if there is less than 20 of battery
// charge left.
@ -374,8 +394,9 @@ void SystemInfoCardProvider::OnBatteryInfoUpdated(
profile_, last_query_, /*url_path=*/base::EmptyString(),
diagnostics_icon_, relevance_,
/*title=*/base::EmptyString16(), new_battery_health->GetPowerTime(),
accessibility_label_details,
SystemInfoAnswerResult::SystemInfoCategory::kDiagnostics,
answer_card_info));
SystemInfoAnswerResult::SystemInfoCardType::kBattery, answer_card_info));
SwapResults(&new_results);
battery_health_ = std::move(new_battery_health);
@ -389,22 +410,26 @@ void SystemInfoCardProvider::UpdateChromeOsVersion() {
: IDS_VERSION_UI_UNOFFICIAL);
std::u16string processor_variation = l10n_util::GetStringUTF16(
sizeof(void*) == 8 ? IDS_VERSION_UI_64BIT : IDS_VERSION_UI_32BIT);
std::u16string channel_name = base::UTF8ToUTF16(
chrome::GetChannelName(chrome::WithExtendedStable(true)));
std::u16string version_string = l10n_util::GetStringFUTF16(
IDS_ASH_VERSION_IN_LAUNCHER_MESSAGE, version, is_official,
base::UTF8ToUTF16(
chrome::GetChannelName(chrome::WithExtendedStable(true))),
IDS_ASH_VERSION_IN_LAUNCHER_MESSAGE, version, is_official, channel_name,
processor_variation);
std::u16string description =
l10n_util::GetStringUTF16(IDS_ASH_VERSION_IN_LAUNCHER_DESCRIPTION);
std::u16string accessibility_label_details = l10n_util::GetStringFUTF16(
IDS_ASH_VERSION_IN_LAUNCHER_ACCESSIBILITY_LABEL, version, is_official,
channel_name, processor_variation);
AnswerCardInfo answer_card_info(
ash::SystemInfoAnswerCardDisplayType::kTextCard);
SearchProvider::Results new_results;
new_results.emplace_back(std::make_unique<SystemInfoAnswerResult>(
profile_, last_query_, kAboutChromeOsSectionPath, os_settings_icon_,
relevance_, version_string, description,
SystemInfoAnswerResult::SystemInfoCategory::kSettings, answer_card_info));
relevance_, version_string, description, accessibility_label_details,
SystemInfoAnswerResult::SystemInfoCategory::kSettings,
SystemInfoAnswerResult::SystemInfoCardType::kVersion, answer_card_info));
SwapResults(&new_results);
}
@ -495,12 +520,17 @@ void SystemInfoCardProvider::CreateStorageAnswerCard() {
std::u16string description = l10n_util::GetStringFUTF16(
IDS_ASH_STORAGE_STATUS_IN_LAUNCHER_DESCRIPTION, in_use_size, total_size);
std::u16string accessibility_label_details = l10n_util::GetStringFUTF16(
IDS_ASH_STORAGE_STATUS_IN_LAUNCHER_ACCESSIBILITY_LABEL, in_use_size,
total_size);
AnswerCardInfo answer_card_info(in_use_bytes * 100 / total_bytes);
SearchProvider::Results new_results;
new_results.emplace_back(std::make_unique<SystemInfoAnswerResult>(
profile_, last_query_, kStorageSubpagePath, os_settings_icon_, relevance_,
/*title=*/base::EmptyString16(), description,
SystemInfoAnswerResult::SystemInfoCategory::kSettings, answer_card_info));
/*title=*/base::EmptyString16(), description, accessibility_label_details,
SystemInfoAnswerResult::SystemInfoCategory::kSettings,
SystemInfoAnswerResult::SystemInfoCardType::kStorage, answer_card_info));
SwapResults(&new_results);
}

@ -42,8 +42,10 @@ class SystemInfoCardProvider : public SearchProvider,
// cpu usage of the device.
class CpuDataObserver : public base::CheckedObserver {
public:
virtual void OnCpuDataUpdated(const std::u16string& title,
const std::u16string& description) = 0;
virtual void OnCpuDataUpdated(
const std::u16string& title,
const std::u16string& description,
const std::u16string& accessibility_label) = 0;
};
// Implemented by clients that wish to be updated periodically about the
@ -51,7 +53,8 @@ class SystemInfoCardProvider : public SearchProvider,
class MemoryObserver : public base::CheckedObserver {
public:
virtual void OnMemoryUpdated(const double memory_usage_percentage,
const std::u16string& description) = 0;
const std::u16string& description,
const std::u16string& accessibility_label) = 0;
};
explicit SystemInfoCardProvider(Profile* profile);

@ -12,7 +12,6 @@
#include "base/metrics/histogram_functions.h"
#include "base/time/time.h"
#include "chrome/browser/ash/app_list/search/system_info/cpu_usage_data.h"
#include "chrome/grit/generated_resources.h"
#include "chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_probe.mojom.h"
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "ui/base/l10n/l10n_util.h"
@ -231,13 +230,14 @@ std::u16string GetBatteryTimeText(base::TimeDelta time_left) {
time_left);
}
std::u16string CalculatePowerTime(
const power_manager::PowerSupplyProperties& proto) {
void PopulatePowerStatus(const power_manager::PowerSupplyProperties& proto,
BatteryHealth& battery_health) {
bool charging = proto.battery_state() ==
power_manager::PowerSupplyProperties_BatteryState_CHARGING;
bool calculating = proto.is_calculating_battery_time();
int percent =
ash::power_utils::GetRoundedBatteryPercent(proto.battery_percent());
DCHECK(percent <= 100 && percent >= 0);
base::TimeDelta time_left;
bool show_time = false;
@ -248,25 +248,28 @@ std::u16string CalculatePowerTime(
}
std::u16string status_text;
std::u16string accessibility_string;
if (show_time) {
status_text = l10n_util::GetStringFUTF16(
charging ? IDS_ASH_BATTERY_STATUS_CHARGING_IN_LAUNCHER_DESCRIPTION_LEFT
: IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_DESCRIPTION_LEFT,
base::NumberToString16(percent), GetBatteryTimeText(time_left));
accessibility_string = l10n_util::GetStringFUTF16(
charging
? IDS_ASH_BATTERY_STATUS_CHARGING_IN_LAUNCHER_ACCESSIBILITY_LABEL
: IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_ACCESSIBILITY_LABEL,
base::NumberToString16(percent), GetBatteryTimeText(time_left));
} else {
status_text = l10n_util::GetStringFUTF16(
IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_DESCRIPTION_LEFT_SHORT,
base::NumberToString16(percent));
accessibility_string = l10n_util::GetStringFUTF16(
IDS_ASH_BATTERY_STATUS_IN_LAUNCHER_ACCESSIBILITY_LABEL_SHORT,
base::NumberToString16(percent));
}
return status_text;
}
void PopulatePowerStatus(const power_manager::PowerSupplyProperties& proto,
BatteryHealth& battery_health) {
int percent =
ash::power_utils::GetRoundedBatteryPercent(proto.battery_percent());
battery_health.SetPowerTime(CalculatePowerTime(proto));
battery_health.SetPowerTime(status_text);
battery_health.SetAccessibilityLabel(accessibility_string);
battery_health.SetBatteryPercentage(percent);
}

@ -67,9 +67,6 @@ void PopulateBatteryHealth(
const ash::cros_healthd::mojom::BatteryInfo& battery_info,
BatteryHealth& battery_health);
std::u16string CalculatePowerTime(
const power_manager::PowerSupplyProperties& proto);
void PopulatePowerStatus(
const power_manager::PowerSupplyProperties& power_supply_properties,
BatteryHealth& battery_health);