selectively taming background android …...new policies tamer-15: events allowed every 15 minutes...
TRANSCRIPT
Selectively Taming Background Android Apps to Improve Battery Lifetime
Rodrigo Fonseca
Brown University
Justin Cappos
New York University
Marcelo Martins
Brown University
2
Your Battery and You
Active device high battery drainage
Matches our battery life expectation
3
4
Your Battery and You
Idle device expect low battery drain (?)
Background activities break low-power harmony
Energy bugs keep the device awake
Hid
de
n E
ne
rgy
Dra
in
Pure AOSP + Google Mobile Services5
6
0
20
40
60
80
100
0 50 100 150 200 250
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
ASUS MeMO Pad 7
~8.3 days
0
20
40
60
80
100
0 20 40 60 80 100 120 140
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
Samsung Galaxy Nexus
~1.8 days
0
1
2
3
0 50 100 150 200 250 300 350
Po
we
r (W
)
Timeline (s)
NlpLocationReceiverServicePendingIntentCallbackServiceUlrDispatchingServiceNlpWakeLockNlpCollectorWakeLockGeofencerStateMachineGCoreFlpNetworkLocationServiceAlarmManager
Hid
de
n E
ne
rgy
Dra
in
0
1
2
0 50 100 150 200 250 300 350
Po
we
r (W
)
Timeline (s)
AlarmManager
Pure AOSP
+ Google Mobile Services
7
What Can We Do Today?
Reconfigure apps
Uninstall/Switch apps
Kill apps
Change system settings
8
What Can We Do Today?
Reconfigure apps
Uninstall/Switch apps
Kill apps
Change system settings
9
What Can We Do Today?
Reconfigure apps
Uninstall/Switch apps
Kill apps
Change system settings
10
What Can We Do Today?
Reconfigure apps
Uninstall/Switch apps
Kill apps
Change system settings
11
TAMER
12
Runtime mechanism to rate-limit background events
Backgrounding Sources?
Services
Alarms
Intent Receivers
Wakelocks
Tomorrow’s
temperature?
25o C
13
Backgrounding Sources?
Services
Alarms
Intent Receivers
Wakelocks
Sync files
every 15 min
14
Backgrounding Sources?
Services
Alarms
Intent Receivers
Wakelocks
Wake me up
on new msg
15
Backgrounding Sources?
Services
Alarms
Intent Receivers
Wakelocks
Keep screen
awake
16
Services
Alarms
Intent Receivers
Wakelocks
Backgrounding Sources?
Asynchronous
17
Symmetric
Prelude to Blocking: Event Dispatching
1. Event definition (what)
class fetchTemperature extends IntentService {
@Override
public void onHandleIntent(…) {…}
};
18
Tomorrow’s
temperature?
Prelude to Blocking: Event Dispatching
1. Event definition (what)
2. Event request
class fetchTemperature extends IntentService {…}
startService(new Intent(…, fetchTemperature.class));
19
Tomorrow’s
temperature?
Prelude to Blocking: Event Dispatching
1. Event definition (what)
2. Event request
3. Event callback (where)
20
Tomorrow’s
temperature?
startService(…)
⁞
acquireWakelock(…)
⁞
startServiceLocked(…)
⁞
startRunningLocked(…)
Call
ord
er
class fetchTemperature extends IntentService {…}
startService(new Intent(…, fetchTemperature.class));
Blocking the Event Dispatch
1. Event definition (what)
2. Event request
3. Event callback (where)
class fetchTemperature extends IntentService {…}
startService(new Intent(…, fetchTemperature.class));
21
Tomorrow’s
temperature?
startService(…)
⁞
acquireWakelock(…)
⁞
startServiceLocked(…)
⁞
startRunningLocked(…)
Call
ord
er
Throttling Abstraction
Observer Arbiter Actuator Controller
22
Observer Arbiter ActuatorEvent rateEvent
Controller
23
App Name Type #Calls
fetchTemp Service 1231+1
syncPhotos Service 342
scanSystem Service 3
TAMER
Tomorrow’s
temperature?
App
ControllerObserver Arbiter ActuatorEvent rate
Policy
DecisionEvent
only syncs
once a hour
User
24
(Ideal case)
if (monitoredRate > policyThreshold) should block
ControllerObserver Arbiter ActuatorEvent rate
Policy
DecisionEvent
only syncs
once a hour
Expert
25
(Current state)
if (monitoredRate > policyThreshold) should block
ControllerObserver Arbiter ActuatorEvent rate
Policy
DecisionEvent Action
26
Tomorrow’s
temperature?
App TAMER
Observer Arbiter ActuatorObserver Arbiter Actuator
Observer Arbiter ActuatorObserver Arbiter Actuator
Intent Receivers
Alarms
Wakelocks
Services
Libraries
Application Framework
Android Runtime
Kernel
Tamer
Wa
kelock
Service
Inte
nt
Ala
rm
27
Implementation
http://repo.xposed.info
startService(…)
⁞
acquireWakelock(…)
⁞
startServiceLocked(…)
startRunningLocked(…)
Call
ord
er
Tomorrow’s
temperature?
accept
controller
deny
(early return)
28
Java-based runtime code injection via Xposed
Interposes on event callbacks to control their execution
Policies in JSON format
Installation
Installs like any other app (APK file)
Runtime modifications
No need for app recompilation/reinstallation
Android compatibility
Different vendors (Samsung, HTC, ASUS, CyanogenMod, etc.)
Different versions (Ice Cream to KitKat)
Requires rooting
29
Evaluation
Four devices
Android KitKat
Experiments
General lifetime
Energy Bugs
GPS throttling
30
Galaxy Nexus
(2011)
Kindle Fire2
(2012)
Galaxy S4
(2013)
MeMOPad 7
(2014)
Evaluation
Four devices
Android KitKat
Experiments
General lifetime
Energy Bugs
GPS throttling
31
Galaxy Nexus
(2011)
Kindle Fire2
(2012)
Galaxy S4
(2013)
MeMOPad 7
(2014)
Ge
ne
ral L
ife
tim
e
Pure AOSP + Google Mobile Services32
0
20
40
60
80
100
0 50 100 150 200 250
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
ASUS MeMO Pad 7
33
0
20
40
60
80
100
0 20 40 60 80 100 120 140
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
Samsung Galaxy Nexus
Exploring Taming Possibilities
New Policies
Tamer-15: Events allowed every 15 minutes
Tamer-45: Events allowed every 45 minutes
34
ObserverEvent
Monitoring time: 100 hours
One call per minSys awake 11hs
0
20
40
60
80
100
0 50 100 150 200 250
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
ASUS MeMO Pad 7
35
0
20
40
60
80
100
0 20 40 60 80 100 120 140
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
Samsung Galaxy Nexus
36
0
20
40
60
80
100
0 50 100 150 200 250
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
w/ GMS + Tamer-15
w/ GMS + Tamer-45
ASUS MeMO Pad 7
+4.6 days
+5.8 days
0
20
40
60
80
100
0 20 40 60 80 100 120 140
Batt
ery
Level (%
)
Hours
Pure AOSP
w/ Google M. Services
w/ GMS + Tamer-15
w/ GMS + Tamer-45
Samsung Galaxy Nexus
+23 hours
+32 hours
Chasing Energy Bugs – Bejeweled Blitz
10M+ downloads on Play Store
Top 20 on Puzzle Category
37
Chasing Energy Bugs – Bejeweled Blitz
AudioIn AudioIn (!!)
38
Bejeweled Blitz – Effects on Battery Lifetime
0
20
40
60
80
100
0 2 4 6 8 10 12
Battery
Leve
l(%
)
Hours
Candy Crush Saga
Bejeweled (Untamed) 0
20
40
60
80
100
CP
U R
esid
ency (
%)
CPU Frequency
Untamed
Samsung Galaxy S4 39
{“AppName”: “com.ea.BejeweledBlitz_na”
“EventList”: {“Entry”: {
“Type”: “wakelock”“Name”: “AudioIn”“AllowEvery”: “0”“BackgroundOnly”: “true”
}}
}
Chasing Energy Bugs – Bejeweled Blitz
AudioIn
40
After Taming
0
20
40
60
80
100
0 2 4 6 8 10 12
Battery
Leve
l(%
)
Hours
Candy Crush Saga
Bejeweled (Untamed)
Bejeweled (Tamed) 0
20
40
60
80
100
CP
U R
esid
ency (
%)
CPU Frequency
Untamed
Tamed
Samsung Galaxy S4 41
Limitations and Extensions
How to define good policies?
Avoid breaking functionality
Dynamic policies
Context awareness
42
Limitations and Extensions
How to define good policies?
How to engage users?
43
Limitations and Extensions
How to define good policies?
How to engage users?
Event batching instead of blocking
44
Wrap Up
Mobile apps can silently kill battery
TAMER: OS-level mechanism to throttle background events
Separation of control and policy
Extends battery life / Selectively keeps functionality
Effectively mitigates energy bugs
45