/usr/share/ofono/scripts/test-advice-of-charge is in ofono-scripts 1.12.bzr6858+14.04.20140318-0ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #!/usr/bin/python
from gi.repository import GLib
import sys
import dbus
import dbus.mainloop.glib
def cm_property_changed(name, value):
print("CallMeter property: '%s' changed to '%s'" % (name, str(value)))
if canexit:
mainloop.quit()
def cm_maximum_reached():
print("Only 30 seconds call time remains, recharge.")
def print_useage(s):
print("Usage: %s <property> <newvalue> <password>" % (s))
print("Usage: %s reset <password>" % (s))
sys.exit(1);
if __name__ == "__main__":
if len(sys.argv) != 3 and len(sys.argv) != 4:
print_useage(sys.argv[0])
if (sys.argv[1] == 'reset'):
pin = sys.argv[2]
else:
if (len(sys.argv) != 4):
print_useage(sys.argv[0])
property = sys.argv[1]
newvalue = sys.argv[2]
pin = sys.argv[3]
canexit = False
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
'org.ofono.Manager')
modems = manager.GetModems()
cm = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
'org.ofono.CallMeter')
cm.connect_to_signal("PropertyChanged", cm_property_changed)
cm.connect_to_signal("NearMaximumWarning", cm_maximum_reached)
properties = cm.GetProperties()
print("Currency: %s" % (properties['Currency']))
print("PricePerUnit %s" % (properties['PricePerUnit']))
print("Call meter for the current call: %s" % (properties['CallMeter']))
print("Call meter for current and previous calls: %s" %\
properties['AccumulatedCallMeter'])
print("Call meter maximum, once reached calls are not possible: %s" %\
properties['AccumulatedCallMeterMaximum'])
total = properties['PricePerUnit'] * properties['AccumulatedCallMeter']
print("Accumulated Meter in Currency: %s %s" %\
(total, properties['Currency']))
if (sys.argv[1] == 'reset'):
print("Resetting Accumulated Call Meter")
try:
cm.Reset(pin)
except dbus.DBusException as e:
print("Unable to reset ACM: %s" % e)
sys.exit(1)
else:
try:
if property == 'AccumulatedCallMeterMaximum':
newvalue = dbus.UInt32(newvalue)
elif property == 'PricePerUnit':
newvalue = float(newvalue)
cm.SetProperty(property, newvalue, pin)
except dbus.DBusException as e:
print("Unable to set property: %s" % e)
sys.exit(1)
canexit = True
mainloop = GLib.MainLoop()
mainloop.run()
|