GithubHelp home page GithubHelp logo

mozilla / powerusage-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gmierz/powerusage-android

0.0 3.0 3.0 99 KB

Battery and power usage measurement tools for Android

License: Mozilla Public License 2.0

Python 91.41% Shell 8.59%

powerusage-android's Introduction

powerusage-android

Mozilla-driven battery and power-usage measurement tools for Android (7,8).

🔥🦊⏱

======

license Build Status black

Preliminary Setup:

  1. Your Moto G5 (unlock, specs) and/or Pixel 2 unlockspecs phones should be rooted and OEM/carrier-unlocked (further unlocking docs
  2. Python 3.7.3 is installed and available in your system $PATH
  3. You have git installed and configured, also available in your system $PATH
  4. adb is installed and available in your system $PATH (if adb devices doesn't spit out errors, you should be good to go)
  5. git clone your fork of https://github.com/mozilla/powerusage-android (read-only would be: git clone https://github.com/mozilla/powerusage-android)
  6. cd powerusage-android
  7. python3 setup.py develop:
$ python3 setup.py develop
running develop
running egg_info
writing powerusage_android.egg-info/PKG-INFO
writing dependency_links to powerusage_android.egg-info/dependency_links.txt
writing top-level names to powerusage_android.egg-info/top_level.txt
reading manifest file 'powerusage_android.egg-info/SOURCES.txt'
writing manifest file 'powerusage_android.egg-info/SOURCES.txt'
running build_ext
Creating /usr/local/lib/python3.7/site-packages/powerusage-android.egg-link (link to .)

Installed /Users/stephendonner/powerusage-android
Processing dependencies for powerusage-android==0.1.0
Finished processing dependencies for powerusage-android==0.1.0

Test-Environment (Device) Cleanup

Uninstall Browser Apps

Manually: tap and hold until you can drag to the Uninstall option at the top right) all of your current Firefox-based browser apps (Fennec, GeckoView Example [GVE], Fenix, and Reference Browser [RefBrow]).

Install Browser APKs:

I will prettify this later, but here are my (Stephen) build sources, for my Moto G5, running Android 7.x:

(Greg can add his here too if so desired)

Running a Test:

  1. For each color's power test, you must mkdir [unique name] with a convention of your choosing; black-bg, white-bg, etc.
  2. From the top-level (root) dir, run (e.g. substituting values, where appropriate): $ ./scripts/blackbg-test.sh --output black-bg Ensure that your custom dir exists prior to the above test run; results or similar, will do, for our purposes.
  3. You should now see output similar to https://gist.github.com/stephendonner/9c611a3dfc6d26c4f203bd06b38f688b:

Here's a sample "batch" test of colors, called eye_of_sauron.py:

#!/bin/bash 

scripts/blackbg-test.sh black-bg fennec-64.0.2.en-US.android-arm.apk refbrow-target.arm.apk target.arm.apk geckoview_example.apk
scripts/whitebg-test.sh white-bg fennec-64.0.2.en-US.android-arm.apk refbrow-target.arm.apk target.arm.apk geckoview_example.apk
scripts/redbg-test.sh red-bg fennec-64.0.2.en-US.android-arm.apk refbrow-target.arm.apk target.arm.apk geckoview_example.apk
scripts/greenbg-test.sh green-bg fennec-64.0.2.en-US.android-arm.apk refbrow-target.arm.apk target.arm.apk geckoview_example.apk
scripts/bluebg-test.sh blue-bg fennec-64.0.2.en-US.android-arm.apk refbrow-target.arm.apk target.arm.apk geckoview_example.apk

Note: at the time of this doc update, greenbg-test.sh and bluebg-test.sh are not in-tree, and are used to test locally and here for illustrative purposes.

We'll soon be moving to Raptor proper, to hook into All the Things™ we need for capabilities of all types.

Running Android Pre/Post test. Running white background color test.

Make sure you have no extra apps running in the background. Make sure that there is a wakelock app running(if going passed 30 minutes of testing). Charging is disabled before the test starts. It is enabled automatically when we reach the end of the test. Getting Phone Model... Is the model Moto_G__5 correct? Disabling charging... Old screen timeout: 12000000

On trial 0

Installing app... Attempting to start white test... Starting: Intent { act=android.intent.action.VIEW dat=data:text/html;base64,PGJvZHkgc3R5bGU9ImJhY2tncm91bmQtY29sb3I6d2hpdGUiPjwvYm9keT4= (forced wrap here for illustration)
cmp=org.mozilla.reference.browser/.IntentReceiverActivity (has extras) }

followed by the magic and substance of the test/measurements, which are the (many) datapoints, of which we are currently focused on Charge-Counter values (Charge counter: 267234), as well as deltas, variance across scenarios, etc:

Waiting for a charge counter drop...

Time elapsed waiting for drop: 35.473793029785156 seconds
Drop detected, starting test
Start time: 2019-04-10 23:06:34.454324
Starting values:
AC powered: false
USB powered: false
Wireless powered: false
MOD powered: false
Max charging current: 0
Max charging voltage: 0
**Charge counter: 2627234**
status: 3
health: 2
present: true
level: 94
scale: 100
voltage: 4242
temperature: 297
technology: Li-ion
mod level: -1
mod status: 1
mod flag: 0
mod type: 0
timestamp: 1554937594.504281
Elapsed time (seconds): 1200.3231749534607
End time: 2019-04-10 23:26:34.919007
Final values:
AC powered: false
USB powered: false
Wireless powered: false
MOD powered: false
Max charging current: 0
Max charging voltage: 0
**Charge counter: 2549718**
status: 3
health: 2
present: true
level: 93
scale: 100
voltage: 4220
temperature: 315
technology: Li-ion
mod level: -1
mod status: 1
mod flag: 0
mod type: 0
timestamp: 1554938794.918973

**Charge counter used: 77516**
**Percent used: 1**

powerusage-android's People

Contributors

gmierz avatar stephendonner avatar

Watchers

 avatar  avatar  avatar

powerusage-android's Issues

Agree on and address/fix current flake8 issues

We should fix/mitigate these (and any subsequent issues which crop up), and then re-enable flake8 checking/enforcing in Travis/GitHub PRs, just to make it easy and consistent for us all (line numbers will shift; also, methinks the "no config found...isort" issues might be mine, only):

Stephens-MacBook-Pro:powerusage-android stephendonner$ flake8
./setup.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./tests/android_pre_post_general_test.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./tests/android_pre_post_general_test.py:6:1: F401 'utils.adb_utils.wait_for_drop' imported but unused
./tests/android_pre_post_general_test.py:30:5: F841 local variable '_' is assigned to but never used
./tests/android_os_baseline_test.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./tests/android_os_baseline_test.py:23:5: F841 local variable '_' is assigned to but never used
./tests/android_os_baseline_test.py:52:17: W503 line break before binary operator
./tests/android_os_baseline_test.py:53:17: W503 line break before binary operator
./tests/android_os_baseline_test.py:74:25: F841 local variable 'e' is assigned to but never used
./tests/android_pre_post_color_test.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./tests/android_os_baseline_by_percent.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./tests/android_os_baseline_by_percent.py:7:1: F401 'utils.adb_utils.wait_for_drop' imported but unused
./tests/android_os_baseline_by_percent.py:7:1: F401 'utils.adb_utils.get_battery_level' imported but unused
./tests/android_os_baseline_by_percent.py:49:5: F841 local variable '_' is assigned to but never used
./tests/android_os_baseline_by_percent.py:99:25: W503 line break before binary operator
./tests/android_os_baseline_by_percent.py:100:25: W503 line break before binary operator
./tests/android_os_baseline_by_percent.py:121:33: F841 local variable 'e' is assigned to but never used
./tests/__init__.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./utils/test_utils.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./utils/test_utils.py:21:9: W503 line break before binary operator
./utils/__init__.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./utils/data_saver.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./utils/utils.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./utils/adb_utils.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./utils/adb_utils.py:48:61: F821 undefined name 'model'
./utils/adb_utils.py:154:5: F841 local variable 'decrease' is assigned to but never used
./utils/android_parser.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./processors/os_baseline_processor.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./processors/os_baseline_processor.py:1:1: F401 'os' imported but unused
./processors/by_percent_processor.py:0:1: I002 no configuration found (.isort.cfg or [isort] in configs)
./processors/by_percent_processor.py:1:1: F401 'os' imported but unused

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.