Beruflich Dokumente
Kultur Dokumente
B. Vasu Dev
vasu@easyarm.com
Android Architecture
Agenda
Android Source
Android Build System
Adding new code in Android Build System
Building & Executing C Code on Android Device
Debugging C/C++ using GDB
Experimenting & Understanding JAVA JNI
Compiling Android Source
Building Android RootFS
Android Source
|-- bionic ==> Not glib/uclib
|-- bootable ==> boot and startup related code
|-- build
==> build setup files
|-- cts
==> Android certification
|-- dalvik ==> DVM/JVM
|-- development =>source for NDK/SDK
|-- device ==> New devices are added her
|-- external ==> open souce lib / execuatle / helper
|-- frameworks =>service / server
|-- hardware => bluetoth/wlan/camera/gpio/sensor
|-- kernel
==> optional
|-- ndk
==> NDK
|-- out
==> out/target/product
|-- packages ==> All packaes contact/calnder
|-- prebuilt ==> tool chains are placed here
|-- sdk
=>SDK
|-- system ==>source code files for the core Android
system. That is the minimal Linux system that is started
before the Dalvik VM and any java based services are
enabled
`-- u-boot
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.4
TARGET_PRODUCT=beaglebone
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRJ22
============================================
beaglebone_gb$ printconfig
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.4
TARGET_PRODUCT=beaglebone
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GRJ22
============================================
beaglebone_gb/external/myprogram$ . ../../build/envsetup.sh
beaglebone_gb/external/myprogram$ mm
TARGET_PRODUCT=beaglebone
Adding CUSTOM_LOCALES [mdpi hdpi] to PRODUCT_LOCALES []
make: Entering directory
`/home/alexander/projects/android/work/BeagleBone/beaglebone_gb'
target thumb C: my_program <= external/myprogram/my_program.c
target Executable: my_program
(out/target/product/beaglebone/obj/EXECUTABLES/my_program_inter
mediates/LINKED/my_program)
target Non-prelinked: my_program
(out/target/product/beaglebone/symbols/system/bin/my_program)
target Strip: my_program
(out/target/product/beaglebone/obj/EXECUTABLES/my_program_inter
mediates/my_program)
Install: out/target/product/beaglebone/system/bin/my_program
make: Leaving directory
`/home/alexander/projects/android/work/BeagleBone/beaglebone_gb'
Debugging
Android SDK includes a useful logging utility class called android.util.Log.
The Log.e() method is used to log errors.
The Log.w() method is used to log warnings.
The Log.i() method is used to log informational messages.
The Log.d() method is used to log debug messages.
The Log.v() method is used to log verbose messages.
The Log.wtf() method is used to log terrible failures that should never
happen. (WTF stands for What a Terrible Failure! of course.)
import android.util.Log;
public class MySimpleAppActivity extends Activity {
private static final String DEBUG_TAG= "MySimpleAppLogging";
Log.i(DEBUG_TAG, "Info about MySimpleAppActivity.");
JNI
Service Manager
==============
The APIS needed to manage the services are provided by the ServiceMangaer.
Source of ServiceManager
The ServiceManager source can be found in the file
frameworks/base/core/java/android/os/ServiceManager.java
SystemServer
============
This SystemServer service is the master of all Java service. On boot time this
service starts all the Java services. In this file you can find the list of Java
services started. Presently the services are hard coded in this file. If you want
your service to be started at the boot time adding it here will start it
automatically.
Services are hard coded
Presently the services initialised by the SystemServer are hard coded.
frameworks/base/services/java/com/android/server/SystemServer.java
SystemServer Initialisation
Once the system server is started it will print the log as Entered the Android system server!
which can be view using logcat. Then it starts the ServerThread which in turn starts the
services which are listed below.
Critical services
Entropy Service
Power Manager
Activity Manager
Telephony Registry
Package Manager
Account Manager
Content Manager
System Content Providers
Battery Service
Lights Service
Vibrator Service
Alarm Manager
Init Watchdog
Sensor Service
Window Manager
Note: If any of the above system services failed to start, you will get exception "Failure
starting core service"
Additional services
Bluetooth Service
Device Policy
Status Bar
Clipboard Service
Input Method Service
NetStat Service
NetworkManagement Service
Connectivity Service
Throttle Service
Accessibility Manager
Mount Service
Notification Manager
Device Storage Monitor
Location Manager
Search Service
Demo Thread
DropBox Service
Wallpaper Service
Audio Service
Headset Observer - Listen for wired headset changes
Dock Observer - Listen for dock station changes
UI Mode Manager Service - Listen for dock station changes
Backup Service
AppWidget Service
Recognition Service