-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhoneDataExport.py
More file actions
77 lines (68 loc) · 2.16 KB
/
PhoneDataExport.py
File metadata and controls
77 lines (68 loc) · 2.16 KB
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
#!/usr/bin/python3
import dbus
import time
import json
bus = dbus.SystemBus()
phone_data =''
def main():
global phone_data
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
'org.ofono.Manager')
modems = manager.GetModems()
for path, properties in modems:
# print("[ %s ]" % (path))
# print(path)
json_properties = json.dumps(properties)
json_data = json.loads(json_properties)
# print(json_data)
Name = json_data.get('Name')
Type = json_data.get('Type')
Online = json_data.get('Online')
Serial = json_data.get('Serial')
# print(Name)
# print(Online)
# print(Type)
# print(Serial)
# if (Online == 0) and (Type == "hardware"):
# print("Wrong modem")
if (Online == 0) and (Type == "hfp"):
State = "Not connected"
Number = "Not connected"
StartTime = "Not connected"
Path = "Not connected"
Phone = "Not connected"
Serial= "Not connected"
phone_data = {'Phone': Phone, 'Serial': Serial, 'State': State, 'Number': Number, 'StartTime': StartTime, 'Path': Path}
# print(Name)
# print(Type)
# print(Online)
# print(Serial)
if (Online == 1) and (Type == "hfp"):
Phone = Name
if "org.ofono.VoiceCallManager" not in properties["Interfaces"]:
continue
mgr = dbus.Interface(bus.get_object('org.ofono', path),
'org.ofono.VoiceCallManager')
try:
calls = mgr.GetCalls()
#print("Call Data")
json_properties_call = json.dumps(calls)
#print(json_properties_calls)
path = json_properties_call.split('"', 1)[1].split('"', 1)[0]
#print(json_properties_path)
json_properties_call = json_properties_call.split(",", 1)[1].split("}", 1)[0]
json_properties_call = str(json_properties_call + "}")
json_data_call = json.loads(json_properties_call)
State = json_data_call.get('State')
Number = json_data_call.get('LineIdentification')
StartTime = json_data_call.get('StartTime')
Path = path
except:
State = "No active calls"
Number = " "
StartTime = " "
Path = " "
phone_data = {'Phone': Phone, 'Serial': Serial, 'State': State, 'Number': Number, 'StartTime': StartTime, 'Path': Path}
#print(phone_data)
if __name__ == '__main__':
main()