EcoAndroid
EcoAndroid is an Android Studio plugin that suggests automated refactorings for reducing energy consumption of Java android applications. It is also compatible with IntelliJ.
Installation
For users of the plugin
EcoAndroid can be installed from the JetBrains Plugin Repository.
Alternatively, you can install the plugin manually by following these steps:
- Clone this repository
- Run
gradle buildPlugin
. - The plugin file is available in the folder
build/distributions/
. You can now install it.
For developers
If you are interested in changing or exploring the source code of the plugin, follow these steps:
- Clone this repository
- Open the project in your favourite IDE
- Once you made the desired changes, run
gradle runIde
. An IntelliJ IDE with the plugin activated will open.
If you wish to add a new refactoring to the plugin, follow these steps:
- Add a <localInspection> element to the plugin.xml file present in
src/main/resources
, following the specifications in the other inspections - Create a subclass of com.intellij.codeInspection.LocalInspectionTool (the one stated in the previous step) in the folder of the corresponding energy pattern
- Create a subclass of com.intellij.codeInspection.LocalQuickFix to apply the refactoring to the source code
EcoAndroid in Practice
EcoAndroid has been used to improve the energy efficiency of several Android applications. Examples include:
- Timetable: Cache Energy Pattern(#3)
- SecondScreen: Dynamic Retry Delay and Cache Energy Patterns (#72)
- ZimLX: Cache Energy Pattern (#85)
- Twire: Cache Energy Pattern (#111)
- Taskbar: Cache Energy Pattern (#138)
- Audinaut: Cache Energy Pattern (#93)
- Inwallet: Cache Energy Pattern (#26)
- DownloadNavi: Cache Energy Pattern (#104)
- Omega: Cache Energy Pattern (#3)
- Onpc: Reduce Size Energy Pattern (#90)
- tracker-control-android: Reduce Size Energy Pattern (#130)
- Vanilla-music-lyrics-search: Reduce Size Energy Pattern (#14)
- DokuwikiAndroid: Reduce Size Energy Pattern (#13)
Have you used EcoAndroid to improve your application? Please let us know so that we can add it to the list above!
Energy Patterns
The energy patterns that are currently detected by EcoAndroid are:
-
Dynamic Retry Delay, with the following cases:
- Switching the time a thread goes to sleep from constant to dynamic (only considering the cases where variables are used to put the thread to sleep)
- Giving information to the developer about a package to aid while dealing with the retry of work
- Checking the network connection before processing a thread
-
Push over Poll, with the following case:
- Giving information to the developer about the possibility of implementing push notifications through Firebase Cloud Messaging (FCM) instead of a polling service
-
Reduce Size, with the following case:
- Asking for the response to be received compressed by the gzip scheme, if possible
-
Cache, with the following cases:
- Checking the metadata before reloading information
- Verifying the size of a view before resetting said view
- Switching to LocationManager.PASSIVE_PROVIDER when invoking the method requestLocationUpdates from the class android.location.LocationManager
- Increasing the size of the cache on a SSL Session
- Creating a TODO in the source code for when nothing is different since the last update from an URL connection
-
Avoid Graphics and Animations, with the following case:
- Switching the rendering mode to GLSurfaceView.RENDERMODE_WHEN_DIRTY
The examples in the folder src/test are retrieved from real-life mobile applications. In order to make the files more readable, parts of the original source code are either removed or commented.
Resources
For more information about energy patterns, we recommend Cruz and Abreu's open catalogue of energy-related patterns in mobile applications.