Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4217713pxt; Wed, 11 Aug 2021 00:13:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdlmRlQuVfaXerZIN+rjZ7wYDXTrqDc741DfJo0z4eJWO5fABHnb9fLeCDMFeoPjsSGg5F X-Received: by 2002:a05:6e02:1cad:: with SMTP id x13mr6222ill.188.1628665984080; Wed, 11 Aug 2021 00:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628665984; cv=none; d=google.com; s=arc-20160816; b=LHJ5S7eU/acv1eO49hHONUTvNXuFSxiwcM1jsdT9T98wtXzOAY65UfOP2PsdfTUoCf 8Hj5lk9FpO5y4k0FPWsOu+e3bzfSZ/yDqfXvyMLyUq4KeEMxvnlw2SoVjTMXvREbm8lh S2tMzsOYbej3732BvdMG6o7OoP+7/ZPzHODgsk42qIV0eHnbE4KKi24C4gb2ihTUEDr+ OUVMntxHM+LdoX+Tj19vODIh8v77snPEuG3JhQqdSsUIPh8Bzh6ZBdd/tkES5JGSn/Ga G2ChF8favCBj1vjbJ/ZUuR169fv9eWknMgNlzSQ7LxXF8rDetKniWZL7mt9c+GAp2FaF hXsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=3Zxj33TTjkKhOKutgoM7B02duZHtVt6F+j0ORgUTiLQ=; b=ZG828ioNk7zEfN9d7Y7fxXlQoaepJxBn8HcTSRcWN9zRE9P7btKp7ub9gZV4+0++oa FG6XqDMenKtfV7ExswYY2qDWibAEIbTqXYhiUhihbVPR9uKNJk8BDSGr2eM7AeQ/KQ6b hRIwIX5g2sg3bh9R01YJbwwSfWs4uUa2pnGcnqLNh2B7BeiRuWmBoWakSPbLt5Rakfcn l59LCm8LggzUH97TrCKwlf4IeS1uV8tEJZ2Fjzez/HlmhhwQrJv9/X/uXqmdLsZw0kzw uHcyA86dnLnMtpnMkYOObmbHdehy19PmXW6T1ZN74+cVP77CHcJ9bfeFGjavkbX3UH4o IdPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HmkirzI4; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si34380825iov.62.2021.08.11.00.12.51; Wed, 11 Aug 2021 00:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=HmkirzI4; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235037AbhHKHJd (ORCPT + 99 others); Wed, 11 Aug 2021 03:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234855AbhHKHJd (ORCPT ); Wed, 11 Aug 2021 03:09:33 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40B66C061765 for ; Wed, 11 Aug 2021 00:09:10 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id c196-20020ae9edcd0000b02903c9e325c3b2so815707qkg.2 for ; Wed, 11 Aug 2021 00:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=3Zxj33TTjkKhOKutgoM7B02duZHtVt6F+j0ORgUTiLQ=; b=HmkirzI418P3VU5vFedRa4npsvpcxumSuDAX5Sr3B24qfp0hp9Ujfc8zaED3uNy5Pv bNkAag411bSQ7K9M0NKjBzH52MvYsThdVu4WistHD3uvcUsRlsA/fTMjD50AAls9gwuC 7Tqnx+xQ8k2Vey3vJq6NOyw71+H/PEpk8PI0FXAoWXksS54Zh2iXi7o4U3E6Fu2G0vyU bkl7w/fxHKOon8FBxRrv/jv4Ko4VwUpAZDhJQ6lrj6/Y8fVa3Ptz2TxKZ6oITnu9/Pt3 qHlSdwszpXsjWEyVmXakJNjq84Hui4E+dIrBOlMXYNawkZ/azqfuh7bAs/3fOFWoU3xn SjAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3Zxj33TTjkKhOKutgoM7B02duZHtVt6F+j0ORgUTiLQ=; b=aYdfgCagsxZf9Vwrw05Rn87+hmeAsIFtbQyST/HQClGUPpgqBtdHnRsAsELxVRWlp5 oLUfA6TxBP3Wy5LZxHYAnWEtG+KFazLiOnTovghDyQVR4TF/umDLPTvHtw4U1ddwdGL6 am2XlgvOB7qg6AePa7UnX2oj53hcnMajtOxJafVN9X32XejrwjyWMHJTklgljFzqIzw4 s9emcx1l0fhlEZ9LMp1szAaOfFFcXroUdsE417kUB9679Eprtz1pe011elo+8PzHEVSo d9qCy4beEIjCcyU/ydu2WoY0qryUPGtWJTfm5SGn4nhtVvRulccSCxfEtXtExHL5G1Dt uR7g== X-Gm-Message-State: AOAM532Twqn0dkpgZaGbtNzjrX740A9szhzJ+Yn7XSmy2/w+k0RY5Ocp MJ1sr1Oia3DstsMEZrMSbYgep+Ct6QRxRWxMX8PEpcaihmOlvkd72na+7TZX9o+Tf8eSIEiXxFR 0so2UNRvK9sLz42yotOFt+u+yJreH7QnSLXyFGYCj3lVfZjIrm1K9aD9TybgNQIwSOQmhrIFzMm nVqGhV5wIdhlU= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:42fe:de1a:97f8:9006]) (user=howardchung job=sendgmr) by 2002:a05:6214:240a:: with SMTP id fv10mr21897457qvb.11.1628665749451; Wed, 11 Aug 2021 00:09:09 -0700 (PDT) Date: Wed, 11 Aug 2021 15:08:57 +0800 In-Reply-To: <20210811150752.v3.1.Ie7d876ad0b7defabfa86beb64e83f655f12be7ab@changeid> Message-Id: <20210811150752.v3.3.I4f0ce40e36938756509ebe62a97929957936e648@changeid> Mime-Version: 1.0 References: <20210811150752.v3.1.Ie7d876ad0b7defabfa86beb64e83f655f12be7ab@changeid> X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [PATCH v3 3/3] client: add AffectedByPolicy property From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Cc: Yun-Hao Chung , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Yun-Hao Chung 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 --- 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 a983066eda34..506602bbdb6d 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