Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp220768iob; Mon, 2 May 2022 17:37:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLXy0N1J4xnuuABRUDODEVU5dpqzSh4AivO1xNyoTwIU2lXSD0jZKf5cdB+9BbGEqFiF6Z X-Received: by 2002:a05:6a00:212c:b0:50d:a337:7437 with SMTP id n12-20020a056a00212c00b0050da3377437mr13823241pfj.70.1651538239997; Mon, 02 May 2022 17:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651538239; cv=none; d=google.com; s=arc-20160816; b=Jm0IbFelaQAu30LagZEedZpazvF0Q43ut/Ix2rwok9xP0N23LTFt7hFh0i3gsaN/WD sMGrRf4bUMMpMs0C+4LiZwTgwKm9B6TRbLnZxVZI6PokTbxcnS3+tg0ZY41zAk/KTvvb 4u1vqgWF/8EEtqj9qt425ok6cRDL3OIOvvAiSkhqOT+p737vxYft6h+B+rsi08WV91GL jHckFsc3bZ3+OTLiKPM19MZrqAWReFbRYg41TTgQRyj+63xEYbk9mxJ9He5NKPMhboXQ DDqn3HpFihR+bvmIracWJ2LFbSzE64YMdMeO6i4F45rVAz78mq/cGl2wBuTLceSvtnGq nj0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mjEyjWzwg01OjZmfgcXhjH7l+zjibnXv5mKAEZHcc4g=; b=WMDum5SQJn59632KVs5FgPmctfWPI6/S4E+wC5DdqhVZhBkpxDlNCghH1Zc3EyShPD 0aYHvk/0U+v5B2Su01aZvjhKSNqhuDEVIFuucKQDo3q6rGudfV22Vfw9stN46vTE2Gzb GPZeTllApGNHvQ9R9LjXOxjEhAp81vCJ4vjkYhf8yop3yv/S0efduZ+EKBXl/y1D0wLA yvVkj0lDd7iPqEkfvZsb47m+4dPs+p3NtKYdd9WMMSg3QprzLBw/G2XD/YLlT6+WIx0r Y4XT5utqrpGAF0A8ThLpxois3yTHRssLoBiD6P71BeJZiLJufJMVTmYWaTl2Ix1wE0Nr vtUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="fj7/xFtw"; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i2-20020a170902eb4200b001584ee3ba07si14261869pli.439.2022.05.02.17.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:37:19 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="fj7/xFtw"; spf=softfail (google.com: domain of transitioning linux-bluetooth-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 190CA3C710; Mon, 2 May 2022 17:29:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387579AbiEBVPi (ORCPT + 99 others); Mon, 2 May 2022 17:15:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234807AbiEBVPi (ORCPT ); Mon, 2 May 2022 17:15:38 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CBCE1104 for ; Mon, 2 May 2022 14:12:08 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id j8-20020a17090a060800b001cd4fb60dccso418271pjj.2 for ; Mon, 02 May 2022 14:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mjEyjWzwg01OjZmfgcXhjH7l+zjibnXv5mKAEZHcc4g=; b=fj7/xFtwibHaNuOW3ws2R7mf2axo0NYQ1dUKDOo4vrclFf+O4aG51SprO6BCQOUBa5 gWycH1dxNUhWqnFR1zYtnwCC5ftSOLRoP0RoEWOYIEZg+wvlK+L52hTBkxV+1Df/ya4U fJdth8VnV4nV3HIiwcH4+GGXHh62Cv+zw9dWfy27FuofmUtNj+fwEh7GWGvjKWNPLUxK grTKkO+Mo1R/NvVuOt9mNXB1pfn2ady9+L5lrPR2RwGoB7vpiA5U+8u2WR5jC5grz+T4 nyJvvPtTq9BoIne+mchbo62YarptvKWiQBvrraCR6AJVKdFhpkp6Y84piwxupAlQ8HmH wxGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mjEyjWzwg01OjZmfgcXhjH7l+zjibnXv5mKAEZHcc4g=; b=s0GxbiNeWcww98T5s/7Ntgpm3Sqhtv3WeK9Ftm1HSzpmq3aSPoAdo42+uG6i2egHat 5a5/JLBwbor44VA3wtTWS64Bn/otmPj+CDAHh1CsjSj97yWDdNtPNHl7C17OVhNIK7WY cvbQaiXMCshokb6ggdKSetqrG3ClRPO7miN13iSTVygckMjfFjp4Y5jLx7xXUrD5KvwK x19LxBAhdFQ+r7nU8sTX+yHT/RSJOwK8TCNbuav49dBOFvb+o2CuiXncWsQ0gOMtT4jf zKRNq7kzqTvoApXC0WzwLepUd+xlqUZR8kBh1KMApDSWIsk+3/ukSi3DfhIWukbJS7+9 6grw== X-Gm-Message-State: AOAM532c8MMrmQ/X4Jipwh/eUq905bicOFg54z7PZW3a17atzN5q4a+T Sk6ox1TKWygfVf1z7C+U3sU9V1FwzeTiztrhFU0= X-Received: by 2002:a17:90a:8a92:b0:1d7:3cca:69d8 with SMTP id x18-20020a17090a8a9200b001d73cca69d8mr1124169pjn.61.1651525927657; Mon, 02 May 2022 14:12:07 -0700 (PDT) MIME-Version: 1.0 References: <20220418174929.2777339-1-jiangzp@google.com> <20220418174914.Bluez.v2.1.I6ab300fa4999c9310f4cb6fc09b1290edb6b2c2b@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Mon, 2 May 2022 14:11:56 -0700 Message-ID: Subject: Re: [Bluez PATCH v2 1/2] device: Add "Bonded" flag to dbus property To: Zhengping Jiang Cc: "linux-bluetooth@vger.kernel.org" , ChromeOS Bluetooth Upstreaming , Sonny Sasaka , Yun-Hao Chung Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Zhengping, On Mon, Apr 18, 2022 at 3:41 PM Luiz Augusto von Dentz wrote: > > Hi Zhengping, > > On Mon, Apr 18, 2022 at 10:49 AM Zhengping Jiang wrote: > > > > Add "Bonded" to dbus device property table. When setting the "Bonded > > flag, check the status of the Bonded property first. If the Bonded > > property is changed, send property changed signal. > > > > Reviewed-by: Sonny Sasaka > > Reviewed-by: Yun-Hao Chung > > > > Signed-off-by: Zhengping Jiang > > --- > > > > Changes in v2: > > - Move one variable declaration to the top following C90 standard > > > > Changes in v1: > > - Add "Bonded" to D-Bus interface > > - Send property changed signal if the bonded flag is changed > > > > doc/device-api.txt | 4 ++++ > > src/device.c | 40 +++++++++++++++++++++++++++++++++++----- > > 2 files changed, 39 insertions(+), 5 deletions(-) > > > > diff --git a/doc/device-api.txt b/doc/device-api.txt > > index 4e824d2dec17..6162755f954c 100644 > > --- a/doc/device-api.txt > > +++ b/doc/device-api.txt > > @@ -171,6 +171,10 @@ Properties string Address [readonly] > > > > Indicates if the remote device is paired. > > > > + boolean Bonded [readonly] > > + > > + Indicates if the remote device is bonded. > > It is probably a good idea to add a description about Bonded vs > Paired. Btw, API documentation should be in a separate patch. Will you be updating following this comments or you are waiting more feedback from upstream? > > + > > boolean Connected [readonly] > > > > Indicates if the remote device is currently connected. > > diff --git a/src/device.c b/src/device.c > > index 8dc12d026827..868c41f025d9 100644 > > --- a/src/device.c > > +++ b/src/device.c > > @@ -1042,6 +1042,22 @@ static gboolean dev_property_get_paired(const GDBusPropertyTable *property, > > return TRUE; > > } > > > > +static gboolean dev_property_get_bonded(const GDBusPropertyTable *property, > > + DBusMessageIter *iter, void *data) > > +{ > > + struct btd_device *dev = data; > > + dbus_bool_t val; > > + > > + if (dev->bredr_state.bonded || dev->le_state.bonded) > > + val = TRUE; > > + else > > + val = FALSE; > > + > > + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); > > + > > + return TRUE; > > +} > > + > > static gboolean dev_property_get_legacy(const GDBusPropertyTable *property, > > DBusMessageIter *iter, void *data) > > { > > @@ -3120,6 +3136,7 @@ static const GDBusPropertyTable device_properties[] = { > > { "Icon", "s", dev_property_get_icon, NULL, > > dev_property_exists_icon }, > > { "Paired", "b", dev_property_get_paired }, > > + { "Bonded", "b", dev_property_get_bonded }, > > { "Trusted", "b", dev_property_get_trusted, dev_property_set_trusted }, > > { "Blocked", "b", dev_property_get_blocked, dev_property_set_blocked }, > > { "LegacyPairing", "b", dev_property_get_legacy }, > > @@ -6114,17 +6131,30 @@ void btd_device_set_trusted(struct btd_device *device, gboolean trusted) > > > > void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type) > > { > > + struct bearer_state *state; > > + > > if (!device) > > return; > > > > - DBG(""); > > + state = get_state(device, bdaddr_type); > > > > - if (bdaddr_type == BDADDR_BREDR) > > - device->bredr_state.bonded = true; > > - else > > - device->le_state.bonded = true; > > + if (state->bonded) > > + return; > > + > > + DBG("setting bonded for device to true"); > > + > > + state->bonded = true; > > > > btd_device_set_temporary(device, false); > > + > > + /* If the other bearer state was already true we don't need to > > + * send any property signals. > > + */ > > + if (device->bredr_state.bonded == device->le_state.bonded) > > + return; > > + > > + g_dbus_emit_property_changed(dbus_conn, device->path, > > + DEVICE_INTERFACE, "Bonded"); > > } > > > > void device_set_legacy(struct btd_device *device, bool legacy) > > -- > > 2.36.0.rc0.470.gd361397f0d-goog > > > > > -- > Luiz Augusto von Dentz -- Luiz Augusto von Dentz