selectively taming background android apps to improve battery

14
This paper is included in the Proceedings of the 2015 USENIX Annual Technical Conference (USENIC ATC ’15). July 8–10, 2015 • Santa Clara, CA, USA ISBN 978-1-931971-225 Open access to the Proceedings of the 2015 USENIX Annual Technical Conference (USENIX ATC ’15) is sponsored by USENIX. Selectively Taming Background Android Apps to Improve Battery Lifetime Marcelo Martins, Brown University; Justin Cappos, New York University; Rodrigo Fonseca, Brown University https://www.usenix.org/conference/atc15/technical-session/presentation/martins

Upload: dinhhanh

Post on 14-Feb-2017

219 views

Category:

Documents


1 download

TRANSCRIPT

This paper is included in the Proceedings of the 2015 USENIX Annual Technical Conference (USENIC ATC ’15).

July 8–10, 2015 • Santa Clara, CA, USA

ISBN 978-1-931971-225

Open access to the Proceedings of the 2015 USENIX Annual Technical Conference (USENIX ATC ’15) is sponsored by USENIX.

Selectively Taming Background Android Apps to Improve Battery Lifetime

Marcelo Martins, Brown University; Justin Cappos, New York University; Rodrigo Fonseca, Brown University

https://www.usenix.org/conference/atc15/technical-session/presentation/martins

USENIX Association 2015 USENIX Annual Technical Conference 563

Selectively Taming Background Android Apps to Improve Battery Lifetime

Marcelo MartinsBrown University

Justin CapposNew York University

Rodrigo FonsecaBrown University

AbstractBackground activities on mobile devices can cause signi�-cant battery drain with little visibility or recourse to theuser. �ey can range from useful but sometimes overly ag-gressive tasks, such as polling formessages or updates fromsensors and online services, to outright bugs that causeresources to be held unnecessarily. In this paper we instru-ment theAndroidOS to characterize background activitiesthat prevent the device from sleeping. We present Tamer,an OS mechanism that interposes on events and signalsthat cause task wakeups, and allows for their detailed mon-itoring, �ltering, and rate-limiting. We demonstrate howTamer can help reduce battery drain in scenarios involv-ing popular Android apps with background tasks. We alsoshow how Tamer can mitigate the e�ects of well-knownenergy bugs while maintaining most of the apps’ function-ality. Finally, we elaborate on how developers and users candevise their own application-control policies for Tamerto maximize battery lifetime.

1 Introduction�e accelerated growth of sensing, computational, stor-age, and communication capabilities of mobile deviceshas enabled a rich application environment that rivals theperformance of desktop computers. Even so, battery tech-nology has not followed the same advancement pace andthere is little evidence that this situation will dramaticallyimprove. As a result, battery lifetime has become a majorusability concern, with users willing to enjoy the latestapps on their smartphones and tablets, but, at the sametime, worrying that their battery will not last long enough.Since the inception of mobile computing, both indus-

try and academia have developed a slew of techniques toreduce power at the architecture [8, 24], OS [49, 43] andapplication levels [16, 21], and today’s systems draw littlepower while idling. Due to its user-centric and interac-tive nature, the �ow of a mobile application is driven byevents such as user actions, sensor I/O, and message ex-changes. Such event-driven paradigm lets the system idleuntil a new event arrives. Mobile OSes, such as Android,iOS, and Windows Phone, take advantage of such idlingopportunities to engage in opportunistic suspend. Uponbrief periods of idling, the handheld switches to the defaultsuspend state. Hardware blocks, including the CPU, GPU,GPS, and network modem, shi� to low-power mode andso�ware state is kept in self-refreshing RAM. �e same

blocks return from suspension upon interrupts emitted byhardware or so�ware indicating that they have pending re-quests.With the rise ofmultitasking and themultiplicationof background services and complex mobile applications,we expect this amount of interrupts to increase, forcingthe system to spend more time active to attend requests.Such active periods take a toll on battery lifetime. A recentstudy by Google clearly shows this impact: each second ofactive use of a typical phone reduces the standby time bytwo minutes [18].

�is paper studies the problem of battery drain mostlydue to app-originated background operations that wake upthe mobile system. We present Tamer, an OS mechanismwe built for Android that interposes on events and signalsresponsible for task wakeups – alarms, wakelocks, broad-cast receivers, and service invocations. Like a number ofpro�ling tools, Tamer allows us to characterize the back-ground behavior of di�erent apps installed on a device. In§2, using Tamer’s instrumentation, we show how a set ofinstalled applications can dramatically a�ect the batterylifetime of four di�erent devices. Unlike existing pro�lingtools, however, Tamer can also selectively block or rate-limit the handling of such events and signals following�exible policies. In this way, Tamer can, for example, limitthe frequency at which an application schedules alarms orreceives noti�cations of speci�ed events, providing �ne-grained control over the energy usage of apps that may beuseful, but are irresponsible or ine�cient with respect totheir background activities. In §5.2 we show via a few casestudies how Tamer can reduce the energy consumed byenergy bugs [35] in legitimate apps. We summarize ourcontributions as follows:

• We characterize how applications and core compo-nents of the Android OS use speci�c features to en-able background computing, and how this computingsigni�cantly a�ects energy use. In special, we notethat Google Mobile Services play a major role onbattery drain while the device is dormant (§2).

• We introduce Tamer, an OS mechanism to controlthe frequency at which background tasks are handled,thereby limiting their impact on energy consumption(§4). Tamer leverages code-injection technology andis applicable to any Java-based Android application.

• We demonstrate how Tamer can successfully throt-tle the background behavior of popular applications,thus reducing their energy footprint (§5). We show

564 2015 USENIX Annual Technical Conference USENIX Association

howdi�erent policies reduce power draw in exchangefor little to no impact on functionality.

Despite being a powerful mechanism, Tamer is only astep towards e�ective control of background energy usage.In particular, there are still challenges in helping usersde�ne policies that are e�ective, yet not disruptive to theuser experience. We discuss such challenges in §7.

2 MotivationSmartphone and tablet users are used to being always con-nected, expecting immediate noti�cations of a new e-mailor application update. Other common background oper-ations include polling navigational sensors for locationclues and turning on the network radio for incoming mes-sages. Especially inAndroid, where there is little restrictionon what apps can do in the background and developer’sdiscipline is the main factor preventing ine�cient applica-tions, apps can hog resources and waste energy.

Traditionally there has been little visibility, both to appdevelopers and to users, on the contribution of individualapps to energy use, especially while in the background. It iseven harder to know whether an app is actually running oridling. Recent monitoring and pro�ling tools have helpedbridge this visibility gap [9, 39, 19, 36, 30, 33, 45], as onecannot optimize what cannot be measured.Today’s average handheld contains a large amount of

third-party so�ware. A 2013 survey shows a global averageof 26 apps installed on a mobile device [20]. Even with thebest currently available tools, the end user can do little tocope with ine�cient apps. Most of the tools above targetdevelopers and provide little help for the user. Even thefriendlier ones, such as eStar [30] and Carat [33], whenhighlighting energy-ine�cient programs, can only o�er tokill or uninstall the culprit app, perhaps suggesting replace-ments. Unfortunately, this is too coarse-grained a solutionand some apps with irreplaceable functionality become aninconvenience one has to live with.

Tamer o�ers the possibility of much �ner-grained con-trol once an energy hog or bug is found. It provides infor-mation on which tasks are expending the most energy andcan rate-limit their execution. Tamer detects most causesof device wakeup that are visible at the framework level ofAndroid, and can �lter their continuation in real time.

To demonstrate the signi�cant di�erence that a set ofrunning tasks can make in a device’s battery life, we mea-sured the battery drop of four Android devices (two smart-phones and two tablets, cf. Table 1) running two di�erentapplication sets, while idling and with the screen o�. Con-servatively, we consider three scenarios: the �rst testingenvironment (Pure AOSP) consists of a stripped version ofthe Android Open Source Project (AOSP) OS containinga minimum number of services and apps; the second oneadds Google Mobile Services (GMS) on top of Pure AOSP.GMS consists of proprietary applications and services de-

veloped by Google, such as Calendar, Google+ (social me-dia), Google Now (personal assistant), Hangouts (instantmessaging), Maps, Photos, Play Service (integrating API),Play Store, and Search. Due to their popularity and addedvalue, GMS apps are included in most Android devicessold today. For the third scenario, which we only ran onthe Galaxy Nexus phone, we also installed the ten mostpopular free apps of Google’s Play Store as of January 20151.We based all environments on the KitKat (4.4) version ofAndroid. For the experiments, we le� each device unat-tended running with its con�guration at default settings.Other relevant settings include connection to a WiFi ac-cess point, enabled location-reporting, and backgroundnetwork synchronization. We expect most of the batterydrainage to stem from static-voltage leakage and eventualbackground processing.Figure 1 shows the time taken by each environment-

device combination to deplete the battery. For all devices,PureAOSP took the longest to completely drain the battery.In the case of tablets, this di�erence spanned dozens ofhours. To investigate why this happened, we instrumentedthe Android so�ware stack to timestamp the occurrenceof background events. Additionally, we connected one ofour devices (Galaxy Nexus) to a Monsoon power moni-tor [31] and collected power traces from the battery. Finally,we aligned and synchronized both the event and powertimelines to understand their correlation. Figure 2 depictsa six-minute slice of this combination. We observe thatGMS triggers more events in the background and that theyare correlated with the surge of power peaks. We used thistracing knowledge to build a mechanism that counters theenergy e�ect due to excessive wakeups. Because this mech-anism relies on OS internals, we �rst need to understandhow an Android app functions while in the background.

3 Background�is section provides a concise description of Android’spower-management system followed by an overview ofthe components constituting a mobile app and how appli-cations behave while running in the background. Finally,we highlight the in�uence of background execution on bat-tery drain using four types of events: wakelocks, services,broadcast receivers, and alarms. §4 describes Tamer, ourcontrol system that adjusts the frequency at which suchevents occur.

3.1 Mobile Power ManagementAndroid employs an aggressive form of power manage-ment to extend battery life. By default, the entire systemsuspends itself, sometimes even when there are processesrunning. Opportunistic suspend is e�ective in prevent-ing programs from keeping the system awake and quickly

1Crossy Road, Candy Crush Soda Saga, Pandora Radio, Trivia Crack,Snapchat, Facebook Messenger, Facebook, 360 Security Antivirus, Insta-gram and Super-Bright LED Flashlight.

2

USENIX Association 2015 USENIX Annual Technical Conference 565

Device Name Device Type Processor FeaturesGoogle Galaxy Nexus Smartphone Dual-core 1.2GHz ARM Cortex-A9 WiFi, GPS+A-GPS, 3GSamsung Galaxy S4 Smartphone Quad-core 1.9GHz Qualcomm Krait 300 WiFi, GPS+A-GPS, 3G/LTEAmazon Kindle Fire 2 Tablet Dual-core 1.2GHz ARM Cortex-A9 WiFi

ASUS MeMO Pad 7 (ME176C) Tablet Quad-core 1.83GHz Intel Atom Z3560 WiFi, GPS+A-GPS

Table 1: List of devices used for battery-drop monitoring.

0

20

40

60

80

100

0 20 40 60 80 100 120 140

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

w/ GMS + Top10

(a) Galaxy Nexus

0

20

40

60

80

100

0 20 40 60 80 100 120 140 160

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

(b) Galaxy S4

0

20

40

60

80

100

0 50 100 150 200 250 300 350

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

(c) Fire 2

0

20

40

60

80

100

0 50 100 150 200 250

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

(d) MeMO Pad 7

Figure 1: Battery drop of four Android devices idling with the screen o�. With Google Mobile Services installed, battery life decreasedto 29.5% (Fire 2) and 77.5% (MeMO Pad 7) of its initial decay (without GMS).

0

1

2

0 50 100 150 200 250 300 350

AlarmManager

Pow

er

(W)

Timeline (s)

(a) Pure AOSP

0

1

2

3

0 50 100 150 200 250 300 350

NlpLocationReceiverServicePendingIntentCallbackServiceUlrDispatchingServiceNlpWakeLockNlpCollectorWakeLockGeofencerStateMachineGCoreFlpNetworkLocationServiceAlarmManager

Po

we

r (W

)

Timeline (s)

(b) Pure AOSP + GMS

Figure 2: Six minutes sampled frommeasurements on the GalaxyNexus for two scenarios. For each graph, the top stack showsdi�erent event occurrences over time. �e bottom curve depictsthe corresponding system’s power draw during the same period.

draining the battery. To curb system suspension, Androiduses Wakelocks to keep the system awake. Wakelocks arereference-counted objects, similar to concurrency locks,that can be acquired/released by kernel and privilegeduserspace code. A wakelock acquire expresses a process’sneed for the system to remain awake until run completion.A wakelock acquire either holds a resource awake until arelease call occurs or sets up a timer to relinquish the lockat a later time.

Kernel drivers use wakelocks to block the suspension ofdi�erent system components (e.g., CPU, network, screen),whereas the Android application framework leverageswakelocks for di�erent levels of suspension, representedby groups of components (e.g., keep the network radio

awake vs. keep the radio, screen, and CPU awake). Asan example of suspend-blocking by the OS, Android au-tomatically acquires a wakelock as soon as it is noti�edof an input event and only releases the wakelock oncesome application handles the event or there is a timeout.Application developers can also directly instantiate andmanipulate wakelocks using the Wakelock API. A propere-book reader app must acquire a wakelock to keep thescreen awake so that the user can read her favorite novelwithout interruption. Wakelocks play an important rolein guaranteeing proper background task execution in faceof default suspension, as we will see next.

3.2 Android Applications: Dealing withLifecycle Changes

Barring a few interface-less system processes, an Androidapplication consists of a set of Activities that placesthe UI widgets on the screen. An application starts witha single thread of execution attached to the foregroundUI, which is mostly responsible for dispatching interfaceevents. To avoid appunresponsiveness and user frustration,a wise programmer would move other computations toconcurrent worker threads while the UI responds to inputevents. Support for concurrency comes in the form of anumber of standard Java primitives, such as Threads andFutures, as well as Android’s own �avors: AsyncTasksand message Handlers. However, such primitives onlywork when the application is in the active state.

As the user navigates through, out of, and back to anapplication, its lifecycle transitions between di�erent statesaccording to activity visibility. An application is active ifone of its activities receives user focus in the foreground. Ifthe user switches to another app or decides to turn o� thescreen, the application is paused and moved to the back-ground. Because mobile apps are multitasked, developersmust have a way to run code even when their app is notoccupying the screen.

3

566 2015 USENIX Annual Technical Conference USENIX Association

3.2.1 Dispatching Background Tasks�e small screen size of a smartphone or tablet preventsmultiple applications from running simultaneously. Toconserve energy, apps are frozen and stop working oncesent to the background, either due to the opening of an-other application or a screen timeout. Context switchingopens room for opportunistic suspend – by making appsinvisible, the Android OS frees its own set of wakelocks,opening space for hardware throttling.

Android o�ers application developers a small and well-de�ned interface for background-task o�oading that takescare of scheduling latent tasks [2].�is interface comprisesa handful of components including services, broadcastreceivers, and alarms.�e internal implementation of suchcomponents also leverages wakelocks to keep the deviceawake while executing tasks.Services are application components that run asyn-

chronously on background threads or processes and donot directly interact with the user. Instead, Activitiesdispatch services to perform long-duration operations orto access resources on behalf of users, such as download-ing remote �les or synchronizing data with a cloud-basedstorage. An advantage of running services separately is thattheir running persists even a�er closing the owner’s inter-face. Apps and widgets rely on services being operationalwithout need of manual restart.BroadcastReceiver is a reactive mechanism that per-

mits programs to asynchronously respond to speci�edevents. An application registers a BroadcastReceiveralong with an event-subscription list – the IntentFilter– that is used to determine if the application is eligible torespond to a given event. Events can be prede�ned by thesystem (e.g., “battery fully charged”) or developer-de�ned(e.g., “backup �nished”). Receiver threads remain dormantuntil a matched event arrives and respond by running acallback function. A �le-hosting app could, for instance,register a receiver to display a noti�cation box once it dis-covers that a scheduled data synchronization has �nished.

Another common programming pattern is the ability toperform time-based operations outside the lifetime of anapplication. For instance, checking for incoming e-mailsevery so o�en is a recurrent user operation that couldbe automatized. �e Android SDK o�ers developers theAlarmManagermechanism to ful�ll the scheduling of pe-riodic tasks at set points. At each alarm trigger, the systemwakes up and executes the scheduled callback function,whose contents can take various forms: a UI update, a ser-vice call, an I/O operation, scheduling a new alarm, etc.Alarms are a good �t for opportunistic suspend: apps areonly activated when there is work to do.In summary, Android uses at least three types of asyn-

chronous mechanisms to perform background tasking:services, broadcast receivers, and alarms. Aligned withwakelocks, we have a powerful collection of events that can

keep the system awake. In the next section, we introduceTamer, a system that acts on this small and well-de�nedinterface to throttle the rate at which background eventsare handled in exchange for energy savings.

4 Tamer4.1 DesignHaving seen that background events can noteworthily af-fect the sleeping pattern of mobile devices, we considerthe possibility of regulating their frequency to improvebattery life. We introduce a con�guration mechanism fordeclaring thresholds to the frequency of these events. Wemodel this regulation process using three sequential steps:(1) observation; (2) comparison; and (3) action.

Event-frequency regulation works based on the speci�-cation of occurrence limits. We establish a policy mecha-nism that lets users de�ne how o�en the running systemshould permit a given background event to proceed. A pol-icy is a contract that declares the conditions for an event ex-ecution. �is contract speci�es the event type as well as itsidenti�er; an optional list of a�ected apps, in case we wantto restrict such enforcement to a subset of event dispatch-ers or receivers; whether the policy enforcement also takesplace when the event owner (app) is in the foreground; andthe rate at which they are allowed to execute. From thisde�nition, an energy-savvy user could program her smart-phone to permit calls to WeatherUpdateService from aweather-forecast app atmost once every six hours, whereascalls to LocationUpdateService from the same appwould remain unlimited.

To enforce user-de�ned policies, we outline a controllercomprising three agents: observer, arbiter and actuator.�e observer intercepts every event occurrence and book-keeps its frequency. �e arbiter veri�es whether the mea-sured event rate is above the policy-de�ned threshold, if itexists, and noti�es the actuator, which hijacks the eventcontinuation to arti�cially reduce its occurrence rate. Fig-ure 3 illustrates our control sequence.

Observer Arbiter ActuatorEvent rate

Policy

DecisionEvent Action

Figure 3: Sketch of our event-control system as a three-stagepipeline.

�ere are two ways to ful�ll event throttling: cancelingor delaying. An event cancel denies the continuation of itscall, with an early return that prevents the payload or theevent callback from running. An event delay, on the otherhand, postpones the continuation of the event call for alimited time. In this work, we opt for canceling the eventhandling. We discuss the pros and cons of each choicein §7. It is important to understand that an event cancel

4

USENIX Association 2015 USENIX Annual Technical Conference 567

does not result in a crash. Alarms, services and broadcastreceivers all run asynchronously. Wakelock requests, onthe other hand, are synchronous and their denial will resultin a sleeping systemwhen a waiting task is expected to run.Still, the task is never aborted, but runs in chunks whenthe system wakes up. Our method prevents the triggeringof unwanted events. When it is not possible, we abort theevent continuation at the earliest opportunity to reduce theenergy cost of the event payload.

To drive the implementation of our system, we establisha few requisites and considerations:Comprehensive support for events.�e control systemshould be inclusive. While app-speci�c solutions are e�ec-tive, they do not scale to other programs.�e stage pipelineshould monitor and, if necessary, actuate on every eventinstance. Particulars about a speci�ed event should be con-�ned to its policy and not a�ect the controller. It is theresponsibility of the policy designer to de�ne a sane eventfrequency, considering, perhaps, the context and the im-pact of an event hijack. To implement an all-encompassingmonitor system, we target an OS-level solution.Support for power-oblivious applications.Users shouldnot abstain from using their favorite apps even if they arepower hogs. Uninstalling or suggesting alternative appsfor the same purpose should not be acceptable.�e systemshould cope with the existence of ill-behaved apps and actupon their misbehavior if directed by the policy designer.Compatibility. Many solutions that rely on deep sys-tem introspection require extensive rewrites of systemcomponents [11, 14, 6] or even writing systems fromscratch [43]. Although tempting, straying from the main-line can severely limit the userbase, especially in the case ofconsumer-oriented OSes. With that in mind, our solutionshould exhibit high compatibility and keep a minimumamount of changes to the underlying OS.E�ciency.Mobile apps must cope with limited computa-tional and energy resources. �e control system shouldavoid high computational overhead to prevent high batterydrain and system slowdown.

4.2 ImplementationTo avoid reimplementingOS components to regulate eventhandling, Tamer uses the Xposed framework [42] to en-able system modi�cations at runtime.

While requiring the device to be rooted, Xposed enablesdeep system modi�cations with no need to decompile ap-plications nor �ash the device2. Xposed intercepts Javamethods and temporarily diverts the execution �ow tofunction-hook callbacks for inspection and modi�cation.Developers de�ne these callbacks and compile them as sep-arate modules. Function-call hooking happens by match-ing the method’s name and signature of the declared call-

2For brevity reasons, we refer readers to [41] for an explanation on howsuch thing is possible.

back with the running code. Callbacks run on the contextof the intercepted application. Xposed allows for changingthe parameters of amethod call, modifying its return valueor terminating it early. We leverage the hooking mecha-nism to intercept function calls originating from or di-rected at our events of interest. Finally, function hooks canbe distributed as separate programs in self-contained APK�les.�ey are not bound to a speci�c Android version andwork without changes on the majority of customized An-droid releases, including those from Samsung, HTC, Sony,LG, and the CyanogenMod open-source community [10].Figure 4 shows how Tamer relates to the Android OS.

Tamer sits, along with Xposed, between user applicationsand the Java-based application framework, which servesas the foundation for the Android SDK. Events have direc-tions, which helps us de�ne how to write the interceptionpayload. While service and wakelock calls originate fromapps and are forwarded to the framework, alarms andbroadcast receivers work in the opposite direction.

Tamer consists of a series of function hooks that inter-pose on the background-processing interface and act asa controller mechanism to enforce user-de�ned policies.To implement Tamer’s event-canceling mechanism, weleverage Xposed’s introspection API to explore, monitor,intercept and modify public and private classes, methodsand members of the framework (Table 2). We used ourknowledge on the Android SDK aligned with the sourcecode of Android’s framework stack to decide where toplace the instrumentation points that would constituteour controller. We analyzed the source code stemmingfrom each event call on the SDK’s public interface. Model-ing the relationships between subroutines as a call graph,we considered each interface function as a leaf node. Insome occasions, we had to backtrack the call graph to �nda proper instrumentation point. �is was necessary forthree reasons: (1) the public interface did not o�er enoughcontext to feed our monitoring system (e.g., missing re-ceiver name, unclear caller-callee relationship, etc.); (2) inthe case of receiving events, it was better to interpose on acall as early as possible to avoid unnecessary operationsbefore a cancellation; (3) an event call may have more thanone function signature, therefore we looked for a converg-ing function node. We found one exception to the last rulewhen handling broadcast receivers. Applications can de-clare receivers in two ways: statically via a Manifest �leor dynamically using the Android SDK API. Since the An-droid framework keeps separate data structures for eachcase, we had to instrument them separately.Tamer’s interception can suppress wakeups due to ser-

vice invocations, wakelock acquires, and intent broadcasts.Because of the way Android handles alarms, our imple-mentation can only curtail the alarm’s callback payload.�e system will still periodically wake up according to thealarm’s schedule, but will immediately return to sleep. Our

5

568 2015 USENIX Annual Technical Conference USENIX Association

Event Class Method Instrumentation Payload

Wakelock com.android.server.PowerManagerService acquireWakeLockInternal

Search for policy. If found, early returnin case call happens before graceperiod. Else, let acquire proceed;bookkeep wakelock and startgrace-period timer.

releaseWakeLockInternal Only called if there was no block;report how long wakelock was held.

Service com.android.server.am.ActivityManagerService startServiceLocked Search for active policy. Proceed as inwakelock case.

BroadcastReceiverandroid.app.ContextImpl registerReceiverInternal Add reference to API-registered

receiver.

unregisterReceiverInternal Remove reference to API-registeredreceiver.

com.android.server.pm.PackageManagerService addActivity Add reference to receiver registeredstatically.

removeActivity Remove reference to receiverunregistered statically.

com.android.server.am.ActivityManagerService broadcastIntentLocked

Search for active policy. Temporarilyremove receiver from framework indexto prevent event broadcasts. Updatestats.

Alarm com.android.server.AlarmManagerService triggerAlarmsLocked Search for active policy. Proceed as inwakelock case.

GPS (See §5.3) android.location.LocationRequest requestLocationUpdates Enable GPS throttling for calling app.removeUpdate Disable GPS throttling for calling app.

com.android.server.LocationManagerService reportLocation

Search for active policy. Let callbackreport incoming location, buttemporarily switch off GPS sensor forblocking period.

Table 2: A brief description of Tamer’s instrumentation points.

controller implementation covers all versions of Androidranging from Ice Cream Sandwich to KitKat3. In a hand-ful of occasions, we resorted to di�erent instrumentationpoints for a given event, mostly due to small di�erencesin the function signatures between OS versions. Becausethe framework interface is fairly stable, covering futureversions of Android should not require major changes.

Libraries

Application Framework

Android Runtime

Kernel

Tamer

Wakelock

Service

Inten

t

Alar

m

Figure 4: Tamer sits between apps and the framework stack andinterposes on events between these two. Lower system layers areoblivious to our system.

5 EvaluationWe evaluate Tamer in four ways. First, we revisit our moti-vating scenario (§2) and use Tamer to extend the battery

3This limitation is due to Xposed’s limited OS support. Support forAndroid’s latest release (Lollipop) is not stable enough to cover our needs.

life of the GMS-based installation. We then investigatehow Tamer can e�ectively mitigate energy bugs, a sys-tem behavior that causes unexpected heavy use of energynot intrinsic to the desired functionality of an applica-tion. Next, we show how to use code injection to createspecialized versions of controllers for situations that ourfour-event toolset cannot handle. Last, we measure theoverhead caused by Tamer on performance and energy.

5.1 DealingWith Google Mobile ServicesIn §2, we saw how the inclusion of GMS into the baselineAOSP signi�cantly reduced the battery life of all testeddevices. Nonetheless, GMS adds a series of services andapplications that truly enhance the user’s mobile experi-ence. In fact, most users do not even have the option ofuninstalling them, as GMS comes pre-installed as a sys-tem package in the majority of handhelds. We show howTamer can reach a tradeo� between GMS’s functionalityand battery savings. We aim to keep the added value ofGMS without the cost of a silent battery depletion.

Event Name Type Count Duration (s)NlpWakelock W 5963 1662.71NlpCollectorWakelock W 2121 3926.63LocationManagerService W 2030 67.12NlpLocationReceiverService S 1159 -NetworkLocationService S 579 -

Table 3: Top event occurrences for the Galaxy Nexus’ batterydrain due to GMS. A handful of events are responsible for thema-jor impact on the battery. W signi�es a wakelock event, whereasS stands for service invocation.With the control mechanism established, our next

6

USENIX Association 2015 USENIX Annual Technical Conference 569

0

20

40

60

80

100

0 20 40 60 80 100 120 140

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

w/ GMS + Tamer-15w/ GMS + Tamer-45

(a) Galaxy Nexus

0

20

40

60

80

100

0 20 40 60 80 100 120 140 160

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

w/ GMS + Tamer-15w/ GMS + Tamer-45

(b) Galaxy S4

0

20

40

60

80

100

0 50 100 150 200 250 300 350

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

w/ GMS + Tamer-15w/ GMS + Tamer-45

(c) Fire 2

0

20

40

60

80

100

0 50 100 150 200 250

Ba

tte

ry L

eve

l (%

)

Hours

Pure AOSPw/ Google M. Services

w/ GMS + Tamer-15w/ GMS + Tamer-45

(d) MeMO Pad 7

Figure 5: Battery drop for the four devices while idling with the screen o�. A�er applying our policies to GMS, battery life improvedin dozens of hours for all devices.

step is to design a policy that reduces the battery im-pact of events originating from or destined to GMS. Ta-ble 3 ranks the top triggered events reported by Tamer’smonitoring module. For wakelocks, we also report thetime they were held. We use event frequency as anheuristic to guide policy con�guration. We note thatNlpCollectorWakelock was primarily responsible forkeeping the system awake in the background. Online re-ports [40, 5] indicate that NlpCollectorWakelock is re-lated to Location Reporting, an Android feature toestimate and report the current location based on WiFiAPs and cell-tower signals. Apps that use this feature in-clude Google Now and Google Maps, among others. �eother frequently reported events are also related to thesame feature. Disabling location reporting on the device’sSettings menu would be a logic solution to increase sleeptime, if dependent apps did not stop working.�e problem with NlpCollectorWakelock and asso-

ciated events is the frequency they wake up the system andkeep it awake, which sums to a substantial period of non-sleepiness. During a discharge period of 80 hours for theGalaxy Nexus smartphone, NlpWakelockwas called oncea minute on average, whereas NlpCollectorWakelockcontributed to keeping the system awake for more thanone hour. Such a high battery impact coming from a singlepackage does not justify the bene�t of having GMS run-ning as it is in the background. For this reason, we devisedtwo policies forGMS, targetingNlpCollectorWakelockand its associated events, to alleviate this wakeup burden.For each wakelock and service in Table ??, the �rst pol-icy (Tamer-15) allows a single call every 15 minutes. �esecond policy (Tamer-45) allows one call every 45 min-utes. Deciding on an appropriate rate is a subjective matter.Our setup tries to reach a balance between informing sub-ordinate apps of location updates and increasing batterylifetime. Figure 5 shows that our policies substantially re-duced the battery-drain rate of all tested devices.

5.2 Chasing Energy BugsAn energy bug, or ebug, is a system error either in anapplication, OS, �rmware or hardware that causes an un-expected amount of high energy consumption [35]. Sucherrors occur due to a variety of reasons such as program-ming mistakes, faulty hardware, malicious intent, etc. Be-

cause such errors may not result in a crash, users will onlynotice their e�ect when it is too late: an early dead battery.

Di�erently from previous research which identi�ed andcharacterized energy bugs [46, 37], in our evaluation wefocus on mitigating them at runtime. Tamer allows usersto run the o�ending applications without the adverse ef-fects of the bugs. Finding ebugs is not trivial and the lackof a centralized repository of updated samples preventsus from testing our controller more extensively. We suc-cessfully reproduced and circumvented three applicationebugs described in [23]. For the other described cases, wecould not con�rm the existence of bugs. We assume thesedefects have been �xed by developer updates.

Next, we present two detailed case studies of new ebugsthat we found. To identify them, we used eStar [30], a toolthat ranks the contribution of apps to battery depletion.We�rst selected apps that display poor energy e�ciency and�ltered them based on high popularity at the Google PlayStore (our two selections featured on the top-20 ranking oftheir respective categories: Games and Health & Fitness).Although eStar ranks energy-ine�cient apps, we still hadto manually verify whether such ine�ciency was due toforeground or background activity. For each application,we simulated a user interaction consisting of a short-lengthactive session followed by a long period in the background.Bejeweled Blitz [13] is an award-winning puzzle gamewith over 10 million installs from Google Play Store. A�era 15-minute play session on the Galaxy S4 smartphone,Tamer reported that our game generated a single back-ground event – the acquire of the AudioIn wakelock. Be-cause games are resource-hungry apps, this event call ini-tially did not instigate any suspicion. We discovered a red�ag, though, a�er switching Bejeweled to the background:AudioIn was not released a�er the game suspension. Tomitigate this bug, we wrote a simple policy targeting Bejew-eled Blitz that blocks the renewal of the culprit wakelockduring background time. Figure 6 depicts the battery dropof a 12-hour session with Bejeweled loaded in the back-ground before and a�er applying our policy. We see a 4×improvement on battery drain. Figure 7 con�rms the e�ectof releasing the ill-behaved wakelock: before being tamed,the smartphone spent approximately 95% of the time withan awake CPU. With Tamer’s interposition, most of theresidency ratio was converted to deep sleep.

7

570 2015 USENIX Annual Technical Conference USENIX Association

0

20

40

60

80

100

0 2 4 6 8 10 12

Ba

tte

ry L

eve

l(%

)

Hours

NormalTamed

Figure 6: Battery drain over 12 hours for Bejeweled Blitz withoutTamer (Normal) andwith aTamer policy blocking the AudioInwakelock. In both cases, the game was started and the phoneswitched to idle mode with the screen o�.

0

20

40

60

80

100

Dee

p Sle

ep

384

MHz

486

MHz

594

MHz

702

MHz

810

MHz

918

MHz

1.03

GHz

1.13

GHz

1.24

GHz

1.35

GHz

1.46

GHz

1.57

GHz

1.67

GHz

1.78

GHz

1.89

GHz

% o

f T

ime

Sp

en

t

CPU Frequency

NormalTamed

Figure 7: CPU residency time for the original and tamed versionsof Bejeweled Blitz on the Galaxy S4. �e tamed version spent94% of the time in Deep Sleep.

Nike+ Running [32] is a �tness app for tracking runs.Nike+ relies on the GPS sensor, the accelerometer, andbarometer to estimate distance and speed. According toTamer, Nike+ acquired �ve wakelocks while running:AudioMix, FullPower Acc Sensor, FullPowerPressure Sensor, FullPower Recording andNlpWakeLock. Judging from the wakelock names, wecan assume a few hardware components remained awaketo prevent device-sleeping. We found an ebug whenpausing our running session and switching Nike+ to thebackground. In this case, we expected the application torelease all wakelocks. Like Bejeweled Blitz, Nike+ forgotto relinquish the locks upon leaving the foreground. Ourpolicy was also equivalent: block the culprit wakelocksduring background time. Figure 8 shows the battery dropa�er an eight-hour session before and a�er applying ourpolicy. We see a 5× improvement on battery drainage.Figure 9 displays the CPU residency on both scenarios:CPU deep-sleep residency jumped from a 0% to 89.8%.We also acknowledge a major contribution of the GPSand sensors to battery decay. �eir duty cycle is equivalentto the time the homonymous wakelocks were held.

5.3 Looking at the Other Side of EventsTamer can block events at their imminent arrival or dis-patch, thus saving energy that would be consumed by their

0

20

40

60

80

100

0 1 2 3 4 5 6 7 8

Ba

tte

ry L

eve

l(%

)

Hours

NormalTamed

Figure 8: Battery drain over 8 hours for Nike+ Running withoutTamer (Normal) and with a Tamer policy that blocked all �veheldwakelocks. In both curves, the appwas started and the phoneswitched to idle mode with the screen o�.

0

20

40

60

80

100

Dee

p Sle

ep

350

MHz

700

MHz

920

MHz

1.2

GHz

% o

f T

ime

Sp

en

t

CPU Frequency

NormalTamed

Figure 9: CPU residency time for the original and tamed versionsof Nike+ Running on the Galaxy Nexus.�e tamed version spent89.4% of the time in Deep Sleep.

continuation. One can say that Tamer focuses on the ef-fect of an event. Still, there are situations in which theenergy cost of its cause is signi�cant. A user could write apolicy targeting an instant messenger’s broadcast receiverto throttle the e�ect of a message arrival – a noti�cationin the form of sound or vibration. However, she cannotblock the message arrival itself, the major contributor toenergy consumption in this case, as the remote sender isnot covered by Tamer.

Acting on the cause of an event is complicated becauseits originator, when known, can take various shapes, likea disk or network I/O operation. Consequently, �ndinga converging instrument point in the source code thatencompasses all such shapes is complex. In parallel, weshould avoid point solutions that only �t one app. Betweenthese two extremes, we can reach a balance by instrument-ing code that abstracts common functionality and gener-ates events used by a subset of applications. We considerthe case of navigation apps to illustrate such scenario.�rottling Localization. Android applications that relyon the GPS sensor follow a basic model: (1) they register aposition listener and (2) they periodically receive locationupdates from a provider proxy, the only interface to thelocalization system [3]. A provider proxy serves as aninterface to various location sources, including the GPSsensor, WiFi APs, and cell towers.

8

USENIX Association 2015 USENIX Annual Technical Conference 571

Given that the GPS is an energy-hungry resource, weconsider a throttling mechanism for its duty cycle. Paek etal. [34] successfully demonstrated the potential energy sav-ings of duty cycling by creating a rate-adaptive positioningsystem that switches the GPS sensor on and o� and usesalternative location sources based on position accuracy.As a demonstration, we consider a simpler GPS-throttlingimplementation sans secondary sources. An advantage ofour approach is the dispensing of OS recompilation, keep-ing it compatible with the majority of Android devices.�e GPS sensor provides periodic position �xes (everysecond) to the OS. Some of these �xes are not relayed bythe Android framework to the navigation app as they arenot signi�cantly di�erent. We can reach a more energy-e�cient navigation by directing the GPS duty cycle. Weinject code into internal classes related to the framework’sGPS provider and open a direct communication channelbetween the GPS device and our throttling mechanism.�is direct channel permits our controller to switch theGPS on and o�. Table 2 summarizes our instrumentation.Evaluation.We consider two location-based apps, GoogleMaps and Nike+ Running. We ran these two applicationsseparately on the Galaxy Nexus phone and applied threedi�erent throttling policies to the GPS duty cycle: locationupdates every one, �ve and ��een seconds.�e rate choicedepends on the user’s purpose. For pedestrian navigation,a slower update rate does not a�ect the estimated positionas much as in the case of a highway car trip. Paek et al.’swork includes a thorough tradeo� analysis between posi-tion accuracy and energy savings. We, on the other hand,only report the potential savings. For each scenario, weprogrammed a pedestrian route lasting ten minutes. Weturned the screen o� while running the application in thebackground. Because of the small timespan, we comparethe energy dispensed instead of battery-level drop. Weused the Monsoon monitor to measure the energy con-sumption. Figure 10 portrays the savings per application.We observe an upper bound of 27.7% on savings for theNike+ Running application when reducing the location-update rate to 1:15s. Although a lower update rate increasesthe energy savings, position accuracy is penalized.

5.4 Performance ImpactJust like a network �rewall, Tamer intercepts every event-happening, inspects it, evaluates the corresponding policycriterion, and �nally actuates to ful�ll the policy’s condi-tions. Because Tamer diverts the normal �ow of applica-tions, it should incur as little performance overhead andenergy burden as possible. We instrumented Tamer tomeasure the time taken to hijack an event and perform itsblockage. For the longest diverted execution �ow, Tamertook, on average, 320µs to execute on the Galaxy Nexusdevice. With regards to energy consumption, Tamer isactivated only when other applications generate events.

0

100

200

300

400

500

600

700

800

Maps

Nike+

Tota

l E

nerg

y (

J)

1s-rate Policy5s-rate Policy

15s-rate Policy

Figure 10: Total energy consumed by Google Maps and Nike+Running a�er applying three di�erent duty-cycle policies to theGPS provider. For both apps, the update rate is inversely propor-tional to energy savings.

Tamer does not acquire any wakelocks, but freeloads thesystem’s active state from other wakeup sources.

6 RelatedWorkWe are not the �rst to propose control of functionality inexchange for battery savings.Tamer builds upon a numberof contributions to mobile power management.Collateral RelatedWork. E�cient power management inmobile platforms is a challenging research problem dueto the multitude of hardware con�gurations and powerstates. To improve energy consumption, we need to under-stand how hardware components draw power on behalfof applications. �ere is a myriad of tools that help quan-tify a device’s energy expenditure. PowerScope [17] is oneof the �rst works in the mobile domain to map energyto a program’s structure. PowerScope employs linear re-gression and statistical sampling to apportion energy tohardware and applications. A series of recent pro�lers forsmartphones complements PowerScope, including Power-Tutor [50], ARO [38], AppScope [22], WattsOn [29] andeprof [36]. Sesame [12] and V-edge [47] go a step furtherand propose self-calibrating models that dispense the useof external power monitors, relying instead on internalbattery data to model energy expenditure. Our analysismainly adopts battery-drop rate as a proxy for energy con-sumption, but we expect such advanced contributions tobe integrated by OEMs in future devices.Saving Energy FromBackgroundTasking.Android taskkillers once were the solution for background powersavings, but their e�ectiveness is now a point of con-tention [27]. Task killers force background applicationsto quit, assuming that their removal from memory willreduce the energy footprint of released resources. Suchassumption is incorrect as there is little correlation be-tween memory and CPU usage in Android [4]. Excessivetask killing may lead to the opposite e�ect: by discardingcached data, Android must reload apps from storage. A

9

572 2015 USENIX Annual Technical Conference USENIX Association

killed app may restart itself immediately a�er being killed,using up CPU time and draining even more battery.

Rather than killing background tasks, popular apps likeJuiceDefender [26] and Easy Battery Saver [1] can con�g-ure the access to power-greedy components, such as theradio and GPS, on a schedule basis. Although e�ective inmany cases, some apps do not behave properly when theycannot, for instance, connect to the Internet. Some appsmay even produce more energy overhead as they insiston accessing a resource made unavailable. Tamer circum-vents such problems by mainly throttling asynchronousactions: the expecting app does not block while waitingfor an event arrival or dispatch. Greenify [15] is an An-droid tool for hibernating apps, preventing the arrival ordispatch of events once an app switches to background.�e original functionality is only restored when the appreturns to the foreground. Greenify is e�ective in block-ing misbehaving and start-at-boot apps, but its treatmentof background computing is coarse and not applicableto noti�cation-based apps that mostly run in the back-ground (e.g., mail readers, instant messengers, calendars,etc.) Tamer is applicable in such cases as it throttles, butdoes not completely eliminate, background functionality.

Android also includes its own controls for background-task management. �e AutoSync feature controls the au-tomatic data synchronization between client apps and on-line accounts. With a mere tap, users can choose betweendisabling the synchronization of a speci�c feature of aselected account (e.g., photo uploads for Google+) or to-tally prevent any background synchronization for all reg-istered accounts. AutoSync is mostly applicable to appsadopting Google Cloud Messaging (GCM), an API piecefromGoogleMobile Services. GCMprovides a lightweightmechanism that third-party servers can use to notify mo-bile applications of available content to be fetched. As longas the application is subscribed to receive GCMmessages,the Android device does not need to run continuously.Instant messengers, for instance, use GCM to receive noti-�cations of new incoming messages. Tamer complementsthis service by o�ering a similar control to applicationsthat do not adopt the GCM approach. Moreover, Tamerallows for the management of a variety of backgroundevents, whereas AutoSync focuses mainly on networking.Partial inspiration for deep event monitoring stems

from applications such as BetterBatteryStats [25] andWakelock Detector [45]. Both apps report wakelock-usagestatistics that developers can use to understand the rootcause of battery drainage. Tamer complements such appsby empowering users to take action a�er they pinpoint theorigin of abnormal energy consumption.Carat [33] and eStar [30] use data collected from thou-

sands of smartphone and tablet users to model the batterydrainage of applications. By combining rich context infor-mation of multiple devices with energy awareness, it is

possible to determine whether the energy used by an appli-cation deviates from its expected consumption.�ese toolsare conservative in controlling energy expenditure, withboth systems suggesting users to kill or uninstall culpritapps. eStar further recommends energy-e�cient alterna-tives to power-hog apps, if they exist. Tamer let users keeptheir apps while modifying the culprit’s behavior to reduceenergy consumption.

7 DiscussionAs any prototype, Tamer has limitations. Tamer’s mainutility comes from policy de�nition, which, at its currentstate, will not appeal to the end user. In the following, weelaborate on how to circumvent this usability issue. Wealso suggest improvements that are le� as future work.

7.1 Policy GuidelinesIn §5, we demonstrated how a wise policy selection canpartially inhibit the surge of energy-hungry events. Ourexperience de�ning policies arose from intuition, readingsource code (when available) and, in some cases, multipleattempts. At its current state, Tamer would better serveas a backend for higher-level power management toolsthan as an end-user app. With such limitations in mind, auser willing to run Tamer as it is, would bene�t from thefollowing guidelines to explore the event space and de�nee�ective policies.Choosing events to control. Handhelds may carry tensor even hundreds of applications that generate thousandsof events. We should not imply that policy de�nition mustconsider all of them equally. First, users prefer some appsover others. Second, event triggering does not follow a uni-form distribution. As a rule of thumb, users should startwith policies targeting the most frequent events. Tamer’smonitoring module periodically outputs an event sum-mary that can assist in such cases.Cutting the red wire. Even a�er selecting the most promi-nent events for policy testing, there are no guarantees thatthe policy will work without side e�ects. Side e�ects mayinclude an increase in the frequency of correlated events,the rise of unexpected events, and abnormal application be-havior. Blocking alarm events recklessly could, for instance,totally defeat the purpose of a calendar app. Because mostapps are only available in binary form, understanding thepurpose of an event is not always clear and neither is un-covering its dependencies. Techniques used in black-boxtesting, such as cause-e�ect graphs can help. Events mayalso show a temporal correlation with others. To uncovertemporal dependency, we generated event timelines fromTamer’s monitoring output.Use common sense. �e Android OS de�nes two cate-gories of applications: system and user. �e former in-cludes programs that are deemed critical, are deeply in-tegrated into the OS, and cannot be uninstalled. Exam-

10

USENIX Association 2015 USENIX Annual Technical Conference 573

ples include the dialer, browser, and network manager, toname a few. Users apps are replaceable programs that canbe freely removed and installed from the app store. Aspart of Tamer’s design, we adopted the support of genericevents. Consequently, system- and user-app events aretreated equally. Policies that alter the frequency of sys-tem events may result in unwanted or abnormal behavior.Users should be mindful when de�ning policies involvingcritical events to avoid such situations. Removing supportfor system events would prevent such unfortunate occa-sions, but the de�nition of a system app is blurry. GMS,for example, comes pre-installed as a system package onmany devices. Carriers also sell devices with bloatwareinstalled as system apps. As demonstrated, systems appspresent great opportunities for energy savings.

7.2 Potential ImprovementsEvent batching over cancellation. Our current imple-mentation dismisses event continuation if there is a needfor throttling. Alternatively, we could reschedule the asyn-chronous delivery of such events to coalescemultiple wake-ups into one, saving even more energy. Although promis-ing, event coalescing may lead to unexpected results thatrequire deeper investigation. Some apps assume a �xed fre-quency of events. A pedometermay use the time di�erencebetween position �xes to estimate speed. Batching multi-ple �xes into one delivery may create havoc if the trackerdoes not discard outdated values. Nevertheless, coalescinghas found its way in other domains. �e Linux ticklesskernel [44] reduced the precision of so�ware timers to al-low the synchronization of process wakeups, minimizingthe number of CPU power-state transitions. From its Lol-lipop release, Android started to batch alarms that occurat reasonably similar times, turning them inexact. Xu etal.’s recent work on coalescing events to save energy in thecontext of email synchronization [48] is another success-ful example of careful event-handling for mobile devices.As long as developers do not assume guarantees on eventdelivery and commutativity, we believe coalescing shouldsupersede cancellation as an energy-saving feature.Native code support. Tamer controls applications bywrapping function calls from the Android Java API. Ap-plications that make heavy use of native code, like games,multimedia apps and ELF libraries, could acquire wake-locks, spawn threads and perform background tasks usingC/C++ code, thus bypassing our control system. Extend-ing support to native code would require a similar e�orton analyzing and instrumenting libc function calls.Support for other mobile OSes. Background processingis not exclusive to Android, although handled di�erentlyby other mobile OSes. Apple’s iOS 7+ regards backgroundprocessing as a privilege [7]. Other than network trans-fers, common background tasks have limited time to com-pletion and must respect the device’s will to sleep, do-

ing their processing in chunks a�er the device wakes upto handle phone calls, noti�cations and other interrup-tions. Windows Phone enforces background tasks to belightweight by applying quotas to resources likeCPU,mem-ory, and network usage while apps are running behind thescenes [28]. Event-frequency control may not producethe same gains on Apple’s and Microso�’s mobile devicesgiven their stricter stance on deploying background tasks(mainly in the name of battery savings).Feedback control. Tamer works as an open-loop con-troller, not using feedback to gauge whether the systemneeds more adjustments. During the design stage of thisproject, we discarded the closed-loop approach as it wouldrequire knowledge of application semantics as well as userperception of performance degradation. Modeling thesetwo elements are hard problems beyond our scope.

8 Conclusion�is paper presented Tamer, an OS mechanism that in-terposes on task wakeups in Android and allows eventhandling to be monitored, �ltered, and rate-limited. Wedemonstrated that Tamer substantially reduces the back-ground energy use in popular Android applications. WithTamer, a device spends more time in low-power mode,which increases the battery lifetime signi�cantly.

While this work shows Tamer’s e�ectiveness as a mech-anism, future work is needed to understand how to bestconstruct policies that improve battery life while preserv-ing application functionality. In future work, we will in-vestigate techniques for determining if functionality isnegatively impacted when exploring user visible elements(e.g., UI di�erences) between runs of an application withdi�erent policies. We will also explore which policies aremost likely to have substantial battery savings in practice.With the combination of such techniques, we will striveto devise policies that improve battery life while retainingnormal application functionality.

AcknowledgementsWe thank Tim Nelson, Hammurabi Mendes, the anony-mous reviewers, and our shepherd, Lin Zhong, for theirfeedback. Marcelo was funded in part by a generous gi�from Intel Corporation.

11

574 2015 USENIX Annual Technical Conference USENIX Association

References[1] 2Easy Team. Easy Battery Saver. http://www.

2easydroid.com.

[2] Android Developers. Best practices for back-ground jobs. https://developer.android.com/training/best-background.html.

[3] Android Developers. Location strategies.https://developer.android.com/guide/topics/location/strategies.html.

[4] Android Developers. Managing your app’smemory. https://developer.android.com/training/articles/memory.html.

[5] AndroidCentral.com. Google Services batterydrain. http://forums.androidcentral.com/google-nexus-4/302559-google-services-battery-drain.html.

[6] Andrus, J., Dall, C., Hof, A. V. H., Laadan, O.,and Nieh, J. Cells: A virtual mobile smartphonearchitecture. In ACM SOSP’11.

[7] Apple Inc. App programming guidefor iOS. https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html.

[8] ARM Limited. big.LITTLE technology: �e futureof mobile. http://www.arm.com/files/pdf/big_LITTLE_Technology_the_Futue_of_Mobile.pdf .

[9] AT&T. Application resource optimizer (ARO).http://developer.att.com/application-resource-optimizer.

[10] CyanogenMod Community. http://www.cyanogenmod.org.

[11] Dietz, M., Shekhar, S., Pisetsky, Y., Shu, A., andWallach, D. S. QUIRE: Lightweight provenancefor smart phone operating systems. In USENIX Secu-rity’11.

[12] Dong, M., and Zhong, L. Self-constructive high-rate system energy modeling for battery-poweredmobile systems. In ACMMobiSys’11.

[13] Electronic Arts Inc. Bejeweled Blitz.http://play.google.com/store/apps/details?id=com.ea.BejeweledBlitz_na.

[14] Enck,W., Gilbert, P., Chun, B.-G., Cox, L. P., Jung,J., McDaniel, P., and Sheth, A. N. TaintDroid:An information-�ow tracking system for realtimeprivacy monitoring on smartphones. In USENIXOSDI’10.

[15] Feng, O. Greenify. https://play.google.com/store/apps/details?id=com.oasisfeng.greenify.

[16] Flinn, J., and Satyanarayanan, M. Energy-awareadaptation for mobile applications. In ACM SOSP’99.

[17] Flinn, J., and Satyanarayanan, M. PowerScope:A tool for pro�ling the energy usage of mobile appli-cations. In IEEE WMCSA’99.

[18] Gigaom. Google’s killer Android L feature: Upto 36% more battery life thanks to Project Volta.http://gigaom.com/2014/07/02/googles-killer-android-l-feature-up-to-36-more-battery-life-thanks-to-project-volta.

[19] Google. Battery Historian. https://github.com/google/battery-historian.

[20] Google. Our mobile planet. http://think.withgoogle.com/mobileplanet/en.

[21] Hoffmann, H., Sidiroglou, S., Carbin, M., Mis-ailovic, S., and Agarwal, Anant ad Rinard, M.Dynamic knobs for responsive power-aware comput-ing. In ASPLOS’11.

[22] Jung, W., Kang, C., Yoon, C., Dongwon, K., andCha, H. AppScope: Application energy meteringframework for Android smartphone using kernel ac-tivity monitoring. In USENIX ATC’12.

[23] Kim, K., and Cha, H. WakeScope: Runtime wake-lock anomaly management scheme for Android plat-form. In ACM EMSOFT’13.

[24] Kim, W., Gupta, M. S., Wei, G.-Y., and Brooks,D. System level analysis of fast per-core DVFS usingon-chip switching regulators. In IEEE HPCA’08.

[25] Knispel, S. BetterBatteryStats. https://play.google.com/store/apps/details?id=com.asksven.betterbatterystats.

[26] Latedroid. JuiceDefender – battery saver. http://www.juicedefender.com.

[27] LifeHacker.com. Android task killers explained:What they do and why you shouldn’t use them. http://lifehacker.com/5650894.

[28] Microsoft. Supporting your app with backgroundtasks. https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977056.aspx.

12

USENIX Association 2015 USENIX Annual Technical Conference 575

[29] Mittal, R., Kansal, A., and Chandra, R. Empow-ering developers to estimate app energy consumption.In ACMMobiCom’12.

[30] Mobile Enerlytics LCC. eStar: Because mobiledevices are not mobile if they are plugged in. http://mobileenerlytics.com.

[31] Monsoon Solutions Inc. Power monitor. http://www.msoon.com/LabEquipment/PowerMonitor.

[32] Nike, Inc. Nike+Running. http://play.google.com/store/apps/details?id=com.nike.plusgps.

[33] Oliner, A. J., Iyer, A. P., Stoica, I., Lagerspetz,E., and Tarkoma, S. Carat: Collaborative energydiagnosis for mobile devices. In ACM SenSys’13.

[34] Paek, J., Kim, J., and Govindan, R. Energy-e�cient rate-adaptive GPS-based positioning forsmartphones. In ACMMobiSys’10.

[35] Pathak, A., Hu, Y. C., and Zhang, M. Bootstrap-ping energy debugging on smartphones: A �rst lookat energy bugs in mobile devices. In ACMHotNets’11.

[36] Pathak, A., Hu, Y. C. H., and Zhang, M. Finegrained energy accounting on smartphones witheprof. In EuroSys’12.

[37] Pathak, A., Jindal, A., Hu, Y. C., andMidkiff, S. P.What is keepingmy phone awake? characterizing anddetecting no-sleep energy bugs in smartphone apps.In ACMMobiSys’12.

[38] Qian, F., Wang, Z., Gerber, A., Mao, Z., Sen, S.,and Spatscheck, O. Pro�ling resource usage formobile applications: a cross-layer approach. In ACMMobiSys’11.

[39] Qualcomm. Trepn Pro�ler. http://developer.qualcomm.com/mobile-development/increase-app-performance/trepn-profiler.

[40] Reddit. NlpWakeLock and NlpCollectorWake-Lock discussion. https://www.reddit.com/r/

Android/comments/1rvmlr/nlpwakelock_and_nlpcollectorwakelock_discussion/.

[41] rovo89. Xposed development tutorial.https://github.com/rovo89/XposedBridge/wiki/Development-tutorial.

[42] rovo89. Xposed module repository. http://repo.xposed.info.

[43] Roy, A., Rumble, S. M., Stutsman, R., Levis, P.,Mazières, D., and Zeldovich, N. Energy manage-ment in mobile devices with the Cinder operatingsystem. In EuroSys’11.

[44] Siddha, S., Pallipadi, V., and Van De Ven, A. Get-ting maximum mileage out of tickless. In OttawaLinux Symposium’07.

[45] UzumApps. Wakelock Detector. https://play.google.com/store/apps/details?id=com.uzumapps.wakelockdetector.

[46] Vekris, P., Jhala, R., Lerner, S., and Agarwal, Y.Towards verifying android apps for the absence ofno-sleep energy bugs. In HotPower’12.

[47] Xu, F., Liu, Y., Li, Q., andZhang, Y. V-edge: Fast self-constructive power modeling of smartphones basedon battery voltage dynamics. In USENIX NSDI’13.

[48] Xu, F., Liu, Y., Moscibroda, T., Chandra, R., Jin,L., Zhang, Y., and Li, Q. Optimizing backgroundemail sync on smartphones. In ACMMobiSys’13.

[49] Zeng, H., Ellis, C. S., Lebeck, A. R., and Vah-dat, A. ECOSystem: Managing energy as a �rst classoperating system resource. In ASPLOS’02.

[50] Zhang, L., Tiwana, B., Qian, Z., Wang, Z., Dick,R. P., Mao, Z. M., and Yang, L. Accurate onlinepower estimation and automatic battery behaviorbased power model generation for smartphones. In

CODES+ISSS’10.

13