SlideShare a Scribd company logo
Android: A Bunch of Tools
Romain Guy
@romainguy
http://www.curious-creature.org/+
Command line
$ adb bugreport
$ adb shell dumpsys
$ adb shell dumpsys meminfo <process>
** MEMINFO in pid 1523 [com.example.android.sample] **
                         Shared Private      Heap      Heap     Heap
                   Pss    Dirty    Dirty     Size    Alloc      Free
                ------   ------   ------   ------   ------    ------
       Native     3260      944     3220     9960      6359       20
       Dalvik     6952    15612     6344    21319    16224      5095
       Cursor        0        0        0
       Ashmem        0        0        0
    Other dev    12583      660     1096
     .so mmap     1149     1812      352
    .jar mmap        0        0        0
    .apk mmap      114        0        0
    .ttf mmap        7        0        0
    .dex mmap      807        0        0
   Other mmap       44        8       28
      Unknown     1439      356     1424
        TOTAL    26355    19392    12464    31279    22583      5115




                               1 of 2
** MEMINFO in pid 1523 [com.example.android.sample] **
                         Shared Private      Heap      Heap     Heap
                   Pss    Dirty    Dirty     Size    Alloc      Free
                ------   ------   ------   ------   ------    ------
       Native     3260      944     3220     9960      6359       20
       Dalvik     6952    15612     6344    21319    16224      5095
       Cursor        0        0        0
       Ashmem        0        0        0
    Other dev    12583      660     1096
     .so mmap     1149     1812      352
    .jar mmap        0        0        0
    .apk mmap      114        0        0
    .ttf mmap        7        0        0
    .dex mmap      807        0        0
   Other mmap       44        8       28
      Unknown     1439      356     1424
        TOTAL    26355    19392    12464    31279    22583      5115




                               1 of 2
** MEMINFO in pid 1523 [com.example.android.sample] **
                         Shared Private      Heap      Heap     Heap
                   Pss    Dirty    Dirty     Size    Alloc      Free
                ------   ------   ------   ------   ------    ------
       Native     3260      944     3220     9960      6359       20
       Dalvik     6952    15612     6344    21319    16224      5095
       Cursor        0        0        0
       Ashmem        0        0        0
    Other dev    12583      660     1096
     .so mmap     1149     1812      352
    .jar mmap        0        0        0
    .apk mmap      114        0        0
    .ttf mmap        7        0        0
    .dex mmap      807        0        0
   Other mmap       44        8       28
      Unknown     1439      356     1424
        TOTAL    26355    19392    12464    31279    22583      5115




                               1 of 2
** MEMINFO in pid 1523 [com.example.android.sample] **
                         Shared Private      Heap      Heap     Heap
                   Pss    Dirty    Dirty     Size    Alloc      Free
                ------   ------   ------   ------   ------    ------
       Native     3260      944     3220     9960      6359       20
       Dalvik     6952    15612     6344    21319    16224      5095
       Cursor        0        0        0
       Ashmem        0        0        0
    Other dev    12583      660     1096
     .so mmap     1149     1812      352
    .jar mmap        0        0        0
    .apk mmap      114        0        0
    .ttf mmap        7        0        0
    .dex mmap      807        0        0
   Other mmap       44        8       28
      Unknown     1439      356     1424
        TOTAL    26355    19392    12464    31279    22583      5115




                               1 of 2
Objects
                 Views:    45             ViewRootImpl:    1
           AppContexts:     2               Activities:    1
                Assets:     2            AssetManagers:    2
         Local Binders:    13            Proxy Binders:   14
      Death Recipients:     0
       OpenSSL Sockets:     0

SQL
               heap:        0              MEMORY_USED:    0
 PAGECACHE_OVERFLOW:        0              MALLOC_SIZE:    0



Asset Allocations
   zip:/data/app/com.example.android.sample-2.apk:/resources.arsc: 2K




                                2 of 2
Objects
                 Views:    45             ViewRootImpl:    1
           AppContexts:     2               Activities:    1
                Assets:     2            AssetManagers:    2
         Local Binders:    13            Proxy Binders:   14
      Death Recipients:     0
       OpenSSL Sockets:     0

SQL
               heap:        0              MEMORY_USED:    0
 PAGECACHE_OVERFLOW:        0              MALLOC_SIZE:    0



Asset Allocations
   zip:/data/app/com.example.android.sample-2.apk:/resources.arsc: 2K




                                2 of 2
Objects
                 Views:    45             ViewRootImpl:    1
           AppContexts:     2               Activities:    1
                Assets:     2            AssetManagers:    2
         Local Binders:    13            Proxy Binders:   14
      Death Recipients:     0
       OpenSSL Sockets:     0

SQL
               heap:        0              MEMORY_USED:    0
 PAGECACHE_OVERFLOW:        0              MALLOC_SIZE:    0



Asset Allocations
   zip:/data/app/com.example.android.sample-2.apk:/resources.arsc: 2K




                                2 of 2
$ adb shell dumpsys gfxinfo <process>
Caches:
Current memory usage / total memory usage (bytes):
  TextureCache           1166964 / 25165824
  LayerCache                   0 / 16777216
  GradientCache                0 /   524288
  PathCache                    0 / 4194304
  CircleShapeCache             0 / 1048576
  OvalShapeCache               0 / 1048576
  RoundRectShapeCache          0 / 1048576
  RectShapeCache               0 / 1048576
  ArcShapeCache                0 / 1048576
  TextDropShadowCache          0 / 2097152
  FontRenderer 0          262144 /   262144
  FontRenderer 1          262144 /   262144
  FontRenderer 2          262144 /   262144
Other:
  FboCache                     1 /       16
  PatchCache                  22 /      512
Total memory usage:
  1953396 bytes, 1.86 MB

View hierarchy:
  android.view.ViewRootImpl@40b82f70: 45 views, 4.97 kB (display lists)

Total ViewRootImpl: 1
Total Views:        45
Total DisplayList: 4.97 kB
Caches:
Current memory usage / total memory usage (bytes):
  TextureCache           1166964 / 25165824
  LayerCache                   0 / 16777216
  GradientCache                0 /   524288
  PathCache                    0 / 4194304
  CircleShapeCache             0 / 1048576
  OvalShapeCache               0 / 1048576
  RoundRectShapeCache          0 / 1048576
  RectShapeCache               0 / 1048576
  ArcShapeCache                0 / 1048576
  TextDropShadowCache          0 / 2097152
  FontRenderer 0          262144 /   262144
  FontRenderer 1          262144 /   262144
  FontRenderer 2          262144 /   262144
Other:
  FboCache                     1 /       16
  PatchCache                  22 /      512
Total memory usage:
  1953396 bytes, 1.86 MB

View hierarchy:
  android.view.ViewRootImpl@40b82f70: 45 views, 4.97 kB (display lists)

Total ViewRootImpl: 1
Total Views:        45
Total DisplayList: 4.97 kB
Caches:
Current memory usage / total memory usage (bytes):
  TextureCache           1166964 / 25165824
  LayerCache                   0 / 16777216
  GradientCache                0 /   524288
  PathCache                    0 / 4194304
  CircleShapeCache             0 / 1048576
  OvalShapeCache               0 / 1048576
  RoundRectShapeCache          0 / 1048576
  RectShapeCache               0 / 1048576
  ArcShapeCache                0 / 1048576
  TextDropShadowCache          0 / 2097152
  FontRenderer 0          262144 /   262144
  FontRenderer 1          262144 /   262144
  FontRenderer 2          262144 /   262144
Other:
  FboCache                     1 /       16
  PatchCache                  22 /      512
Total memory usage:
  1953396 bytes, 1.86 MB

View hierarchy:
  android.view.ViewRootImpl@40b82f70: 45 views, 4.97 kB (display lists)

Total ViewRootImpl: 1
Total Views:        45
Total DisplayList: 4.97 kB
And more...
Tracking memory
Memory tracking tools
• DDMS heap dump
 – hat, Eclipse MAT
• Allocation Tracker
More information
• Eclipse Memory Analyzer (MAT)
 – Supported by ADT
 – http://eclipse.org/mat/
• Memory Management for Android Apps
 – Google I/O 2011
 – http://www.google.com/events/io/2011/sessions/memory-
   management-for-android-apps.html
Demo
DDMS & hat
Tracking... stuff
Demo
DDMS graphs
Analyzing performance
Performance analysis tools
• Frame rate
• traceview
Tracking Frame Rate
Framerate counter



 preDrawListener = new OnPreDrawListener() {
     @Override
     public boolean onPreDraw() {
         trackFPS();
         return true;
     }
 };

 ViewTreeObserver observer = view.getViewTreeObserver();
 observer.addOnPreDrawListener(preDrawListener);
long mFpsStartTime = -1;
long mFpsPrevTime = -1;
int mFpsNumFrames = 0;

private void trackFPS() {
    long nowTime = System.currentTimeMillis();
    if (mFpsStartTime < 0) {
        mFpsStartTime = mFpsPrevTime = nowTime;
        mFpsNumFrames = 0;
    } else {
        ++mFpsNumFrames;
        long frameTime = nowTime - mFpsPrevTime;
        long totalTime = nowTime - mFpsStartTime;
        Log.d("FPS", "Frame time:t" + frameTime);
        mFpsPrevTime = nowTime;
        if (totalTime > 1000) {
             float fps = (float) mFpsNumFrames * 1000 / totalTime;
             Log.d("FPS", "FPS:t" + fps);
             mFpsStartTime = nowTime;
             mFpsNumFrames = 0;
        }
    }
}
Framerate counter
• Use code on preceding slides in your onDraw() method
• Or if you can change the source
 – Set DEBUG_FPS to true in ViewRootImpl.java
 – Rebuild frameworks
Demo
traceview
Hardware
HDMI Capture
• 60 fps recording
• Frame by frame replay
• Requires fast computer
• Requires HDMI output on device
 – Xoom
 – Galaxy Nexus
• e.g. BlackMagic Intensity Pro
Android tools - 17 avril 2012
High-speed Camera
• Great framerate
 – 60 to 1200 fps
• Low resolution & affordable
 – e.g. Casio EX-F1 300fps@512x384
• High resolution & (very) expensive
 – e.g. RED EPIC-M 300fps@2048x854
• Support all devices
Android tools - 17 avril 2012
Demo
HDMI recorder and high-speed camera
HierarchyViewer
@ViewDebug.ExportedProperty
@ViewDebug.ExportedProperty
• Fields
• Methods
  – No argument
  – Return value
  – i.e. getters
@ViewDebug.ExportedProperty(mapping = {
    @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"),
    @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"),
    @ViewDebug.IntToString(from = GONE, to = "GONE")
})
int mVisibility;
@ViewDebug.ExportedProperty(resolveId = true)
int mID = NO_ID;
@ViewDebug.ExportedProperty(
        deepExport = true,
        prefix = "layout_")
public ViewGroup.LayoutParams getLayoutParams() {
    return mLayoutParams;
}
Limitations
• Does not work on retail devices
 – “user” builds
 – Security reasons
• Works on
 – “userdebug” builds
 – “eng” builds
 – emulator
ViewServer
https://github.com/romainguy/ViewServer
public class ViewServerActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ViewServer.get(this).addWindow(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ViewServer.get(this).removeWindow(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        ViewServer.get(this).setFocusedWindow(this);
    }
}
public class ViewServerActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ViewServer.get(this).addWindow(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ViewServer.get(this).removeWindow(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        ViewServer.get(this).setFocusedWindow(this);
    }
}
public class ViewServerActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ViewServer.get(this).addWindow(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ViewServer.get(this).removeWindow(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        ViewServer.get(this).setFocusedWindow(this);
    }
}
public class ViewServerActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        ViewServer.get(this).addWindow(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        ViewServer.get(this).removeWindow(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        ViewServer.get(this).setFocusedWindow(this);
    }
}
ViewServer
• Single class
  – Apache 2.0 license
  – Requires INTERNET permission
• API works with
  – Activity
  – Window
• Only
  – for your app
  – for debuggable apps
  – on user builds
layoutopt
li n t
layoutopt
lint

$ lint frameworks/base/tests/ChetBugs/TextViewScale

AndroidManifest.xml: Warning: Manifest should specify a minimum API level with <uses-sdk
android:minSdkVersion="?" />; if it really supports all versions of Android set it to 1. [UsesSdk]
res/drawable-hdpi/change_background.png: Warning: The resource R.drawable.change_background appears to be unused
[UnusedResources]
res/drawable-hdpi/gbread.jpg: Warning: The resource R.drawable.gbread appears to be unused [UnusedResources]
res/drawable-hdpi/gbread_sm.jpg: Warning: The resource R.drawable.gbread_sm appears to be unused
[UnusedResources]
res/drawable-hdpi/refresh.png: Warning: The resource R.drawable.refresh appears to be unused [UnusedResources]
res/drawable-hdpi/self_portrait.jpg: Warning: The resource R.drawable.self_portrait appears to be unused
[UnusedResources]
res/drawable-hdpi/gbread.jpg: Warning: The image gbread.jpg varies significantly in its density-independent (dip)
size across the various density versions: drawable-mdpi/gbread.jpg: 2560x1920 dp (2560x1920 px), drawable-hdpi/
gbread.jpg: 1707x1280 dp (2560x1920 px) [IconDipSize]
res/drawable-hdpi/gbread_sm.jpg: Warning: The image gbread_sm.jpg varies significantly in its density-independent
(dip) size across the various density versions: drawable-mdpi/gbread_sm.jpg: 480x640 dp (480x640 px), drawable-
hdpi/gbread_sm.jpg: 320x427 dp (480x640 px) [IconDipSize]
res/drawable-hdpi/self_portrait.jpg: Warning: The image self_portrait.jpg varies significantly in its density-
independent (dip) size across the various density versions: drawable-mdpi/self_portrait.jpg: 671x800 dp (671x800
px), drawable-hdpi/self_portrait.jpg: 447x533 dp (671x800 px) [IconDipSize]
res/drawable-mdpi/gbread.jpg: Warning: The gbread.jpg icon has identical contents in the following configuration
folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig]
res/drawable-mdpi/gbread_sm.jpg: Warning: The gbread_sm.jpg icon has identical contents in the following
configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig]
res/drawable-mdpi/self_portrait.jpg: Warning: The self_portrait.jpg icon has identical contents in the following
configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig]
res/drawable-mdpi/self_portrait.jpg: Warning: The self_portrait.jpg icon has identical contents in the following
configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig]
res: Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder]
0 errors, 13 warnings
Better yet, use html
$ lint frameworks/base/tests/ChetBugs/TextViewScale --html ~/tmp/lintoutput.html
Future tools
OpenGL Monitor
• Tracing
• Profiling
• State tracking
• Capture
  – Framebuffer
  – Intermediate drawing stages
  – Textures
Demo
OpenGL Monitor
Android tools - 17 avril 2012
Q&A

More Related Content

PDF
200.1,2-Capacity Planning
PPT
Performance analysis in a multitenant cloud environment Using Hadoop Cluster ...
PDF
High Availability With DRBD & Heartbeat
PPTX
High Availability Server with DRBD in linux
PDF
FreeBSD 2014 Flame Graphs
PDF
Exadata and OLTP
PDF
Open Source Systems Performance
PDF
EuroBSDcon 2017 System Performance Analysis Methodologies
200.1,2-Capacity Planning
Performance analysis in a multitenant cloud environment Using Hadoop Cluster ...
High Availability With DRBD & Heartbeat
High Availability Server with DRBD in linux
FreeBSD 2014 Flame Graphs
Exadata and OLTP
Open Source Systems Performance
EuroBSDcon 2017 System Performance Analysis Methodologies

What's hot (14)

PDF
Blazing Performance with Flame Graphs
PDF
The New Systems Performance
DOCX
Tutorial to setup OpenStreetMap tileserver with customized boundaries of India
PDF
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
PDF
Modeling and Control Robot Arm using Gazebo, MoveIt!, ros_control
PDF
LSFMM 2019 BPF Observability
PDF
DOD 2016 - Jörg Schad - Nobody Puts Java in the Conainer
PPTX
QCon 2015 Broken Performance Tools
PDF
Performance Wins with BPF: Getting Started
PPTX
Ros자작로봇황성관21
PDF
marko_go_in_badoo
PDF
Linux Performance Tools
PDF
Linux Performance Profiling and Monitoring
PDF
Universal Userland
Blazing Performance with Flame Graphs
The New Systems Performance
Tutorial to setup OpenStreetMap tileserver with customized boundaries of India
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
Modeling and Control Robot Arm using Gazebo, MoveIt!, ros_control
LSFMM 2019 BPF Observability
DOD 2016 - Jörg Schad - Nobody Puts Java in the Conainer
QCon 2015 Broken Performance Tools
Performance Wins with BPF: Getting Started
Ros자작로봇황성관21
marko_go_in_badoo
Linux Performance Tools
Linux Performance Profiling and Monitoring
Universal Userland
Ad

Similar to Android tools - 17 avril 2012 (20)

PDF
Android Development Tools
PDF
Android Development Tools
PDF
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
PDF
Reusing your existing software on Android
PPTX
Percona Live UK 2014 Part III
PDF
Docker 활용법: dumpdocker
PPTX
IDS.pptx
ODP
Analysis of Compromised Linux Server
PDF
Multipath
PDF
Headless Android at AnDevCon3
PDF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
PDF
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
PDF
PDF
Debugging TV Frame 0x34
PDF
BPF: Tracing and more
PDF
Docker - container and lightweight virtualization
PDF
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
PDF
Android developer tools
PDF
SBA Live Academy - Secure Containers for Developer by Mathias Tausig
PPTX
How to build a container monitoring solution - David Gildeh, CEO and Co-Found...
Android Development Tools
Android Development Tools
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
Reusing your existing software on Android
Percona Live UK 2014 Part III
Docker 활용법: dumpdocker
IDS.pptx
Analysis of Compromised Linux Server
Multipath
Headless Android at AnDevCon3
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Ceph Day SF 2015 - Big Data Applications and Tuning in Ceph
Debugging TV Frame 0x34
BPF: Tracing and more
Docker - container and lightweight virtualization
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Android developer tools
SBA Live Academy - Secure Containers for Developer by Mathias Tausig
How to build a container monitoring solution - David Gildeh, CEO and Co-Found...
Ad

More from Paris Android User Group (20)

PDF
Workshop: building your mobile backend with Parse - Droidcon Paris2014
PDF
Workshop: Amazon developer ecosystem - DroidCon Paris2014
PDF
Extending your apps to wearables - DroidCon Paris 2014
PDF
Scaling android development - DroidCon Paris 2014
PDF
Ingredient of awesome app - DroidCon Paris 2014
PDF
Framing the canvas - DroidCon Paris 2014
PDF
Deep dive into android restoration - DroidCon Paris 2014
PDF
Archos Android based connected home solution - DroidCon Paris 2014
PDF
Porting VLC on Android - DroidCon Paris 2014
PDF
Robotium vs Espresso: Get ready to rumble ! - DroidCon Paris 2014
PDF
Buildsystem.mk - DroidCon Paris 2014
PDF
maximize app engagement and monetization - DroidCon Paris 2014
PPTX
Using the android ndk - DroidCon Paris 2014
PPTX
Holo material design transition - DroidCon Paris 2014
PPTX
Death to passwords - DroidCon Paris 2014
PPTX
Google glass droidcon - DroidCon Paris 2014
PPTX
Embedded webserver implementation and usage - DroidCon Paris 2014
PDF
Petit design Grande humanité par Geoffrey Dorne - DroidCon Paris 2014
PDF
What's new in android 4.4 - Romain Guy & Chet Haase
PDF
Efficient Image Processing - Nicolas Roard
Workshop: building your mobile backend with Parse - Droidcon Paris2014
Workshop: Amazon developer ecosystem - DroidCon Paris2014
Extending your apps to wearables - DroidCon Paris 2014
Scaling android development - DroidCon Paris 2014
Ingredient of awesome app - DroidCon Paris 2014
Framing the canvas - DroidCon Paris 2014
Deep dive into android restoration - DroidCon Paris 2014
Archos Android based connected home solution - DroidCon Paris 2014
Porting VLC on Android - DroidCon Paris 2014
Robotium vs Espresso: Get ready to rumble ! - DroidCon Paris 2014
Buildsystem.mk - DroidCon Paris 2014
maximize app engagement and monetization - DroidCon Paris 2014
Using the android ndk - DroidCon Paris 2014
Holo material design transition - DroidCon Paris 2014
Death to passwords - DroidCon Paris 2014
Google glass droidcon - DroidCon Paris 2014
Embedded webserver implementation and usage - DroidCon Paris 2014
Petit design Grande humanité par Geoffrey Dorne - DroidCon Paris 2014
What's new in android 4.4 - Romain Guy & Chet Haase
Efficient Image Processing - Nicolas Roard

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
Teaching material agriculture food technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
sap open course for s4hana steps from ECC to s4
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Teaching material agriculture food technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
sap open course for s4hana steps from ECC to s4
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Advanced methodologies resolving dimensionality complications for autism neur...
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Per capita expenditure prediction using model stacking based on satellite ima...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KodekX | Application Modernization Development

Android tools - 17 avril 2012

  • 1. Android: A Bunch of Tools Romain Guy @romainguy http://www.curious-creature.org/+
  • 4. $ adb shell dumpsys
  • 5. $ adb shell dumpsys meminfo <process>
  • 6. ** MEMINFO in pid 1523 [com.example.android.sample] ** Shared Private Heap Heap Heap Pss Dirty Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ Native 3260 944 3220 9960 6359 20 Dalvik 6952 15612 6344 21319 16224 5095 Cursor 0 0 0 Ashmem 0 0 0 Other dev 12583 660 1096 .so mmap 1149 1812 352 .jar mmap 0 0 0 .apk mmap 114 0 0 .ttf mmap 7 0 0 .dex mmap 807 0 0 Other mmap 44 8 28 Unknown 1439 356 1424 TOTAL 26355 19392 12464 31279 22583 5115 1 of 2
  • 7. ** MEMINFO in pid 1523 [com.example.android.sample] ** Shared Private Heap Heap Heap Pss Dirty Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ Native 3260 944 3220 9960 6359 20 Dalvik 6952 15612 6344 21319 16224 5095 Cursor 0 0 0 Ashmem 0 0 0 Other dev 12583 660 1096 .so mmap 1149 1812 352 .jar mmap 0 0 0 .apk mmap 114 0 0 .ttf mmap 7 0 0 .dex mmap 807 0 0 Other mmap 44 8 28 Unknown 1439 356 1424 TOTAL 26355 19392 12464 31279 22583 5115 1 of 2
  • 8. ** MEMINFO in pid 1523 [com.example.android.sample] ** Shared Private Heap Heap Heap Pss Dirty Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ Native 3260 944 3220 9960 6359 20 Dalvik 6952 15612 6344 21319 16224 5095 Cursor 0 0 0 Ashmem 0 0 0 Other dev 12583 660 1096 .so mmap 1149 1812 352 .jar mmap 0 0 0 .apk mmap 114 0 0 .ttf mmap 7 0 0 .dex mmap 807 0 0 Other mmap 44 8 28 Unknown 1439 356 1424 TOTAL 26355 19392 12464 31279 22583 5115 1 of 2
  • 9. ** MEMINFO in pid 1523 [com.example.android.sample] ** Shared Private Heap Heap Heap Pss Dirty Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ Native 3260 944 3220 9960 6359 20 Dalvik 6952 15612 6344 21319 16224 5095 Cursor 0 0 0 Ashmem 0 0 0 Other dev 12583 660 1096 .so mmap 1149 1812 352 .jar mmap 0 0 0 .apk mmap 114 0 0 .ttf mmap 7 0 0 .dex mmap 807 0 0 Other mmap 44 8 28 Unknown 1439 356 1424 TOTAL 26355 19392 12464 31279 22583 5115 1 of 2
  • 10. Objects Views: 45 ViewRootImpl: 1 AppContexts: 2 Activities: 1 Assets: 2 AssetManagers: 2 Local Binders: 13 Proxy Binders: 14 Death Recipients: 0 OpenSSL Sockets: 0 SQL heap: 0 MEMORY_USED: 0 PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0 Asset Allocations zip:/data/app/com.example.android.sample-2.apk:/resources.arsc: 2K 2 of 2
  • 11. Objects Views: 45 ViewRootImpl: 1 AppContexts: 2 Activities: 1 Assets: 2 AssetManagers: 2 Local Binders: 13 Proxy Binders: 14 Death Recipients: 0 OpenSSL Sockets: 0 SQL heap: 0 MEMORY_USED: 0 PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0 Asset Allocations zip:/data/app/com.example.android.sample-2.apk:/resources.arsc: 2K 2 of 2
  • 12. Objects Views: 45 ViewRootImpl: 1 AppContexts: 2 Activities: 1 Assets: 2 AssetManagers: 2 Local Binders: 13 Proxy Binders: 14 Death Recipients: 0 OpenSSL Sockets: 0 SQL heap: 0 MEMORY_USED: 0 PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0 Asset Allocations zip:/data/app/com.example.android.sample-2.apk:/resources.arsc: 2K 2 of 2
  • 13. $ adb shell dumpsys gfxinfo <process>
  • 14. Caches: Current memory usage / total memory usage (bytes): TextureCache 1166964 / 25165824 LayerCache 0 / 16777216 GradientCache 0 / 524288 PathCache 0 / 4194304 CircleShapeCache 0 / 1048576 OvalShapeCache 0 / 1048576 RoundRectShapeCache 0 / 1048576 RectShapeCache 0 / 1048576 ArcShapeCache 0 / 1048576 TextDropShadowCache 0 / 2097152 FontRenderer 0 262144 / 262144 FontRenderer 1 262144 / 262144 FontRenderer 2 262144 / 262144 Other: FboCache 1 / 16 PatchCache 22 / 512 Total memory usage: 1953396 bytes, 1.86 MB View hierarchy: android.view.ViewRootImpl@40b82f70: 45 views, 4.97 kB (display lists) Total ViewRootImpl: 1 Total Views: 45 Total DisplayList: 4.97 kB
  • 15. Caches: Current memory usage / total memory usage (bytes): TextureCache 1166964 / 25165824 LayerCache 0 / 16777216 GradientCache 0 / 524288 PathCache 0 / 4194304 CircleShapeCache 0 / 1048576 OvalShapeCache 0 / 1048576 RoundRectShapeCache 0 / 1048576 RectShapeCache 0 / 1048576 ArcShapeCache 0 / 1048576 TextDropShadowCache 0 / 2097152 FontRenderer 0 262144 / 262144 FontRenderer 1 262144 / 262144 FontRenderer 2 262144 / 262144 Other: FboCache 1 / 16 PatchCache 22 / 512 Total memory usage: 1953396 bytes, 1.86 MB View hierarchy: android.view.ViewRootImpl@40b82f70: 45 views, 4.97 kB (display lists) Total ViewRootImpl: 1 Total Views: 45 Total DisplayList: 4.97 kB
  • 16. Caches: Current memory usage / total memory usage (bytes): TextureCache 1166964 / 25165824 LayerCache 0 / 16777216 GradientCache 0 / 524288 PathCache 0 / 4194304 CircleShapeCache 0 / 1048576 OvalShapeCache 0 / 1048576 RoundRectShapeCache 0 / 1048576 RectShapeCache 0 / 1048576 ArcShapeCache 0 / 1048576 TextDropShadowCache 0 / 2097152 FontRenderer 0 262144 / 262144 FontRenderer 1 262144 / 262144 FontRenderer 2 262144 / 262144 Other: FboCache 1 / 16 PatchCache 22 / 512 Total memory usage: 1953396 bytes, 1.86 MB View hierarchy: android.view.ViewRootImpl@40b82f70: 45 views, 4.97 kB (display lists) Total ViewRootImpl: 1 Total Views: 45 Total DisplayList: 4.97 kB
  • 19. Memory tracking tools • DDMS heap dump – hat, Eclipse MAT • Allocation Tracker
  • 20. More information • Eclipse Memory Analyzer (MAT) – Supported by ADT – http://eclipse.org/mat/ • Memory Management for Android Apps – Google I/O 2011 – http://www.google.com/events/io/2011/sessions/memory- management-for-android-apps.html
  • 25. Performance analysis tools • Frame rate • traceview
  • 27. Framerate counter preDrawListener = new OnPreDrawListener() { @Override public boolean onPreDraw() { trackFPS(); return true; } }; ViewTreeObserver observer = view.getViewTreeObserver(); observer.addOnPreDrawListener(preDrawListener);
  • 28. long mFpsStartTime = -1; long mFpsPrevTime = -1; int mFpsNumFrames = 0; private void trackFPS() { long nowTime = System.currentTimeMillis(); if (mFpsStartTime < 0) { mFpsStartTime = mFpsPrevTime = nowTime; mFpsNumFrames = 0; } else { ++mFpsNumFrames; long frameTime = nowTime - mFpsPrevTime; long totalTime = nowTime - mFpsStartTime; Log.d("FPS", "Frame time:t" + frameTime); mFpsPrevTime = nowTime; if (totalTime > 1000) { float fps = (float) mFpsNumFrames * 1000 / totalTime; Log.d("FPS", "FPS:t" + fps); mFpsStartTime = nowTime; mFpsNumFrames = 0; } } }
  • 29. Framerate counter • Use code on preceding slides in your onDraw() method • Or if you can change the source – Set DEBUG_FPS to true in ViewRootImpl.java – Rebuild frameworks
  • 32. HDMI Capture • 60 fps recording • Frame by frame replay • Requires fast computer • Requires HDMI output on device – Xoom – Galaxy Nexus • e.g. BlackMagic Intensity Pro
  • 34. High-speed Camera • Great framerate – 60 to 1200 fps • Low resolution & affordable – e.g. Casio EX-F1 300fps@512x384 • High resolution & (very) expensive – e.g. RED EPIC-M 300fps@2048x854 • Support all devices
  • 36. Demo HDMI recorder and high-speed camera
  • 39. @ViewDebug.ExportedProperty • Fields • Methods – No argument – Return value – i.e. getters
  • 40. @ViewDebug.ExportedProperty(mapping = { @ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"), @ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"), @ViewDebug.IntToString(from = GONE, to = "GONE") }) int mVisibility;
  • 42. @ViewDebug.ExportedProperty( deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams() { return mLayoutParams; }
  • 43. Limitations • Does not work on retail devices – “user” builds – Security reasons • Works on – “userdebug” builds – “eng” builds – emulator
  • 45. public class ViewServerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewServer.get(this).addWindow(this); } @Override public void onDestroy() { super.onDestroy(); ViewServer.get(this).removeWindow(this); } @Override public void onResume() { super.onResume(); ViewServer.get(this).setFocusedWindow(this); } }
  • 46. public class ViewServerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewServer.get(this).addWindow(this); } @Override public void onDestroy() { super.onDestroy(); ViewServer.get(this).removeWindow(this); } @Override public void onResume() { super.onResume(); ViewServer.get(this).setFocusedWindow(this); } }
  • 47. public class ViewServerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewServer.get(this).addWindow(this); } @Override public void onDestroy() { super.onDestroy(); ViewServer.get(this).removeWindow(this); } @Override public void onResume() { super.onResume(); ViewServer.get(this).setFocusedWindow(this); } }
  • 48. public class ViewServerActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewServer.get(this).addWindow(this); } @Override public void onDestroy() { super.onDestroy(); ViewServer.get(this).removeWindow(this); } @Override public void onResume() { super.onResume(); ViewServer.get(this).setFocusedWindow(this); } }
  • 49. ViewServer • Single class – Apache 2.0 license – Requires INTERNET permission • API works with – Activity – Window • Only – for your app – for debuggable apps – on user builds
  • 52. lint $ lint frameworks/base/tests/ChetBugs/TextViewScale AndroidManifest.xml: Warning: Manifest should specify a minimum API level with <uses-sdk android:minSdkVersion="?" />; if it really supports all versions of Android set it to 1. [UsesSdk] res/drawable-hdpi/change_background.png: Warning: The resource R.drawable.change_background appears to be unused [UnusedResources] res/drawable-hdpi/gbread.jpg: Warning: The resource R.drawable.gbread appears to be unused [UnusedResources] res/drawable-hdpi/gbread_sm.jpg: Warning: The resource R.drawable.gbread_sm appears to be unused [UnusedResources] res/drawable-hdpi/refresh.png: Warning: The resource R.drawable.refresh appears to be unused [UnusedResources] res/drawable-hdpi/self_portrait.jpg: Warning: The resource R.drawable.self_portrait appears to be unused [UnusedResources] res/drawable-hdpi/gbread.jpg: Warning: The image gbread.jpg varies significantly in its density-independent (dip) size across the various density versions: drawable-mdpi/gbread.jpg: 2560x1920 dp (2560x1920 px), drawable-hdpi/ gbread.jpg: 1707x1280 dp (2560x1920 px) [IconDipSize] res/drawable-hdpi/gbread_sm.jpg: Warning: The image gbread_sm.jpg varies significantly in its density-independent (dip) size across the various density versions: drawable-mdpi/gbread_sm.jpg: 480x640 dp (480x640 px), drawable- hdpi/gbread_sm.jpg: 320x427 dp (480x640 px) [IconDipSize] res/drawable-hdpi/self_portrait.jpg: Warning: The image self_portrait.jpg varies significantly in its density- independent (dip) size across the various density versions: drawable-mdpi/self_portrait.jpg: 671x800 dp (671x800 px), drawable-hdpi/self_portrait.jpg: 447x533 dp (671x800 px) [IconDipSize] res/drawable-mdpi/gbread.jpg: Warning: The gbread.jpg icon has identical contents in the following configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig] res/drawable-mdpi/gbread_sm.jpg: Warning: The gbread_sm.jpg icon has identical contents in the following configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig] res/drawable-mdpi/self_portrait.jpg: Warning: The self_portrait.jpg icon has identical contents in the following configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig] res/drawable-mdpi/self_portrait.jpg: Warning: The self_portrait.jpg icon has identical contents in the following configuration folders: drawable-hdpi, drawable-mdpi [IconDuplicatesConfig] res: Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder] 0 errors, 13 warnings
  • 53. Better yet, use html $ lint frameworks/base/tests/ChetBugs/TextViewScale --html ~/tmp/lintoutput.html
  • 55. OpenGL Monitor • Tracing • Profiling • State tracking • Capture – Framebuffer – Intermediate drawing stages – Textures
  • 58. Q&A