forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ash: keyboard: Virtual Keyboard Listnr Logging
Add Listnr Logging to the Virtual Keyboard in order to collate device information used to determine whether the virtual keyboard is displayed or not. Bug: b:217559869 Change-Id: Ie5f9e9970874c205efb196df2aae96ff8cf6ceb8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3544926 Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org> Commit-Queue: William Mahon <wmahon@google.com> Reviewed-by: Darren Shen <shend@chromium.org> Cr-Commit-Position: refs/heads/main@{#1019462}
- Loading branch information
William Mahon
authored and
Chromium LUCI CQ
committed
Jun 30, 2022
1 parent
771c884
commit eecd251
Showing
6 changed files
with
219 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
chrome/browser/ash/system_logs/virtual_keyboard_log_source.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ash/system_logs/virtual_keyboard_log_source.h" | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <utility> | ||
|
||
#include "ash/keyboard/keyboard_controller_impl.h" | ||
#include "ash/keyboard/ui/keyboard_ui_controller.h" | ||
#include "ash/keyboard/virtual_keyboard_controller.h" | ||
#include "ash/public/cpp/keyboard/keyboard_types.h" | ||
#include "ash/shell.h" | ||
#include "base/strings/strcat.h" | ||
#include "base/strings/string_number_conversions.h" | ||
|
||
namespace system_logs { | ||
|
||
namespace { | ||
|
||
std::string LogEntryForBooleanField(const std::string& field_name, bool value) { | ||
return base::StrCat({field_name, ": ", base::NumberToString(value), "\n"}); | ||
} | ||
|
||
} // namespace | ||
|
||
VirtualKeyboardLogSource::VirtualKeyboardLogSource() | ||
: SystemLogsSource("VirtualKeyboard") {} | ||
|
||
void VirtualKeyboardLogSource::Fetch(SysLogsSourceCallback callback) { | ||
DCHECK(!callback.is_null()); | ||
|
||
auto response = std::make_unique<SystemLogsResponse>(); | ||
|
||
keyboard::KeyboardUIController* keyboard_ui_controller = | ||
keyboard::KeyboardUIController::Get(); | ||
ash::VirtualKeyboardController* virtual_keyboard_controller = | ||
ash::Shell::Get()->keyboard_controller()->virtual_keyboard_controller(); | ||
|
||
std::string log_data; | ||
|
||
int touchscreen_count = 1; | ||
for (const ui::InputDevice& device : | ||
virtual_keyboard_controller->GetTouchscreens()) { | ||
const std::string touchscreen_count_converted = | ||
base::NumberToString(touchscreen_count); | ||
log_data += base::StrCat({"Touchscreen ", touchscreen_count_converted, | ||
" Product ID"}) + | ||
": " + base::NumberToString(device.product_id) + "\n"; | ||
log_data += base::StrCat({"Touchscreen ", touchscreen_count_converted, | ||
" Vendor ID"}) + | ||
": " + base::NumberToString(device.vendor_id) + "\n"; | ||
++touchscreen_count; | ||
} | ||
|
||
log_data += | ||
"Has Internal Keyboard: " + | ||
base::NumberToString(virtual_keyboard_controller->HasInternalKeyboard()) + | ||
"\n"; | ||
log_data += "Is Internal Keyboard Ignored: " + | ||
base::NumberToString( | ||
virtual_keyboard_controller->IsInternalKeyboardIgnored()) + | ||
"\n"; | ||
|
||
int external_keyboard_count = 1; | ||
for (const ui::InputDevice& device : | ||
virtual_keyboard_controller->GetExternalKeyboards()) { | ||
const std::string external_keyboard_count_converted = | ||
base::NumberToString(external_keyboard_count); | ||
log_data += | ||
base::StrCat({"External Keyboard ", external_keyboard_count_converted, | ||
" Product ID"}) + | ||
": " + base::NumberToString(device.product_id) + "\n"; | ||
log_data += | ||
base::StrCat({"External Keyboard ", external_keyboard_count_converted, | ||
" Vendor ID"}) + | ||
": " + base::NumberToString(device.vendor_id) + "\n"; | ||
++external_keyboard_count; | ||
} | ||
|
||
log_data += LogEntryForBooleanField( | ||
"Is External Keyboard Ignored: ", | ||
virtual_keyboard_controller->IsExternalKeyboardIgnored()); | ||
log_data += LogEntryForBooleanField( | ||
"kPolicyEnabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kPolicyEnabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kPolicyDisabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kPolicyDisabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kAndroidDisabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kAndroidDisabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kExtensionEnabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kExtensionEnabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kExtensionDisabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kExtensionDisabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kAccessibilityEnabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kAccessibilityEnabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kShelfEnabled Flag: ", keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kShelfEnabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kTouchEnabled Flag: ", keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kTouchEnabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kCommandLineEnabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kCommandLineEnabled)); | ||
log_data += LogEntryForBooleanField( | ||
"kCommandLineDisabled Flag: ", | ||
keyboard_ui_controller->IsEnableFlagSet( | ||
keyboard::KeyboardEnableFlag::kCommandLineDisabled)); | ||
response->emplace("virtual_keyboard", log_data); | ||
|
||
std::move(callback).Run(std::move(response)); | ||
} | ||
|
||
} // namespace system_logs |
27 changes: 27 additions & 0 deletions
27
chrome/browser/ash/system_logs/virtual_keyboard_log_source.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_ASH_SYSTEM_LOGS_VIRTUAL_KEYBOARD_LOG_SOURCE_H_ | ||
#define CHROME_BROWSER_ASH_SYSTEM_LOGS_VIRTUAL_KEYBOARD_LOG_SOURCE_H_ | ||
|
||
#include "components/feedback/system_logs/system_logs_source.h" | ||
|
||
namespace system_logs { | ||
|
||
class VirtualKeyboardLogSource : public SystemLogsSource { | ||
public: | ||
VirtualKeyboardLogSource(); | ||
~VirtualKeyboardLogSource() override = default; | ||
|
||
VirtualKeyboardLogSource(const VirtualKeyboardLogSource&) = delete; | ||
VirtualKeyboardLogSource& operator=(const VirtualKeyboardLogSource&) = delete; | ||
|
||
private: | ||
// Overridden from SystemLogsSource: | ||
void Fetch(SysLogsSourceCallback callback) override; | ||
}; | ||
|
||
} // namespace system_logs | ||
|
||
#endif // CHROME_BROWSER_ASH_SYSTEM_LOGS_VIRTUAL_KEYBOARD_LOG_SOURCE_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters