Commit 621cd9d9 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Commit Bot

device/bluetooth: Add bluetooth suspend notifier flag

ChromeOS BlueZ is adding better support for system suspend and it can be
enabled by setting the UseKernelSuspendNotifier property. Add a
BluetoothKernelSuspendNotifier feature flag, expose it in chrome://flags
and use it in device/bluetooth to enable or disable the feature when the
adapter becomes available.

BUG=b:147884615
TEST=Built for Sarien, deploy_chrome to physical device, toggled flag in
     guest mode while running dbus-monitor to confirm property changes.
R=hansberry,mcchou

Change-Id: I6cdc874e2adaa7fb59435d1768fb29bffe4e424a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2029258Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Commit-Queue: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742908}
parent b43063eb
......@@ -1858,6 +1858,10 @@ const FeatureEntry kFeatureEntries[] = {
kOsCrOS,
FEATURE_VALUE_TYPE(
chromeos::features::kBluetoothAggressiveAppearanceFilter)},
{"bluetooth-kernel-suspend-notifier",
flag_descriptions::kBluetoothKernelSuspendNotifierName,
flag_descriptions::kBluetoothKernelSuspendNotifierDescription, kOsCrOS,
FEATURE_VALUE_TYPE(chromeos::features::kBluetoothKernelSuspendNotifier)},
{"cryptauth-v2-device-activity-status",
flag_descriptions::kCryptAuthV2DeviceActivityStatusName,
flag_descriptions::kCryptAuthV2DeviceActivityStatusDescription, kOsCrOS,
......
......@@ -370,6 +370,11 @@
"owners": [ "hansberry", "cros-system-services@google.com" ],
"expiry_milestone": 85
},
{
"name": "bluetooth-kernel-suspend-notifier",
"owners": [ "abhishekpandit", "chromeos-bluetooth@google.com" ],
"expiry_milestone": 83
},
{
"name": "BundledConnectionHelp",
"owners": [ "carlosil" ],
......
......@@ -3093,6 +3093,12 @@ const char kBluetoothAggressiveAppearanceFilterDescription[] =
"Enables a more aggressive Bluetooth filter in the UI to hide devices that "
"likely cannot be connected to.";
const char kBluetoothKernelSuspendNotifierName[] =
"Bluetooth kernel suspend notifier handler";
const char kBluetoothKernelSuspendNotifierDescription[] =
"Enables the Bluetooth kernel suspend notifier which will allow wake from "
"suspend using Bluetooth HID devices.";
const char kCameraSystemWebAppName[] = "Camera System Web App";
const char kCameraSystemWebAppDescription[] =
"Run the Chrome Camera App as a System Web App.";
......
......@@ -1782,6 +1782,9 @@ extern const char kAshSwipingFromLeftEdgeToGoBackDescription[];
extern const char kBluetoothAggressiveAppearanceFilterName[];
extern const char kBluetoothAggressiveAppearanceFilterDescription[];
extern const char kBluetoothKernelSuspendNotifierName[];
extern const char kBluetoothKernelSuspendNotifierDescription[];
extern const char kCameraSystemWebAppName[];
extern const char kCameraSystemWebAppDescription[];
......
......@@ -42,6 +42,10 @@ const base::Feature kBluetoothAggressiveAppearanceFilter{
const base::Feature kBluetoothPhoneFilter{"BluetoothPhoneFilter",
base::FEATURE_ENABLED_BY_DEFAULT};
// Enables or disables using the kernel suspend notifier instead of powerd.
const base::Feature kBluetoothKernelSuspendNotifier{
"BluetoothKernelSuspendNotifier", base::FEATURE_DISABLED_BY_DEFAULT};
// Feature containing param to block provided long term keys.
const base::Feature kBlueZLongTermKeyBlocklist{
"BlueZLongTermKeyBlocklist", base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -28,6 +28,8 @@ extern const base::Feature kBluetoothAggressiveAppearanceFilter;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kBluetoothPhoneFilter;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kBluetoothKernelSuspendNotifier;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const base::Feature kBlueZLongTermKeyBlocklist;
COMPONENT_EXPORT(CHROMEOS_CONSTANTS)
extern const char kBlueZLongTermKeyBlocklistParamName[];
......
......@@ -15,6 +15,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback_helpers.h"
#include "base/feature_list.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
......@@ -25,6 +26,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
#include "device/base/features.h"
#include "device/bluetooth/bluetooth_common.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_discovery_session_outcome.h"
......@@ -50,6 +52,7 @@
#include "third_party/cros_system_api/dbus/service_constants.h"
#if defined(OS_CHROMEOS)
#include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/devicetype.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/chromeos/bluetooth_utils.h"
......@@ -1059,6 +1062,10 @@ void BluetoothAdapterBlueZ::SetAdapter(const dbus::ObjectPath& object_path) {
if (properties->discovering.value())
DiscoveringChanged(true);
#if defined(OS_CHROMEOS)
SetChromeOSKernelSuspendNotifier(properties);
#endif
std::vector<dbus::ObjectPath> device_paths =
bluez::BluezDBusManager::Get()
->GetBluetoothDeviceClient()
......@@ -1098,6 +1105,25 @@ void BluetoothAdapterBlueZ::SetStandardChromeOSAdapterName() {
base::PersistentHash(address) & 0xFFFF);
SetName(alias, base::DoNothing(), base::DoNothing());
}
// If the property is available, set the value according to the feature flag.
void BluetoothAdapterBlueZ::SetChromeOSKernelSuspendNotifier(
bluez::BluetoothAdapterClient::Properties* properties) {
if (!properties->use_kernel_suspend_notifier.is_valid())
return;
bool use_notifier = base::FeatureList::IsEnabled(
chromeos::features::kBluetoothKernelSuspendNotifier);
base::OnceCallback<void(bool)> cb = base::BindOnce(
[](bool value, bool success) {
if (!success) {
BLUETOOTH_LOG(ERROR) << "Failed to set suspend notifier to " << value;
}
},
use_notifier);
properties->use_kernel_suspend_notifier.Set(use_notifier, std::move(cb));
}
#endif
void BluetoothAdapterBlueZ::RemoveAdapter() {
......
......@@ -351,6 +351,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterBlueZ final
#if defined(OS_CHROMEOS)
// Set the adapter name to one chosen from the system information.
void SetStandardChromeOSAdapterName();
// Set the kernel suspend notifier property based off value of chrome://flags.
void SetChromeOSKernelSuspendNotifier(
bluez::BluetoothAdapterClient::Properties* properties);
#endif
// Remove the currently tracked adapter. IsPresent() will return false after
......
......@@ -182,6 +182,8 @@ BluetoothAdapterClient::Properties::Properties(
RegisterProperty(bluetooth_adapter::kDiscoveringProperty, &discovering);
RegisterProperty(bluetooth_adapter::kUUIDsProperty, &uuids);
RegisterProperty(bluetooth_adapter::kModaliasProperty, &modalias);
RegisterProperty(bluetooth_adapter::kUseSuspendNotifierProperty,
&use_kernel_suspend_notifier);
}
BluetoothAdapterClient::Properties::~Properties() = default;
......
......@@ -106,6 +106,10 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterClient : public BluezDBusClient {
// Local Device ID information in Linux kernel modalias format. Read-only.
dbus::Property<std::string> modalias;
// Flag to enable usage of kernel suspend notifier.
// TODO(b/149795111): Remove once feature is default behavior in stable.
dbus::Property<bool> use_kernel_suspend_notifier;
Properties(dbus::ObjectProxy* object_proxy,
const std::string& interface_name,
const PropertyChangedCallback& callback);
......
......@@ -37081,6 +37081,7 @@ from previous Chrome versions.
<int value="-1939003674" label="NetworkServiceInProcess:disabled"/>
<int value="-1938263248" label="enable-extension-info-dialog"/>
<int value="-1937077699" label="http-form-warning"/>
<int value="-1936630125" label="BluetoothKernelSuspendNotifier:enabled"/>
<int value="-1936032607" label="enable-experimental-webassembly-features"/>
<int value="-1934661084" label="ForceUnifiedConsentBump:disabled"/>
<int value="-1933425042" label="OfflinePreviews:enabled"/>
......@@ -37452,6 +37453,7 @@ from previous Chrome versions.
<int value="-1472825316" label="ContextualSearchLongpressResolve:enabled"/>
<int value="-1471021059"
label="OmniboxUIExperimentShowSuggestionFavicons:disabled"/>
<int value="-1470178735" label="BluetoothKernelSuspendNotifier:disabled"/>
<int value="-1469536698" label="ChromeHomeDoodle:enabled"/>
<int value="-1469228683" label="QuickUnlockPinSignin:disabled"/>
<int value="-1468126425" label="ResourceLoadScheduler:disabled"/>
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