feat: Reject HFP connections to disable phone calls
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
9
main.py
9
main.py
@@ -13,6 +13,7 @@ from aiomqtt import Client
|
|||||||
from dbus_next.aio import MessageBus
|
from dbus_next.aio import MessageBus
|
||||||
from dbus_next.service import ServiceInterface, method
|
from dbus_next.service import ServiceInterface, method
|
||||||
from dbus_next.constants import BusType
|
from dbus_next.constants import BusType
|
||||||
|
from dbus_next.errors import DBusError
|
||||||
from dbus_next import Variant
|
from dbus_next import Variant
|
||||||
|
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ AGENT_IFACE = 'org.bluez.Agent1'
|
|||||||
AGENT_MANAGER_IFACE = 'org.bluez.AgentManager1'
|
AGENT_MANAGER_IFACE = 'org.bluez.AgentManager1'
|
||||||
AGENT_PATH = '/io/bluetooth_speaker/agent'
|
AGENT_PATH = '/io/bluetooth_speaker/agent'
|
||||||
CAPABILITY = 'DisplayYesNo'
|
CAPABILITY = 'DisplayYesNo'
|
||||||
|
HFP_UUID = '0000111e-0000-1000-8000-00805f9b34fb'
|
||||||
|
|
||||||
class Agent(ServiceInterface):
|
class Agent(ServiceInterface):
|
||||||
def __init__(self, interface_name):
|
def __init__(self, interface_name):
|
||||||
@@ -69,8 +71,11 @@ class Agent(ServiceInterface):
|
|||||||
|
|
||||||
@method()
|
@method()
|
||||||
def AuthorizeService(self, device: 'o', uuid: 's'):
|
def AuthorizeService(self, device: 'o', uuid: 's'):
|
||||||
logging.info(f"AuthorizeService for {device} with uuid {uuid}")
|
logging.info(f"AuthorizeService request for device {device} with UUID {uuid}")
|
||||||
pass
|
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()
|
@method()
|
||||||
def Cancel(self):
|
def Cancel(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user