3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

auto-t: ofono.py: fix timeout cleanup and wait for service

Ofono.py was not cleaning up the timeout, nor waiting for the ofono.org
service to come up before continuing.
This commit is contained in:
James Prestwood 2020-09-10 16:12:26 -07:00 committed by Denis Kenzior
parent 85259bb519
commit ad97dbee08

View File

@ -1,4 +1,5 @@
import dbus import dbus
import time
from gi.repository import GLib from gi.repository import GLib
SIM_AUTH_IFACE = 'org.ofono.SimAuthentication' SIM_AUTH_IFACE = 'org.ofono.SimAuthentication'
@ -7,6 +8,14 @@ class Ofono(dbus.service.Object):
def __init__(self): def __init__(self):
self._bus = dbus.SystemBus() self._bus = dbus.SystemBus()
tries = 0
while not self._bus.name_has_owner('org.ofono'):
if tries > 100:
raise TimeoutError('Waiting for org.ofono service timed out')
tries += 1
time.sleep(0.1)
def enable_modem(self, path): def enable_modem(self, path):
self._modem_path = path self._modem_path = path
self._modem_iface = dbus.Interface( self._modem_iface = dbus.Interface(
@ -37,6 +46,7 @@ class Ofono(dbus.service.Object):
self._wait_timed_out = True self._wait_timed_out = True
return False return False
try:
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb) timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
context = mainloop.get_context() context = mainloop.get_context()
while (not self._sim_auth_up): while (not self._sim_auth_up):
@ -44,4 +54,5 @@ class Ofono(dbus.service.Object):
if self._wait_timed_out: if self._wait_timed_out:
raise TimeoutError('waiting for SimAuthentication timed out') raise TimeoutError('waiting for SimAuthentication timed out')
finally:
GLib.source_remove(timeout) GLib.source_remove(timeout)