Core Android

Post on 22-Jun-2015

435 views 0 download

description

In dieser Session werfen wir einen Blick auf die Android Platform jenseits der Dalvik VM. Wir entdecken den Android Source Code und erklären wo sich interessante Beispiele und Referenzen für App-Entwickler sowie nützliche Tools verbergen. Ein High-Level Überblick über die Platform-Architektur und das Platform-Build-System runden die Session ab.

Transcript of Core Android

Dominik Helleberg | inovex GmbH

Core Android

Dominik Helleberg

Mobile Development

Android

HTML5

http://dominik-helleberg.de/+

Core Android

Warum?

Neugier

Verständnis

- Bugs

- Beispiele

- Doku

Anwendungen / Projekte

http://www.ouya.tv/about/ https://mediacenter.motorola.com/Image-Gallery/MOTOACTV-Golf-Edition-8c1.aspx http://www.tolino.de https://www.honeywellaidc.com/en-US/resources/image-library/Pages/default.aspx?Category=7800&keywords=7800&title=7800&description=7800

Android is different…

Android is open?

https://twitter.com/Arubin/status/27808662429

Android Architektur Stock Apps

Framework / API

User Apps

Java System Services

Dalvik / Runtime / Zygote

Kernel

Libs HAL Init

Android Architektur / Source Stock Apps

Framework / API

User Apps

Java System Services

Dalvik / Runtime / Zygote

Kernel

Libs Init

https://android.googlesource.com/ HAL

Get the source! $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

$ chmod a+x ~/bin/repo

$ repo init -u https://android.googlesource.com/platform/manifest

$ repo sync

Check: http://source.android.com

Sources: approx. 16 GB

Getting around AOSP abi

bionic

bootable

build

cts

dalvik

development

device

docs

external

frameworks

gdk

hardware

libcore

libnativehelper

ndk

packages

pdk

prebuilts

sdk

system

tools

Getting around AOSP abi

bionic

bootable

build

cts

dalvik

development

device

docs

external

frameworks

gdk

hardware

libcore

libnativehelper

ndk

packages

pdk

prebuilts

sdk

system

tools

android core Framework

icons

Stock Apps IMEs

Wallpapers..

The.... S D K

packages

Calendar

Contacts

Gallery2

Launcher2

Framework base/core/java/android/app/ActivityManager.java

base/core/java/android/widget/RelativeLayout.java

base/packages/SystemUI/res/*

base/core/res/res/*

base/core/java/android/os/PowerManager.java

sdk

bash_completion/adb.bash

screenshot/

Compile...

You need:

•  Ubuntu LTS (10.04) or Mac OS X

•  A bunch of tools

•  HDD space (~ 30 GB)

•  Time (Hours - depending on your HW)

Compile... $ source build/envsetup.sh

including device/generic/armv7-a-neon/vendorsetup.sh

including device/generic/armv7-a/vendorsetup.sh

....

Compile... $ lunch

You're building on Linux

Lunch menu... pick a combo:

1. full-eng

2. full_x86-eng

3. vbox_x86-eng

4. full_mips-eng

5. full_grouper-userdebug

...

Which would you like? [full-eng]

zzzzzZZZZZZzzzzzz

device mappings crespo Samsung Nexus S

manta Samsung Nexus 10

mako LG Nexus 4

grouper / tilapia Asus Nexus 7

toro / maguro Samsung Galaxy Nexus

wingray Motorola Xoom

…zzZZZzz… and run! $ emulator &

…zzZZZzz… and run!

Architecture by example - GPS Stock Apps

Framework / API

User Apps

Java System Services

Dalvik / Runtime / Zygote

Kernel

Libs HAL Init

Architecture by example - GPS Stock Apps User Apps

locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

locationManager.requestLocationUpdates(

LocationManager.GPS_PROVIDER, 0, 0, locationListener);

frameworks/base/location/java/android/location/LocationManager.java

try { mService.requestLocationUpdates(request,

transport, intent, packageName); } catch (RemoteException e) { Log.e(TAG, "RemoteException", e); }

Architecture by example - GPS

Framework / API System Services

frameworks/base/location/java/android/location/LocationManager.java

private final ILocationManager mService;

Architecture by example - GPS

Framework / API System Services

frameworks/base/location/java/android/location/ILocationListener.aidl

void requestLocationUpdates( in LocationRequest request, in ILocationListener listener, in PendingIntent intent, String packageName);

Architecture by example - GPS

Framework / API System Services

frameworks/base/services/java/com/android/server/LocationManagerService.java

LocationProviderInterface provider =

mProvidersByName.get(name);...provider.setRequest(providerRequest,

worksource);

Architecture by example - GPS

Framework / API System Services

frameworks/base/services/java/com/android/server/location/GpsLocationProvider.java

private native boolean native_start();

Architecture by example - GPS

Framework / API System Services

hardware/libhardware/include/hardware/gps.h

/** Represents the standard GPS interface. */typedef struct { int (*init)( GpsCallbacks* callbacks );

/** Starts navigating. */ int (*start)( void );...

Architecture by example - GPS

Libs HAL Init

development/tools/emulator/system/gps/gps_qemu.c

device/samsung/manta/gps/gps.exynos5.so

Architecture by example - GPS

Libs HAL Init

What’s next? Tips + Tricks •  Level 1:

Check source for samples and understanding

•  Level 2:

Compile your own emulator images

•  Level 3:

Get a supported nexus device and burn images

•  Level 4:

Get a development board an build android embedded Software

Level 1: grep $ jgrep LocationManager ./base/core/java/android/app/ContextImpl.java:60:import android.location.ILocationManager; ./base/core/java/android/app/ContextImpl.java:61:import android.location.LocationManager; ./base/core/java/android/app/ContextImpl.java:403: return new LocationManager(ctx, ILocationManager.Stub.asInterface(b)); ./base/core/java/android/content/Context.java:1749: * <dd> A {@link android.location.LocationManager} for controlling location ./base/core/java/android/content/Context.java:1795: * @see android.location.LocationManager ./base/core/java/android/content/Context.java:1912: * android.location.LocationManager} for controlling location ./base/core/java/android/content/Context.java:1916: * @see android.location.LocationManager ./base/core/java/android/provider/Settings.java:3096: * LocationManager service for testing purposes during application development. These ./base/core/java/android/webkit/GeolocationService.java:23:import android.location.LocationManager; ./base/core/java/android/webkit/GeolocationService.java:39: private LocationManager mLocationManager; ./base/core/java/android/webkit/GeolocationService.java:54: mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); ./base/core/java/android/webkit/GeolocationService.java:55: if (mLocationManager == null) { ./base/core/java/android/webkit/GeolocationService.java:118: if (LocationManager.NETWORK_PROVIDER.equal ....

Level 1: AndroidXRef

http://androidxref.com/

Level 1: explain-plz

https://github.com/timroes/explain-plz

@local:/Volumes/android/dalvik $ explain-plz Explanation for folder dalvik: This directory contains the Dalvik virtual machine and core class library, as well as related tools, libraries, and tests. Git project directory: dalvik Git fetch URL: https://android.googlesource.com/platform/dalvik Subfolders with explanation: dexdump dexgen dx opcode-gen tools/hprof-conv vm

Level 2: ccache $ export USE_CCACHE=1 $ export CCACHE_DIR=/<path_of_your_choice>/.ccache $ prebuilts/misc/linux-x86/ccache/ccache -M 50G The suggested cache size is 50-100G. You can watch ccache being used by doing the following: $ watch -n1 -d prebuilts/misc/linux-x86/ccache/ccache -s

http://source.android.com/source/building.html

Level 3

Level 4

https://android-build.linaro.org/

Credits http://www.ouya.tv/about/ https://mediacenter.motorola.com/Image-Gallery/MOTOACTV-Golf-Edition-8c1.aspx http://www.tolino.de https://www.honeywellaidc.com/en-US/resources/image-library/Pages/default.aspx?Category=7800&keywords=7800&title=7800&description=7800 https://android-build.linaro.org/ http://source.android.com/source/building.html

DANKE!