Add test scripts to to lock and unlock pin
authorKalle Valo <kalle.valo@canonical.com>
Mon, 9 Aug 2010 14:22:31 +0000 (17:22 +0300)
committerDenis Kenzior <denkenz@gmail.com>
Mon, 9 Aug 2010 14:24:15 +0000 (09:24 -0500)
Makefile.am
test/lock-pin [new file with mode: 0755]
test/unlock-pin [new file with mode: 0755]

index 8d1d2c2..38210e2 100644 (file)
@@ -344,7 +344,9 @@ test_scripts = test/activate-context \
                test/set-use-sms-reports \
                test/set-cbs-topics \
                test/enable-cbs \
-               test/propose-scan
+               test/propose-scan \
+               test/lock-pin \
+               test/unlock-pin
 
 if TEST
 testdir = $(pkglibdir)/test
diff --git a/test/lock-pin b/test/lock-pin
new file mode 100755 (executable)
index 0000000..a0b6e30
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 4:
+       path = sys.argv[1]
+       pin_type = sys.argv[2]
+       pin = sys.argv[3]
+elif len(sys.argv) == 3:
+       manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+                                'org.ofono.Manager')
+       properties = manager.GetProperties()
+       path = properties["Modems"][0]
+       pin_type = sys.argv[1]
+       pin = sys.argv[2]
+else:
+       print "%s [PATH] pin_type pin" % (sys.argv[0])
+       sys.exit(0)
+
+print "Lock %s %s for modem %s..." % (pin_type, pin, path)
+
+simmanager = dbus.Interface(bus.get_object('org.ofono', path),
+                           'org.ofono.SimManager')
+simmanager.LockPin(pin_type, pin)
diff --git a/test/unlock-pin b/test/unlock-pin
new file mode 100755 (executable)
index 0000000..4a05cd4
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+
+import dbus
+import sys
+
+bus = dbus.SystemBus()
+
+if len(sys.argv) == 4:
+       path = sys.argv[1]
+       pin_type = sys.argv[2]
+       pin = sys.argv[3]
+elif len(sys.argv) == 3:
+       manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+                                'org.ofono.Manager')
+       properties = manager.GetProperties()
+       path = properties["Modems"][0]
+       pin_type = sys.argv[1]
+       pin = sys.argv[2]
+else:
+       print "%s [PATH] pin_type pin" % (sys.argv[0])
+       sys.exit(0)
+
+print "Unlock %s %s for modem %s..." % (pin_type, pin, path)
+
+simmanager = dbus.Interface(bus.get_object('org.ofono', path),
+                           'org.ofono.SimManager')
+simmanager.UnlockPin(pin_type, pin)