-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
85 lines (62 loc) · 1.92 KB
/
Copy pathmain.py
File metadata and controls
85 lines (62 loc) · 1.92 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
78
79
80
81
82
83
84
85
import json
from flask import Flask, make_response
from flask.json import jsonify
from flask_cors import CORS
from adbm import ADB_Modules
from fps import FPS
from cpu import CPU
from memory import Memory
from utils import Utils
app = Flask(__name__)
CORS(app)
@app.route("/")
def hello():
return jsonify({'text': 'Hello World'})
@app.route('/fps/<package_name>', methods=['GET', 'POST'])
def getfps(package_name):
fps = FPS(package_name=package_name, duration=60, dumpfile="text",
print_latency=False, require_full_name=True)
frames = fps._get_recent_frames()
if not fps.error:
if len(frames) < 3:
return
total = len(frames) - 1
dt = (frames[-1].vsync - frames[0].vsync) / 1000000000
avg = total / dt
return jsonify(str(avg))
else:
return fps.error
@app.route('/cpu/<package_name>', methods=['GET', 'POST'])
def getcpu(package_name):
cpu = CPU(package_id=package_name)
output = cpu._web_gather_cpu_usage()
return output
@app.route('/mem/<package_name>', methods=['GET', 'POST'])
def getmem(package_name):
mem = Memory(package_name=package_name, require_full_name=False)
output = mem._web_gather_mem_usage()
return output
@app.route('/checkadb', methods=['GET'])
def checkADB():
mod = ADB_Modules()
return mod.verifyAdb()
@app.route('/getdevices', methods=['GET'])
def getDevices():
mod = ADB_Modules()
return mod.showDevices()
@app.route('/getdeviceprop', methods=['GET'])
def getDeviceProp():
mod = ADB_Modules()
return mod.get_device_info()
@app.route("/setpackage")
def set_package_name():
return "hello"
@app.route("/getpackage")
def get_package_name():
return "hello"
@app.route("/packages/<package_name>", methods=['POST'])
def validate_package_name(package_name):
utils = Utils()
return utils._validate_package_name(package_name)
if __name__ == "__main__":
app.run(port=5002)