mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 09:39: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:
parent
85259bb519
commit
ad97dbee08
@ -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,11 +46,13 @@ class Ofono(dbus.service.Object):
|
|||||||
self._wait_timed_out = True
|
self._wait_timed_out = True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
|
try:
|
||||||
context = mainloop.get_context()
|
timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
|
||||||
while (not self._sim_auth_up):
|
context = mainloop.get_context()
|
||||||
context.iteration(may_block=True)
|
while (not self._sim_auth_up):
|
||||||
if self._wait_timed_out:
|
context.iteration(may_block=True)
|
||||||
raise TimeoutError('waiting for SimAuthentication timed out')
|
if self._wait_timed_out:
|
||||||
|
raise TimeoutError('waiting for SimAuthentication timed out')
|
||||||
|
|
||||||
GLib.source_remove(timeout)
|
finally:
|
||||||
|
GLib.source_remove(timeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user