manafa 0.2.7__tar.gz → 0.2.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/emanafa.py +33 -11
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/services/perfettoService.py +1 -1
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/utils/Utils.py +4 -2
- Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa/utils/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa-0.2.9-py3.8.egg-info}/PKG-INFO +1 -1
- {manafa-0.2.7/manafa.egg-info → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa-0.2.9-py3.8.egg-info}/SOURCES.txt +0 -2
- manafa-0.2.7/MANIFEST.in +0 -4
- manafa-0.2.7/README.md +0 -86
- manafa-0.2.7/manafa/resources/apktool_2.4.0.jar +0 -0
- manafa-0.2.7/manafa/results/batterystats/__init__.py +0 -1
- manafa-0.2.7/manafa/results/perfetto/__init__.py +0 -1
- manafa-0.2.7/manafa.egg-info/PKG-INFO +0 -104
- manafa-0.2.7/notes.txt +0 -24
- manafa-0.2.7/requirements.txt +0 -4
- manafa-0.2.7/setup.cfg +0 -4
- manafa-0.2.7/setup.py +0 -51
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/batteryStats/BatteryStatsConstants.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/batteryStats/BatteryStatsParser.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/batteryStats/BatteryStatus.json +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/batteryStats/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/perfetto/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/perfetto/perfettoParser.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/powerProfile/PowerProfile.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/powerProfile/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/resources/__init__.py +0 -0
- /manafa-0.2.7/manafa/services/__init__.py → /Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa/resources/apktool_2.4.0.jar +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/resources/profiles/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/resources/record_android_trace +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/resources/traceconv +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/results/__init__.py +0 -0
- {manafa-0.2.7/manafa/tests → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa/services}/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/services/batteryStatsService.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/services/service.py +0 -0
- {manafa-0.2.7/manafa/tests/batterystats → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa/tests}/__init__.py +0 -0
- {manafa-0.2.7/manafa/tests/perfetto → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa/tests/batterystats}/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/tests/batterystats/test_batteryStatsService.py +0 -0
- {manafa-0.2.7/manafa/utils → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa/tests/perfetto}/__init__.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/tests/perfetto/test_perfettoService.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/utils/Logger.py +0 -0
- {manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/utils/dateUtils.py +0 -0
- {manafa-0.2.7/manafa.egg-info → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa-0.2.9-py3.8.egg-info}/dependency_links.txt +0 -0
- {manafa-0.2.7/manafa.egg-info → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa-0.2.9-py3.8.egg-info}/requires.txt +0 -0
- {manafa-0.2.7/manafa.egg-info → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages/manafa-0.2.9-py3.8.egg-info}/top_level.txt +0 -0
{manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/emanafa.py
RENAMED
|
@@ -38,7 +38,7 @@ def is_float(string):
|
|
|
38
38
|
|
|
39
39
|
class EManafa(Service):
|
|
40
40
|
"""docstring for GreenStats"""
|
|
41
|
-
def __init__(self, power_profile=None, timezone=None, resources_dir=
|
|
41
|
+
def __init__(self, power_profile=None, timezone=None, resources_dir=MANAFA_RESOURCES_DIR):
|
|
42
42
|
Service.__init__(self)
|
|
43
43
|
self.resources_dir = resources_dir
|
|
44
44
|
self.power_profile = power_profile if power_profile is not None else self.inferPowerProfile()
|
|
@@ -48,6 +48,7 @@ class EManafa(Service):
|
|
|
48
48
|
self.perf_events = None
|
|
49
49
|
self.perfetto = PerfettoService()
|
|
50
50
|
self.timezone = timezone if timezone is not None else self.__inferTimezone()
|
|
51
|
+
self.unplugged=False
|
|
51
52
|
|
|
52
53
|
def config(self, **kwargs):
|
|
53
54
|
pass
|
|
@@ -56,6 +57,7 @@ class EManafa(Service):
|
|
|
56
57
|
self.boot_time = get_last_boot_time()
|
|
57
58
|
self.batterystats.init(boot_time=self.boot_time)
|
|
58
59
|
self.perfetto.init(boot_time=self.boot_time)
|
|
60
|
+
self.__unplug_if_fully_charged()
|
|
59
61
|
|
|
60
62
|
def start(self):
|
|
61
63
|
self.batterystats.start()
|
|
@@ -64,6 +66,8 @@ class EManafa(Service):
|
|
|
64
66
|
def stop(self):
|
|
65
67
|
b_out = self.batterystats.stop()
|
|
66
68
|
p_out = self.perfetto.stop()
|
|
69
|
+
if self.unplugged:
|
|
70
|
+
self.__plug_back()
|
|
67
71
|
return b_out, p_out
|
|
68
72
|
|
|
69
73
|
def clean(self):
|
|
@@ -165,16 +169,16 @@ class EManafa(Service):
|
|
|
165
169
|
return lasti,lasti
|
|
166
170
|
|
|
167
171
|
|
|
168
|
-
def __extractPowerProfile(self,
|
|
172
|
+
def __extractPowerProfile(self, filename):
|
|
169
173
|
# extracting power_profile.xml from device
|
|
170
|
-
res, suc, _ = execute_shell_command("adb pull /system/framework/framework-res.apk %s" % resources_dir)
|
|
174
|
+
res, suc, _ = execute_shell_command("adb pull /system/framework/framework-res.apk %s" % self.resources_dir)
|
|
171
175
|
if res==0:
|
|
172
|
-
cmd = """java -jar {res_dir}/apktool_2.4.0.jar d -s {res_dir}/framework-res.apk -o {res_dir}/out_jar_dir/""".format(res_dir=resources_dir)
|
|
173
|
-
res, suc,
|
|
174
|
-
pp_file = resources_dir + "/out_jar_dir/res/xml/power_profile.xml"
|
|
176
|
+
cmd = """java -jar {res_dir}/apktool_2.4.0.jar d -s {res_dir}/framework-res.apk -f -o {res_dir}/out_jar_dir/""".format(res_dir=self.resources_dir)
|
|
177
|
+
res, suc, v = execute_shell_command(cmd)
|
|
178
|
+
pp_file = self.resources_dir + "/out_jar_dir/res/xml/power_profile.xml"
|
|
175
179
|
if res==0:
|
|
176
180
|
# cp to profiles, remove out_jar_dir and framework-res.apk
|
|
177
|
-
res,_,_= execute_shell_command("cp {extracted_file} \"{res_dir}/profiles/{new_file}\" ; rm -rf {res_dir}/out_jar_dir {res_dir}/framework-res.apk".format(extracted_file=pp_file, new_file=filename, res_dir=resources_dir ))
|
|
181
|
+
res,_,_= execute_shell_command("cp {extracted_file} \"{res_dir}/profiles/{new_file}\" ; rm -rf {res_dir}/out_jar_dir {res_dir}/framework-res.apk".format(extracted_file=pp_file, new_file=filename, res_dir=self.resources_dir ))
|
|
178
182
|
if res ==0:
|
|
179
183
|
return filename
|
|
180
184
|
|
|
@@ -189,7 +193,8 @@ class EManafa(Service):
|
|
|
189
193
|
return matching_profiles[0]
|
|
190
194
|
else:
|
|
191
195
|
# if power profile not present in profiles directory, extract from device
|
|
192
|
-
power_profile = self.__extractPowerProfile(
|
|
196
|
+
power_profile = self.__extractPowerProfile( model_profile_file)
|
|
197
|
+
print(power_profile)
|
|
193
198
|
return power_profile
|
|
194
199
|
else:
|
|
195
200
|
return DEFAULT_PROFILE
|
|
@@ -202,6 +207,25 @@ class EManafa(Service):
|
|
|
202
207
|
log("Using timezone: %s" % default_tz)
|
|
203
208
|
return "UTC" if default_tz == "WEST" else default_tz
|
|
204
209
|
|
|
210
|
+
def __unplug_if_fully_charged(self):
|
|
211
|
+
# battery stats file comes empty when battery level == 100
|
|
212
|
+
# using adb to trick device to think it is not charging th battery
|
|
213
|
+
res, o, e = execute_shell_command("adb shell dumpsys battery | grep level | grep 100")
|
|
214
|
+
has_full_charge = res ==0 and "100" in o
|
|
215
|
+
if has_full_charge:
|
|
216
|
+
#mock unplug
|
|
217
|
+
res, o, e = execute_shell_command("adb shell dumpsys battery unplug")
|
|
218
|
+
if res == 0:
|
|
219
|
+
self.unplugged=True
|
|
220
|
+
log("virtually unplugging battery charger while running (battery == 100)", LogSeverity.WARNING)
|
|
221
|
+
|
|
222
|
+
def __plug_back(self):
|
|
223
|
+
res, o, e = execute_shell_command("adb shell dumpsys battery reset")
|
|
224
|
+
self.unplugged=False
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
205
229
|
|
|
206
230
|
def have_connected_devices():
|
|
207
231
|
res,o,e = execute_shell_command("adb devices -l | grep -v attached")
|
|
@@ -209,20 +233,18 @@ def have_connected_devices():
|
|
|
209
233
|
|
|
210
234
|
|
|
211
235
|
if __name__ == '__main__':
|
|
212
|
-
default_resources_dir = "resources"
|
|
213
236
|
parser = argparse.ArgumentParser()
|
|
214
237
|
parser.add_argument("-p", "--profile", default=None, type=str)
|
|
215
238
|
parser.add_argument("-t", "--timezone", default=None, type=str)
|
|
216
239
|
parser.add_argument("-pft", "--perfettofile", default=None, type=str)
|
|
217
240
|
parser.add_argument("-bts", "--batstatsfile", default=None, type=str)
|
|
218
241
|
args = parser.parse_args()
|
|
219
|
-
|
|
220
242
|
has_device_conn = have_connected_devices()
|
|
221
243
|
invalid_file_args = (args.perfettofile is None or args.batstatsfile is None )
|
|
222
244
|
if not has_device_conn and invalid_file_args:
|
|
223
245
|
log("Fatal error. No connected devices and result files submittted for analysis", LogSeverity.FATAL)
|
|
224
246
|
exit(-1)
|
|
225
|
-
g = EManafa(power_profile=args.profile, timezone=args.timezone, resources_dir=
|
|
247
|
+
g = EManafa(power_profile=args.profile, timezone=args.timezone, resources_dir=MANAFA_RESOURCES_DIR)
|
|
226
248
|
if has_device_conn and invalid_file_args:
|
|
227
249
|
g.init()
|
|
228
250
|
g.start()
|
|
@@ -37,7 +37,7 @@ class PerfettoService(Service):
|
|
|
37
37
|
def export(self):
|
|
38
38
|
last_exported = ""
|
|
39
39
|
for f in os.listdir(self.results_dir):
|
|
40
|
-
execute_shell_command("%s/traceconv systrace %s/%s %s/%s.systrace" %(RESOURCES_DIR,self.results_dir,f,self.results_dir,f) )
|
|
40
|
+
res, o, e = execute_shell_command("chmod +x %s/traceconv ; %s/traceconv systrace %s/%s %s/%s.systrace" %(RESOURCES_DIR,RESOURCES_DIR,self.results_dir,f,self.results_dir,f) )
|
|
41
41
|
last_exported = "%s/%s.systrace" %(self.results_dir,f)
|
|
42
42
|
return last_exported
|
|
43
43
|
|
{manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/utils/Utils.py
RENAMED
|
@@ -2,13 +2,15 @@ import sysconfig
|
|
|
2
2
|
from subprocess import Popen, PIPE
|
|
3
3
|
from textops import find
|
|
4
4
|
|
|
5
|
-
DEV=
|
|
5
|
+
DEV=True
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
def get_resources_dir(packname="manafa", default_res_dir="resources"):
|
|
8
9
|
if DEV:
|
|
9
10
|
return packname + "/" + default_res_dir
|
|
10
11
|
return sysconfig.get_path("purelib") + "/" + packname + "/" + default_res_dir
|
|
11
12
|
|
|
13
|
+
|
|
12
14
|
def get_pack_dir(packname="manafa"):
|
|
13
15
|
if DEV:
|
|
14
16
|
return packname
|
|
@@ -30,6 +32,6 @@ def execute_shell_command(cmd, args=[]):
|
|
|
30
32
|
|
|
31
33
|
def mega_find(basedir, pattern="*", maxdepth=999, mindepth=0, type_file='n'):
|
|
32
34
|
basedir_len = len(basedir.split("/"))
|
|
33
|
-
res = find(basedir, pattern=pattern, only_files=type_file=='f',only_dirs=type_file=='d' )
|
|
35
|
+
res = find(basedir, pattern=pattern, only_files=type_file=='f', only_dirs=type_file=='d' )
|
|
34
36
|
# filter by depth
|
|
35
37
|
return list( filter(lambda x : len(x.split("/")) >= basedir_len + mindepth and len(x.split("/")) <= maxdepth + basedir_len , res ) )
|
|
File without changes
|
|
@@ -24,8 +24,6 @@ manafa/resources/record_android_trace
|
|
|
24
24
|
manafa/resources/traceconv
|
|
25
25
|
manafa/resources/profiles/__init__.py
|
|
26
26
|
manafa/results/__init__.py
|
|
27
|
-
manafa/results/batterystats/__init__.py
|
|
28
|
-
manafa/results/perfetto/__init__.py
|
|
29
27
|
manafa/services/__init__.py
|
|
30
28
|
manafa/services/batteryStatsService.py
|
|
31
29
|
manafa/services/perfettoService.py
|
manafa-0.2.7/MANIFEST.in
DELETED
manafa-0.2.7/README.md
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
[](https://travis-ci.com/RRua/e-manafa)
|
|
2
|
-
[](https://www.python.org/)
|
|
3
|
-
[](https://badge.fury.io/py/manafa)
|
|
4
|
-
[](https://pypi.python.org/pypi/manafa)
|
|
5
|
-
[](https://pypi.python.org/pypi/manafa)
|
|
6
|
-
# E-MANAFA: Energy Monitor and ANAlyzer For Android
|
|
7
|
-
|
|
8
|
-
E-MANAFA is a software model-based tool for performing fine-grained estimates of energy consumption on Android devices. For this purpose, it uses values from power_profile.xml and from the BatteryStats and Perfetto services to estimate the energy consumption of each resource / component of the device.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# SETUP
|
|
12
|
-
|
|
13
|
-
In order to run this tool, the following resources are required:
|
|
14
|
-
- A rooted Android device (running Android 9 or above);
|
|
15
|
-
- A *nix-based environment (MAC OS , Linux);
|
|
16
|
-
- Python 3.6 or above;
|
|
17
|
-
- Android Sdk tools (https://developer.android.com/studio/releases/platform-tools)
|
|
18
|
-
|
|
19
|
-
# Installation
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
pip install manafa
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## define environment variables
|
|
26
|
-
|
|
27
|
-
In order to run this tool, there are at least 2 env. variables that need to be defined in the shell startup script (e.g .bashrc or .bash_profile file)
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
export ANDROID_HOME=$HOME/<your-android-instalation-folder>/
|
|
31
|
-
export PATH=$ANDROID_HOME/platform-tools:$PATH
|
|
32
|
-
```
|
|
33
|
-
## Replicate the environment
|
|
34
|
-
|
|
35
|
-
Install virtual virtualenv enviroment (via python-pip):
|
|
36
|
-
```
|
|
37
|
-
$ python -m pip install --user virtualenv
|
|
38
|
-
```
|
|
39
|
-
## Replicate locally the dev virtualenv
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
$ virtualenv env/
|
|
43
|
-
```
|
|
44
|
-
## Activate the virtual environment
|
|
45
|
-
```
|
|
46
|
-
$ source env/bin/activate
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Extract power_profile.xml file from device (https://source.android.com/devices/tech/power/values)
|
|
50
|
-
Note: This file present in every device since Android 5 should contain values that were estimated by device manufacturers using external apparatus. However, most
|
|
51
|
-
devices don't provide a fine-grained power profile. Google provides a set of instructions in order to complete this file with more accurate values(https://source.android.com/devices/tech/power/component).
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
TODO
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
# Install required packages
|
|
58
|
-
```
|
|
59
|
-
$ pip install -r requirements.txt
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
# Examples
|
|
63
|
-
```
|
|
64
|
-
# getting the energy consumed during a profiling session (between first and last measurement)
|
|
65
|
-
g = GreenStats(power_profile=DEFAULT_PROFILE, timezone="EST")
|
|
66
|
-
g.init()
|
|
67
|
-
g.start()
|
|
68
|
-
do_some_work()
|
|
69
|
-
batstats_out_file, perfetto_out_file = g.stop()
|
|
70
|
-
g.parseResults( DEFAULT_PROFILE, batstats_out_file , perfetto_out_file )
|
|
71
|
-
begin = g.bat_events.events[0].time
|
|
72
|
-
end = g.bat_events.events[-1].time
|
|
73
|
-
consumption,per_component_consumption = g.getConsumptionInBetween(begin, end)
|
|
74
|
-
print("Energy consumed: %f Joules" % consumption)
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
# Supported devices:
|
|
78
|
-
This tool can be used with any Android device able to run Perfetto, that is available since Android 9 (P). The tool so far was successfuly executed on the following devices:
|
|
79
|
-
- Pixel 3a
|
|
80
|
-
- Pixel 4a 5G
|
|
81
|
-
- Xiaomi Mi 9 Lite
|
|
82
|
-
|
|
83
|
-
# TODO
|
|
84
|
-
- calibrate the model
|
|
85
|
-
- test using flashlight
|
|
86
|
-
- wifi pixel4a
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: manafa
|
|
3
|
-
Version: 0.2.7
|
|
4
|
-
Summary: E-MANAFA: Energy Monitor and ANAlyzer For Android
|
|
5
|
-
Home-page: https://github.com/RRua/e-manafa
|
|
6
|
-
Author: Rui Rua
|
|
7
|
-
Author-email: rui.rrua@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Bug Tracker, https://github.com/RRua/e-manafa/issues
|
|
10
|
-
Description: [](https://travis-ci.com/RRua/e-manafa)
|
|
11
|
-
[](https://www.python.org/)
|
|
12
|
-
[](https://badge.fury.io/py/manafa)
|
|
13
|
-
[](https://pypi.python.org/pypi/manafa)
|
|
14
|
-
[](https://pypi.python.org/pypi/manafa)
|
|
15
|
-
# E-MANAFA: Energy Monitor and ANAlyzer For Android
|
|
16
|
-
|
|
17
|
-
E-MANAFA is a software model-based tool for performing fine-grained estimates of energy consumption on Android devices. For this purpose, it uses values from power_profile.xml and from the BatteryStats and Perfetto services to estimate the energy consumption of each resource / component of the device.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# SETUP
|
|
21
|
-
|
|
22
|
-
In order to run this tool, the following resources are required:
|
|
23
|
-
- A rooted Android device (running Android 9 or above);
|
|
24
|
-
- A *nix-based environment (MAC OS , Linux);
|
|
25
|
-
- Python 3.6 or above;
|
|
26
|
-
- Android Sdk tools (https://developer.android.com/studio/releases/platform-tools)
|
|
27
|
-
|
|
28
|
-
# Installation
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
pip install manafa
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## define environment variables
|
|
35
|
-
|
|
36
|
-
In order to run this tool, there are at least 2 env. variables that need to be defined in the shell startup script (e.g .bashrc or .bash_profile file)
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
export ANDROID_HOME=$HOME/<your-android-instalation-folder>/
|
|
40
|
-
export PATH=$ANDROID_HOME/platform-tools:$PATH
|
|
41
|
-
```
|
|
42
|
-
## Replicate the environment
|
|
43
|
-
|
|
44
|
-
Install virtual virtualenv enviroment (via python-pip):
|
|
45
|
-
```
|
|
46
|
-
$ python -m pip install --user virtualenv
|
|
47
|
-
```
|
|
48
|
-
## Replicate locally the dev virtualenv
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
$ virtualenv env/
|
|
52
|
-
```
|
|
53
|
-
## Activate the virtual environment
|
|
54
|
-
```
|
|
55
|
-
$ source env/bin/activate
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Extract power_profile.xml file from device (https://source.android.com/devices/tech/power/values)
|
|
59
|
-
Note: This file present in every device since Android 5 should contain values that were estimated by device manufacturers using external apparatus. However, most
|
|
60
|
-
devices don't provide a fine-grained power profile. Google provides a set of instructions in order to complete this file with more accurate values(https://source.android.com/devices/tech/power/component).
|
|
61
|
-
|
|
62
|
-
```
|
|
63
|
-
TODO
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
# Install required packages
|
|
67
|
-
```
|
|
68
|
-
$ pip install -r requirements.txt
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
# Examples
|
|
72
|
-
```
|
|
73
|
-
# getting the energy consumed during a profiling session (between first and last measurement)
|
|
74
|
-
g = GreenStats(power_profile=DEFAULT_PROFILE, timezone="EST")
|
|
75
|
-
g.init()
|
|
76
|
-
g.start()
|
|
77
|
-
do_some_work()
|
|
78
|
-
batstats_out_file, perfetto_out_file = g.stop()
|
|
79
|
-
g.parseResults( DEFAULT_PROFILE, batstats_out_file , perfetto_out_file )
|
|
80
|
-
begin = g.bat_events.events[0].time
|
|
81
|
-
end = g.bat_events.events[-1].time
|
|
82
|
-
consumption,per_component_consumption = g.getConsumptionInBetween(begin, end)
|
|
83
|
-
print("Energy consumed: %f Joules" % consumption)
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
# Supported devices:
|
|
87
|
-
This tool can be used with any Android device able to run Perfetto, that is available since Android 9 (P). The tool so far was successfuly executed on the following devices:
|
|
88
|
-
- Pixel 3a
|
|
89
|
-
- Pixel 4a 5G
|
|
90
|
-
- Xiaomi Mi 9 Lite
|
|
91
|
-
|
|
92
|
-
# TODO
|
|
93
|
-
- calibrate the model
|
|
94
|
-
- test using flashlight
|
|
95
|
-
- wifi pixel4a
|
|
96
|
-
|
|
97
|
-
Platform: UNKNOWN
|
|
98
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
99
|
-
Classifier: Intended Audience :: Science/Research
|
|
100
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
101
|
-
Classifier: Operating System :: POSIX
|
|
102
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
103
|
-
Requires-Python: >=3.8
|
|
104
|
-
Description-Content-Type: text/markdown
|
manafa-0.2.7/notes.txt
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# extract powe values file
|
|
2
|
-
#adb pull system/framework/framework-res.apk .
|
|
3
|
-
#apktool d -s framework-res.apk -o out/
|
|
4
|
-
connect adb via tcp ip
|
|
5
|
-
|
|
6
|
-
adb tcpip 5555
|
|
7
|
-
adb connect 192.168.0.101:5555
|
|
8
|
-
Be sure to replace 192.168.0.101 with the IP address that is actually assigned to your device. Once you are done, you can disconnect from the adb tcp session by running:
|
|
9
|
-
|
|
10
|
-
adb disconnect 192.168.0.101:5555
|
|
11
|
-
You can find the IP address of a tablet in two ways:
|
|
12
|
-
|
|
13
|
-
Manual IP Discovery:
|
|
14
|
-
|
|
15
|
-
Go into Android's WiFi settings, click the menu button in the action bar (the vertical ellipsis), hit Advanced and see the IP address at the bottom of the screen.
|
|
16
|
-
|
|
17
|
-
Use ADB to discover IP:
|
|
18
|
-
|
|
19
|
-
Execute the following command via adb:
|
|
20
|
-
|
|
21
|
-
adb shell ip -f inet addr show wlan0
|
|
22
|
-
To tell the ADB daemon return to listening over USB
|
|
23
|
-
|
|
24
|
-
adb usb
|
manafa-0.2.7/requirements.txt
DELETED
manafa-0.2.7/setup.cfg
DELETED
manafa-0.2.7/setup.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import setuptools
|
|
2
|
-
from setuptools import setup
|
|
3
|
-
|
|
4
|
-
with open("README.md", "r", encoding='utf-8') as fh:
|
|
5
|
-
long_description = fh.read()
|
|
6
|
-
|
|
7
|
-
setup(
|
|
8
|
-
name='manafa',
|
|
9
|
-
version='0.2.7',
|
|
10
|
-
description='E-MANAFA: Energy Monitor and ANAlyzer For Android',
|
|
11
|
-
long_description=long_description,
|
|
12
|
-
long_description_content_type='text/markdown',
|
|
13
|
-
author='Rui Rua',
|
|
14
|
-
author_email='rui.rrua@gmail.com',
|
|
15
|
-
url='https://github.com/RRua/e-manafa',
|
|
16
|
-
license='MIT',
|
|
17
|
-
#package_dir={"": "manafa"},
|
|
18
|
-
packages=setuptools.find_packages(),
|
|
19
|
-
install_requires=[
|
|
20
|
-
'pytz==2021.1',
|
|
21
|
-
'termcolor==1.1.0',
|
|
22
|
-
'python-textops3==3.1.0',
|
|
23
|
-
'python-dateutil==2.8.1',
|
|
24
|
-
"setuptools>=42",
|
|
25
|
-
"wheel"
|
|
26
|
-
],
|
|
27
|
-
include_package_data=True,
|
|
28
|
-
classifiers=[
|
|
29
|
-
'License :: OSI Approved :: MIT License',
|
|
30
|
-
'Intended Audience :: Science/Research',
|
|
31
|
-
'Operating System :: Microsoft :: Windows',
|
|
32
|
-
'Operating System :: POSIX',
|
|
33
|
-
'Programming Language :: Python :: 3.8',
|
|
34
|
-
],
|
|
35
|
-
project_urls={
|
|
36
|
-
'Bug Tracker': 'https://github.com/RRua/e-manafa/issues'
|
|
37
|
-
},
|
|
38
|
-
python_requires=">=3.8",
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
'''setup(
|
|
42
|
-
name='e-manafa',
|
|
43
|
-
version='0.1.0',
|
|
44
|
-
packages=[ 'tests.perfetto', 'tests.batterystats', 'manafa', 'manafa.utils', 'manafa.perfetto',
|
|
45
|
-
'manafa.services', 'manafa.batteryStats', 'manafa.powerProfile', 'manafa.resources', 'manafa.results'],
|
|
46
|
-
url='https://github.com/RRua/e-manafa',
|
|
47
|
-
license='MIT',
|
|
48
|
-
author='ruirua',
|
|
49
|
-
author_email='rui.rrua@gmail.com',
|
|
50
|
-
description='e-manafa tool'
|
|
51
|
-
)'''
|
{manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{manafa-0.2.7 → Users/ruirua/repos/emanafa/venv/lib/python3.8/site-packages}/manafa/utils/Logger.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|