SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
Extending Android's Platform
Toolsuite
Embedded Linux Conference Europe 2015
Karim Yaghmour
@karimyaghmour / +karimyaghmour
karim.yaghmour@opersys.com
2 2
These slides are made available to you under a Creative Commons Share-Alike 3.0 license.
The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/
Attribution requirements and misc., PLEASE READ:
● This slide must remain as-is in this specific location (slide #2), everything else you are free
to change; including the logo :-)
● Use of figures in other documents must feature the below “Originals at” URL immediately
under that figure and the below copyright notice where appropriate.
● You are free to fill in the “Delivered and/or customized by” space on the right as you see fit.
● You are FORBIDEN from using the default “About” slide as-is or any of its contents.
●
You are FORBIDEN from using any content provided by 3rd
parties without the EXPLICIT
consent from those parties.
(C) Copyright 2015, Opersys inc.
These slides created by: Karim Yaghmour
Originals at: www.opersys.com/community/docs
Delivered and/or customized by
3 3
About
● Author of:
● Introduced Linux Trace Toolkit in 1999
● Originated Adeos and relayfs (kernel/relay.c)
● Ara Android Arch Oversight
● Training, Custom Dev, Consulting, ...
4 4
Agenda
● What's out there?
● What's the problem?
● Our Objectives
● Discovering System Service Interfaces
● Architecture for Creating Monitoring Tools
● Process Monitoring
● Filesystem Monitoring/Browsing
● Understanding Binder Relationships
● Boot Animation
● The Road Ahead
5 5
1. What's Out There Now?
● Official App Dev Tools
● Official Platform Dev Tools
●
3rd
Party Power User Tools
●
3rd
Party App Dev Tools
●
3rd
Party Platform Dev Tools
6 6
1.1. Official App Dev tools
● Android Studio (IntelliJ)
● Android Monitor (formerly DDMS)
● Several tools built into Studio for performance analysis:
– Rendering
– Memory
– CPU usage
– Battery
● Plenty of documentation
7 7
1.2. Official Platform Dev Tools
● Tools on the previous pages
● gdb / gdbserver
● ftrace, systrace, atrace
● perf
8 8
1.3. 3rd
Party Power User Tools
● Google Play has a ton of apps for:
– Process monitoring
– File management
– System information
– etc.
● They all assume that the device's screen is for output
● Useless if you're trying to use the tool while doing something
else on screen.
9 9
1.4. 3rd
Party App Dev Tools
● CrossWalk / Cordova
● Delphi
● Xamarin Android
● etc.
10 10
1.5. 3rd
Party Platform Dev Tools
● Qualcomm tools
● Intel tools, Nvidia tools, etc
● ARM Tools – DS-5
● JTAG -- Lauterbach
11 11
2. What's The Problem?
● Google obviously catering to app developers
– App dev tools have nice finish
– Platform dev tools ... not so much
● Official tools heavily tied to app dev IDE
– Requires IDE-specific knowledge to extend/customize
– Assumes official IDE is being used and/or is present
– Assume the developer is developing an app and is trying to fix his app's problems
● Platform is huge
● Documentation is often spartan
● Existing platform dev tools assume internals understanding
– Do you truly know how to use “dumpsys procstats”, “dumpsys meminfo” or “vdc”?
● Most platform tools can only be used on the command line
● Most 3rd party tools assume on-screen rendering of information
12 12
3. Our Objectives
● Reduce barrier to entry for platform development
● Address unmet patform developer needs
● Easy to use platform dev tools
● Build on lightweight/mainstream technologies:
– No IDE-specific tie-in
– Extensible language
– Large ecosystem of reusable packages/add-ons
● Avoid monopolizing device screen
13 13
4. Discovering System Service Interfaces
● Question: What is service X's AIDL interface?
● find -name “*File.aidl”
● godir
● Android documentation
– Focused on app developers
– Doesn't cover everything
14 14
4.1. Raidl - Features
● Returns the AIDL interface of a service
– AIDL based service
– Best effort for other services (Activity service)
– No interface for C++ service
– No parameters names
15 15
4.2. Example Output
root@generic:/data/local/tmp # ./raidl iface ­n power                          
// Service: power, Interface: android.os.IPowerManager
package android.os;
interface IPowerManager {
    void acquireWakeLock(IBinder p1, int n2, String s3, String s4, WorkSource p5, String s6); // 1
    void acquireWakeLockWithUid(IBinder p1, int n2, String s3, String s4, int n5); // 2
    void releaseWakeLock(IBinder p1, int n2); // 3
    void updateWakeLockUids(IBinder p1, int[] p2); // 4
    void powerHint(int n1, int n2); // 5
    void updateWakeLockWorkSource(IBinder p1, WorkSource p2, String s3); // 6
    boolean isWakeLockLevelSupported(int n1); // 7
    void userActivity(long n1, int n2, int n3); // 8
    void wakeUp(long n1); // 9
    void goToSleep(long n1, int n2, int n3); // 10
    void nap(long n1); // 11
    boolean isInteractive(); // 12
    boolean isPowerSaveMode(); // 13
    boolean setPowerSaveMode(boolean p1); // 14
    void reboot(boolean p1, String s2, boolean p3); // 15
    void shutdown(boolean p1, boolean p2); // 16
    void crash(String s1); // 17
    void setStayOnSetting(int n1); // 18
    void setMaximumScreenOffTimeoutFromDeviceAdmin(int n1); // 19
    void setTemporaryScreenBrightnessSettingOverride(int n1); // 20
    void setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(float p1); // 21
    void setAttentionLight(boolean p1, int n2); // 22
}
16 16
4.3. Raidl - Demo
17 17
4.4. Raidl – How Does It Work?
ServiceStubClass = Raidl.class.getClassLoader()
                              .loadClass(serviceClass.getCanonicalName()+"$Stub");
for (Field serviceField : serviceStubClass.getDeclaredFields()) {
    // Get the fields that look like transaction code. 
}
for (Method serviceMethod : serviceClass.getMethods())
    serviceMethods.put(serviceMethod.getName(), serviceMethod);
for (Integer serviceCode : serviceCodesMethods.keySet()) {
    // ...
    if (serviceMethod != null && isRemoteMethod(serviceMethod))
        aidlService.addMethod(serviceCode, serviceMethod);
}
18 18
4.5. Raidl - AOSP integration
LOCAL_PATH:= $(call my­dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(call all­java­files­under, src)
LOCAL_PACKAGE_NAME := raidl
LOCAL_MODULE_TAGS := optional
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := raidl
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE := raidl
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
19 19
4.6. Raidl - Running an .apk
● .apk == .jar (with some DEX code)
● DexClassLoader:“A class loader that loads classes from .jar
and .apk files [...]”
● Ergo:
export CLASSPATH=/system/app/raidl.apk:/system/app/raidl/raidl.apk
exec app_process /system/app com.opersys.raidl.Raidl "$@"
20 20
5. Architecture for Creating Monitoring Tools
21 21
5.1. Tool architecture
● Backend: Node.js + Express
● Frontend: Backbone.js + w2ui
● AJAX communication
● Websocket or Server-Sent events
22 22
5.2. Node.js in Android – Why?
● One language to rule them all: Javascript
● 132 510 Node.js packages
● Ease of use
● Web 2.0 support (SSE, WebSockets)
● Speed
– V8
– Binary modules
● Runtime independence
● Few actual alternatives: Go, C/C++, Python, etc.
23 23
5.3. Node.js – It's easy!
var express = require('express');
var app = express();
app.get('/home', function(req, res) {
 res.send('Hello World');
});
app.listen(process.env.PORT || 8080);
24 24
5.4. Node.js in Android – Why not?
● Still pretty slow
● Runtime independence
– Node is within its Linux bottle
● Difficult to package in Android
● It's Javascript
– WAT! https://www.destroyallsoftware.com/talks/wat
25 25
5.5. How to use Node.js on Android
● Older versions (0.8), binaries available
– Too old for comfort
● Development version (0.11, now 0.12) was patched with Android
support
● Backported to 0.10
● V0.10 Binaries are avaible!
● Io.js and Node v0.12: TBD.
● https://github.com/opersys/node
26 26
5.6. Distribution
● Extracted in local files
● Multiple binary packages
– ARM, ARM + PIE, ia32, ia32 + PIE
● Started by a simple Android application
● Able to start as root
27 27
6. Process Monitoring
● ps / top
● htop (Cyanogenmod)
● Studio/Eclipse/DDMS/Monitor integrated
● On the Play Store...
– ... hundreds of candidates
– Few are aimed at developers
28 28
6.1. Process Explorer
● Browser based process manager
● Displays logcat (live!)
● Process statistics
– /proc based
● Needs root access for better function
● Works on Chrome and Firefox
29 29
6.2. Process Explorer - Demo
30 30
7. Filesystem Monitoring/Browsing
● ls, find
● adb push/pull
● On the Play Store...
– ... hundreds of candidates
– Few are aimed at developers
31 31
7.1. File Explorer
● Browser based file manager for Android systems
● File upload/download
● File updates (live!)
● Needs root access for better function
32 32
7.2. File Explorer - Demo
33 33
8. Understanding Binder Relationships
● Binder is essentially Android's core
● Binder enables us to have an Object Oriented OS on top of a
General Purpose OS
● Problem: there is no way to understand which components talk
to each other.
34 34
35 35
8.1. Binder Explorer
● In development...
● Analyzes the links between Binder Services and Android
applications
● Uses data from /sys/kernel/debug/binder
● Pushing further: JSLibBinder
36 36
8.2. Binder Explorer - Demo
37 37
8.3. Reaching Inside Android
● JSLibBinder – libbinder for Android
var Binder = require("jslibbinder"), 
var sm = new Binder.ServiceManager();
var services = sm.list();
var i = 0;
console.log("Found " + services.length + " services:");
services.forEach(function (s) {
    console.log((i++) + "t" + s 
                + ": [" + sm.getService(s).getInterface() + "]");
});
38 38
9. Boot Animation
If Android fails to boot, you see this:
... forever ...
39 39
9.1. What do people do today?
● Wait for it to boot ... until it's abnormally long ...
● Manual poking:
– Shell into device
– Check processes (ps)
– Check service (service list)
– Check logs (logcat)
– Check kernel logs (dmesg)
● Essentially ... It sucks
40 40
9.2. What do we want?
● Foremost: know that boot is failing
● Would be nice to also know:
– What is failing
– When it's failing (i.e. as soon as it fails)
– Why it's failing
41 41
9.3. What do we have?
● SurfaceFlinger is one of the very first processes to start
● If SF failing = No boot animation
– i.e. you know what your problem is already
● If SF comes up, it starts the default boot animation:
– frameworks/base/cmds/bootanimation/
● Default boot animation has 2 modes of operation:
– Built-in GL rendering of fixed images
– Rendering of sequence of static images in ZIP file
● In short: the default boot animation is of no use to us
● Need custom boot animation that reports issues on screen
● Main issues:
– Surfaces provided by SF are too low level
– All rendering toolkits assume you've got a fully booted Android
42 42
9.4. What did we do?
● Looked for a toolkit that was:
– Light weight
– Properly licensed
– Easily fixable to run on a standalone SF
● Custom version of gameplay3d:
– Make if work on vanilla SF without the fully-booted framework
● Built different UIs on top of this framework:
– On-screen split dmesg/logcat
– On-screen boot progress
● Other UIs could be implemented
● Tangent: gameplay3d can now be used without Android
43 43
9.5. Boot Animation - Demo
44 44
10. The Road Ahead
● New Features
● New Tools
● Integration:
– Across our tools
– With existing tools
● We've got our ideas ;D
● We'd like to hear from you:
– What are you looking for?
45 45
Thank you ...
karim.yaghmour@opersys.com

Más contenido relacionado

La actualidad más candente

Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 

La actualidad más candente (20)

Developing Android Platform Tools
Developing Android Platform ToolsDeveloping Android Platform Tools
Developing Android Platform Tools
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Brillo/Weave Internals
Brillo/Weave InternalsBrillo/Weave Internals
Brillo/Weave Internals
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Project Ara
Project AraProject Ara
Project Ara
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android's Multimedia Framework
Android's Multimedia FrameworkAndroid's Multimedia Framework
Android's Multimedia Framework
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 

Destacado

Embedded Android Workshop at AnDevCon VI
Embedded Android Workshop at AnDevCon VIEmbedded Android Workshop at AnDevCon VI
Embedded Android Workshop at AnDevCon VI
Opersys inc.
 
Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014
Opersys inc.
 
Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VILeveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
Opersys inc.
 
Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014
Opersys inc.
 

Destacado (20)

Embedded Android Workshop at AnDevCon VI
Embedded Android Workshop at AnDevCon VIEmbedded Android Workshop at AnDevCon VI
Embedded Android Workshop at AnDevCon VI
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
 
Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013Embedded Android Workshop at Embedded World Conference 2013
Embedded Android Workshop at Embedded World Conference 2013
 
Android Microconf at Linux Plumber 2012
Android Microconf at Linux Plumber 2012Android Microconf at Linux Plumber 2012
Android Microconf at Linux Plumber 2012
 
Android On Development Boards at AnDevCon3
Android On Development Boards at AnDevCon3Android On Development Boards at AnDevCon3
Android On Development Boards at AnDevCon3
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014
 
Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014
 
Leveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VILeveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VI
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014Running Code in the Android Stack at ABS 2014
Running Code in the Android Stack at ABS 2014
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Project Ara
Project AraProject Ara
Project Ara
 

Similar a Extending Android's Platform Toolsuite

Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon V
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
Opersys inc.
 
Embedded Android Workshop at AnDevCon V
Embedded Android Workshop at AnDevCon VEmbedded Android Workshop at AnDevCon V
Embedded Android Workshop at AnDevCon V
Opersys inc.
 
Is Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IVIs Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IV
Opersys inc.
 
Embedded Android Workshop at AnDevCon IV
Embedded Android Workshop at AnDevCon IVEmbedded Android Workshop at AnDevCon IV
Embedded Android Workshop at AnDevCon IV
Opersys inc.
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 

Similar a Extending Android's Platform Toolsuite (14)

Is Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon VIs Android the New Embedded Linux? at AnDevCon V
Is Android the New Embedded Linux? at AnDevCon V
 
Leveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IVLeveraging Android's Linux Heritage at AnDevCon IV
Leveraging Android's Linux Heritage at AnDevCon IV
 
Android Platform Debugging & Development
Android Platform Debugging & Development Android Platform Debugging & Development
Android Platform Debugging & Development
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Embedded Android Workshop part I ESC SV 2012
Embedded Android Workshop part I ESC SV 2012Embedded Android Workshop part I ESC SV 2012
Embedded Android Workshop part I ESC SV 2012
 
Embedded Android Workshop at AnDevCon V
Embedded Android Workshop at AnDevCon VEmbedded Android Workshop at AnDevCon V
Embedded Android Workshop at AnDevCon V
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 
Is Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IVIs Android the New Embedded Linux? at AnDevCon IV
Is Android the New Embedded Linux? at AnDevCon IV
 
Embedded Android Workshop at AnDevCon IV
Embedded Android Workshop at AnDevCon IVEmbedded Android Workshop at AnDevCon IV
Embedded Android Workshop at AnDevCon IV
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
Intoduction to Android Development
Intoduction to Android DevelopmentIntoduction to Android Development
Intoduction to Android Development
 

Más de Opersys inc. (9)

Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
 
Android 10 Internals Update
Android 10 Internals UpdateAndroid 10 Internals Update
Android 10 Internals Update
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Project Ara
Project AraProject Ara
Project Ara
 

Último

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Último (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

Extending Android's Platform Toolsuite

  • 1. Extending Android's Platform Toolsuite Embedded Linux Conference Europe 2015 Karim Yaghmour @karimyaghmour / +karimyaghmour karim.yaghmour@opersys.com
  • 2. 2 2 These slides are made available to you under a Creative Commons Share-Alike 3.0 license. The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/ Attribution requirements and misc., PLEASE READ: ● This slide must remain as-is in this specific location (slide #2), everything else you are free to change; including the logo :-) ● Use of figures in other documents must feature the below “Originals at” URL immediately under that figure and the below copyright notice where appropriate. ● You are free to fill in the “Delivered and/or customized by” space on the right as you see fit. ● You are FORBIDEN from using the default “About” slide as-is or any of its contents. ● You are FORBIDEN from using any content provided by 3rd parties without the EXPLICIT consent from those parties. (C) Copyright 2015, Opersys inc. These slides created by: Karim Yaghmour Originals at: www.opersys.com/community/docs Delivered and/or customized by
  • 3. 3 3 About ● Author of: ● Introduced Linux Trace Toolkit in 1999 ● Originated Adeos and relayfs (kernel/relay.c) ● Ara Android Arch Oversight ● Training, Custom Dev, Consulting, ...
  • 4. 4 4 Agenda ● What's out there? ● What's the problem? ● Our Objectives ● Discovering System Service Interfaces ● Architecture for Creating Monitoring Tools ● Process Monitoring ● Filesystem Monitoring/Browsing ● Understanding Binder Relationships ● Boot Animation ● The Road Ahead
  • 5. 5 5 1. What's Out There Now? ● Official App Dev Tools ● Official Platform Dev Tools ● 3rd Party Power User Tools ● 3rd Party App Dev Tools ● 3rd Party Platform Dev Tools
  • 6. 6 6 1.1. Official App Dev tools ● Android Studio (IntelliJ) ● Android Monitor (formerly DDMS) ● Several tools built into Studio for performance analysis: – Rendering – Memory – CPU usage – Battery ● Plenty of documentation
  • 7. 7 7 1.2. Official Platform Dev Tools ● Tools on the previous pages ● gdb / gdbserver ● ftrace, systrace, atrace ● perf
  • 8. 8 8 1.3. 3rd Party Power User Tools ● Google Play has a ton of apps for: – Process monitoring – File management – System information – etc. ● They all assume that the device's screen is for output ● Useless if you're trying to use the tool while doing something else on screen.
  • 9. 9 9 1.4. 3rd Party App Dev Tools ● CrossWalk / Cordova ● Delphi ● Xamarin Android ● etc.
  • 10. 10 10 1.5. 3rd Party Platform Dev Tools ● Qualcomm tools ● Intel tools, Nvidia tools, etc ● ARM Tools – DS-5 ● JTAG -- Lauterbach
  • 11. 11 11 2. What's The Problem? ● Google obviously catering to app developers – App dev tools have nice finish – Platform dev tools ... not so much ● Official tools heavily tied to app dev IDE – Requires IDE-specific knowledge to extend/customize – Assumes official IDE is being used and/or is present – Assume the developer is developing an app and is trying to fix his app's problems ● Platform is huge ● Documentation is often spartan ● Existing platform dev tools assume internals understanding – Do you truly know how to use “dumpsys procstats”, “dumpsys meminfo” or “vdc”? ● Most platform tools can only be used on the command line ● Most 3rd party tools assume on-screen rendering of information
  • 12. 12 12 3. Our Objectives ● Reduce barrier to entry for platform development ● Address unmet patform developer needs ● Easy to use platform dev tools ● Build on lightweight/mainstream technologies: – No IDE-specific tie-in – Extensible language – Large ecosystem of reusable packages/add-ons ● Avoid monopolizing device screen
  • 13. 13 13 4. Discovering System Service Interfaces ● Question: What is service X's AIDL interface? ● find -name “*File.aidl” ● godir ● Android documentation – Focused on app developers – Doesn't cover everything
  • 14. 14 14 4.1. Raidl - Features ● Returns the AIDL interface of a service – AIDL based service – Best effort for other services (Activity service) – No interface for C++ service – No parameters names
  • 15. 15 15 4.2. Example Output root@generic:/data/local/tmp # ./raidl iface ­n power                           // Service: power, Interface: android.os.IPowerManager package android.os; interface IPowerManager {     void acquireWakeLock(IBinder p1, int n2, String s3, String s4, WorkSource p5, String s6); // 1     void acquireWakeLockWithUid(IBinder p1, int n2, String s3, String s4, int n5); // 2     void releaseWakeLock(IBinder p1, int n2); // 3     void updateWakeLockUids(IBinder p1, int[] p2); // 4     void powerHint(int n1, int n2); // 5     void updateWakeLockWorkSource(IBinder p1, WorkSource p2, String s3); // 6     boolean isWakeLockLevelSupported(int n1); // 7     void userActivity(long n1, int n2, int n3); // 8     void wakeUp(long n1); // 9     void goToSleep(long n1, int n2, int n3); // 10     void nap(long n1); // 11     boolean isInteractive(); // 12     boolean isPowerSaveMode(); // 13     boolean setPowerSaveMode(boolean p1); // 14     void reboot(boolean p1, String s2, boolean p3); // 15     void shutdown(boolean p1, boolean p2); // 16     void crash(String s1); // 17     void setStayOnSetting(int n1); // 18     void setMaximumScreenOffTimeoutFromDeviceAdmin(int n1); // 19     void setTemporaryScreenBrightnessSettingOverride(int n1); // 20     void setTemporaryScreenAutoBrightnessAdjustmentSettingOverride(float p1); // 21     void setAttentionLight(boolean p1, int n2); // 22 }
  • 17. 17 17 4.4. Raidl – How Does It Work? ServiceStubClass = Raidl.class.getClassLoader()                               .loadClass(serviceClass.getCanonicalName()+"$Stub"); for (Field serviceField : serviceStubClass.getDeclaredFields()) {     // Get the fields that look like transaction code.  } for (Method serviceMethod : serviceClass.getMethods())     serviceMethods.put(serviceMethod.getName(), serviceMethod); for (Integer serviceCode : serviceCodesMethods.keySet()) {     // ...     if (serviceMethod != null && isRemoteMethod(serviceMethod))         aidlService.addMethod(serviceCode, serviceMethod); }
  • 18. 18 18 4.5. Raidl - AOSP integration LOCAL_PATH:= $(call my­dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all­java­files­under, src) LOCAL_PACKAGE_NAME := raidl LOCAL_MODULE_TAGS := optional LOCAL_PROGUARD_ENABLED := disabled include $(BUILD_PACKAGE) include $(CLEAR_VARS) LOCAL_SRC_FILES := raidl LOCAL_MODULE_PATH := $(TARGET_OUT)/bin LOCAL_MODULE_CLASS := EXECUTABLES LOCAL_MODULE := raidl LOCAL_MODULE_TAGS := optional include $(BUILD_PREBUILT)
  • 19. 19 19 4.6. Raidl - Running an .apk ● .apk == .jar (with some DEX code) ● DexClassLoader:“A class loader that loads classes from .jar and .apk files [...]” ● Ergo: export CLASSPATH=/system/app/raidl.apk:/system/app/raidl/raidl.apk exec app_process /system/app com.opersys.raidl.Raidl "$@"
  • 20. 20 20 5. Architecture for Creating Monitoring Tools
  • 21. 21 21 5.1. Tool architecture ● Backend: Node.js + Express ● Frontend: Backbone.js + w2ui ● AJAX communication ● Websocket or Server-Sent events
  • 22. 22 22 5.2. Node.js in Android – Why? ● One language to rule them all: Javascript ● 132 510 Node.js packages ● Ease of use ● Web 2.0 support (SSE, WebSockets) ● Speed – V8 – Binary modules ● Runtime independence ● Few actual alternatives: Go, C/C++, Python, etc.
  • 23. 23 23 5.3. Node.js – It's easy! var express = require('express'); var app = express(); app.get('/home', function(req, res) {  res.send('Hello World'); }); app.listen(process.env.PORT || 8080);
  • 24. 24 24 5.4. Node.js in Android – Why not? ● Still pretty slow ● Runtime independence – Node is within its Linux bottle ● Difficult to package in Android ● It's Javascript – WAT! https://www.destroyallsoftware.com/talks/wat
  • 25. 25 25 5.5. How to use Node.js on Android ● Older versions (0.8), binaries available – Too old for comfort ● Development version (0.11, now 0.12) was patched with Android support ● Backported to 0.10 ● V0.10 Binaries are avaible! ● Io.js and Node v0.12: TBD. ● https://github.com/opersys/node
  • 26. 26 26 5.6. Distribution ● Extracted in local files ● Multiple binary packages – ARM, ARM + PIE, ia32, ia32 + PIE ● Started by a simple Android application ● Able to start as root
  • 27. 27 27 6. Process Monitoring ● ps / top ● htop (Cyanogenmod) ● Studio/Eclipse/DDMS/Monitor integrated ● On the Play Store... – ... hundreds of candidates – Few are aimed at developers
  • 28. 28 28 6.1. Process Explorer ● Browser based process manager ● Displays logcat (live!) ● Process statistics – /proc based ● Needs root access for better function ● Works on Chrome and Firefox
  • 29. 29 29 6.2. Process Explorer - Demo
  • 30. 30 30 7. Filesystem Monitoring/Browsing ● ls, find ● adb push/pull ● On the Play Store... – ... hundreds of candidates – Few are aimed at developers
  • 31. 31 31 7.1. File Explorer ● Browser based file manager for Android systems ● File upload/download ● File updates (live!) ● Needs root access for better function
  • 32. 32 32 7.2. File Explorer - Demo
  • 33. 33 33 8. Understanding Binder Relationships ● Binder is essentially Android's core ● Binder enables us to have an Object Oriented OS on top of a General Purpose OS ● Problem: there is no way to understand which components talk to each other.
  • 34. 34 34
  • 35. 35 35 8.1. Binder Explorer ● In development... ● Analyzes the links between Binder Services and Android applications ● Uses data from /sys/kernel/debug/binder ● Pushing further: JSLibBinder
  • 36. 36 36 8.2. Binder Explorer - Demo
  • 37. 37 37 8.3. Reaching Inside Android ● JSLibBinder – libbinder for Android var Binder = require("jslibbinder"),  var sm = new Binder.ServiceManager(); var services = sm.list(); var i = 0; console.log("Found " + services.length + " services:"); services.forEach(function (s) {     console.log((i++) + "t" + s                  + ": [" + sm.getService(s).getInterface() + "]"); });
  • 38. 38 38 9. Boot Animation If Android fails to boot, you see this: ... forever ...
  • 39. 39 39 9.1. What do people do today? ● Wait for it to boot ... until it's abnormally long ... ● Manual poking: – Shell into device – Check processes (ps) – Check service (service list) – Check logs (logcat) – Check kernel logs (dmesg) ● Essentially ... It sucks
  • 40. 40 40 9.2. What do we want? ● Foremost: know that boot is failing ● Would be nice to also know: – What is failing – When it's failing (i.e. as soon as it fails) – Why it's failing
  • 41. 41 41 9.3. What do we have? ● SurfaceFlinger is one of the very first processes to start ● If SF failing = No boot animation – i.e. you know what your problem is already ● If SF comes up, it starts the default boot animation: – frameworks/base/cmds/bootanimation/ ● Default boot animation has 2 modes of operation: – Built-in GL rendering of fixed images – Rendering of sequence of static images in ZIP file ● In short: the default boot animation is of no use to us ● Need custom boot animation that reports issues on screen ● Main issues: – Surfaces provided by SF are too low level – All rendering toolkits assume you've got a fully booted Android
  • 42. 42 42 9.4. What did we do? ● Looked for a toolkit that was: – Light weight – Properly licensed – Easily fixable to run on a standalone SF ● Custom version of gameplay3d: – Make if work on vanilla SF without the fully-booted framework ● Built different UIs on top of this framework: – On-screen split dmesg/logcat – On-screen boot progress ● Other UIs could be implemented ● Tangent: gameplay3d can now be used without Android
  • 43. 43 43 9.5. Boot Animation - Demo
  • 44. 44 44 10. The Road Ahead ● New Features ● New Tools ● Integration: – Across our tools – With existing tools ● We've got our ideas ;D ● We'd like to hear from you: – What are you looking for?
  • 45. 45 45 Thank you ... karim.yaghmour@opersys.com