OSDN Git Service

test: Add RequestDisconnection support to test-hfp
authorJohan Hedberg <johan.hedberg@intel.com>
Mon, 26 Nov 2012 14:59:34 +0000 (16:59 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 26 Nov 2012 14:59:34 +0000 (16:59 +0200)
test/test-hfp

index 1abd11e..38da076 100755 (executable)
@@ -61,6 +61,13 @@ class HfpConnection:
        features = 0
        pending = None
 
+       def disconnect(self):
+               if (self.fd >= 0):
+                       os.close(self.fd)
+                       self.fd = -1
+                       glib.source_remove(self.io_id)
+                       self.io_id = 0
+
        def slc_completed(self):
                print("SLC establisment complete")
                self.slc_complete = True
@@ -164,6 +171,12 @@ class HfpProfile(dbus.service.Object):
                print("Cancel")
 
        @dbus.service.method("org.bluez.Profile1",
+                               in_signature="o", out_signature="")
+       def RequestDisconnection(self, path):
+               conn = self.conns.pop(path)
+               conn.disconnect()
+
+       @dbus.service.method("org.bluez.Profile1",
                                in_signature="oha{sv}", out_signature="")
        def NewConnection(self, path, fd, properties):
                fd = fd.take()