All of lore.kernel.org
 help / color / mirror / Atom feed
From: Howard Chung <howardchung@google.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: Yun-Hao Chung <howardchung@chromium.org>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: [PATCH v2 3/3] client: add AffectedByPolicy property
Date: Tue, 10 Aug 2021 20:56:03 +0800	[thread overview]
Message-ID: <20210810205522.v2.3.I4f0ce40e36938756509ebe62a97929957936e648@changeid> (raw)
In-Reply-To: <20210810205522.v2.1.Ie7d876ad0b7defabfa86beb64e83f655f12be7ab@changeid>

From: Yun-Hao Chung <howardchung@chromium.org>

This prints property AffectedByPolicy in device info if
org.bluez.AdminPolicyStatus1 exists.

This also rename find_battery_by_path to find_proxies_by_path to reuse
the function.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---
The following test steps were performed:
1. [bluetooth] menu admin
2. [bluetooth] allow 1124 180A 180F 1812 1801
3. Verify only HID devices are not `Affected by Policy`
4. [bluetooth] allow 1108 110A 110B 110C 110D 110E 110F
1112 111E 111F 1203
5. Verify only audio devices are not `Affected by Policy`
devices are expected.

(no changes since v1)

 client/main.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/client/main.c b/client/main.c
index 142a2c08a07f..eb8fa935397c 100644
--- a/client/main.c
+++ b/client/main.c
@@ -56,6 +56,7 @@ static GDBusProxy *default_dev;
 static GDBusProxy *default_attr;
 static GList *ctrl_list;
 static GList *battery_proxies;
+static GList *admin_devices_proxies;
 
 static const char *agent_arguments[] = {
 	"on",
@@ -542,8 +543,11 @@ static void admin_policy_status_added(GDBusProxy *proxy)
 
 	adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy));
 
-	if (!adapter)
+	if (!adapter) {
+		admin_devices_proxies = g_list_append(admin_devices_proxies,
+									proxy);
 		return;
+	}
 
 	admin_policy_set_status_proxy(proxy);
 }
@@ -654,8 +658,11 @@ static void admin_policy_status_removed(GDBusProxy *proxy)
 
 	adapter = find_ctrl(ctrl_list, g_dbus_proxy_get_path(proxy));
 
-	if (!adapter)
+	if (!adapter) {
+		admin_devices_proxies = g_list_remove(admin_devices_proxies,
+									proxy);
 		return;
+	}
 
 	admin_policy_set_status_proxy(NULL);
 }
@@ -837,7 +844,7 @@ static struct adapter *find_ctrl_by_address(GList *source, const char *address)
 	return NULL;
 }
 
-static GDBusProxy *find_battery_by_path(GList *source, const char *path)
+static GDBusProxy *find_proxies_by_path(GList *source, const char *path)
 {
 	GList *list;
 
@@ -1704,6 +1711,7 @@ static struct GDBusProxy *find_device(int argc, char *argv[])
 static void cmd_info(int argc, char *argv[])
 {
 	GDBusProxy *proxy;
+	GDBusProxy *admin_proxy;
 	GDBusProxy *battery_proxy;
 	DBusMessageIter iter;
 	const char *address;
@@ -1747,10 +1755,14 @@ static void cmd_info(int argc, char *argv[])
 	print_property(proxy, "AdvertisingFlags");
 	print_property(proxy, "AdvertisingData");
 
-	battery_proxy = find_battery_by_path(battery_proxies,
+	battery_proxy = find_proxies_by_path(battery_proxies,
+					g_dbus_proxy_get_path(proxy));
+	admin_proxy = find_proxies_by_path(admin_devices_proxies,
 					g_dbus_proxy_get_path(proxy));
 	print_property_with_label(battery_proxy, "Percentage",
 					"Battery Percentage");
+	print_property_with_label(admin_proxy, "AffectedByPolicy",
+					"Affected by Policy");
 
 	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
-- 
2.32.0.605.g8dce9f2422-goog


  parent reply	other threads:[~2021-08-10 12:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 12:56 [PATCH v2 1/3] shared/shell: fix missing stdbool in shell.h Howard Chung
2021-08-10 12:56 ` [PATCH v2 2/3] client: add admin submenu and allow command Howard Chung
2021-08-10 16:34   ` Luiz Augusto von Dentz
2021-08-10 12:56 ` Howard Chung [this message]
2021-08-10 13:15 ` [v2,1/3] shared/shell: fix missing stdbool in shell.h bluez.test.bot

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=20210810205522.v2.3.I4f0ce40e36938756509ebe62a97929957936e648@changeid \
    --to=howardchung@google.com \
    --cc=howardchung@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=mcchou@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.