39
May The ‘P wer’ be with you - Prajyot Mainkar

Android Power Optimization: May the Power be with you

Embed Size (px)

Citation preview

May The ‘P wer’ be with you- PrajyotMainkar

WWW.COMPANY.COM

1

2

3

Agenda For Today

#BatteryMatters

#Requests

Q & A

“I Care Performance”

“Wegot‘awesome’featuresbuiltintheapp”

Users Care about their BatteryBattery Life

WiFi Speed/Quality

Touch Screen

Screen/Display Size

Display Type/ Quality

Connectivity

Memory

Display Resolution

0 10 20 30 40 50 60 70 80 90 100

38%42%44%46%46%48%

52%72%

Source: Qualcomm Band Tracker, Market Search Group, US

Power Banks F.T.W

WWW.COMPANY.COM

Battery is Part of User’s Experience

Compromising for Benefits

20-30%CoreFunctions

70%ADs,GPS,Analytics

..and this is what it should ends like

20-30%CoreFunctions

70%ADs,GPS,Analytics

ReducetheBatteryConsumption

Where does the power go?

CPU RADIOS SCREEN

Screen OFF

e.g. wakelocks e.g. syncs, n/w activities

Background Activities

Screen ON

Design Principal

Reduce Defer Coalesce

Say Minimum/ lesser background activities

If required, defer it to when the

phone is plugged in

Coalesce it with other activities to reduce wakeup

overhead

Doze ( Marshmallow)

Significant Motion Detector is needed for trackingCoalesce

Doze ( Android N)

Significant Motion Detector is needed for tracking

App Standby

System determines the state of an app is idle when the user is not actively using it. It understands the app that is not being touched but also takes into consideration that NONE of these should imply:

The user explicitly launches the app.

The app has a process currently in the foreground (either as an activity or foreground service, or in use by another activity or foreground service).

The app generates a notification that users see on the lock screen or in the notification tray.

WWW.COMPANY.COM

Hello GPS!

setInterval() setFastestInterval()

Knowing Your Location

MoreAccurateMorePower

GPS Provider

LessAccurateLessPower

Cellular Network Provider Passive Provider

ToYourApp

setInterval() Dilemma?

120ms 120ms 120ms

More Accurate Data?

Saving Battery Juice

V/s

Location Flooding

120ms 120ms 120ms

setInterval of other apps can affect your

app

setFastestInterval()setFastestInterval()

20ms 20ms 20ms

Back off based on User Behaviour

SavesBattery

Wait2XLonger

Sync Sync Sync

Wait2XLonger

ExponentialBackoff

PRIORITY_BALANCED_POWER_ACCURACY

Seeking Accuracy?

PRIORITY_HIGH_ACCURACY PRIORITY_LOW_POWER

PRIORITY_NO_POWER

BetterAccuracy BetterBattery

Do Less,When You CanDoyoureallyneedGPS?

Approximation?

AsktheUserCarryOn

YesNo

YesNo

YouareSafe!

Use Proximation in Action to reduce the resource usage

Less time, Less process results but still meeting user’s needs

Approximation of Pixels

2. Networking for GrowthNetworking for Growth

The ‘Networking’ Pain

More Network

More Memory

GPS All the Time!

WWW.COMPANY.COM

Sync LessMore ‘Power’ to you

Understanding “Networking”

Do Now Server Response Data Push

OptimizationisPossible

Think of a good time!

Uploading of Files/Songs

Cropping of Images

Loading of Data

Sync Smartly

Say ‘Bye’ to Polling

New News?No

New News?No

New News?No

New News available

OK

Prefetch Data

A way to avoid number of independent data transfer sessions

Allows user to download all the data in a given period in a single burst & connection, at full capacity. Reduces radio activations and bandwidth, improves battery life and latency. e.g Music Player, News reader

Batch Transfer & Connections

Bundle your data transfers and create a pending transfer queue

Transfer as much data as possible during each transfer session to limit the number of sessions you require

Care about Network State

WiFi will be fast and Cheap - give priority

Avoid connections if NO Network is available.

Manipulate Broadcast receivers on demand

Are you on Roaming?

Varying Download pattern

Modify the pattern based on connection type. Also, think behaviour type

Download more data per session on faster networks

..but involve user in this sceneForce a quicker pre-fetch

Monitor Charge Level & State

Dock Types

Car Desk Low-End (Analog) Desk

High-End (Digital) Desk

Maximise app updates and its frequency when battery is charging

Avoid updates when charge state is discharging

Opt to update the frequency of update when charged with desktop dock than car dock

Programatically control the features

Darker Color, Lesser Consumption

Brightness Level have more impact

WakeLock, Really?

Issue/Issues batch? Job Scheduler

Checking the stats

Wakelock Time

Network Time

Battery Historian

Gather Insight Action

Use the tools that help you gather the information - GPU, CPU or Battery Usage

What it means, and how it will impact your program

Act on it and repeat!

12

3

The LifecycleUnderstanding which

tool to use, to understand what data and then where to look into the code

“Before the battle of the fist comes the battle of the Performance.”

Pr@jyot Mainkar Director/Androcid Media Pvt. Ltd. (www.androcid.com) @prajyotm /prajyotmainkar +prajyotmainkar

Thank you!