From c3c2fc794cb2159cf36532c8a639853745734b0f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 30 Dec 2025 21:42:02 +0000 Subject: [PATCH] feat: Reject HFP connections to disable phone calls Co-authored-by: aider (gemini/gemini-2.5-pro) --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 9fa6dca..b2e0f28 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,7 @@ from aiomqtt import Client from dbus_next.aio import MessageBus from dbus_next.service import ServiceInterface, method from dbus_next.constants import BusType +from dbus_next.errors import DBusError from dbus_next import Variant @@ -27,6 +28,7 @@ AGENT_IFACE = 'org.bluez.Agent1' AGENT_MANAGER_IFACE = 'org.bluez.AgentManager1' AGENT_PATH = '/io/bluetooth_speaker/agent' CAPABILITY = 'DisplayYesNo' +HFP_UUID = '0000111e-0000-1000-8000-00805f9b34fb' class Agent(ServiceInterface): def __init__(self, interface_name): @@ -69,8 +71,11 @@ class Agent(ServiceInterface): @method() def AuthorizeService(self, device: 'o', uuid: 's'): - logging.info(f"AuthorizeService for {device} with uuid {uuid}") - pass + logging.info(f"AuthorizeService request for device {device} with UUID {uuid}") + if uuid.lower() == HFP_UUID: + logging.warning("Rejecting Hands-Free Profile (HFP) connection.") + raise DBusError('org.bluez.Error.Rejected', 'HFP profile not supported') + logging.info(f"Authorizing service UUID {uuid}") @method() def Cancel(self):