public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Pacho Ramos" <pacho@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: net-wireless/bluez/, net-wireless/bluez/files/
Date: Sun, 11 Sep 2022 07:50:42 +0000 (UTC)	[thread overview]
Message-ID: <1662882630.c7e05832f00875182becdba543cfdfd4a62ed26a.pacho@gentoo> (raw)

commit:     c7e05832f00875182becdba543cfdfd4a62ed26a
Author:     Pacho Ramos <pacho <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 11 07:43:27 2022 +0000
Commit:     Pacho Ramos <pacho <AT> gentoo <DOT> org>
CommitDate: Sun Sep 11 07:50:30 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c7e05832

net-wireless/bluez: add 5.65

Thanks-to: Joakim Tjernlund
Closes: https://bugs.gentoo.org/866025
Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org>

 net-wireless/bluez/Manifest                        |   1 +
 net-wireless/bluez/bluez-5.65.ebuild               | 297 +++++++++
 ...et-pending-settings-when-receiving-MGMT-e.patch | 170 +++++
 .../bluez/files/power-state-adapter-property.patch | 723 +++++++++++++++++++++
 4 files changed, 1191 insertions(+)

diff --git a/net-wireless/bluez/Manifest b/net-wireless/bluez/Manifest
index 1f5ef5199e6c..1bf6ed310204 100644
--- a/net-wireless/bluez/Manifest
+++ b/net-wireless/bluez/Manifest
@@ -1 +1,2 @@
 DIST bluez-5.64.tar.xz 2175148 BLAKE2B 828c620330d1993d5c5c2a865f2d27a29425e3583aac01a1a782290a805ee0fd6456b6832c804ad323dd8714fa9329487b2616ed08f1f491ea29403ee05dba2d SHA512 f11f9974b29c5c6fce3890d7e42425c1cb02e42c1b8f49c5cc4b249234e67b64317d0e5e82721e2fbf1b53269c8569a9c869d59ce42b5e927f6622f0753e53cd
+DIST bluez-5.65.tar.xz 2208100 BLAKE2B 9d2937e2e14d8d8945183c6436921d9d16a6d3bcb5dbe3e2493554fbc4972bb4c006aabc793c9fb8eae47a7e9f29ae9fdf47551dfc0a238e86f5a76ce7436ae2 SHA512 c20c09a1a75053c77d73b3ce15ac7fd321eb6df5ca1646d57c6848b87c0c9957908bc17dd928da4ef2aacfc8667877cbc7511c1ba43db839bfa9bf1fb8269907

diff --git a/net-wireless/bluez/bluez-5.65.ebuild b/net-wireless/bluez/bluez-5.65.ebuild
new file mode 100644
index 000000000000..74ffae23b148
--- /dev/null
+++ b/net-wireless/bluez/bluez-5.65.ebuild
@@ -0,0 +1,297 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+PYTHON_COMPAT=( python3_{8..10} )
+
+inherit autotools linux-info python-single-r1 readme.gentoo-r1 systemd udev multilib-minimal
+
+DESCRIPTION="Bluetooth Tools and System Daemons for Linux"
+HOMEPAGE="http://www.bluez.org"
+SRC_URI="https://www.kernel.org/pub/linux/bluetooth/${P}.tar.xz"
+
+LICENSE="GPL-2+ LGPL-2.1+"
+SLOT="0/3"
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~riscv ~x86"
+IUSE="btpclient cups doc debug deprecated extra-tools experimental +mesh midi +obex +readline selinux systemd test test-programs +udev"
+
+# Since this release all remaining extra-tools need readline support, but this could
+# change in the future, hence, this REQUIRED_USE constraint could be dropped
+# again in the future.
+# btpclient needs mesh, bug #790587
+REQUIRED_USE="
+	btpclient? ( mesh )
+	extra-tools? ( deprecated readline )
+	test? ( ${PYTHON_REQUIRED_USE} )
+	test-programs? ( ${PYTHON_REQUIRED_USE} )
+"
+
+TEST_DEPS="${PYTHON_DEPS}
+	$(python_gen_cond_dep '
+		>=dev-python/dbus-python-1[${PYTHON_USEDEP}]
+		dev-python/pygobject:3[${PYTHON_USEDEP}]
+	')
+"
+BDEPEND="
+	dev-python/docutils
+	virtual/pkgconfig
+	test? ( ${TEST_DEPS} )
+"
+DEPEND="
+	>=dev-libs/glib-2.28:2[${MULTILIB_USEDEP}]
+	btpclient? ( >=dev-libs/ell-0.39 )
+	cups? ( net-print/cups:= )
+	mesh? (
+		>=dev-libs/ell-0.39
+		>=dev-libs/json-c-0.13:=
+		sys-libs/readline:0=
+	)
+	midi? ( media-libs/alsa-lib )
+	obex? ( dev-libs/libical:= )
+	readline? ( sys-libs/readline:0= )
+	systemd? ( sys-apps/systemd )
+	>=sys-apps/dbus-1.6:=
+	udev? ( >=virtual/udev-172 )
+"
+RDEPEND="${DEPEND}
+	selinux? ( sec-policy/selinux-bluetooth )
+	test-programs? ( ${TEST_DEPS} )
+"
+
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+	# Try both udevadm paths to cover udev/systemd vs. eudev locations (#539844)
+	# http://www.spinics.net/lists/linux-bluetooth/msg58739.html
+	# https://bugs.gentoo.org/539844
+	# https://github.com/bluez/bluez/issues/268
+	"${FILESDIR}"/${PN}-udevadm-path-r1.patch
+
+	# Fedora patches
+	# http://www.spinics.net/lists/linux-bluetooth/msg40136.html
+	"${FILESDIR}"/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
+
+	# Fixed in next release
+	"${FILESDIR}"/0001-adapter-Reset-pending-settings-when-receiving-MGMT-e.patch
+	"${FILESDIR}"/power-state-adapter-property.patch
+)
+
+pkg_setup() {
+	# From http://www.linuxfromscratch.org/blfs/view/svn/general/bluez.html
+	# to prevent bugs like:
+	# https://bugzilla.kernel.org/show_bug.cgi?id=196621
+	CONFIG_CHECK="~NET ~BT ~BT_RFCOMM ~BT_RFCOMM_TTY ~BT_BNEP ~BT_BNEP_MC_FILTER
+		~BT_BNEP_PROTO_FILTER ~BT_HIDP ~CRYPTO_USER_API_HASH ~CRYPTO_USER_API_SKCIPHER ~RFKILL"
+	# https://bugzilla.kernel.org/show_bug.cgi?id=196621
+	# https://bugzilla.kernel.org/show_bug.cgi?id=206815
+	if use mesh || use test; then
+		CONFIG_CHECK="${CONFIG_CHECK} ~CRYPTO_USER
+		~CRYPTO_USER_API ~CRYPTO_USER_API_AEAD ~CRYPTO_AES ~CRYPTO_CCM ~CRYPTO_AEAD ~CRYPTO_CMAC
+		~CRYPTO_MD5 ~CRYPTO_SHA1 ~KEY_DH_OPERATIONS"
+	fi
+	linux-info_pkg_setup
+
+	if use test || use test-programs; then
+		python-single-r1_pkg_setup
+	fi
+
+	if ! use udev; then
+		ewarn
+		ewarn "You are installing ${PN} with USE=-udev. This means various bluetooth"
+		ewarn "devices and adapters from Apple, Dell, Logitech etc. will not work,"
+		ewarn "and hid2hci will not be available."
+		ewarn
+	fi
+}
+
+src_prepare() {
+	default
+
+	# http://www.spinics.net/lists/linux-bluetooth/msg38490.html
+	if ! use systemd; then
+		eapply "${FILESDIR}"/0001-Allow-using-obexd-without-systemd-in-the-user-session-r2.patch
+	fi
+
+	eautoreconf
+
+	if use cups; then
+		# Only not .am to not need to run eautoreconf only because of this
+		sed -i \
+			-e "s:cupsdir = \$(libdir)/cups:cupsdir = $(cups-config --serverbin):" \
+			Makefile.{in,tools} || die
+	fi
+
+	multilib_copy_sources
+}
+
+multilib_src_configure() {
+	local myconf=(
+		# readline is automagic when client is enabled
+		# --enable-client always needs readline, bug #504038
+		# --enable-mesh is handled in the same way
+		ac_cv_header_readline_readline_h=$(multilib_native_usex readline)
+		ac_cv_header_readline_readline_h=$(multilib_native_usex mesh)
+	)
+
+	if ! multilib_is_native_abi; then
+		myconf+=(
+			# deps not used for the library
+			{DBUS,GLIB}_{CFLAGS,LIBS}=' '
+		)
+	fi
+
+	econf \
+		--localstatedir=/var \
+		--disable-android \
+		--enable-datafiles \
+		--enable-optimization \
+		$(use_enable debug) \
+		--enable-pie \
+		--enable-threads \
+		--enable-library \
+		--enable-tools \
+		--enable-manpages \
+		--enable-monitor \
+		--with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
+		--with-systemduserunitdir="$(systemd_get_userunitdir)" \
+		$(multilib_native_use_enable btpclient) \
+		$(multilib_native_use_enable btpclient external-ell) \
+		$(multilib_native_use_enable cups) \
+		$(multilib_native_use_enable deprecated) \
+		$(multilib_native_use_enable experimental) \
+		$(multilib_native_use_enable mesh) \
+		$(multilib_native_use_enable mesh external-ell) \
+		$(multilib_native_use_enable midi) \
+		$(multilib_native_use_enable obex) \
+		$(multilib_native_use_enable readline client) \
+		$(multilib_native_use_enable systemd) \
+		$(multilib_native_use_enable test-programs test) \
+		$(multilib_native_use_enable udev) \
+		$(multilib_native_use_enable udev hid2hci) \
+		$(multilib_native_use_enable udev sixaxis)
+}
+
+multilib_src_compile() {
+	if multilib_is_native_abi; then
+		default
+	else
+		emake -f Makefile -f - libs \
+			<<<'libs: $(lib_LTLIBRARIES)'
+	fi
+}
+
+multilib_src_test() {
+	multilib_is_native_abi && default
+}
+
+multilib_src_install() {
+	if multilib_is_native_abi; then
+		emake DESTDIR="${D}" install
+
+		# Only install extra-tools when relevant USE flag is enabled
+		if use extra-tools; then
+			ewarn "Upstream doesn't support using this tools and their bugs are"
+			ewarn "likely to be ignored forever, also they can break without"
+			ewarn "previous announcement."
+			ewarn "Upstream also states all this tools are not really needed,"
+			ewarn "then, if you still need to rely on them, you must ask them"
+			ewarn "to either install that tool by default or add the needed"
+			ewarn "functionality to the existing 'official' tools."
+			ewarn "Please report this issues to:"
+			ewarn "http://www.bluez.org/development/lists/"
+
+			# Upstream doesn't install this, bug #524640
+			# http://permalink.gmane.org/gmane.linux.bluez.kernel/53115
+			# http://comments.gmane.org/gmane.linux.bluez.kernel/54564
+			dobin tools/btmgmt
+			# gatttool is only built with readline, bug #530776
+			# https://bugzilla.redhat.com/show_bug.cgi?id=1141909
+			# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720486
+			# https://bugs.archlinux.org/task/37686
+			dobin attrib/gatttool
+			# https://bugzilla.redhat.com/show_bug.cgi?id=1699680
+			dobin tools/avinfo
+		fi
+
+		# Not installed by default after being built, bug #666756
+		use btpclient && dobin tools/btpclient
+
+		# Unittests are not that useful once installed, so make them optional
+		if use test-programs; then
+			# Drop python2 only test tools
+			# https://bugzilla.kernel.org/show_bug.cgi?id=206819
+			rm "${ED}"/usr/$(get_libdir)/bluez/test/simple-player || die
+			# https://bugzilla.kernel.org/show_bug.cgi?id=206821
+			rm "${ED}"/usr/$(get_libdir)/bluez/test/test-hfp || die
+			# https://bugzilla.kernel.org/show_bug.cgi?id=206823
+			rm "${ED}"/usr/$(get_libdir)/bluez/test/test-sap-server	|| die
+
+			python_fix_shebang "${ED}"/usr/$(get_libdir)/bluez/test
+
+			for i in $(find "${ED}"/usr/$(get_libdir)/bluez/test -maxdepth 1 -type f ! -name "*.*"); do
+				dosym "${i}" /usr/bin/bluez-"${i##*/}"
+			done
+		fi
+	else
+		emake DESTDIR="${D}" \
+			install-pkgincludeHEADERS \
+			install-libLTLIBRARIES \
+			install-pkgconfigDATA
+	fi
+}
+
+multilib_src_install_all() {
+	# We need to ensure obexd can be spawned automatically by systemd
+	# when user-session is enabled:
+	# http://marc.info/?l=linux-bluetooth&m=148096094716386&w=2
+	# https://bugs.gentoo.org/show_bug.cgi?id=577842
+	# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804908
+	# https://bugs.archlinux.org/task/45816
+	# https://bugzilla.redhat.com/show_bug.cgi?id=1318441
+	# https://bugzilla.redhat.com/show_bug.cgi?id=1389347
+	if use systemd; then
+		dosym obex.service /usr/lib/systemd/user/dbus-org.bluez.obex.service
+	fi
+
+	find "${D}" -name '*.la' -type f -delete || die
+
+	keepdir /var/lib/bluetooth
+
+	# Upstream don't want people to play with them
+	# But we keep installing them due to 'historical' reasons
+	insinto /etc/bluetooth
+	local d
+	for d in input network; do
+		doins profiles/${d}/${d}.conf
+	done
+	# Setup auto enable as Fedora does for allowing to use
+	# keyboards/mouse as soon as possible
+	sed -i 's/#\[Policy\]$/\[Policy\]/; s/#AutoEnable=false/AutoEnable=true/' src/main.conf || die
+	doins src/main.conf
+
+	newinitd "${FILESDIR}"/bluetooth-init.d-r5 bluetooth
+	newconfd "${FILESDIR}"/bluetooth-conf.d bluetooth
+
+	einstalldocs
+	use doc && dodoc doc/*.txt
+	# Install .json files as examples to be used by meshctl
+	if use mesh; then
+		dodoc tools/mesh-gatt/*.json
+		local DOC_CONTENTS="Some example .json files were installed into
+		/usr/share/doc/${PF} to be used with meshctl. Feel free to
+		uncompress and copy them to ~/.config/meshctl to use them."
+		readme.gentoo_create_doc
+	fi
+}
+
+pkg_postinst() {
+	use udev && udev_reload
+	systemd_reenable bluetooth.service
+
+	has_version net-dialup/ppp || elog "To use dial up networking you must install net-dialup/ppp"
+	use mesh && readme.gentoo_print_elog
+}
+
+pkg_postrm() {
+	use udev && udev_reload
+}

diff --git a/net-wireless/bluez/files/0001-adapter-Reset-pending-settings-when-receiving-MGMT-e.patch b/net-wireless/bluez/files/0001-adapter-Reset-pending-settings-when-receiving-MGMT-e.patch
new file mode 100644
index 000000000000..b9b432fadff0
--- /dev/null
+++ b/net-wireless/bluez/files/0001-adapter-Reset-pending-settings-when-receiving-MGMT-e.patch
@@ -0,0 +1,170 @@
+From ede7b915980fbc80eff80aa189c35ca016956c61 Mon Sep 17 00:00:00 2001
+From: Archie Pusaka <apusaka@chromium.org>
+Date: Tue, 23 Aug 2022 12:15:56 +0800
+Subject: [PATCH] adapter: Reset pending settings when receiving MGMT error
+
+We set the pending settings flag when sending MGMT_SETTING_*
+commands to the MGMT layer and clear them when receiving a
+successful reply, but we don't clear them when receiving an error
+reply. This might cause a setting to be stuck in pending state.
+
+Therefore, also clear the pending flag when receiving error.
+Furthermore, this patch also postpones setting the pending flag
+until we queue the MGMT command in order to avoid setting it too
+soon but we return early.
+
+This was caught during power off test, where MGMT_OP_SET_POWERED
+returns Authentication Failed because disconnection takes too long.
+Future attempts to switch power will then be ignored.
+
+< HCI Command: Disconnect (0x01|0x0006) plen 3   #17916 [hci0] 12.502908
+        Handle: 512
+        Reason: Remote Device Terminated due to Power Off (0x15)
+> HCI Event: Command Status (0x0f) plen 4        #17917 [hci0] 12.503185
+      Disconnect (0x01|0x0006) ncmd 1
+        Status: Success (0x00)
+@ MGMT Event: Command Status (0x0002) plen 3   {0x0001} [hci0] 14.519491
+      Set Powered (0x0005)
+        Status: Authentication Failed (0x05)
+= bluetoothd: Failed to set mode: Authentication Failed (0x05) 14.520042
+= bluetoothd: adapter /org/bluez/hci0 set power to 0           14.813533
+> HCI Event: Disconnect Complete (0x05) plen 4   #17918 [hci0] 16.509043
+        Status: Success (0x00)
+        Handle: 512
+        Reason: Connection Timeout (0x08)
+
+Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
+---
+ src/adapter.c | 39 +++++++++++++++++++++++++++++++--------
+ 1 file changed, 31 insertions(+), 8 deletions(-)
+
+diff --git a/src/adapter.c b/src/adapter.c
+index ec26aab1a..b453e86a0 100644
+--- a/src/adapter.c
++++ b/src/adapter.c
+@@ -640,14 +640,21 @@ static void new_settings_callback(uint16_t index, uint16_t length,
+ 	settings_changed(adapter, settings);
+ }
+ 
++struct set_mode_data {
++	struct btd_adapter *adapter;
++	uint32_t setting;
++};
++
+ static void set_mode_complete(uint8_t status, uint16_t length,
+ 					const void *param, void *user_data)
+ {
+-	struct btd_adapter *adapter = user_data;
++	struct set_mode_data *data = user_data;
++	struct btd_adapter *adapter = data->adapter;
+ 
+ 	if (status != MGMT_STATUS_SUCCESS) {
+ 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
+ 						mgmt_errstr(status), status);
++		adapter->pending_settings &= ~data->setting;
+ 		return;
+ 	}
+ 
+@@ -677,6 +684,7 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
+ {
+ 	struct mgmt_mode cp;
+ 	uint32_t setting = 0;
++	struct set_mode_data *data;
+ 
+ 	memset(&cp, 0, sizeof(cp));
+ 	cp.val = mode;
+@@ -699,15 +707,20 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
+ 		break;
+ 	}
+ 
+-	adapter->pending_settings |= setting;
+-
+ 	DBG("sending set mode command for index %u", adapter->dev_id);
+ 
++	data = g_new0(struct set_mode_data, 1);
++	data->adapter = adapter;
++	data->setting = setting;
++
+ 	if (mgmt_send(adapter->mgmt, opcode,
+ 				adapter->dev_id, sizeof(cp), &cp,
+-				set_mode_complete, adapter, NULL) > 0)
++				set_mode_complete, data, g_free) > 0) {
++		adapter->pending_settings |= setting;
+ 		return true;
++	}
+ 
++	g_free(data);
+ 	btd_error(adapter->dev_id, "Failed to set mode for index %u",
+ 							adapter->dev_id);
+ 
+@@ -718,6 +731,7 @@ static bool set_discoverable(struct btd_adapter *adapter, uint8_t mode,
+ 							uint16_t timeout)
+ {
+ 	struct mgmt_cp_set_discoverable cp;
++	struct set_mode_data *data;
+ 
+ 	memset(&cp, 0, sizeof(cp));
+ 	cp.val = mode;
+@@ -734,11 +748,16 @@ static bool set_discoverable(struct btd_adapter *adapter, uint8_t mode,
+ 									mode);
+ 	}
+ 
++	data = g_new0(struct set_mode_data, 1);
++	data->adapter = adapter;
++	data->setting = 0;
++
+ 	if (mgmt_send(adapter->mgmt, MGMT_OP_SET_DISCOVERABLE,
+ 				adapter->dev_id, sizeof(cp), &cp,
+-				set_mode_complete, adapter, NULL) > 0)
++				set_mode_complete, data, g_free) > 0)
+ 		return true;
+ 
++	g_free(data);
+ 	btd_error(adapter->dev_id, "Failed to set mode for index %u",
+ 							adapter->dev_id);
+ 
+@@ -2877,6 +2896,7 @@ static gboolean property_get_mode(struct btd_adapter *adapter,
+ 
+ struct property_set_data {
+ 	struct btd_adapter *adapter;
++	uint32_t setting;
+ 	GDBusPendingPropertySet id;
+ };
+ 
+@@ -2901,6 +2921,8 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
+ 
+ 		g_dbus_pending_property_error(data->id, dbus_err,
+ 							mgmt_errstr(status));
++
++		adapter->pending_settings &= ~data->setting;
+ 		return;
+ 	}
+ 
+@@ -2969,8 +2991,6 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
+ 
+ 	mode = (enable == TRUE) ? 0x01 : 0x00;
+ 
+-	adapter->pending_settings |= setting;
+-
+ 	switch (setting) {
+ 	case MGMT_SETTING_POWERED:
+ 		opcode = MGMT_OP_SET_POWERED;
+@@ -3024,11 +3044,14 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
+ 		goto failed;
+ 
+ 	data->adapter = adapter;
++	data->setting = setting;
+ 	data->id = id;
+ 
+ 	if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param,
+-			property_set_mode_complete, data, g_free) > 0)
++			property_set_mode_complete, data, g_free) > 0) {
++		adapter->pending_settings |= setting;
+ 		return;
++	}
+ 
+ 	g_free(data);
+ 
+-- 
+2.37.2
+

diff --git a/net-wireless/bluez/files/power-state-adapter-property.patch b/net-wireless/bluez/files/power-state-adapter-property.patch
new file mode 100644
index 000000000000..1d6f2cd0ae7f
--- /dev/null
+++ b/net-wireless/bluez/files/power-state-adapter-property.patch
@@ -0,0 +1,723 @@
+From a282944af40893fc79f0ae3aa1bf52031aa07ffe Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 31 Aug 2022 10:56:06 +0200
+Subject: [PATCH 1/6] adapter: Keep track of whether the adapter is rfkill'ed
+
+Instead of only replying to D-Bus requests with an error saying the
+adapter is blocked, keep track of the rfkill being enabled or disabled
+so we know the rfkill state of the adapter at all times.
+---
+ src/adapter.c | 25 +++++++++++++--
+ src/adapter.h |  1 +
+ src/btd.h     |  1 +
+ src/rfkill.c  | 89 ++++++++++++++++++++++++++++++++++++++-------------
+ 4 files changed, 91 insertions(+), 25 deletions(-)
+
+diff --git a/src/adapter.c b/src/adapter.c
+index 51b099dae..7c11a688d 100644
+--- a/src/adapter.c
++++ b/src/adapter.c
+@@ -250,6 +250,7 @@ struct btd_adapter {
+ 	uint32_t dev_class;		/* controller class of device */
+ 	char *name;			/* controller device name */
+ 	char *short_name;		/* controller short name */
++	bool blocked;			/* whether rfkill is enabled */
+ 	uint32_t supported_settings;	/* controller supported settings */
+ 	uint32_t pending_settings;	/* pending controller settings */
+ 	uint32_t current_settings;	/* current controller settings */
+@@ -654,6 +655,8 @@ static void set_mode_complete(uint8_t status, uint16_t length,
+ 	if (status != MGMT_STATUS_SUCCESS) {
+ 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
+ 						mgmt_errstr(status), status);
++		if (status == MGMT_STATUS_RFKILLED)
++			adapter->blocked = true;
+ 		adapter->pending_settings &= ~data->setting;
+ 		return;
+ 	}
+@@ -2947,10 +2950,12 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
+ 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
+ 						mgmt_errstr(status), status);
+ 
+-		if (status == MGMT_STATUS_RFKILLED)
++		if (status == MGMT_STATUS_RFKILLED) {
+ 			dbus_err = ERROR_INTERFACE ".Blocked";
+-		else
++			adapter->blocked = true;
++		} else {
+ 			dbus_err = ERROR_INTERFACE ".Failed";
++		}
+ 
+ 		g_dbus_pending_property_error(data->id, dbus_err,
+ 							mgmt_errstr(status));
+@@ -6681,6 +6686,7 @@ static void load_config(struct btd_adapter *adapter)
+ static struct btd_adapter *btd_adapter_new(uint16_t index)
+ {
+ 	struct btd_adapter *adapter;
++	int blocked;
+ 
+ 	adapter = g_try_new0(struct btd_adapter, 1);
+ 	if (!adapter)
+@@ -6689,6 +6695,9 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
+ 	adapter->dev_id = index;
+ 	adapter->mgmt = mgmt_ref(mgmt_primary);
+ 	adapter->pincode_requested = false;
++	blocked = rfkill_get_blocked(index);
++	if (blocked > 0)
++		adapter->blocked = true;
+ 
+ 	/*
+ 	 * Setup default configuration values. These are either adapter
+@@ -6714,6 +6723,8 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
+ 	DBG("Modalias: %s", adapter->modalias);
+ 	DBG("Discoverable timeout: %u seconds", adapter->discoverable_timeout);
+ 	DBG("Pairable timeout: %u seconds", adapter->pairable_timeout);
++	if (blocked > 0)
++		DBG("Blocked: yes");
+ 
+ 	adapter->auths = g_queue_new();
+ 	adapter->exps = queue_new();
+@@ -7581,6 +7592,9 @@ int btd_cancel_authorization(guint id)
+ 
+ int btd_adapter_restore_powered(struct btd_adapter *adapter)
+ {
++	if (adapter->blocked)
++		adapter->blocked = false;
++
+ 	if (btd_adapter_get_powered(adapter))
+ 		return 0;
+ 
+@@ -7589,6 +7603,13 @@ int btd_adapter_restore_powered(struct btd_adapter *adapter)
+ 	return 0;
+ }
+ 
++int btd_adapter_set_blocked(struct btd_adapter *adapter)
++{
++	if (!adapter->blocked)
++		adapter->blocked = true;
++	return 0;
++}
++
+ void btd_adapter_register_pin_cb(struct btd_adapter *adapter,
+ 							btd_adapter_pin_cb_t cb)
+ {
+diff --git a/src/adapter.h b/src/adapter.h
+index f38f473b7..78eb069ae 100644
+--- a/src/adapter.h
++++ b/src/adapter.h
+@@ -144,6 +144,7 @@ guint btd_request_authorization_cable_configured(const bdaddr_t *src, const bdad
+ int btd_cancel_authorization(guint id);
+ 
+ int btd_adapter_restore_powered(struct btd_adapter *adapter);
++int btd_adapter_set_blocked(struct btd_adapter *adapter);
+ 
+ typedef ssize_t (*btd_adapter_pin_cb_t) (struct btd_adapter *adapter,
+ 			struct btd_device *dev, char *out, bool *display,
+diff --git a/src/btd.h b/src/btd.h
+index c02b2691e..63be6d8d4 100644
+--- a/src/btd.h
++++ b/src/btd.h
+@@ -144,6 +144,7 @@ void plugin_cleanup(void);
+ 
+ void rfkill_init(void);
+ void rfkill_exit(void);
++int rfkill_get_blocked(uint16_t index);
+ 
+ GKeyFile *btd_get_main_conf(void);
+ bool btd_kernel_experimental_enabled(const char *uuid);
+diff --git a/src/rfkill.c b/src/rfkill.c
+index 2099c5ac5..a0a50d9e4 100644
+--- a/src/rfkill.c
++++ b/src/rfkill.c
+@@ -55,12 +55,71 @@ struct rfkill_event {
+ };
+ #define RFKILL_EVENT_SIZE_V1    8
+ 
++static int get_adapter_id_for_rfkill(int rfkill_id)
++{
++	char sysname[PATH_MAX];
++	int namefd;
++
++	snprintf(sysname, sizeof(sysname) - 1,
++			"/sys/class/rfkill/rfkill%u/name", rfkill_id);
++
++	namefd = open(sysname, O_RDONLY);
++	if (namefd < 0)
++		return -1;
++
++	memset(sysname, 0, sizeof(sysname));
++
++	if (read(namefd, sysname, sizeof(sysname) - 1) < 4) {
++		close(namefd);
++		return -1;
++	}
++
++	close(namefd);
++
++	if (g_str_has_prefix(sysname, "hci") == FALSE)
++		return -1;
++
++	return atoi(sysname + 3);
++}
++
++int rfkill_get_blocked(uint16_t index)
++{
++	int fd;
++	int blocked = -1;
++
++	fd = open("/dev/rfkill", O_RDWR);
++	if (fd < 0) {
++		DBG("Failed to open RFKILL control device");
++		return -1;
++	}
++
++	while (1) {
++		struct rfkill_event event = { 0 };
++		int id;
++		ssize_t len;
++
++		len = read(fd, &event, sizeof(event));
++		if (len < RFKILL_EVENT_SIZE_V1)
++			break;
++
++		id = get_adapter_id_for_rfkill(event.idx);
++
++		if (index == id) {
++			blocked = event.soft || event.hard;
++			break;
++		}
++	}
++	close(fd);
++
++	return blocked;
++}
++
+ static gboolean rfkill_event(GIOChannel *chan,
+ 				GIOCondition cond, gpointer data)
+ {
+ 	struct rfkill_event event = { 0 };
+ 	struct btd_adapter *adapter;
+-	char sysname[PATH_MAX];
++	bool blocked = false;
+ 	ssize_t len;
+ 	int fd, id;
+ 
+@@ -84,7 +143,7 @@ static gboolean rfkill_event(GIOChannel *chan,
+ 						event.soft, event.hard);
+ 
+ 	if (event.soft || event.hard)
+-		return TRUE;
++		blocked = true;
+ 
+ 	if (event.op != RFKILL_OP_CHANGE)
+ 		return TRUE;
+@@ -93,26 +152,7 @@ static gboolean rfkill_event(GIOChannel *chan,
+ 					event.type != RFKILL_TYPE_ALL)
+ 		return TRUE;
+ 
+-	snprintf(sysname, sizeof(sysname) - 1,
+-			"/sys/class/rfkill/rfkill%u/name", event.idx);
+-
+-	fd = open(sysname, O_RDONLY);
+-	if (fd < 0)
+-		return TRUE;
+-
+-	memset(sysname, 0, sizeof(sysname));
+-
+-	if (read(fd, sysname, sizeof(sysname) - 1) < 4) {
+-		close(fd);
+-		return TRUE;
+-	}
+-
+-	close(fd);
+-
+-	if (g_str_has_prefix(sysname, "hci") == FALSE)
+-		return TRUE;
+-
+-	id = atoi(sysname + 3);
++	id = get_adapter_id_for_rfkill(event.idx);
+ 	if (id < 0)
+ 		return TRUE;
+ 
+@@ -122,7 +162,10 @@ static gboolean rfkill_event(GIOChannel *chan,
+ 
+ 	DBG("RFKILL unblock for hci%d", id);
+ 
+-	btd_adapter_restore_powered(adapter);
++	if (blocked)
++		btd_adapter_set_blocked(adapter);
++	else
++		btd_adapter_restore_powered(adapter);
+ 
+ 	return TRUE;
+ }
+-- 
+2.37.2
+
+
+From 7711e4081bf6096f2210f5b5d715f005d654abf1 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 31 Aug 2022 13:23:23 +0200
+Subject: [PATCH 2/6] adapter: Implement PowerState property
+
+This property should allow any program to show whether an adapter is in
+the process of being turned on.
+
+As turning on an adapter isn't instantaneous, it's important that the UI
+reflects the transitional state of the adapter's power, and doesn't
+assume the device is already turned on but not yet working, or still off
+despite having requested for it to be turned on, in both cases making
+the UI feel unresponsive.
+
+This can also not be implemented in front-ends directly as, then,
+the status of an adapter wouldn't be reflected correctly in the Settings
+window if it's turned on in the system menu. Implementing it in the
+front-ends would also preclude from having feedback about the state of
+the adapter when bluetoothd is the one powering up the adapter after the
+rfkill was unblocked.
+
+See https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/issues/121
+and the original https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773
+---
+ src/adapter.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 128 insertions(+), 11 deletions(-)
+
+diff --git a/src/adapter.c b/src/adapter.c
+index 7c11a688d..59afbcb6d 100644
+--- a/src/adapter.c
++++ b/src/adapter.c
+@@ -239,6 +239,14 @@ struct btd_adapter_pin_cb_iter {
+ 	/* When the iterator reaches the end, it is NULL and attempt is 0 */
+ };
+ 
++enum {
++	ADAPTER_POWER_STATE_OFF,
++	ADAPTER_POWER_STATE_ON,
++	ADAPTER_POWER_STATE_ON_DISABLING,
++	ADAPTER_POWER_STATE_OFF_ENABLING,
++	ADAPTER_POWER_STATE_OFF_BLOCKED,
++};
++
+ struct btd_adapter {
+ 	int ref_count;
+ 
+@@ -250,9 +258,9 @@ struct btd_adapter {
+ 	uint32_t dev_class;		/* controller class of device */
+ 	char *name;			/* controller device name */
+ 	char *short_name;		/* controller short name */
+-	bool blocked;			/* whether rfkill is enabled */
+ 	uint32_t supported_settings;	/* controller supported settings */
+ 	uint32_t pending_settings;	/* pending controller settings */
++	uint32_t power_state;		/* the power state */
+ 	uint32_t current_settings;	/* current controller settings */
+ 
+ 	char *path;			/* adapter object path */
+@@ -326,6 +334,24 @@ struct btd_adapter {
+ 	struct queue *exps;
+ };
+ 
++static char *adapter_power_state_str(uint32_t power_state)
++{
++	switch (power_state) {
++	case ADAPTER_POWER_STATE_OFF:
++		return "off";
++	case ADAPTER_POWER_STATE_ON:
++		return "on";
++	case ADAPTER_POWER_STATE_ON_DISABLING:
++		return "on-disabling";
++	case ADAPTER_POWER_STATE_OFF_ENABLING:
++		return "off-enabling";
++	case ADAPTER_POWER_STATE_OFF_BLOCKED:
++		return "off-blocked";
++	}
++	DBG("Invalid power state %d", power_state);
++	return "";
++}
++
+ typedef enum {
+ 	ADAPTER_AUTHORIZE_DISCONNECTED = 0,
+ 	ADAPTER_AUTHORIZE_CHECK_CONNECTED
+@@ -619,6 +645,29 @@ static void settings_changed(struct btd_adapter *adapter, uint32_t settings)
+ 	}
+ }
+ 
++static void adapter_set_power_state(struct btd_adapter *adapter, uint32_t value)
++{
++	if (adapter->power_state == value)
++		return;
++
++	DBG("%s", adapter_power_state_str(value));
++	adapter->power_state = value;
++	g_dbus_emit_property_changed(dbus_conn, adapter->path,
++					ADAPTER_INTERFACE, "PowerState");
++}
++
++static void reset_power_state_target(struct btd_adapter *adapter,
++					uint32_t value)
++{
++	if (value &&
++	    adapter->power_state == ADAPTER_POWER_STATE_OFF_ENABLING) {
++		adapter_set_power_state(adapter, ADAPTER_POWER_STATE_ON);
++	} else if (!value &&
++		   adapter->power_state == ADAPTER_POWER_STATE_ON_DISABLING) {
++		adapter_set_power_state(adapter, ADAPTER_POWER_STATE_OFF);
++	}
++}
++
+ static void new_settings_callback(uint16_t index, uint16_t length,
+ 					const void *param, void *user_data)
+ {
+@@ -636,6 +685,12 @@ static void new_settings_callback(uint16_t index, uint16_t length,
+ 	if (settings == adapter->current_settings)
+ 		return;
+ 
++	if ((adapter->current_settings ^ settings) & MGMT_SETTING_POWERED) {
++		reset_power_state_target(adapter,
++					settings & MGMT_SETTING_POWERED ?
++					0x01 : 0x00);
++	}
++
+ 	DBG("Settings: 0x%08x", settings);
+ 
+ 	settings_changed(adapter, settings);
+@@ -644,6 +699,7 @@ static void new_settings_callback(uint16_t index, uint16_t length,
+ struct set_mode_data {
+ 	struct btd_adapter *adapter;
+ 	uint32_t setting;
++	uint8_t value;
+ };
+ 
+ static void set_mode_complete(uint8_t status, uint16_t length,
+@@ -656,8 +712,12 @@ static void set_mode_complete(uint8_t status, uint16_t length,
+ 		btd_error(adapter->dev_id, "Failed to set mode: %s (0x%02x)",
+ 						mgmt_errstr(status), status);
+ 		if (status == MGMT_STATUS_RFKILLED)
+-			adapter->blocked = true;
++			adapter_set_power_state(adapter,
++					ADAPTER_POWER_STATE_OFF_BLOCKED);
+ 		adapter->pending_settings &= ~data->setting;
++		if (status != MGMT_STATUS_RFKILLED &&
++		    data->setting & MGMT_SETTING_POWERED)
++			reset_power_state_target(adapter, data->value);
+ 		return;
+ 	}
+ 
+@@ -695,6 +755,11 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
+ 	switch (opcode) {
+ 	case MGMT_OP_SET_POWERED:
+ 		setting = MGMT_SETTING_POWERED;
++		if (adapter->power_state != ADAPTER_POWER_STATE_OFF_BLOCKED) {
++			adapter_set_power_state(adapter, mode ?
++					ADAPTER_POWER_STATE_OFF_ENABLING :
++					ADAPTER_POWER_STATE_ON_DISABLING);
++		}
+ 		break;
+ 	case MGMT_OP_SET_CONNECTABLE:
+ 		setting = MGMT_SETTING_CONNECTABLE;
+@@ -715,6 +780,7 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
+ 	data = g_new0(struct set_mode_data, 1);
+ 	data->adapter = adapter;
+ 	data->setting = setting;
++	data->value = mode;
+ 
+ 	if (mgmt_send(adapter->mgmt, opcode,
+ 				adapter->dev_id, sizeof(cp), &cp,
+@@ -722,8 +788,13 @@ static bool set_mode(struct btd_adapter *adapter, uint16_t opcode,
+ 		adapter->pending_settings |= setting;
+ 		return true;
+ 	}
+-
+ 	g_free(data);
++	if (setting == MGMT_SETTING_POWERED) {
++		/* cancel the earlier setting */
++		adapter_set_power_state(adapter, mode ?
++					ADAPTER_POWER_STATE_OFF :
++					ADAPTER_POWER_STATE_ON);
++	}
+ 	btd_error(adapter->dev_id, "Failed to set mode for index %u",
+ 							adapter->dev_id);
+ 
+@@ -2934,6 +3005,7 @@ struct property_set_data {
+ 	struct btd_adapter *adapter;
+ 	uint32_t setting;
+ 	GDBusPendingPropertySet id;
++	uint8_t value;
+ };
+ 
+ static void property_set_mode_complete(uint8_t status, uint16_t length,
+@@ -2952,7 +3024,8 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
+ 
+ 		if (status == MGMT_STATUS_RFKILLED) {
+ 			dbus_err = ERROR_INTERFACE ".Blocked";
+-			adapter->blocked = true;
++			adapter_set_power_state(adapter,
++					ADAPTER_POWER_STATE_OFF_BLOCKED);
+ 		} else {
+ 			dbus_err = ERROR_INTERFACE ".Failed";
+ 		}
+@@ -2961,6 +3034,9 @@ static void property_set_mode_complete(uint8_t status, uint16_t length,
+ 							mgmt_errstr(status));
+ 
+ 		adapter->pending_settings &= ~data->setting;
++		if (status != MGMT_STATUS_RFKILLED &&
++		    data->setting & MGMT_SETTING_POWERED)
++			reset_power_state_target(adapter, data->value);
+ 		return;
+ 	}
+ 
+@@ -3084,6 +3160,15 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
+ 	data->adapter = adapter;
+ 	data->setting = setting;
+ 	data->id = id;
++	data->setting = setting;
++	data->value = mode;
++
++	if (setting == MGMT_SETTING_POWERED &&
++	    adapter->power_state != ADAPTER_POWER_STATE_OFF_BLOCKED) {
++		adapter_set_power_state(adapter, mode ?
++					ADAPTER_POWER_STATE_OFF_ENABLING :
++					ADAPTER_POWER_STATE_ON_DISABLING);
++	}
+ 
+ 	if (mgmt_send(adapter->mgmt, opcode, adapter->dev_id, len, param,
+ 			property_set_mode_complete, data, g_free) > 0) {
+@@ -3092,6 +3177,12 @@ static void property_set_mode(struct btd_adapter *adapter, uint32_t setting,
+ 	}
+ 
+ 	g_free(data);
++	if (setting == MGMT_SETTING_POWERED) {
++		/* cancel the earlier setting */
++		adapter_set_power_state(adapter, mode ?
++					ADAPTER_POWER_STATE_OFF :
++					ADAPTER_POWER_STATE_ON);
++	}
+ 
+ failed:
+ 	btd_error(adapter->dev_id, "Failed to set mode for index %u",
+@@ -3123,6 +3214,18 @@ static void property_set_powered(const GDBusPropertyTable *property,
+ 	property_set_mode(adapter, MGMT_SETTING_POWERED, iter, id);
+ }
+ 
++static gboolean property_get_power_state(const GDBusPropertyTable *property,
++					DBusMessageIter *iter, void *user_data)
++{
++	struct btd_adapter *adapter = user_data;
++	const char *str;
++
++	str = adapter_power_state_str(adapter->power_state);
++	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str);
++
++	return TRUE;
++}
++
+ static gboolean property_get_discoverable(const GDBusPropertyTable *property,
+ 					DBusMessageIter *iter, void *user_data)
+ {
+@@ -3761,6 +3864,8 @@ static const GDBusPropertyTable adapter_properties[] = {
+ 	{ "Alias", "s", property_get_alias, property_set_alias },
+ 	{ "Class", "u", property_get_class },
+ 	{ "Powered", "b", property_get_powered, property_set_powered },
++	{ "PowerState", "s", property_get_power_state, NULL, NULL,
++			     G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
+ 	{ "Discoverable", "b", property_get_discoverable,
+ 					property_set_discoverable },
+ 	{ "DiscoverableTimeout", "u", property_get_discoverable_timeout,
+@@ -5567,6 +5672,7 @@ static void adapter_start(struct btd_adapter *adapter)
+ {
+ 	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+ 						ADAPTER_INTERFACE, "Powered");
++	adapter_set_power_state(adapter, ADAPTER_POWER_STATE_ON);
+ 
+ 	DBG("adapter %s has been enabled", adapter->path);
+ 
+@@ -6697,7 +6803,7 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
+ 	adapter->pincode_requested = false;
+ 	blocked = rfkill_get_blocked(index);
+ 	if (blocked > 0)
+-		adapter->blocked = true;
++		adapter->power_state = ADAPTER_POWER_STATE_OFF_BLOCKED;
+ 
+ 	/*
+ 	 * Setup default configuration values. These are either adapter
+@@ -6724,7 +6830,8 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
+ 	DBG("Discoverable timeout: %u seconds", adapter->discoverable_timeout);
+ 	DBG("Pairable timeout: %u seconds", adapter->pairable_timeout);
+ 	if (blocked > 0)
+-		DBG("Blocked: yes");
++		DBG("Power state: %s",
++			adapter_power_state_str(adapter->power_state));
+ 
+ 	adapter->auths = g_queue_new();
+ 	adapter->exps = queue_new();
+@@ -7316,6 +7423,9 @@ static void adapter_stop(struct btd_adapter *adapter)
+ 
+ 	g_dbus_emit_property_changed(dbus_conn, adapter->path,
+ 						ADAPTER_INTERFACE, "Powered");
++	g_dbus_emit_property_changed(dbus_conn, adapter->path,
++						ADAPTER_INTERFACE,
++						"PowerState");
+ 
+ 	DBG("adapter %s has been disabled", adapter->path);
+ }
+@@ -7592,10 +7702,18 @@ int btd_cancel_authorization(guint id)
+ 
+ int btd_adapter_restore_powered(struct btd_adapter *adapter)
+ {
+-	if (adapter->blocked)
+-		adapter->blocked = false;
++	bool powered;
+ 
+-	if (btd_adapter_get_powered(adapter))
++	powered = btd_adapter_get_powered(adapter);
++	if (adapter->power_state == ADAPTER_POWER_STATE_OFF_BLOCKED &&
++	    rfkill_get_blocked(adapter->dev_id) == 0) {
++		adapter_set_power_state(adapter,
++					powered ?
++					ADAPTER_POWER_STATE_ON :
++					ADAPTER_POWER_STATE_OFF);
++	}
++
++	if (powered)
+ 		return 0;
+ 
+ 	set_mode(adapter, MGMT_OP_SET_POWERED, 0x01);
+@@ -7605,8 +7723,7 @@ int btd_adapter_restore_powered(struct btd_adapter *adapter)
+ 
+ int btd_adapter_set_blocked(struct btd_adapter *adapter)
+ {
+-	if (!adapter->blocked)
+-		adapter->blocked = true;
++	adapter_set_power_state(adapter, ADAPTER_POWER_STATE_OFF_BLOCKED);
+ 	return 0;
+ }
+ 
+-- 
+2.37.2
+
+
+From f86d0c8092ca8f9fee7c140f5f4df3938ea1ec29 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 31 Aug 2022 11:01:22 +0200
+Subject: [PATCH 3/6] client: Print the PowerState property
+
+---
+ client/main.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/client/main.c b/client/main.c
+index 6773d5262..2816e880f 100644
+--- a/client/main.c
++++ b/client/main.c
+@@ -981,6 +981,7 @@ static void cmd_show(int argc, char *argv[])
+ 	print_property(adapter->proxy, "Alias");
+ 	print_property(adapter->proxy, "Class");
+ 	print_property(adapter->proxy, "Powered");
++	print_property(adapter->proxy, "PowerState");
+ 	print_property(adapter->proxy, "Discoverable");
+ 	print_property(adapter->proxy, "DiscoverableTimeout");
+ 	print_property(adapter->proxy, "Pairable");
+-- 
+2.37.2
+
+
+From 4b2587ecdb437f6c24d1c42576eb9d4ecb01a7f3 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 31 Aug 2022 11:01:44 +0200
+Subject: [PATCH 4/6] adapter-api: Add PowerState property documentation
+
+---
+ doc/adapter-api.txt | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
+index 48466ab75..9b2721c1b 100644
+--- a/doc/adapter-api.txt
++++ b/doc/adapter-api.txt
+@@ -269,6 +269,21 @@ Properties	string Address [readonly]
+ 			restart or unplugging of the adapter it will reset
+ 			back to false.
+ 
++		string PowerState [readonly, experimental]
++
++			The power state of an adapter.
++
++			The power state will show whether the adapter is
++			turning off, or turning on, as well as being on
++			or off.
++
++			Possible values:
++				"on" - powered on
++				"off" - powered off
++				"off-enabling" - transitioning from "off" to "on"
++				"on-disabling" - transitioning from "on" to "off"
++				"off-blocked" - blocked by rfkill
++
+ 		boolean Discoverable [readwrite]
+ 
+ 			Switch an adapter to discoverable or non-discoverable
+-- 
+2.37.2
+
+
+From 0e723ee0f8e9024b6319267637253e5d7f982ef1 Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 31 Aug 2022 11:05:56 +0200
+Subject: [PATCH 5/6] adapter: Fix typo in function name
+
+---
+ src/adapter.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/adapter.c b/src/adapter.c
+index 59afbcb6d..8fb2acdc8 100644
+--- a/src/adapter.c
++++ b/src/adapter.c
+@@ -3511,7 +3511,7 @@ static gboolean property_get_experimental(const GDBusPropertyTable *property,
+ 	return TRUE;
+ }
+ 
+-static gboolean property_experimental_exits(const GDBusPropertyTable *property,
++static gboolean property_experimental_exists(const GDBusPropertyTable *property,
+ 								void *data)
+ {
+ 	struct btd_adapter *adapter = data;
+@@ -3879,7 +3879,7 @@ static const GDBusPropertyTable adapter_properties[] = {
+ 					property_exists_modalias },
+ 	{ "Roles", "as", property_get_roles },
+ 	{ "ExperimentalFeatures", "as", property_get_experimental, NULL,
+-					property_experimental_exits },
++					property_experimental_exists },
+ 	{ }
+ };
+ 
+-- 
+2.37.2
+
+
+From 70309219acd4c81e3a9e2b3652d2d93eb08b0aee Mon Sep 17 00:00:00 2001
+From: Bastien Nocera <hadess@hadess.net>
+Date: Wed, 31 Aug 2022 11:16:34 +0200
+Subject: [PATCH 6/6] adapter: Remove experimental flag for PowerState
+
+Now that the feature has been tested, that the API is deemed adequate
+and the reliability sufficient.
+---
+ src/adapter.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/src/adapter.c b/src/adapter.c
+index 8fb2acdc8..841096d7f 100644
+--- a/src/adapter.c
++++ b/src/adapter.c
+@@ -3864,8 +3864,7 @@ static const GDBusPropertyTable adapter_properties[] = {
+ 	{ "Alias", "s", property_get_alias, property_set_alias },
+ 	{ "Class", "u", property_get_class },
+ 	{ "Powered", "b", property_get_powered, property_set_powered },
+-	{ "PowerState", "s", property_get_power_state, NULL, NULL,
+-			     G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
++	{ "PowerState", "s", property_get_power_state },
+ 	{ "Discoverable", "b", property_get_discoverable,
+ 					property_set_discoverable },
+ 	{ "DiscoverableTimeout", "u", property_get_discoverable_timeout,
+-- 
+2.37.2
+


             reply	other threads:[~2022-09-11  7:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-11  7:50 Pacho Ramos [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-05 11:40 [gentoo-commits] repo/gentoo:master commit in: net-wireless/bluez/, net-wireless/bluez/files/ Sam James
2024-11-24 22:30 Sam James
2024-11-08 15:51 Pacho Ramos
2024-09-24  6:12 Sam James
2024-09-15 11:41 Pacho Ramos
2024-06-16 11:40 Pacho Ramos
2023-08-23 14:49 Pacho Ramos
2023-07-08 10:00 Pacho Ramos
2023-01-31  5:56 Sam James
2022-09-11  7:50 Pacho Ramos
2022-04-18 16:27 Pacho Ramos
2022-01-09 19:52 Pacho Ramos
2021-12-02 13:31 Pacho Ramos
2021-07-08  8:09 Pacho Ramos
2021-06-05 10:53 Pacho Ramos
2020-03-11 15:01 Pacho Ramos
2019-11-10 12:11 Pacho Ramos
2019-11-10 12:11 Pacho Ramos
2019-10-20  8:55 Pacho Ramos
2019-09-29 13:47 Pacho Ramos
2019-04-29 12:22 Pacho Ramos
2016-04-09 10:49 Pacho Ramos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1662882630.c7e05832f00875182becdba543cfdfd4a62ed26a.pacho@gentoo \
    --to=pacho@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox