Skip to content

EcoAndroid is an Android Studio plugin that suggests automated refactorings for reducing energy consumption of Java android applications.

License

Notifications You must be signed in to change notification settings

sr-lab/EcoAndroid

Repository files navigation

EcoAndroid

EcoAndroid logo

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:

  1. Clone this repository
  2. Run gradle buildPlugin.
  3. 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:

  1. Clone this repository
  2. Open the project in your favourite IDE
  3. 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:

  1. Add a <localInspection> element to the plugin.xml file present in src/main/resources, following the specifications in the other inspections
  2. Create a subclass of com.intellij.codeInspection.LocalInspectionTool (the one stated in the previous step) in the folder of the corresponding energy pattern
  3. 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:

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:

  1. 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
  2. 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
  3. Reduce Size, with the following case:

    • Asking for the response to be received compressed by the gzip scheme, if possible
  4. 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
  5. 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.

About

EcoAndroid is an Android Studio plugin that suggests automated refactorings for reducing energy consumption of Java android applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published