pilot_drive.services.phone package
Submodules
pilot_drive.services.phone.abstract_manager module
The abstract manager used for phone connectivity
- class pilot_drive.services.phone.abstract_manager.AbstractManager
Bases:
ABCAbstract manager that to encourage proper implementation of Android/iOS devices
- abstract property device_name: str
Get the name of the connected device
- Returns:
the name of the connected device
- abstract property notifications: List[dict]
Get the list of aggregated notifications
- Returns:
a list of notifications collected by the manager
- abstract property state: PhoneStates
Return the state of the connected device
- Returns:
the current state of the phone via the PhoneState attribute
pilot_drive.services.phone.ancs_api module
The DBus APIs required by the IOS/ANCS manager
- class pilot_drive.services.phone.ancs_api.ANCSObserver
Bases:
PropertiesAPIType wrapper for the ANCS Observer service
- DismissNotification: dbus_signal
- abstract InvokeDeviceAction(device_handle: str, notification_id: UInt32, is_positive: bool)
Invoke an action on the ANCS device
- Parameters:
device_handle – the handle of the specified device
notification_id – the id of the intended notification action
is_positive – if the action is positive
- ShowNotification: dbus_signal
- classmethod connect(bus: MessageBus) ANCSObserver
Get a proxy for the ANCS Observer DBus object
- Returns:
an instance of BluezGattCharacteristic
- name = 'ancs4linux.Observer'
- path = '/'
pilot_drive.services.phone.android_manager module
Module for interfacing with ADB to pull in Android notifications
- exception pilot_drive.services.phone.android_manager.AdbCommandFailedException
Bases:
ExceptionRaised when an ADB command failed to execute
- exception pilot_drive.services.phone.android_manager.AdbDependenciesMissingException(missing_dep: str, return_str: str)
Bases:
ExceptionRaised when dependencies are missing (ie. ADB or AAPT2)
- exception pilot_drive.services.phone.android_manager.AdbFailedToFindPackageException
Bases:
ExceptionRaised when a package was not found
- exception pilot_drive.services.phone.android_manager.AdbFailedToGetDeviceNameException
Bases:
ExceptionRaised when the device name could not be retrieved
- class pilot_drive.services.phone.android_manager.AndroidManager(logger: MasterLogger)
Bases:
AbstractManagerThe ADB notification manager
- property device_name: str
Get the name of the connected ADB device
- Returns:
the name of the connected ADB device
- property notifications: list
Get the list of notifications that have been aggregated via ADB
- Returns:
the list of notifications pulled from ADB
- property state: PhoneStates
The state of the ADB device. Maps ADB to PILOT Drive phone states
- Returns:
PHONE_STATE object
pilot_drive.services.phone.constants module
Constants for the phone service
- class pilot_drive.services.phone.constants.AdbCommands(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnumThe commands that are used by ADB
- AAPT_DUMP_BADGING = 'aapt2 dump badging '
- AAPT_HELP = 'aapt2 -h'
- ADB = 'adb'
- ADB_DEVICE_NAME = 'adb shell dumpsys bluetooth_manager'
- ADB_DUMP_NOTIFICATIONS = 'adb shell dumpsys notification --noredact'
- ADB_GET_PACKAGE_PATH = 'adb shell pm path '
- ADB_GET_STATE = 'adb get-state'
- ADB_PULL_PACKAGE = 'adb pull '
- class pilot_drive.services.phone.constants.AdbNotificationAttributes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
EnumThe prefixes of the notification dump
- OP_PACKAGE = '^ {6}opPkg=(.\\S*)'
- TEXT = '^ {16}android.text=.*String \\((.*)\\)'
- TIME = '^ {6}mRankingTimeMs=([0-9]*)'
- TITLE = '^ {16}android.title=.*String \\((.*)\\)'
- UID = '^ {6}uid=(.\\S*)'
- class pilot_drive.services.phone.constants.AdbState(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
StrEnumThe different ADB responses to determine state
- ADB_BOOTLOADER = 'bootloader'
- ADB_DEVICE = 'device'
- ADB_NOT_CONNECTED = 'error: no devices/emulators found'
- ADB_NOT_TRUSTED = 'error: device unauthorized.'
- ADB_NO_PERMISSIONS = 'error: insufficient permissions for device'
- ADB_OFFLINE = 'offline'
- class pilot_drive.services.phone.constants.Notification(id: int, device: str, app_id: str, app_name: str, title: str, time: int, body: str | None = None)
Bases:
objectData class used to store a phone notification
- app_id: str
- app_name: str
- body: str | None = None
- device: str
- id: int
- time: int
- title: str
- class pilot_drive.services.phone.constants.PhoneContainer(enabled: bool, type: str | None = None, state: str | None = 'disconnected', notifications: ~typing.List[~pilot_drive.services.phone.constants.Notification] | None = <factory>)
Bases:
objectData class used to store phone info
- enabled: bool
- notifications: List[Notification] | None
- state: str | None = 'disconnected'
- type: str | None = None
- class pilot_drive.services.phone.constants.PhoneStates(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
EnumAll of the PILOT Drive phone states
- BLUETOOTH_DISABLED = 'bluetooth-disabled'
- CONNECTED = 'connected'
- DISCONNECTED = 'disconnected'
- LOCKED = 'locked'
- UNTRUSTED = 'untrusted'
pilot_drive.services.phone.exceptions module
The exceptions of the phone service
- exception pilot_drive.services.phone.exceptions.NoANCSDeviceConnectedException
Bases:
ExceptionRaised when a property of an ANCS device is requested that doesn’t exist
pilot_drive.services.phone.ios_manager module
The iOS notification manager for PILOT Drive phone notifications
- class pilot_drive.services.phone.ios_manager.IOSManager(logger: MasterLogger, bluetooth: Bluetooth)
Bases:
objectAbstract manager that to encourage proper implementation of Android/iOS devices
- device_added(device: BluetoothDevice) None
Callback utilized when a new interface is added
- Parameters:
path – DBus path to the new interface
interface – name of the interface that was added
- property device_name: str
Get the name of the connected device
- Returns:
the name of the connected device
- dismiss_notification(notification_id: int) None
Callback used when a notification is dismissed on the iOS device
- Parameters:
notification_id – integer indicating the notification ID to be dismissed
- interfaces_removed(path: ObjPath, interfaces: List[str]) None
Callback utilized when an interface is removed
- Parameters:
path – DBus path to the new interface
interface – list of names of interfaces that were removed
- property notifications: List[Notification]
Get the list of aggregated notifications
- Returns:
a list of notifications collected by the manager
- properties_changed(interface: str, changes: Dict[str, Variant], invalidated_properties: List[str]) None
Callback utilized when an interface’s properties change
- Parameters:
interface – names of interface that had a property change
changes – a dict of changes on the properties of the interface
invalidated_properties – a list of properties that were invalidated
- show_notification(notification_json: str) None
Callback used when a new notification is detected on the iOS device
- Parameters:
notification_json – JSON string passed by ANCS containing new notification
- property state: PhoneStates
Return the state of the connected ANCS device
- Returns:
the current state of the phone via the PhoneState attribute
pilot_drive.services.phone.phone module
The module that handles the phone connectivity to PILOT Drive
- exception pilot_drive.services.phone.phone.FailedToReadSettingsException
Bases:
ExceptionRaised when the settings have failed to be read
- exception pilot_drive.services.phone.phone.NoPhoneManagerException
Bases:
ExceptionRaised when no phone manager is instantiated
- class pilot_drive.services.phone.phone.Phone(master_event_queue: MasterEventQueue, service_type: EventType, logger: MasterLogger, settings: Settings)
Bases:
AbstractServiceThe phone service that interfaces with the (Android/iOS) connected device
- property enabled: bool
Checks if phone notifications are enabled & properly typed.
- Returns:
a boolean of whether the phone is enabled
- main()
runs servce main loop and logic
- notifications_match(notif_list1: List[Notification], notif_list2: List[Notification]) bool
Check if two notification lists are equal
- Parameters:
notif_list1 – the first list of notifications
notif_list2 – the second list of notifications
- Returns:
a boolean whether the two lists match
- push_to_queue(event: dict, event_type: dict = None)
Push a new event to the master queue.
- Parameters:
event – the dict that will be converted to json & passed to the queue, and in turn to the UI.
event_type – the event type that will go on the queue. If no argument is specified, it defaults to the calling services type
- refresh()
Add any stored events back to the event queue, as this will be called in a client refresh.
- property state: PhoneStates
Get the phone state
- Returns:
the current phone state from PhoneStates
Module contents
The module that manages the connected phone