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.
15. 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)
16. Compile...
$ source build/envsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/armv7-a/vendorsetup.sh
....
17. 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]
22. Architecture by example - GPS
Stock Apps User Apps
Framework / API
Java
System Services
Dalvik / Runtime / Zygote
Libs HAL Init
Kernel
23. Architecture by example - GPS
Stock Apps User Apps
locationManager = (LocationManager)
this.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 0, 0,
locationListener);
24. Architecture by example - GPS
frameworks/base/location/java/android/location/
LocationManager.java
Framework / API System Services
try {
mService.requestLocationUpdates(request,
transport, intent, packageName);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException", e);
}
25. Architecture by example - GPS
frameworks/base/location/java/android/location/
LocationManager.java
Framework / API System Services
private final ILocationManager mService;
26. Architecture by example - GPS
frameworks/base/location/java/android/location/
ILocationListener.aidl
Framework / API System Services
void requestLocationUpdates(
in LocationRequest request,
in ILocationListener listener,
in PendingIntent intent,
String packageName);
27. Architecture by example - GPS
frameworks/base/services/java/com/android/server/
LocationManagerService.java
Framework / API System Services
LocationProviderInterface provider =
mProvidersByName.get(name);
...
provider.setRequest(providerRequest,
worksource);
28. Architecture by example - GPS
frameworks/base/services/java/com/android/server/
location/GpsLocationProvider.java
Framework / API System Services
private native boolean native_start();
29. Architecture by example - GPS
hardware/libhardware/include/hardware/gps.h
/** Represents the standard GPS interface. */
typedef struct {
int (*init)( GpsCallbacks* callbacks );
/** Starts navigating. */
int (*start)( void );
...
Libs HAL Init
30. Architecture by example - GPS
development/tools/emulator/system/gps/
gps_qemu.c
device/samsung/manta/gps/gps.exynos5.so
Libs HAL Init
31. 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
32. 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.asInterfa
./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 deve
./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.getSystemServ
./base/core/java/android/webkit/GeolocationService.java:55: if (mLocationManager == null) {
./base/core/java/android/webkit/GeolocationService.java:118: if (LocationManager.NETWORK_PROVIDER.equal
....
34. Level 1: 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
https://github.com/timroes/explain-plz
35. 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