-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathandroidstuff.py
91 lines (67 loc) · 2.19 KB
/
androidstuff.py
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
88
89
90
91
"""DOCSTRING."""
import sys
import socket
import android
import androidhelper
class Connection():
def Transfer(smsdata):
"""DOCSTRING."""
host = input("Host IP: ")
port = input("Port: ")
mySocket = socket.socket()
mySocket.connect((host, port))
message = smsdata
mySocket.send(message.encode())
data = mySocket.recv(1024).decode()
print('Received from server: ' + data)
mySocket.close()
class Search:
"""DOCSTRING."""
@staticmethod
def view_all():
"""DOCSTRING."""
for message in SMSmsgs:
smsdata = "{}: {}".format(message['address'], message['body'])
Connection.Transfer(smsdata)
@staticmethod
def view_by_address():
"""DOCSTRING."""
user_requested_address = input("Enter Number: ")
for message in SMSmsgs:
if message['address'] == user_requested_address:
smsdata = "{}: {}".format(message['address'], message['body'])
Connection.Transfer(smsdata)
else:
print("Not found")
@staticmethod
def view_by_string():
"""DOCSTRING."""
user_requested_string = input("Enter Search String: ")
for message in SMSmsgs:
if user_requested_string in message['body']:
smsdata = "{}: {}".format(message['address'], message['body'])
Connection.Transfer(smsdata)
else:
print("Not found")
class Requests:
"""DOCSTRING."""
@staticmethod
def decision():
"""DOCSTRING."""
print("""1. View All\n2. View Specific\n""")
user_decision = int(input("Enter Selection: "))
if user_decision == 1:
Search.view_all()
elif user_decision == 2:
print("""1. By Number\n2. By String\n""")
search_decision = int(input("Enter Selection: "))
if search_decision == 1:
Search.view_by_address()
elif search_decision == 2:
Search.view_by_string()
def start():
"""DOCSTRING."""
Requests.decision()
droid = android.Android()
SMSmsgs = droid.smsGetMessages(False, 'inbox').result
start()