Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2036976rbb; Tue, 27 Feb 2024 08:44:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVM6IV0KtLlFqRBwoPCulPg9pG5JTYzQS2ndmJ1xwXtUU1+8/x9qr2by6iRcban6O4LKvfeLg1Cn3GYI0UVEE9FPKPZSNKSUFrRaVOZiw== X-Google-Smtp-Source: AGHT+IE5u67yzzqryVGC7qb0mHFVDHJmJljOWUYmyoPAcxOpGPVx6PGBXbexHM1xf/Mg0dRYNpnY X-Received: by 2002:a05:6808:138c:b0:3c1:adf2:3e15 with SMTP id c12-20020a056808138c00b003c1adf23e15mr2746508oiw.23.1709052285036; Tue, 27 Feb 2024 08:44:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709052285; cv=pass; d=google.com; s=arc-20160816; b=PPADB3GZbVvpf351EW2tGrynF278tsL4kPhQdSn8EHX8FRZAvwEJ0D9ACR0W5jT9Yf tpWKt602CnLj0V6V34JC12l4QfQmswBUVXuw8Dv1t4gSs3vOF9Mm5g0NLETiWjPz1i9W MyHIXTZaewfOwLmvyEBat42PisHuWvIb00SuF6JCj7B3qlCwP8/ZdC6QIiLsBiaINsJX Vu2CbJktEt/HUQTepwLhobFUQ/BFkeUf8QpQAgwilDUEd4lwZaOeJhfMVcMgU1XesIyK RarAVQafuiOHzEpBhhJvYa/4UD+VtnAsHyBxpPYUQuT4Je8VMZa/FWoQrbNegnLZY5aw I0GQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=2vLhphde7KiKM567H6JdrwgApp0exKrb3Gp/hXUliMc=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=prDtW7h6BuQtux0jza7V8nV02USvrYjpa41iM+pzeHEpmyMTTG27JusufeRvUiKHRn +2vETLI1rizBo643r28jgEknktR+TCZltoq/V7wM8a6X7ttpN5qci1AGc8r0iw+2bcdw dNtcGi30MdmRStHzDOu5IwCxybB0fg8e0hTqncOuQTnk17505ntw3dfEa0Svw645mH9Y dnhSTkZpyaAFXE6vhf3MpzAzZhcVSSM16my3jeGSLO9tT690Yi1H7i5mSLmF3jna41v2 bowvBdEZBb/RWW/mXSBtQmJ+GD0iHWOiWzm50MtPUS1ZXx0jQlTYUedyxDR9+EviOhSU LSvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ff4XqUJw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n129-20020a632787000000b005e43cb39729si5723376pgn.870.2024.02.27.08.44.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 08:44:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ff4XqUJw; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2174-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 02D452827AC for ; Tue, 27 Feb 2024 16:44:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BACA2511F; Tue, 27 Feb 2024 16:44:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ff4XqUJw" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED95F2C69D for ; Tue, 27 Feb 2024 16:44:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709052250; cv=none; b=NQN0ZtnUrGWPdRkBN7r/GpNIJc4Nyf1D+n9FX1uyvKNJgzF9Ihnzmb8Qucr7vGkqTwDQ3MtkoKEjcYk7HA+qvM+TW1y5dxQR0nztFiMUbr78robZFjyiN+/sd0iJvi0S9ZDz8itaPljMExA3xN7KCDDxYSW8fwfAp6vDc8sdZJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709052250; c=relaxed/simple; bh=ubKQJPV5hCvqV4OpR8OcKERTXKdBFJBog/T2TFvYut4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L6CIDphPEwtDBe6DoEzG+ORN/D33m8MRIExobHb3Cv6+E7nbVKtiBD+vZ5fTUzikV+ngjZLV4BZO0Qu9y60nS1uo6Z5wsR0wP1eiq80Z6qgkQTSP05VdMUiz6vWfWYl/mxP4TLXIbUJvtg4/Jm0EO88hUMbT/4/pB9tfIq86hMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ff4XqUJw; arc=none smtp.client-ip=209.85.217.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-47048ea1b17so543324137.0 for ; Tue, 27 Feb 2024 08:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709052246; x=1709657046; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2vLhphde7KiKM567H6JdrwgApp0exKrb3Gp/hXUliMc=; b=ff4XqUJwgolJeEaiDQWn8jGHqhT7cygOVK//UpLfuh8AOzs5D31iNWMQGK1hCzyz4b 1NJ1ZQQulefWJXxDcxWmG+i1HFgybsrcuLlgegPhQBvTRki2XPMcNxaPZVXm/a90kkC6 NCnHWRPtx6vbJ4SGpXfNB6ZbmWbNVwQurkPctJ4SIWRc6f0bT3yLltbtykP1rI9Rus54 jHXP9k9eiUZwciyxm/hGroPx0SfmQ5c+pLU9h4iqugMQCnjlLaMonTLnqwOjmV4LN2tX j9op+EF4djUatJZrhfjRPyTIUiftw/F3RUgoYdLKSD3wZBj/UxWcPN7KMtG9mX2CIzjX uiyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709052246; x=1709657046; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2vLhphde7KiKM567H6JdrwgApp0exKrb3Gp/hXUliMc=; b=TcDfFS1q2Uuxoz6B58YKKow9r345EQfX9zN+K9+GqliQIA7JEf21Qc3YdiHIdJbpHv Wd9fzPqf2TO2wumdZLROIg7dClNFwqHvbhrGEDPfO5gnjZjleV+FJNxjYIKxBUT61rvz 1XCikN9+QSdU6imZOQRAVmUU2JCy8YWkrMoZrNt20DQDReAZAMZrPss5Fl9mWiW9IrBD JUj4gmoQu+8fqzWMepaO9Ugh945mjTXDMxeyuO3enXSeLKtidQV+UJ6SS7wHwY8PFZTs f/TcRuEUhLpGBIPEWHbiD3Vg1F1A9TtdTzRUuZcI3jER1/Qfscj+7mPlrc05ccQJz+2t nY4Q== X-Gm-Message-State: AOJu0Yz/s70s0G/nJ+DOu2IVLBoMn/VwNmX03oWwdzbVMRari7NvSp4H jlY6grezdqWsGAaQfOh7qGoN4eBcZCI7JbSB73l1PwR1DAfPrqerwrWFNBoR X-Received: by 2002:a05:6102:55aa:b0:470:4a5f:684d with SMTP id dc42-20020a05610255aa00b004704a5f684dmr10516771vsb.29.1709052245898; Tue, 27 Feb 2024 08:44:05 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id j30-20020a0561023e1e00b0046d28239032sm1378126vsv.5.2024.02.27.08.44.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 08:44:05 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v1 2/2] device: Consider service state on device_is_connected Date: Tue, 27 Feb 2024 11:44:03 -0500 Message-ID: <20240227164403.1904213-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227164403.1904213-1-luiz.dentz@gmail.com> References: <20240227164403.1904213-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz This checks if there is any service connected on device_is_connected since some profiles maybe probed using advertising data which doesn't require a connection. --- src/device.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/device.c b/src/device.c index 1db96d9a672c..e5191cabe81a 100644 --- a/src/device.c +++ b/src/device.c @@ -3225,7 +3225,11 @@ uint8_t btd_device_get_bdaddr_type(struct btd_device *dev) bool btd_device_is_connected(struct btd_device *dev) { - return dev->bredr_state.connected || dev->le_state.connected; + if (dev->bredr_state.connected || dev->le_state.connected) + return true; + + return find_service_with_state(dev->services, + BTD_SERVICE_STATE_CONNECTED); } static void clear_temporary_timer(struct btd_device *dev) @@ -3276,6 +3280,13 @@ static bool device_disappeared(gpointer user_data) { struct btd_device *dev = user_data; + if (btd_device_is_connected(dev)) { + char addr[18]; + ba2str(&dev->bdaddr, addr); + DBG("Device %s is marked as connected", dev->path); + return TRUE; + } + /* If there are services connecting restart the timer to give more time * for the service to either complete the connection or disconnect. */ -- 2.43.0