Ver código fonte

bluetooth OnloadCb,RefreshDevices will block n secs if there is no bluez daemon

cuu 5 anos atrás
pai
commit
eeb0a616c3
1 arquivos alterados com 10 adições e 6 exclusões
  1. 10 6
      Menu/GameShell/10_Settings/Bluetooth/__init__.py

+ 10 - 6
Menu/GameShell/10_Settings/Bluetooth/__init__.py

@@ -544,12 +544,16 @@ class BluetoothPage(Page):
     def RefreshDevices(self):
         global devices
         devices = {}
-        proxy_obj = bus.get_object("org.bluez", "/")
-        manager = dbus.Interface(proxy_obj,"org.freedesktop.DBus.ObjectManager")
-        objects = manager.GetManagedObjects()
-        for path, interfaces in objects.iteritems():
-            if "org.bluez.Device1" in interfaces:
-                devices[path] = interfaces["org.bluez.Device1"] ## like /org/bluez/hci0/dev_xx_xx_xx_yy_yy_yy
+        try:
+            proxy_obj = bus.get_object("org.bluez", "/")
+            manager = dbus.Interface(proxy_obj,"org.freedesktop.DBus.ObjectManager")
+            objects = manager.GetManagedObjects()
+            for path, interfaces in objects.iteritems():
+                if "org.bluez.Device1" in interfaces:
+                    devices[path] = interfaces["org.bluez.Device1"] ## like /org/bluez/hci0/dev_xx_xx_xx_yy_yy_yy
+        except Exception,e:
+            print(str(e))
+            devices={}
         
         self._Devices = devices