summaryrefslogtreecommitdiff
path: root/src/device.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-11-03 17:26:30 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-11-09 14:45:51 -0800
commit37be50d6793eaf6cfbc72b7dd69e3d57b468db2c (patch)
tree9f346b3023b37e67ab3b8ef7b458d643d24fd4c9 /src/device.c
parent20adf23209c8848fe60742eeedcb714bf92eec2e (diff)
downloadbluez-37be50d6793eaf6cfbc72b7dd69e3d57b468db2c.tar.gz
adapter: Set Device Privacy Mode
This adds support for setting Device Privacy flag when enabled in main.conf via Privacy = device,limited-device.
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c58
1 files changed, 43 insertions, 15 deletions
diff --git a/src/device.c b/src/device.c
index 1b4dae685..6b398bd39 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1403,9 +1403,45 @@ void device_set_wake_override(struct btd_device *device, bool wake_override)
}
}
+static void device_set_wake_allowed_complete(struct btd_device *device)
+{
+ if (device->wake_id != -1U) {
+ g_dbus_pending_property_success(device->wake_id);
+ device->wake_id = -1U;
+ }
+
+ device->wake_allowed = device->pending_wake_allowed;
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE, "WakeAllowed");
+
+ store_device_info(device);
+}
+
+static void set_wake_allowed_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ const struct mgmt_rp_set_device_flags *rp = param;
+ struct btd_device *dev = user_data;
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ error("Set device flags return status: %s",
+ mgmt_errstr(status));
+ return;
+ }
+
+ if (length < sizeof(*rp)) {
+ error("Too small Set Device Flags complete event: %d", length);
+ return;
+ }
+
+ device_set_wake_allowed_complete(dev);
+}
+
void device_set_wake_allowed(struct btd_device *device, bool wake_allowed,
GDBusPendingPropertySet id)
{
+ uint32_t flags;
+
/* Pending and current value are the same unless there is a change in
* progress. Only update wake allowed if pending value doesn't match the
* new value.
@@ -1415,25 +1451,17 @@ void device_set_wake_allowed(struct btd_device *device, bool wake_allowed,
device->wake_id = id;
device->pending_wake_allowed = wake_allowed;
- adapter_set_device_wakeable(device_get_adapter(device), device,
- wake_allowed);
-}
-void device_set_wake_allowed_complete(struct btd_device *device)
-{
- if (device->wake_id != -1U) {
- g_dbus_pending_property_success(device->wake_id);
- device->wake_id = -1U;
- }
-
- device->wake_allowed = device->pending_wake_allowed;
- g_dbus_emit_property_changed(dbus_conn, device->path,
- DEVICE_INTERFACE, "WakeAllowed");
+ flags = device->current_flags;
+ if (wake_allowed)
+ flags |= DEVICE_FLAG_REMOTE_WAKEUP;
+ else
+ flags &= ~DEVICE_FLAG_REMOTE_WAKEUP;
- store_device_info(device);
+ adapter_set_device_flags(device->adapter, device, flags,
+ set_wake_allowed_complete, device);
}
-
static gboolean
dev_property_get_wake_allowed(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)