Extending Android's Platform Toolsuite

Similar documents
Inside Android's UI Embedded Linux Conference Europe 2012 Karim

Android Platform Debugging and Development

Introduction to Native Android Development with NDK

Android Programming and Security

Android Hands-On Labs

Multithreading and Java Native Interface (JNI)!

Android Sensors This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. CC-BY Google

With a single download, the ADT Bundle includes everything you need to begin developing apps:

How To Develop Android On Your Computer Or Tablet Or Phone

ANDROID DEVELOPER TOOLS TRAINING GTC Sébastien Dominé, NVIDIA

Android Systems Programming Tips and Tricks

Example of Standard API

Android Architecture For Beginners

A Look through the Android Stack

What else can you do with Android? Inside Android. Chris Simmonds. Embedded Linux Conference Europe Copyright 2010, 2net Limited.

ICON UK 2015 node.js for Domino developers. Presenter: Matt White Company: LDC Via

Android WebKit Development: A cautionary tale. Joe Bowser Nitobi joe.bowser@nitobi.com

Certified Selenium Professional VS-1083

Performance Analysis of Android Platform

Extending Tizen Native Framework with Node.js

Mobile Application Security and Penetration Testing Syllabus

Crosswalk: build world class hybrid mobile apps

XenMobile Logs Collection Guide

Here to take you beyond Mobile Application development using Android Course details

Android Environment SDK

Android Development Exercises Version Hands On Exercises for. Android Development. v

Enable Your Automated Web App Testing by WebDriver. Yugang Fan Intel

Android Development. Lecture AD 0 Android SDK & Development Environment. Università degli Studi di Parma. Mobile Application Development

Технологии Java. Android: Введение. Кузнецов Андрей Николаевич. Санкт-Петербургский Государственный Политехнический Университет

Porting Existing PhoneGap Apps to Tizen OS - Development Story

Developing applications on Yocto. Lianhao Lu Intel Corporation Feb. 29th, 2012

Hacking your Droid ADITYA GUPTA

HP AppPulse Mobile. Adding HP AppPulse Mobile to Your Android App

Android Security Lab WS 2014/15 Lab 1: Android Application Programming

Android Security Evaluation Framework

1 (11) Paperiton DMS Document Management System System Requirements Release: 2012/

Mobile development with Apache OFBiz. Ean Schuessler, Brainfood

The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.

Running a Program on an AVD

Debugging Mobile Apps

How To Use Titanium Studio

ADB (Android Debug Bridge): How it works?

DEVELOPING NFC APPS for BLACKBERRY

HTML5 / NATIVE / HYBRID

Android, Bluetooth and MIAC

Android Environment SDK

The Decaffeinated Robot

Finding Performance and Power Issues on Android Systems. By Eric W Moore

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Lab 4 In class Hands-on Android Debugging Tutorial

ARM* to Intel Atom Microarchitecture - A Migration Study

Building A Self-Hosted WebRTC Project

Introduction to Android. CSG250 Wireless Networks Fall, 2008

Android Basics. Xin Yang

Mobile Application Development 2014

PetaLinux SDK User Guide. Application Development Guide

Android 多 核 心 嵌 入 式 多 媒 體 系 統 設 計 與 實 作

EMPLOYEE LOCATION TRACKING SERVICE

Lecture 1 Introduction to Android

Operational Decision Manager Worklight Integration

Node.JS Appliances on Embedded Linux Devices. Mehmet Fatih Karagöz & Cevahir Turgut

How to develop your own app

ECWM511 MOBILE APPLICATION DEVELOPMENT Lecture 1: Introduction to Android

QML and JavaScript for Native App Development

VM Application Debugging via JTAG: Android TRACE32 JTAG Debug Bridge ADB Architecture Stop-Mode implications for ADB JTAG Transport Outlook

Continuous Integration and Delivery. manage development build deploy / release

Android Geek Night. Application framework

Tushar Dalvi Sr. Security Engineer at LinkedIn Penetration Tester. Responsible for securing a large suite mobile apps

Application-Level Debugging and Profiling: Gaps in the Tool Ecosystem. Dr Rosemary Francis, Ellexus

Mobile Application Development Android

Cloud Powered Mobile Apps with Azure

Android Architecture. Alexandra Harrison & Jake Saxton

Programming the Android Platform. Logistics

Introduction to Android

User Manual Version p BETA III December 23rd, 2015

Frequently Asked Questions Enterprise Mobile Manager

IBM WebSphere Application Server V8.5 lab Basic Liberty profile administration using the job manager

Android Security. Device Management and Security. by Stephan Linzner & Benjamin Reimold

Introduction to Android Development. Jeff Avery CS349, Mar 2013

Introduction to OpenCV for Tegra. Shalini Gupta, Nvidia

Title: Appium Automation for Mac OS X. Created By: Prithivirajan M. Abstract. Introduction

SYLLABUS MOBILE APPLICATION SECURITY AND PENETRATION TESTING. MASPT at a glance: v1.0 (28/01/2014) 10 highly practical modules

Are free Android virus scanners any good?

Webapps Vulnerability Report

Drupal CMS for marketing sites

As shown, the emulator instance connected to adb on port 5555 is the same as the instance whose console listens on port 5554.

Adobe Flash Player and Adobe AIR security

Windmill. Automated Testing for Web Applications

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes

Budget Event Management Design Document

The Yocto Project Eclipse plug-in: An Effective IDE Environment for Embedded Application and System Developers

Android Tutorial. Larry Walters OOSE Fall 2011

farmerswife Contents Hourline Display Lists 1.1 Server Application 1.2 Client Application farmerswife.com

StruxureWare Data Center Expert Release Notes

StruxureWare Data Center Expert Release Notes

Security Issues in Android Custom ROMs

TEGRA X1 DEVELOPER TOOLS SEBASTIEN DOMINE, SR. DIRECTOR SW ENGINEERING

An Introduction to Android. Huang Xuguang Database Lab. Inha University

Transcription:

Extending Android's Platform Toolsuite Embedded Linux Conference Europe 2015 Karim Yaghmour @karimyaghmour / +karimyaghmour karim.yaghmour@opersys.com

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/ Delivered and/or customized by 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 3 rd 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 2 2

About Author of: Introduced Linux Trace Toolkit in 1999 Originated Adeos and relayfs (kernel/relay.c) Ara Android Arch Oversight Training, Custom Dev, Consulting,... 3 3

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 4 4

1. What's Out There Now? Official App Dev Tools Official Platform Dev Tools 3 rd Party Power User Tools 3 rd Party App Dev Tools 3 rd Party Platform Dev Tools 5 5

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 6 6

1.2. Official Platform Dev Tools Tools on the previous pages gdb / gdbserver ftrace, systrace, atrace perf 7 7

1.3. 3 rd 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. 8 8

1.4. 3 rd Party App Dev Tools CrossWalk / Cordova Delphi Xamarin Android etc. 9 9

1.5. 3 rd Party Platform Dev Tools Qualcomm tools Intel tools, Nvidia tools, etc ARM Tools DS-5 JTAG -- Lauterbach 10 10

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 11 11

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 12 12

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 13 13

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 14 14

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 15 15 void setattentionlight(boolean p1, int n2); // 22 }

4.3. Raidl - Demo 16 16

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); 17 17

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) 18 18

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 "$@" 19 19

5. Architecture for Creating Monitoring Tools 20 20

5.1. Tool architecture Backend: Node.js + Express Frontend: Backbone.js + w2ui AJAX communication Websocket or Server-Sent events 21 21

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. 22 22

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); 23 23

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 24 24

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 25 25

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 26 26

6. Process Monitoring ps / top htop (Cyanogenmod) Studio/Eclipse/DDMS/Monitor integrated On the Play Store...... hundreds of candidates Few are aimed at developers 27 27

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 28 28

6.2. Process Explorer - Demo 29 29

7. Filesystem Monitoring/Browsing ls, find adb push/pull On the Play Store...... hundreds of candidates Few are aimed at developers 30 30

7.1. File Explorer Browser based file manager for Android systems File upload/download File updates (live!) Needs root access for better function 31 31

7.2. File Explorer - Demo 32 32

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. 33 33

34 34

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 35 35

8.2. Binder Explorer - Demo 36 36

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() + "]"); }); 37 37

9. Boot Animation If Android fails to boot, you see this:... forever... 38 38

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 39 39

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 40 40

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 41 41

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 42 42

9.5. Boot Animation - Demo 43 43

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? 44 44

Thank you... karim.yaghmour@opersys.com 45 45