mirror of
				https://git.kernel.org/pub/scm/network/wireless/iwd.git
				synced 2025-11-04 08:57:29 +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 time
 | 
			
		||||
from gi.repository import GLib
 | 
			
		||||
 | 
			
		||||
SIM_AUTH_IFACE = 'org.ofono.SimAuthentication'
 | 
			
		||||
@ -7,6 +8,14 @@ class Ofono(dbus.service.Object):
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        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):
 | 
			
		||||
        self._modem_path = path
 | 
			
		||||
        self._modem_iface = dbus.Interface(
 | 
			
		||||
@ -37,11 +46,13 @@ class Ofono(dbus.service.Object):
 | 
			
		||||
            self._wait_timed_out = True
 | 
			
		||||
            return False
 | 
			
		||||
 | 
			
		||||
        timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
 | 
			
		||||
        context = mainloop.get_context()
 | 
			
		||||
        while (not self._sim_auth_up):
 | 
			
		||||
            context.iteration(may_block=True)
 | 
			
		||||
            if self._wait_timed_out:
 | 
			
		||||
                raise TimeoutError('waiting for SimAuthentication timed out')
 | 
			
		||||
        try:
 | 
			
		||||
            timeout = GLib.timeout_add_seconds(max_wait, wait_timeout_cb)
 | 
			
		||||
            context = mainloop.get_context()
 | 
			
		||||
            while (not self._sim_auth_up):
 | 
			
		||||
                context.iteration(may_block=True)
 | 
			
		||||
                if self._wait_timed_out:
 | 
			
		||||
                    raise TimeoutError('waiting for SimAuthentication timed out')
 | 
			
		||||
 | 
			
		||||
        GLib.source_remove(timeout)
 | 
			
		||||
        finally:
 | 
			
		||||
            GLib.source_remove(timeout)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user