Commit 7e5c9d46 authored by Yue Li's avatar Yue Li Committed by Commit Bot

Check board type instead of keyboard layout for Assistant availability

Currently we check if the keyboard has the 'Assistant' key to enable
Assistant. It seems some external wireless keyboards report they do
have the 'Assistant' key.

Since the reason we were checking the keyboard is for nocturne, we
decide to only special case board 'eve', 'nocturne' and 'atlas' instead
of doing the keyboard layout check.

For more background, see discussion in crbug/1025961

Bug: 1025961
Test: Manual Test
Change-Id: Iacb42a6b8bfc01b662002f0d93258642b6976ca0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1978838
Commit-Queue: Yue Li <updowndota@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727002}
parent e9d813b8
......@@ -12,6 +12,7 @@
namespace {
constexpr char kAtlasBoardType[] = "atlas";
constexpr char kEveBoardType[] = "eve";
constexpr char kNocturneBoardType[] = "nocturne";
......@@ -83,6 +84,7 @@ bool ShouldAttemptWarmerWelcome(AssistantEntryPoint entry_point) {
bool IsGoogleDevice() {
const std::string board_name = base::SysInfo::GetLsbReleaseBoard();
return g_override_is_google_device ||
IsBoardType(board_name, kAtlasBoardType) ||
IsBoardType(board_name, kEveBoardType) ||
IsBoardType(board_name, kNocturneBoardType);
}
......
......@@ -24,6 +24,35 @@
#include "third_party/icu/source/common/unicode/locid.h"
#include "ui/chromeos/events/keyboard_layout_util.h"
namespace {
constexpr char kAtlasBoardType[] = "atlas";
constexpr char kEveBoardType[] = "eve";
constexpr char kNocturneBoardType[] = "nocturne";
bool IsBoardType(const std::string& board_name, const std::string& board_type) {
// The sub-types of the board will have the form boardtype-XXX.
// To prevent the possibility of common prefix in board names we check the
// board type with '-' here. For example there might be two board types with
// codename boardtype1 and boardtype123.
return board_name == board_type ||
base::StartsWith(board_name, board_type + '-',
base::CompareCase::SENSITIVE);
}
// TODO(updowndota): Merge this method with the IsGoogleDevice method in
// ash::assistant::util, probably move to ash::public:cpp.
//
// Returns whether the device has a dedicated Assistant key.
bool IsAssistantDevice() {
const std::string board_name = base::SysInfo::GetLsbReleaseBoard();
return IsBoardType(board_name, kAtlasBoardType) ||
IsBoardType(board_name, kEveBoardType) ||
IsBoardType(board_name, kNocturneBoardType);
}
} // namespace
namespace assistant {
ash::mojom::AssistantAllowedState IsAssistantAllowedForProfile(
......@@ -96,12 +125,8 @@ ash::mojom::AssistantAllowedState IsAssistantAllowedForProfile(
return ash::mojom::AssistantAllowedState::DISALLOWED_BY_POLICY;
// Bypass the account type check when using fake gaia login, e.g. in Tast
// tests, or the account is logged in a device with a physical Assistant key
// on keyboard.
if (!chromeos::switches::IsGaiaServicesDisabled() &&
!(ui::DeviceKeyboardHasAssistantKey() ||
base::EqualsCaseInsensitiveASCII(base::SysInfo::GetLsbReleaseBoard(),
"nocturne"))) {
// tests, or the account is logged in a device with dedicated Assistant key.
if (!chromeos::switches::IsGaiaServicesDisabled() && !(IsAssistantDevice())) {
// Only enable non-dasher accounts for devices without physical key.
bool account_supported = false;
auto* identity_manager =
......
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