Commit 1f63c152 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Read side volume button position from commandline.

For boards that don't support unibuild, the side volume button location
info is written into the local file
/usr/share/chromeos-assets/side-volume-button/location.json.
For boards that support unibuild now, the side volume button location
info is in the chrome flag "ash-side-volume-button-position".

This cl goes to read the location info from the flag. After all the
boards support unibuild in the future, the logic that read the location
info from local file can be removed.

Bug: 937907
Change-Id: I2138e3b0c32528767cec1efc746c8cdaa56775d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1638741
Commit-Queue: Min Chen <minch@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665317}
parent 68c9d55f
......@@ -32,6 +32,7 @@
#include "ash/metrics/user_metrics_recorder.h"
#include "ash/multi_profile_uma.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/new_window_delegate.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/interfaces/accessibility_controller.mojom.h"
......@@ -69,6 +70,7 @@
#include "ash/wm/window_util.h"
#include "ash/wm/wm_event.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
......@@ -1941,19 +1943,26 @@ void AcceleratorControllerImpl::MaybeShowConfirmationDialog(
}
void AcceleratorControllerImpl::ParseSideVolumeButtonLocationInfo() {
if (!base::PathExists(side_volume_button_location_file_path_))
return;
std::string location_info;
if (!base::ReadFileToString(side_volume_button_location_file_path_,
&location_info) ||
location_info.empty()) {
const base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kAshSideVolumeButtonPosition)) {
location_info =
cl->GetSwitchValueASCII(switches::kAshSideVolumeButtonPosition);
} else if (!base::PathExists(side_volume_button_location_file_path_) ||
!base::ReadFileToString(side_volume_button_location_file_path_,
&location_info) ||
location_info.empty()) {
return;
}
std::unique_ptr<base::DictionaryValue> info_in_dict =
base::DictionaryValue::From(
base::JSONReader::ReadDeprecated(location_info));
if (!info_in_dict) {
LOG(ERROR) << "JSONReader failed reading side volume button location info: "
<< location_info;
return;
}
info_in_dict->GetString(kVolumeButtonRegion,
&side_volume_button_location_.region);
info_in_dict->GetString(kVolumeButtonSide,
......
......@@ -90,6 +90,12 @@ const char kAshHideNotificationsForFactory[] =
// Enables the heads-up display for tracking touch points.
const char kAshTouchHud[] = "ash-touch-hud";
// The physical position info of the side volume button while in landscape
// primary screen orientation. The value is a JSON object containing a "region"
// property with the value "keyboard", "screen" and a "side" property with the
// value "left", "right", "top", "bottom".
const char kAshSideVolumeButtonPosition[] = "ash-side-volume-button-position";
// (Most) Chrome OS hardware reports ACPI power button releases correctly.
// Standard hardware reports releases immediately after presses. If set, we
// lock the screen or shutdown the system immediately in response to a press
......
......@@ -44,6 +44,7 @@ ASH_PUBLIC_EXPORT extern const char kAshShelfColorSchemeNormalMuted[];
ASH_PUBLIC_EXPORT extern const char kAshShelfColorSchemeNormalVibrant[];
ASH_PUBLIC_EXPORT extern const char kAshShelfColorSchemeDarkMuted[];
ASH_PUBLIC_EXPORT extern const char kAshShelfColorSchemeDarkVibrant[];
ASH_PUBLIC_EXPORT extern const char kAshSideVolumeButtonPosition[];
ASH_PUBLIC_EXPORT extern const char kAshTouchHud[];
ASH_PUBLIC_EXPORT extern const char kAuraLegacyPowerButton[];
ASH_PUBLIC_EXPORT extern const char kForceTabletPowerButton[];
......
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