SlideShare a Scribd company logo
1 of 27
ANDROID
PERFORMANCE
TUNING
Batter y Drain fixed
SERGII KOZYREV
Android TeamLead
29.06.2017
BATTERY
Why we hate?
What is more important - preserved
battery or uploaded cat’s photo?
Battery drain options
•Screen
•Location Scanning
•Sensors
•Cellular Radio
•CPU
Where to start?
DEMO Battery Historian
Screen
•WakeLocks
•Can’t live without WakeLocks/Sound/Flash
•Need bright screen
Screen Fixed
•Remove WakeLocks (unless it’s payment)
•WakeLocks/Sound/Flash – don’t forget to
“close the door” and remove
•Need bright screen – learn from PlanetaKino
Location Scanning
•GPS (LocationManager vs LocationServices)
•Wi-Fi and BLE (use exponential back off)
Location Scanning Fixed
•GPS – use GeoFencing (100points, 2 min)
•Wi-Fi and BLE – ActivityLifecycleCallbacks as
BatterySaver
Sensors
•Accelerometer (Device, Rate etc.)
•Gyro
Sensors Fixed
•Accelerometer (Device, Rate etc.)
•Gyro
Significant motion (Sensor.TYPE_SIGNIFICANT_MOTION – one time trigger)
Geofencing
Networking
Simple but powerful
What we usually do for networking?
Simple but powerful
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.4.1'
Retrofit retrofit = new Retrofit.Builder().client(new
OkHttpClient.Builder().build())
.baseUrl(getString(R.string.base_url))
.addConverterFactory(GsonConverterFactory.create(new
GsonBuilder().setLenient().create()))
.build()
Simple but powerful
if (response.isSuccessful() || response.isRedirect()) {
return response;
} else {
Simple but powerful
private boolean isNetworkConnected() {
ConnectivityManager connectivityManager =
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
}
No connection, No request, no radio module power consumption, PROFIT!
Doze and AppStandby
What we need to know?
AppStandby
Touches: Application
Condition: App in background
Sync allowed: once per day
Doze
Touches: Device
Condition: Screen off & unplugged
Sync allowed: exponential window
Restricted: network, wakelocks, Alarm*, syncadapter, JobScheduler
How to fit: FCM or exclusions (settings allowed for
IM, Task automation, Peripheral Companion)
Reducing Network Battery Drain
Analyze and Fix
Tag Network Requests
if (Build.VERSION.SDK_INT >= 14) {
try {
TrafficStats.setThreadStatsTag(USER_INITIATED|APP_INITIATED|SERVER_INI
TIATED);
// make network request using HttpClient.execute()
} finally {
TrafficStats.clearThreadStatsTag();
}
}
Use DDMS
Bad
Good
Think and Act!
User-initiated traffic App-initiated traffic Server-initiated traffic
Pre-fetch Network Data
Use batch-requests
(multi-payload)
Batch and Schedule Requests Push(Gcm/Fcm), not pool
SyncAdapter – hard to implement and configure(account,
ContentProvider)
JobScheduler - Minimum API 21
Solution … Firebase JobDispatcher
DEMO
Thank You!

More Related Content

Similar to Android performance tuning. Battery drain fixed.

Intelligente visie maakt drones autonoom
Intelligente visie maakt drones autonoomIntelligente visie maakt drones autonoom
Intelligente visie maakt drones autonoomEUKA
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...pycontw
 
台科大機械系 c 程式語言第二次演講
台科大機械系 c 程式語言第二次演講台科大機械系 c 程式語言第二次演講
台科大機械系 c 程式語言第二次演講Peter Chang
 
Indoor & outdoor distance sensing mobile robot
Indoor & outdoor distance sensing mobile robotIndoor & outdoor distance sensing mobile robot
Indoor & outdoor distance sensing mobile robotzolofy
 
Quadcopter navigation using aakash tablet with on board image processing
Quadcopter navigation using aakash tablet with on board image processingQuadcopter navigation using aakash tablet with on board image processing
Quadcopter navigation using aakash tablet with on board image processingD Yogendra Rao
 
Parc Chaperone
Parc ChaperoneParc Chaperone
Parc ChaperoneApurv MODI
 
IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...
IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...
IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...Ikinnoveer
 
COMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR TrackingCOMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR TrackingMark Billinghurst
 
Wearable Technology Design
Wearable Technology DesignWearable Technology Design
Wearable Technology DesignJeffrey Funk
 
Experience with Google Glass and Business Applications
Experience with Google Glass and Business ApplicationsExperience with Google Glass and Business Applications
Experience with Google Glass and Business ApplicationsMarkus Van Kempen
 
2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR Technology2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR TechnologyMark Billinghurst
 
Interfaces of the future now available augmented reality - google glass - 3...
Interfaces of the future now available   augmented reality - google glass - 3...Interfaces of the future now available   augmented reality - google glass - 3...
Interfaces of the future now available augmented reality - google glass - 3...CuriousInventor
 
Drones in the Cloud
Drones in the CloudDrones in the Cloud
Drones in the CloudGuada Casuso
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesNick Landry
 
Esri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGIS
Esri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGISEsri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGIS
Esri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGISAaron Parecki
 
Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November)
Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November) Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November)
Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November) Lviv Startup Club
 

Similar to Android performance tuning. Battery drain fixed. (20)

Intelligente visie maakt drones autonoom
Intelligente visie maakt drones autonoomIntelligente visie maakt drones autonoom
Intelligente visie maakt drones autonoom
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...
 
台科大機械系 c 程式語言第二次演講
台科大機械系 c 程式語言第二次演講台科大機械系 c 程式語言第二次演講
台科大機械系 c 程式語言第二次演講
 
Indoor & outdoor distance sensing mobile robot
Indoor & outdoor distance sensing mobile robotIndoor & outdoor distance sensing mobile robot
Indoor & outdoor distance sensing mobile robot
 
Bathymetry ME Thesis
Bathymetry ME ThesisBathymetry ME Thesis
Bathymetry ME Thesis
 
AV Latency Measurement
AV Latency MeasurementAV Latency Measurement
AV Latency Measurement
 
Quadcopter navigation using aakash tablet with on board image processing
Quadcopter navigation using aakash tablet with on board image processingQuadcopter navigation using aakash tablet with on board image processing
Quadcopter navigation using aakash tablet with on board image processing
 
2013 Lecture3: AR Tracking
2013 Lecture3: AR Tracking 2013 Lecture3: AR Tracking
2013 Lecture3: AR Tracking
 
Parc Chaperone
Parc ChaperoneParc Chaperone
Parc Chaperone
 
IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...
IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...
IA Ondernemen met innovatieve apps. Welcome to the Age of Wearables. Steven V...
 
COMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR TrackingCOMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR Tracking
 
Wearable Technology Design
Wearable Technology DesignWearable Technology Design
Wearable Technology Design
 
Experience with Google Glass and Business Applications
Experience with Google Glass and Business ApplicationsExperience with Google Glass and Business Applications
Experience with Google Glass and Business Applications
 
2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR Technology2022 COMP4010 Lecture3: AR Technology
2022 COMP4010 Lecture3: AR Technology
 
Interfaces of the future now available augmented reality - google glass - 3...
Interfaces of the future now available   augmented reality - google glass - 3...Interfaces of the future now available   augmented reality - google glass - 3...
Interfaces of the future now available augmented reality - google glass - 3...
 
Drones in the Cloud
Drones in the CloudDrones in the Cloud
Drones in the Cloud
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location Services
 
Sensor's inside
Sensor's insideSensor's inside
Sensor's inside
 
Esri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGIS
Esri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGISEsri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGIS
Esri DevSummit 2013 Speed Geeking: Intro to Esri Geotrigger Service for ArcGIS
 
Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November)
Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November) Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November)
Oleg Novosad - "Ar kit vs arcore" - Lviv GameDev Mixer (November)
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Android performance tuning. Battery drain fixed.

Editor's Notes

  1. Device and application should give us additional value, and should not break things.
  2. Both are important)))
  3. https://github.com/google/battery-historian adb kill-server adb devices adb shell dumpsys batterystats —reset adb shell dumpsys batterystats [<package.name>] > batterystats.txt adb shell dumpsys batterystats > com.performance.ua.performancelab > batterystats.txt python historian.py perfstats.txt > perfstats.html https://source.android.com/devices/tech/power/batterystats Understanding 
  4. Kinopoisk gone Planetakino visible
  5. Test your app with https://developer.android.com/training/monitoring-device-state/doze-standby.html#testing_doze_and_app_standby
  6. /batch_request { requests :[{action:feed_content, params: “id=123&category=food&user_type=unregistered”}, {action:friends_list, params:”id=123&bfs=true”}] }
  7. https://github.com/firebase/firebase-jobdispatcher-android
  8. https://github.com/kozyrevsergey89/PerformanceLab