Data Extraction from an Android App using Python
Introduction
Android Application performance metrics include ( Memory, CPU, Network, Systrace Analysis and many more .. ) Out of all memory is most important metric and can be used to create initial data
Which part of memory is the most important one ?
Screenshot from Android Profiler :
- Java: Memory from objects allocated from Java or Kotlin code
- Code: Memory that your app uses for code and resources, such as dex bytecode, optimized or compiled dex code, .so libraries, and fonts
Java and Code are the most important ones. We will concentrate on two for this blog
How to perform Machine Learning in Android ?
We will analyse Application Memory ( Java and Code ) of Benchmark App and Test App using Data Science
Steps involved :
I have divided Blog into 3 parts :
Part 1: Extracting data from Android , Creating Database , Inserting data which includes Classes and Features
Part 2: Reading Data from database , Creating Dataframe, Doing Exploratory Data Analysis , Visualisation using Matplotlib, Creating Machine Learning model , Predicting Accuracy, Analysing using Confusion Matrix
Part 3: Best Practices in Machine Learning, Framework to use …
Part 1
- Get data from Phone using Memory dumpsys ( Adb shell dumpsys meminfo — Package name)
- Save data in database (Sqlite3)
- Read data from db, convert into pandas dataframe
Get data from Android :
Command : adb shell dumpsys meminfo package_name|pid
The output lists all of your app’s current allocations, measured in kilobytes
Proportional Set Size (PSS) : This is a measurement of your app’s RAM use that takes into account sharing pages across processes.In general, be concerned with only the Pss Total
and Private Dirty
columns
Python Function which outputs a dictionary of memory distribution :
Save data in database (Sqlite3):
Every android app contains multiple activities , For Android app performance analysis we should check memory consumption for each activity. Generally apps contain following screens :
1. Pin Screen
2. Home Screen
3. Detail Screen
4. Search Screen
and many more …
Now in terms of Machine Learning we can use each screen as an unique class and Memory details ( Native_Pss , Native_Private_Dirty , Native_Heap_Alloc, Native_Heap_Free, Code_Pss and Code_Private_Dirty ) as Features
Table looks like :
Python Function to save data in sqlite database :
For every class we can insert data using above insertTable function of DatabaseClass
This ends Part1. I will be soon sharing Part2 and Part3
Part2 : https://analysingpatterns.blogspot.com/2019/02/exploratory-data-analysis-using-numpy.html
Other paths are coming up soon! Stay tuned. Please share your valuable feedbacks !
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —