~morphis/phablet-extras/ofono-sms-status-report

« back to all changes in this revision

Viewing changes to test/test-gnss

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-08-22 19:59:08 UTC
  • mfrom: (1.3.3) (6.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20120822195908-0bmmk1hlh989bgk6
Tags: 1.9-1ubuntu1
* Merge with Debian experimental; remaining changes:
  - debian/control: explicitly Conflicts with modemmanager: having both
    installed / running at the same time causes issues causes issues with
    both claiming modem devices.
  - debian/patches/02-dont-handle-stacktraces.patch: stop catching stacktraces
    and printing the information internally, so apport can catch and report
    the possible bugs.
  - debian/ofono.postinst: on configure, notify the user that a reboot is
    required (so ofono can get started by upstart). (LP: #600501)
  - debian/rules: pass --no-restart-on-upgrade so ofono isn't automatically
    restarted when upgrades.
  - Adding upstart config / Removing standard init script
  - Adding Apport support
  - Patch for recognizing special Huawei devices with weird serial
  - Override lintian to avoid script-in-etc-init.d... warnings.
  - Update debian/compat to 7
* debian/series: add our patches to debian/patches/series now that the package
  uses quilt.
* debian/patches/02-dont-handle-stacktraces.patch: refreshed.
* debian/ofono-dev.install, debian/ofono.install:
  - Install usr/sbin/dundee and ofono.pc to the proper packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import gobject
 
4
import sys
 
5
import os
 
6
 
 
7
import dbus
 
8
import dbus.service
 
9
import dbus.mainloop.glib
 
10
 
 
11
GNSS_INTERFACE = "org.ofono.AssistedSatelliteNavigation"
 
12
AGENT_INTERFACE = "org.ofono.PositioningRequestAgent"
 
13
 
 
14
class PositioningAgent(dbus.service.Object):
 
15
        @dbus.service.method(AGENT_INTERFACE,
 
16
                                        in_signature="", out_signature="")
 
17
        def Release(self):
 
18
                print "Release"
 
19
                mainloop.quit()
 
20
 
 
21
        @dbus.service.method(AGENT_INTERFACE,
 
22
                                        in_signature="s", out_signature="")
 
23
        def Request(self, xml):
 
24
                print "positioning data: %s" % (xml)
 
25
 
 
26
        @dbus.service.method(AGENT_INTERFACE,
 
27
                                        in_signature="", out_signature="")
 
28
        def ResetAssistanceData(self):
 
29
                print "Reset Assistance Data request received"
 
30
 
 
31
def print_menu():
 
32
        print "Select test case"
 
33
        print "-----------------------------------------------------------"
 
34
        print "[0] SendPositioningElement"
 
35
        print "[1] RegisterPositioningRequestAgent"
 
36
        print "[2] UnregisterPositioningRequestAgent"
 
37
        print "[x] Exit"
 
38
        print "-----------------------------------------------------------"
 
39
 
 
40
def stdin_handler(fd, condition, gnss, path):
 
41
        in_key = os.read(fd.fileno(), 8).rstrip()
 
42
        if in_key == '0':
 
43
                xml = raw_input('type the element and press enter: ')
 
44
                try:
 
45
                        gnss.SendPositioningElement(dbus.String(xml))
 
46
                        print "ok"
 
47
                except dbus.DBusException, e:
 
48
                        print "Unable to send positioning element"
 
49
 
 
50
        elif in_key == '1':
 
51
                try:
 
52
                        gnss.RegisterPositioningRequestAgent("/test/posagent")
 
53
                        print "ok"
 
54
                except dbus.DBusException, e:
 
55
                        print "Unable to register positioning agent"
 
56
 
 
57
        elif in_key == '2':
 
58
                try:
 
59
                        gnss.UnregisterPositioningRequestAgent(path)
 
60
                        print "ok"
 
61
                except dbus.DBusException, e:
 
62
                        print "Unable to unregister positioning agent"
 
63
        elif in_key == 'x':
 
64
                sys.exit(1)
 
65
 
 
66
        return True
 
67
 
 
68
if __name__ == "__main__":
 
69
        if len(sys.argv) < 1:
 
70
                sys.exit(1)
 
71
 
 
72
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
 
73
        bus = dbus.SystemBus()
 
74
        manager = dbus.Interface(bus.get_object('org.ofono', '/'),
 
75
                                                        'org.ofono.Manager')
 
76
 
 
77
        modems = manager.GetModems()
 
78
        for path, properties in modems:
 
79
                if GNSS_INTERFACE not in properties["Interfaces"]:
 
80
                        continue
 
81
 
 
82
                gnss = dbus.Interface(bus.get_object('org.ofono', path),
 
83
                                                GNSS_INTERFACE)
 
84
 
 
85
        path = "/test/posagent"
 
86
        agent = PositioningAgent(bus, path)
 
87
 
 
88
        print_menu()
 
89
 
 
90
        gobject.io_add_watch(sys.stdin, gobject.IO_IN, stdin_handler,
 
91
                                gnss, path)
 
92
        mainloop = gobject.MainLoop()
 
93
        mainloop.run()