SlideShare a Scribd company logo
Applied Computer Science
     Concepts in Android



Jim Huang ( 黃敬群 )
Developer & Co-Founder, 0xlab
                                        jserv@0xlab.org

                                Dec 31, 2010 / CSIE, NTU
Applied Computer Science
       Concepts in Android



Android = A complete operating system
for mobile computing, open source'd
Rights to copy
                                                                    © Copyright 2010 0xlab
                                                                           http://0xlab.org/
                                                                            contact@0xlab.org
Attribution – ShareAlike 3.0
You are free                                                  Corrections, suggestions, contributions and
                                                                               translations are welcome!
   to copy, distribute, display, and perform the work
   to make derivative works                                                  Latest update:Dec 31, 2010
   to make commercial use of the work
Under the following conditions
      Attribution. You must give the original author credit.
      Share Alike. If you alter, transform, or build upon this work, you may distribute the
      resulting work only under a license identical to this one.
   For any reuse or distribution, you must make clear to others the license terms of this
   work.
   Any of these conditions can be waived if you get permission from the copyright holder.
Your fair use and other rights are in no way affected by the above.
License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode
Agenda                    (1) Android Internals
                                (2) Compiler: 2D/3D Graphics
                                (3) OS: Telephony
                                (4) Virtual Machine: Database




In this presentation, the unaware or indirect applications of
In this presentation, the unaware or indirect applications of
essential computer science concepts are dicussed as showcase.
essential computer science concepts are dicussed as showcase.
Android Internals

… or, the low-level parts ...
Android Internals

• Android Low-Level system
  – Architecture View
  – Everything from “Zygote”
  – Key design concepts in Android
  – System components

• Hardware Abstraction Layer (HAL)
  – GPS, RIL, Graphics (2D/3D), ...
Android Low-level system



• Architecture
• Everything from “Zygote”
• Key design concepts in Android
Android Low-Level System
       [ Architecture ]
GNU/Linux vs. Android




   Linux          Android
Android =   (patched)   Linux Kernel + special user-space
Functional View
                                Applications
   Gallery         Phone         Web Browser    Google Maps   ・・・・・

                            Android Framework
   Activity       Window           Content                       Notification
                                                View System
   Manager        Manager          Manager                        Manager

   Package        Telephony        Resource       Location
   Manager         Manager         Manager        Manager


                            System Library          Android Runtime
SurfaceFlinger   OpenCORE          SQLite                Class Library

                                                    Dalvik Virtual Machine
OpenGL|ES        AudioFlinger      WebKit

    Skia         OpenSSL          bionic libc     Freetype


                                Linux Kernel
Android Low-Level System
   [ Everything from Zygote ]
Android Boot Sequence
Low level initialization         High level perspective (Android specific)

        ARM based                     Initialization process
         Target Board                        /etc/init.rc



   Android bootloader                 Start Android Service
      USB loader

                                 console
                                 adbd
                                 service manager
       Load Linux                mountd
                                 debuggerd
                                 zygote
                                 mediaserver
                                 installd
       Start kernel
                                 flash_recovery
       - /init/main.c
Process View
          User-space:: process


               Process



               PID : 1                                         PPID : 2
                                            1
               PPID : 0

                               spawn
 spawn                        (fork+exec)
(fork+exec)                                                    Process


    Process               Process                spawn
                                                (fork+exec)    PPID : 3
    PID : 2               PID : 3
    PPID : 1              PPID : 1



                                                       2
   Process                Process
  PID : 4                 PID : 5
  PPID : 2                PPID : 3
                                            3




                                                           4


 fork()                                 5
 Copy on Write
Role of Zygote
Everything spawn from Zygote
Android Low-Level System
    [ Key Design Concepts ]
System Interaction




IPC: Inter-Process Communication
Activities



window

 widget


 Activities


 view




view group
Activity state transition
                              Task 1

Home        Activity1         Activity2   Activity3




            1                  2          3
                                           Home
                        Back Key             Key
Home        Activity4         Activity5   Activity6




            4                  5          6
                              Task 2
Activity life cycle
• Entire lifetime
• Visible lifetime
• Foreground lifetime
Services



 Activity       Activity

                                               Service

                                     Invoking specific service
                                     (provided by Media server)




                              Home

                               or
Activity1                     Back


            Activity2
Broadcast Receivers



                                             Components
Components

                                               Receiver
Broadcast


                              SMS_RECEIVED
  Intent

               SMS_RECEIVED
Content Providers


       Components




    Content Providers                  Interface
                               Content Provider Class     Components   A

                                       Preferences
                                                        Content Resolver
                                          Files
                                                          Components   B

                                       SQLite(DB)
                                                        Content Resolver
                                        Network




Content Providers, Intents, Resolver
Components
                                               Intent                  Components




                       Activity
                                                                        Activity
Context.startActivity()
                                                   (Intents)
                                                                           or
Activity.startActivityForResult()


                                                                        Service
Context.startService()
Context.bindService()                                                      or


                      Broadcast                                         Broadcast

Context.sendBroadcast()
Context.sendOrderedBroadcast()                            System
Context.sendStickyBroadcast()              3
                                                manifest                        Components
                                    2          ActivityManager
                                                                                    Class A
      Components

      Service
        Intent                    Intent
                                                                   5
         to class A         1 To Class A
                                                 <class list>
                                                 …
                                                 class A
                                           4     …
Android Services in Action
Content     Telephony            Bluetooth     Connectivity                Location
Manager      Service              Service        Service                   Manager

Window       Activity            Package             Power
                                                                                 …
Manager      Manager             Manager            Manager
                        Add Service
                        Service                     Audio Flinger
                                      Add Service
                        Manager
daemons                                                  Surface
                        Service                          Flinger
  usbd                  Manager

  adbd                                                                            System
                        runtime                                                   Server
debuggerd

   rild                   Init                  Zygote                           Dalvik VM

                                                Kernel         Android Service
                   Linux Kernel
                                                Dalvik         Framework
IPC: Binder(1)
   Binder in Action




      A pool of threads is associated to each service application to process
       incoming IPC (Inter-Process Communication).
      Binder performs mapping of object between two processes.
      Binder uses an object reference as an address in a process’s memory
       space.
      Synchronous call, reference couting
IPC: Binder(2)
Understanding

• Essential components
   – Compiler: Java
  – Virtual Machine: Dalvik
  – OS: Linux Kernel                SSA form




• Anything else?
Applied Computer Science Concepts in Android
Compilers

Applied in 2D/3D Graphics
OpenGL Anywhere


  ARM®           PowerVR
Cortex™- A8        SGX
with NEON VFP    Graphics


C64x+      Other        Display
         Peripherals   Subsystem
 DSP
OpenGL Graphics Pipeline
State Variables                                                                         Front Buffer

                                    Geometry                            Fragment
                                     Pipeline                            Pipeline

Camera Position
 Light Sources                                          F
      Etc.                          C         G
                                                            E
                                                                D
                                                                                        Back Buffer
              A

                                                                C
     GL_TRIANGLES                             A
                            B                                       B

                                            GL_TRIANLE_FAN
                  A             C
                                              E
                                                    F



                        B
                                        D
                                                                         Texture Maps
                      GL_TRIANGLE_STRIP
Texturing Example




Before Texturing          After Texturing
Graphics Pipeline
                               LOD selection
                               Frustum Culling
               Application     Portal Culling
                               …

                                                         Clipping
                                   VERTEX SHADER
Programmable




                Geometry                                 Division by w
                Processing Assembly
                      Primitive                   Viewport transform
                               Backface culling

                               Scan Conversion
               Rasterization       FRAGMENT SHADER



                  Output       Output to Device
Vertex and Fragment Shaders
   ( x, y, z, w )               ( x’, y’, z’, w’ )
   ( nx, ny, nz )               ( nx’, ny’, nz’ )
   ( s, t, r, q )               ( s’, t’, r’, q’ )
   ( r, g, b, a )               ( r’, g’, b’, a’ )

                     VERTEX
                     SHADER




( x, y )                         ( x, y )
( r’, g’, b’, a’ )               ( r, g, b, a )
( depth’ )                       ( depth )


                     FRAGMENT
                      SHADER
Embedded code with no lighting




    OpenGL|ES
•   Added
     – Fixed-point and byte data
•   Retained
     –   Vertex Transforms and Lighting (mostly)     Embedded code with lighting
     –   Multi-texturing (2D only)
     –   Full Scene Antialiasing via Multisampling   (Smooth Shaded)
     –   Alpha blending                                                  Surface Normal Vectors
OpenGL|ES 1.1 Example
// Enable fixed-function shading (smooth or flat)
   glShadeModel(GL_SMOOTH);

// Define the appearance of triangle surfaces
   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, fMaterialAmbient);
   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Shininess);

// Define the appearance and position of a light source
   glLightfv(GL_LIGHT0, GL_AMBIENT, fLightAmbient);
   glLightModelfv(GL_LIGHT_MODEL_AMBIENT, fAmbient);
   glLightfv(GL_LIGHT0, GL_POSITION, fLightPosition);

// Set pointers to geometry and other attributes and draw it
   glVertexPointer(3, GL_FLOAT, 0, Vertices);
   glTexCoordPointer(2, GL_FLOAT, 0, TexCoords);
   glNormalPointer(GL_FLOAT, 0, NormalsPerVertex);
   glDrawArrays(GL_TRIANGLES, 0, Count);


                                                                    38
OpenGL|ES 2.0 Example
// Create a vertex shader object, load source code and compile it
   hVertexShader = glCreateShader(GL_VERTEX_SHADER);
   glShaderSource(hVertexShader, 1, pVertexShaderSourceCode, NULL);
   glCompileShader(hVertexShader);

// Create a shader program and attach the fragment and vertex shaders to it
   hProgram = glCreateProgram();
   glAttachShader(hProgram, hFragmentShader);
   glAttachShader(hProgram, hVertexShader);

// Link and load the new shader programs into the PowerVR SGX
   glLinkProgram(hProgram);
   glUseProgram(hProgram);

// Set pointers to geometry and other attributes and send to the vertex shader
   glVertexAttribPointer(Index, 3, GL_FLOAT, GL_TRUE, Stride, pAttributes);
   glDrawArrays(GL_TRIANGLES, 0, Count);


                                                                                 39
GPU = Graphics Processing Unit
   Pipelining
                                                      1   2   3
     Number      of stages


   Parallelism                                           1

                                                          2
     Number      of parallel processes                   3



   Parallelism + pipelining
                                                      1   2   3
     Number      of parallel pipelines               1   2   3
   Operates on 4 tuples
                                                      1   2   3
     – Position     ( x, y, z, w )
     – Color( red, green, blue, alpha )
     – Texture Coordinates           ( s, t, r, q )
4 tuple ops, 1 clock cycle
         SIMD [ Single Instruction Multiple Data ]
Reyes(scanline,polygon)   Raytracing




  Optimized by SIMD




                          Hard to be optimized by SIMD
                            Computing dependency
                          Dynamic fast-paths required
Specialize         color space convertion takes lots of time.
                   BGRA 444R → RGBA 8888
Technique




 Speedup depends on src/dest format:
 – 5.4x speedup on average, 19.3x max
 speedup: (13.3MB/s to 257.7MB/s)
LLVM = Low Level Virtual Machine
Mandelbort is optimized through LLVM JIT up to 11x.
Android OpenGL|ES
Android SurfaceFlinger
   Properties
        Can combine 2D/3D surfaces and surfaces from multiple applications
        Surfaces passed as buffers via Binder IPC calls
        Can use OpenGL ES and 2D hardware accelerator for its compositions
             Double-buffering using page-flip
Applied Computer Science Concepts in Android
UI Element            GLSurfaceView                 javax .microedition .khronos .opengles

View and Canvas → Surface
View and Canvas → Surface

                              android. view. View                                          com.google.android.gles_jni



                             android. view. Surface          android graphics. Canvas
                                                                    .
   Java Graphics   JAVA
  is implemented Framework
       via JNI     Native
                 Framework           Surface JNI                    Graphic JNI                  OpenGL JNI




                             SurfaceFlinger                              skia                    OpenGL|ES
      Libui +
       Libui +
 SurfaceFlinger +
 SurfaceFlinger +
  libpixelflinger
   libpixelflinger           libui
                               Overlay     Camera       Surface     Key / Event   format         EglWindows




                                                                                           libpixelflinger
                             FrameBuffer                   Event Input
                                Driver                       Driver
Applied Computer Science Concepts in Android
PixelFlinger : software renderer
• Render functions: pointx, linex, recti, trianglex
• Texture and color buffer: activeTexture, bindTexture,
  colorBuffer, readBuffer, depthBuffer, BindTextureLod
• …
• Device framebuffer functions: copyPixels,
  rasterPos2x, rasterPos2i
• Optimizer: codeflinger (JIT assembler)



 I/SurfaceFlinger( 1931): OpenGL informations:

 I/SurfaceFlinger( 1931): vendor    : Android

 I/SurfaceFlinger( 1931): renderer : Android PixelFlinger 1.2

 I/SurfaceFlinger( 1931): version   : OpenGL ES­CM 1.0
GGLAssembler –
GGLAssembler –
codeflinger's JIT Assembler
codeflinger's JIT Assembler
commit 77cadd2ffada95bb3279552e1a29f4bcf4012228
                       commit 77cadd2ffada95bb3279552e1a29f4bcf4012228
                       Author: Jim Huang <jserv@0xlab.org>
                       Author: Jim Huang <jserv@0xlab.org>
                       Date:   Wed Jan 13 01:01:18 2010 +0800
                       Date:   Wed Jan 13 01:01:18 2010 +0800

                           [libpixelflinger] Adds UXTB16 support to Pixelflinger
                           [libpixelflinger] Adds UXTB16 support to Pixelflinger
                           ...
                           ...
                           Uses UXTB16 to extract channels for SIMD operations, rather than creating and
                           Uses UXTB16 to extract channels for SIMD operations, rather than creating and
                           ANDing with masks. Saves a register and is faster on A8, as UXTB16 result can
                           ANDing with masks. Saves a register and is faster on A8, as UXTB16 result can
                           feed into first stage of multiply, unlike AND.
                           feed into first stage of multiply, unlike AND.
                           
                           
                           Also, used SMULWB rather than SMULBB, which allows removal of MOVs used to
                           Also, used SMULWB rather than SMULBB, which allows removal of MOVs used to
                           rescale results.
                           rescale results.
                           
                           
                           Code has been scheduled for A8 pipeline, specifically aiming to allow
                           Code has been scheduled for A8 pipeline, specifically aiming to allow
                           multiplies to issue in pipeline 0, for efficient dual issue operation.
                           multiplies to issue in pipeline 0, for efficient dual issue operation.
                           
                           
                           Testing on SpriteMethodTest (http://code.google.com/p/apps­for­android/) gives
                           Testing on SpriteMethodTest (http://code.google.com/p/apps­for­android/) gives
                           8% improvement (12.7 vs. 13.7 fps.)
                           8% improvement (12.7 vs. 13.7 fps.)




libpixelflinger/codeflinger/ARMAssembler.cpp
libpixelflinger/codeflinger/ARMAssembler.cpp
@@ ­424,5 +424,15 @@ void ARMAssembler::SMLAW(int cc, int y,
@@ ­424,5 +424,15 @@ void ARMAssembler::SMLAW(int cc, int y,
     *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;
     *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;
 }
 }
 
 
+#if 0
+#if 0
+#pragma mark ­
+#pragma mark ­
+#pragma mark Byte/half word extract and extend (ARMv6+ only)...
+#pragma mark Byte/half word extract and extend (ARMv6+ only)...
+#endif
+#endif
+
+
+void ARMAssembler::UXTB16(int cc, int Rd, int Rm, int rotate)
+void ARMAssembler::UXTB16(int cc, int Rd, int Rm, int rotate)
+{
+{
+    *mPC++ = (cc<<28) | 0x6CF0070 | (Rd<<12) | ((rotate >> 3) << 10) | Rm;
+    *mPC++ = (cc<<28) | 0x6CF0070 | (Rd<<12) | ((rotate >> 3) << 10) | Rm;   opcode
+}
+}
+
+
 }; // namespace android
 }; // namespace android
 
 
libpixelflinger/codeflinger/ARMAssemblerProxy.cpp
libpixelflinger/codeflinger/ARMAssemblerProxy.cpp
@@ ­195,6 +195,10 @@ void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) {
@@ ­195,6 +195,10 @@ void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) {
     mTarget­>SMLAW(cc, y, Rd, Rm, Rs, Rn);
     mTarget­>SMLAW(cc, y, Rd, Rm, Rs, Rn);
 }
 }
 
 
+void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) {
+void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) {
+    mTarget­>UXTB16(cc, Rd, Rm, rotate);
+    mTarget­>UXTB16(cc, Rd, Rm, rotate);
+}
+}
+
+
 
 
 }; // namespace android
 }; // namespace android
 
 




                        libpixelflinger/codeflinger/texturing.cpp
                        libpixelflinger/codeflinger/texturing.cpp

                        @@ ­868,6 +869,106 @@ void GGLAssembler::filter24(
                        @@ ­868,6 +869,106 @@ void GGLAssembler::filter24(
                             load(txPtr, texel, 0);
                             load(txPtr, texel, 0);
                         }
                         }
                         
                         
                        +#if __ARM_ARCH__ >= 6
                        +#if __ARM_ARCH__ >= 6
                        +// ARMv6 version, using UXTB16, and scheduled for Cortex­A8 pipeline
                        +// ARMv6 version, using UXTB16, and scheduled for Cortex­A8 pipeline
                        +void GGLAssembler::filter32(
                        +void GGLAssembler::filter32(
                        +        const fragment_parts_t& parts,
                        +        const fragment_parts_t& parts,
                        +        pixel_t& texel, const texture_unit_t& tmu,
                        +        pixel_t& texel, const texture_unit_t& tmu,
                        +        int U, int V, pointer_t& txPtr,
                        +        int U, int V, pointer_t& txPtr,
                        +        int FRAC_BITS)
                        +        int FRAC_BITS)
                        +{
                        +{
                        ...
                        ...

                        +    UXTB16(AL, temp, pixel, 0);
                        +    UXTB16(AL, temp, pixel, 0);
                                                                           Reimplement filter32()
                        +    if (round) {
                        +    if (round) {
                        +        ADD(AL, 0, u, u, imm(1<<(adjust­1)));
                        +        ADD(AL, 0, u, u, imm(1<<(adjust­1)));
                        +        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
                        +        MOV(AL, 0, u, reg_imm(u, LSR, adjust));
                        +    }
                                                                           In optimized ASM
                        +    }
                        +    LDR(AL, pixellb, txPtr.reg, reg_scale_pre(offsetlb));
                        +    LDR(AL, pixellb, txPtr.reg, reg_scale_pre(offsetlb));
                        +    MUL(AL, 0, dh, temp, u);
                        +    MUL(AL, 0, dh, temp, u);
                        +    UXTB16(AL, temp, pixel, 8);
                        +    UXTB16(AL, temp, pixel, 8);
                        +    MUL(AL, 0, dl, temp, u);
                        +    MUL(AL, 0, dl, temp, u);
                        +    RSB(AL, 0, k, u, imm(0x100));
                        +    RSB(AL, 0, k, u, imm(0x100));
                        ...
                        ...
                        +#else
                        +#else
                         void GGLAssembler::filter32(
                         void GGLAssembler::filter32(
                                 const fragment_parts_t& parts,
                                 const fragment_parts_t& parts,
                                 pixel_t& texel, const texture_unit_t& tmu,
                                 pixel_t& texel, const texture_unit_t& tmu,
Operating System

Applied in Telephony
RIL → Telephony
 Radio   Interface Layer(RIL)
     HAL  Android TelephonyManager  baseband modem
     Voice, Data, SMS, SIM, SIMToolkit
     Android RIL  AT command
 RIL   API
     Android follows GSM TS 27.007 standard
 RIL   implementation
     Qualcomm supports CDMA &
      CDMA-GSM Multi-mode
OS Kernels




    Monolithic Kernel                        Micro Kernel
Traditional UNIX, Linux, …               Mach, L4, Symbian OS




                             Exokernel
L4 Microkernel

• Developed by Jochen Liedtke in 1995.
  – German National Research Center for IT
• Developed from scratch
• 2nd generation microkernel
• Small and Fast Kernel
   – 7 system calls
   – 12KB
• In November 2005, NICTA announced that
  Qualcomm was deploying NICTA's L4 version
  on their Mobile Station Modem chipsets.
Pipes and RPC
Communications
                             Processor
                                               L4 Interrupt Handler
                                                -> Send Message

                           L4 microkernel


                                                    RPC
                                System-
                  Server          call
                                Handler

                                         RPC                          Interrupt
            RPC
                                                           RT task
                      Requests from
Shared Memory      Application Processor
                         to Modem
Virtual Machine

Applied in Database
sqlite3_prepare()
/*
** Compile the UTF­8 encoded SQL statement zSql into a statement handle.
*/
int sqlite3_prepare(
  sqlite3 *db,            /* Database handle. */
  const char *zSql,       /* UTF­8 encoded SQL statement. */
  int nBytes,             /* Length of zSql in bytes. */
  sqlite3_stmt **ppStmt,  /* OUT: A pointer to the prepared                         
        statement */
  const char** pzTail     /* OUT: End of parsed string */
)
{
...
      sqlite3VdbeSetNumCols(sParse.pVdbe, 5);
      sqlite3VdbeSetColName(sParse.pVdbe, 0, COLNAME_NAME, "addr", P3_STATIC);
      sqlite3VdbeSetColName(sParse.pVdbe, 1, COLNAME_NAME, "opcode", P3_STATIC);
      sqlite3VdbeSetColName(sParse.pVdbe, 2, COLNAME_NAME, "p1", P3_STATIC);
      sqlite3VdbeSetColName(sParse.pVdbe, 3, COLNAME_NAME, "p2", P3_STATIC);
      sqlite3VdbeSetColName(sParse.pVdbe, 4, COLNAME_NAME, "p3", P3_STATIC);
…
                                                              Opcode!


                 SQLite Virtual Machine (VDBE)                                     61
…And what about other platforms?

The concept can be applied to all VM platforms

Application virtual machines (short list)
  .NET (CLR)
  Java Virtual Machine (JVM)
  Dalvik virtual machine (Google Android)
  PHP (Zend Engine)
  Flash Player / AIR - ActionScript Virtual Machine (AVM)
  SQLite virtual machine (VDBE; Virtual DataBase Engine)
  Perl virtual machine
Inspiration
Applied Computer Science Concepts in Android
Inspiration

• Computer science concepts are applied
  everywhere in Android software stack.
• Essential system software brings the further
  optimizations and feasibility of new technologies.
• Advanced compiler techniques are already
  applied in every domain
• Best Practice in Android
http://0xlab.org
Ad

Recommended

Android IPC Mechanism
Android IPC Mechanism
National Cheng Kung University
 
Design and Concepts of Android Graphics
Design and Concepts of Android Graphics
National Cheng Kung University
 
Low Level View of Android System Architecture
Low Level View of Android System Architecture
National Cheng Kung University
 
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Bin Chen
 
Explore Android Internals
Explore Android Internals
National Cheng Kung University
 
Android Binder: Deep Dive
Android Binder: Deep Dive
Zafar Shahid, PhD
 
Android Binder IPC for Linux
Android Binder IPC for Linux
Yu-Hsin Hung
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture Overview
Yu-Hsin Hung
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Android Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
National Cheng Kung University
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Android Internals
Android Internals
Opersys inc.
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
Android Booting Sequence
Android Booting Sequence
Jayanta Ghoshal
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Inside Android's UI
Inside Android's UI
Opersys inc.
 
Embedded Android Workshop
Embedded Android Workshop
Opersys inc.
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementation
Chethan Pchethan
 
Android Internals
Android Internals
Opersys inc.
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
Emertxe Information Technologies Pvt Ltd
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
Opersys inc.
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Romain Guy
 
Android device driver structure introduction
Android device driver structure introduction
William Liang
 
Android AIDL Concept
Android AIDL Concept
Charile Tsai
 
Yet Another Android Rootkit
Yet Another Android Rootkit
FFRI, Inc.
 
Computer Graphics
Computer Graphics
Kodai Takao
 

More Related Content

What's hot (20)

Android booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Android Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
National Cheng Kung University
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Android Internals
Android Internals
Opersys inc.
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
Android Booting Sequence
Android Booting Sequence
Jayanta Ghoshal
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Inside Android's UI
Inside Android's UI
Opersys inc.
 
Embedded Android Workshop
Embedded Android Workshop
Opersys inc.
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementation
Chethan Pchethan
 
Android Internals
Android Internals
Opersys inc.
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
Emertxe Information Technologies Pvt Ltd
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
Opersys inc.
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Romain Guy
 
Android device driver structure introduction
Android device driver structure introduction
William Liang
 
Android AIDL Concept
Android AIDL Concept
Charile Tsai
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android's Multimedia Framework
Android's Multimedia Framework
Opersys inc.
 
Android Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation Systems
National Cheng Kung University
 
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Opersys inc.
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram
 
Android Booting Sequence
Android Booting Sequence
Jayanta Ghoshal
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram
 
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram
 
Inside Android's UI
Inside Android's UI
Opersys inc.
 
Embedded Android Workshop
Embedded Android Workshop
Opersys inc.
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementation
Chethan Pchethan
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
Opersys inc.
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro
 
Google I/O 2011, Android Accelerated Rendering
Google I/O 2011, Android Accelerated Rendering
Romain Guy
 
Android device driver structure introduction
Android device driver structure introduction
William Liang
 
Android AIDL Concept
Android AIDL Concept
Charile Tsai
 

Viewers also liked (15)

Yet Another Android Rootkit
Yet Another Android Rootkit
FFRI, Inc.
 
Computer Graphics
Computer Graphics
Kodai Takao
 
An HCI Principles based Framework to Support Deaf Community
An HCI Principles based Framework to Support Deaf Community
IJEACS
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
Doug Hawkins
 
OpenGL Introduction
OpenGL Introduction
Yi-Lung Tsai
 
Computer science
Computer science
Vladi Sanchez
 
Computer science ppt
Computer science ppt
brijesh kumar
 
Computer Science Engineering - Better Career Opportunities
Computer Science Engineering - Better Career Opportunities
achaljain11
 
Basics of computer science
Basics of computer science
Paul Schmidt
 
10 Myths for Computer Science
10 Myths for Computer Science
Thanos Hatziapostolou
 
Computer Science & Information Systems
Computer Science & Information Systems
Luis Borges Gouveia
 
Uses of computer in various fields
Uses of computer in various fields
Divyanshu Gupta
 
Making Linux do Hard Real-time
Making Linux do Hard Real-time
National Cheng Kung University
 
Application Of Computers
Application Of Computers
LUZ PINGOL
 
Introduction to computer science
Introduction to computer science
derekoei
 
Yet Another Android Rootkit
Yet Another Android Rootkit
FFRI, Inc.
 
Computer Graphics
Computer Graphics
Kodai Takao
 
An HCI Principles based Framework to Support Deaf Community
An HCI Principles based Framework to Support Deaf Community
IJEACS
 
Inside Android's Dalvik VM - NEJUG Nov 2011
Inside Android's Dalvik VM - NEJUG Nov 2011
Doug Hawkins
 
OpenGL Introduction
OpenGL Introduction
Yi-Lung Tsai
 
Computer science ppt
Computer science ppt
brijesh kumar
 
Computer Science Engineering - Better Career Opportunities
Computer Science Engineering - Better Career Opportunities
achaljain11
 
Basics of computer science
Basics of computer science
Paul Schmidt
 
Computer Science & Information Systems
Computer Science & Information Systems
Luis Borges Gouveia
 
Uses of computer in various fields
Uses of computer in various fields
Divyanshu Gupta
 
Application Of Computers
Application Of Computers
LUZ PINGOL
 
Introduction to computer science
Introduction to computer science
derekoei
 
Ad

Similar to Applied Computer Science Concepts in Android (20)

Android. behind the scenes_programatica 2012
Android. behind the scenes_programatica 2012
Agora Group
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
Opersys inc.
 
TOMOYO Linux on Android
TOMOYO Linux on Android
Toshiharu Harada, Ph.D
 
Leveraging Android's Linux Heritage
Leveraging Android's Linux Heritage
Opersys inc.
 
Improve Android System Component Performance
Improve Android System Component Performance
National Cheng Kung University
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
Tetsuyuki Kobayashi
 
Android village @nullcon 2012
Android village @nullcon 2012
hakersinfo
 
Mobile operating systems - Application Benchmarking
Mobile operating systems - Application Benchmarking
Nicolas Demetriou
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
Opersys inc.
 
Android For Managers Slides
Android For Managers Slides
Marko Gargenta
 
Leveraging Android's Linux Heritage at ELC-E 2011
Leveraging Android's Linux Heritage at ELC-E 2011
Opersys inc.
 
Android application development
Android application development
Linh Vi Tường
 
Android
Android
Leo Liang
 
Android for Java Developers
Android for Java Developers
Marko Gargenta
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3
Opersys inc.
 
Introduction to android
Introduction to android
Jawad Mohmand
 
Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010
Marko Gargenta
 
Android Optimization: Myth and Reality
Android Optimization: Myth and Reality
National Cheng Kung University
 
Zeelogic android-training-2013
Zeelogic android-training-2013
Zeelogic Solu
 
Open Android
Open Android
Marko Gargenta
 
Android. behind the scenes_programatica 2012
Android. behind the scenes_programatica 2012
Agora Group
 
Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
Opersys inc.
 
Leveraging Android's Linux Heritage
Leveraging Android's Linux Heritage
Opersys inc.
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
Tetsuyuki Kobayashi
 
Android village @nullcon 2012
Android village @nullcon 2012
hakersinfo
 
Mobile operating systems - Application Benchmarking
Mobile operating systems - Application Benchmarking
Nicolas Demetriou
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
Opersys inc.
 
Android For Managers Slides
Android For Managers Slides
Marko Gargenta
 
Leveraging Android's Linux Heritage at ELC-E 2011
Leveraging Android's Linux Heritage at ELC-E 2011
Opersys inc.
 
Android application development
Android application development
Linh Vi Tường
 
Android for Java Developers
Android for Java Developers
Marko Gargenta
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3
Opersys inc.
 
Introduction to android
Introduction to android
Jawad Mohmand
 
Android for Java Developers at OSCON 2010
Android for Java Developers at OSCON 2010
Marko Gargenta
 
Zeelogic android-training-2013
Zeelogic android-training-2013
Zeelogic Solu
 
Ad

More from National Cheng Kung University (20)

PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
National Cheng Kung University
 
Making Linux do Hard Real-time
Making Linux do Hard Real-time
National Cheng Kung University
 
2016 年春季嵌入式作業系統課程說明
2016 年春季嵌入式作業系統課程說明
National Cheng Kung University
 
Interpreter, Compiler, JIT from scratch
Interpreter, Compiler, JIT from scratch
National Cheng Kung University
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
National Cheng Kung University
 
Construct an Efficient and Secure Microkernel for IoT
Construct an Efficient and Secure Microkernel for IoT
National Cheng Kung University
 
The Internals of "Hello World" Program
The Internals of "Hello World" Program
National Cheng Kung University
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
National Cheng Kung University
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
National Cheng Kung University
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
National Cheng Kung University
 
從線上售票看作業系統設計議題
從線上售票看作業系統設計議題
National Cheng Kung University
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
National Cheng Kung University
 
Xvisor: embedded and lightweight hypervisor
Xvisor: embedded and lightweight hypervisor
National Cheng Kung University
 
Implement Runtime Environments for HSA using LLVM
Implement Runtime Environments for HSA using LLVM
National Cheng Kung University
 
Priority Inversion on Mars
Priority Inversion on Mars
National Cheng Kung University
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
National Cheng Kung University
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
National Cheng Kung University
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
National Cheng Kung University
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
National Cheng Kung University
 
Open Source from Legend, Business, to Ecosystem
Open Source from Legend, Business, to Ecosystem
National Cheng Kung University
 
PyPy's approach to construct domain-specific language runtime
PyPy's approach to construct domain-specific language runtime
National Cheng Kung University
 
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
進階嵌入式作業系統設計與實做 (2015 年秋季 ) 課程說明
National Cheng Kung University
 
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
給自己更好未來的 3 個練習:嵌入式作業系統設計、實做,與移植 (2015 年春季 ) 課程說明
National Cheng Kung University
 
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
進階嵌入式系統開發與實做 (2014 年秋季 ) 課程說明
National Cheng Kung University
 
Develop Your Own Operating Systems using Cheap ARM Boards
Develop Your Own Operating Systems using Cheap ARM Boards
National Cheng Kung University
 
Lecture notice about Embedded Operating System Design and Implementation
Lecture notice about Embedded Operating System Design and Implementation
National Cheng Kung University
 
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
中輟生談教育: 完全用開放原始碼軟體進行 嵌入式系統教學
National Cheng Kung University
 
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
F9: A Secure and Efficient Microkernel Built for Deeply Embedded Systems
National Cheng Kung University
 

Recently uploaded (20)

War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 

Applied Computer Science Concepts in Android

  • 1. Applied Computer Science Concepts in Android Jim Huang ( 黃敬群 ) Developer & Co-Founder, 0xlab [email protected] Dec 31, 2010 / CSIE, NTU
  • 2. Applied Computer Science Concepts in Android Android = A complete operating system for mobile computing, open source'd
  • 3. Rights to copy © Copyright 2010 0xlab http://0xlab.org/ [email protected] Attribution – ShareAlike 3.0 You are free Corrections, suggestions, contributions and translations are welcome! to copy, distribute, display, and perform the work to make derivative works Latest update:Dec 31, 2010 to make commercial use of the work Under the following conditions Attribution. You must give the original author credit. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. License text: http://creativecommons.org/licenses/by-sa/3.0/legalcode
  • 4. Agenda (1) Android Internals (2) Compiler: 2D/3D Graphics (3) OS: Telephony (4) Virtual Machine: Database In this presentation, the unaware or indirect applications of In this presentation, the unaware or indirect applications of essential computer science concepts are dicussed as showcase. essential computer science concepts are dicussed as showcase.
  • 5. Android Internals … or, the low-level parts ...
  • 6. Android Internals • Android Low-Level system – Architecture View – Everything from “Zygote” – Key design concepts in Android – System components • Hardware Abstraction Layer (HAL) – GPS, RIL, Graphics (2D/3D), ...
  • 7. Android Low-level system • Architecture • Everything from “Zygote” • Key design concepts in Android
  • 8. Android Low-Level System [ Architecture ]
  • 9. GNU/Linux vs. Android Linux Android
  • 10. Android = (patched) Linux Kernel + special user-space
  • 11. Functional View Applications Gallery Phone Web Browser Google Maps ・・・・・ Android Framework Activity Window Content Notification View System Manager Manager Manager Manager Package Telephony Resource Location Manager Manager Manager Manager System Library Android Runtime SurfaceFlinger OpenCORE SQLite Class Library Dalvik Virtual Machine OpenGL|ES AudioFlinger WebKit Skia OpenSSL bionic libc Freetype Linux Kernel
  • 12. Android Low-Level System [ Everything from Zygote ]
  • 13. Android Boot Sequence Low level initialization High level perspective (Android specific) ARM based Initialization process Target Board /etc/init.rc Android bootloader Start Android Service USB loader console adbd service manager Load Linux mountd debuggerd zygote mediaserver installd Start kernel flash_recovery - /init/main.c
  • 14. Process View User-space:: process Process PID : 1 PPID : 2 1 PPID : 0 spawn spawn (fork+exec) (fork+exec) Process Process Process spawn (fork+exec) PPID : 3 PID : 2 PID : 3 PPID : 1 PPID : 1 2 Process Process PID : 4 PID : 5 PPID : 2 PPID : 3 3 4 fork() 5 Copy on Write
  • 17. Android Low-Level System [ Key Design Concepts ]
  • 20. Activity state transition Task 1 Home Activity1 Activity2 Activity3 1 2 3 Home Back Key Key Home Activity4 Activity5 Activity6 4 5 6 Task 2
  • 21. Activity life cycle • Entire lifetime • Visible lifetime • Foreground lifetime
  • 22. Services Activity Activity Service Invoking specific service (provided by Media server) Home or Activity1 Back Activity2
  • 23. Broadcast Receivers Components Components Receiver Broadcast SMS_RECEIVED Intent SMS_RECEIVED
  • 24. Content Providers Components Content Providers Interface Content Provider Class Components   A Preferences Content Resolver Files Components   B SQLite(DB) Content Resolver Network Content Providers, Intents, Resolver
  • 25. Components Intent Components Activity Activity Context.startActivity() (Intents) or Activity.startActivityForResult() Service Context.startService() Context.bindService() or Broadcast Broadcast Context.sendBroadcast() Context.sendOrderedBroadcast() System Context.sendStickyBroadcast() 3 manifest Components 2 ActivityManager Class A Components Service Intent Intent 5 to class A 1 To Class A <class list> … class A 4 …
  • 26. Android Services in Action Content Telephony Bluetooth Connectivity Location Manager Service Service Service Manager Window Activity Package Power … Manager Manager Manager Manager Add Service Service Audio Flinger Add Service Manager daemons Surface Service Flinger usbd Manager adbd System runtime Server debuggerd rild Init Zygote Dalvik VM Kernel Android Service Linux Kernel Dalvik Framework
  • 27. IPC: Binder(1)  Binder in Action  A pool of threads is associated to each service application to process incoming IPC (Inter-Process Communication).  Binder performs mapping of object between two processes.  Binder uses an object reference as an address in a process’s memory space.  Synchronous call, reference couting
  • 29. Understanding • Essential components – Compiler: Java – Virtual Machine: Dalvik – OS: Linux Kernel SSA form • Anything else?
  • 32. OpenGL Anywhere ARM® PowerVR Cortex™- A8 SGX with NEON VFP Graphics C64x+ Other Display Peripherals Subsystem DSP
  • 33. OpenGL Graphics Pipeline State Variables Front Buffer Geometry Fragment Pipeline Pipeline Camera Position Light Sources F Etc. C G E D Back Buffer A C GL_TRIANGLES A B B GL_TRIANLE_FAN A C E F B D Texture Maps GL_TRIANGLE_STRIP
  • 35. Graphics Pipeline LOD selection Frustum Culling Application Portal Culling … Clipping VERTEX SHADER Programmable Geometry Division by w Processing Assembly Primitive Viewport transform Backface culling Scan Conversion Rasterization FRAGMENT SHADER Output Output to Device
  • 36. Vertex and Fragment Shaders ( x, y, z, w ) ( x’, y’, z’, w’ ) ( nx, ny, nz ) ( nx’, ny’, nz’ ) ( s, t, r, q ) ( s’, t’, r’, q’ ) ( r, g, b, a ) ( r’, g’, b’, a’ ) VERTEX SHADER ( x, y ) ( x, y ) ( r’, g’, b’, a’ ) ( r, g, b, a ) ( depth’ ) ( depth ) FRAGMENT SHADER
  • 37. Embedded code with no lighting OpenGL|ES • Added – Fixed-point and byte data • Retained – Vertex Transforms and Lighting (mostly) Embedded code with lighting – Multi-texturing (2D only) – Full Scene Antialiasing via Multisampling (Smooth Shaded) – Alpha blending Surface Normal Vectors
  • 38. OpenGL|ES 1.1 Example // Enable fixed-function shading (smooth or flat) glShadeModel(GL_SMOOTH); // Define the appearance of triangle surfaces glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, fMaterialAmbient); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, Shininess); // Define the appearance and position of a light source glLightfv(GL_LIGHT0, GL_AMBIENT, fLightAmbient); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, fAmbient); glLightfv(GL_LIGHT0, GL_POSITION, fLightPosition); // Set pointers to geometry and other attributes and draw it glVertexPointer(3, GL_FLOAT, 0, Vertices); glTexCoordPointer(2, GL_FLOAT, 0, TexCoords); glNormalPointer(GL_FLOAT, 0, NormalsPerVertex); glDrawArrays(GL_TRIANGLES, 0, Count); 38
  • 39. OpenGL|ES 2.0 Example // Create a vertex shader object, load source code and compile it hVertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(hVertexShader, 1, pVertexShaderSourceCode, NULL); glCompileShader(hVertexShader); // Create a shader program and attach the fragment and vertex shaders to it hProgram = glCreateProgram(); glAttachShader(hProgram, hFragmentShader); glAttachShader(hProgram, hVertexShader); // Link and load the new shader programs into the PowerVR SGX glLinkProgram(hProgram); glUseProgram(hProgram); // Set pointers to geometry and other attributes and send to the vertex shader glVertexAttribPointer(Index, 3, GL_FLOAT, GL_TRUE, Stride, pAttributes); glDrawArrays(GL_TRIANGLES, 0, Count); 39
  • 40. GPU = Graphics Processing Unit  Pipelining 1 2 3  Number of stages  Parallelism 1 2  Number of parallel processes 3  Parallelism + pipelining 1 2 3  Number of parallel pipelines 1 2 3  Operates on 4 tuples 1 2 3 – Position ( x, y, z, w ) – Color( red, green, blue, alpha ) – Texture Coordinates ( s, t, r, q ) 4 tuple ops, 1 clock cycle  SIMD [ Single Instruction Multiple Data ]
  • 41. Reyes(scanline,polygon) Raytracing Optimized by SIMD Hard to be optimized by SIMD Computing dependency Dynamic fast-paths required
  • 42. Specialize color space convertion takes lots of time. BGRA 444R → RGBA 8888 Technique Speedup depends on src/dest format: – 5.4x speedup on average, 19.3x max speedup: (13.3MB/s to 257.7MB/s)
  • 43. LLVM = Low Level Virtual Machine
  • 44. Mandelbort is optimized through LLVM JIT up to 11x.
  • 46. Android SurfaceFlinger  Properties  Can combine 2D/3D surfaces and surfaces from multiple applications  Surfaces passed as buffers via Binder IPC calls  Can use OpenGL ES and 2D hardware accelerator for its compositions  Double-buffering using page-flip
  • 48. UI Element GLSurfaceView javax .microedition .khronos .opengles View and Canvas → Surface View and Canvas → Surface android. view. View com.google.android.gles_jni android. view. Surface android graphics. Canvas . Java Graphics JAVA is implemented Framework via JNI Native Framework Surface JNI Graphic JNI OpenGL JNI SurfaceFlinger skia OpenGL|ES Libui + Libui + SurfaceFlinger + SurfaceFlinger + libpixelflinger libpixelflinger libui Overlay Camera Surface Key / Event format EglWindows libpixelflinger FrameBuffer Event Input Driver Driver
  • 50. PixelFlinger : software renderer • Render functions: pointx, linex, recti, trianglex • Texture and color buffer: activeTexture, bindTexture, colorBuffer, readBuffer, depthBuffer, BindTextureLod • … • Device framebuffer functions: copyPixels, rasterPos2x, rasterPos2i • Optimizer: codeflinger (JIT assembler) I/SurfaceFlinger( 1931): OpenGL informations: I/SurfaceFlinger( 1931): vendor    : Android I/SurfaceFlinger( 1931): renderer : Android PixelFlinger 1.2 I/SurfaceFlinger( 1931): version   : OpenGL ES­CM 1.0
  • 51. GGLAssembler – GGLAssembler – codeflinger's JIT Assembler codeflinger's JIT Assembler
  • 52. commit 77cadd2ffada95bb3279552e1a29f4bcf4012228 commit 77cadd2ffada95bb3279552e1a29f4bcf4012228 Author: Jim Huang <[email protected]> Author: Jim Huang <[email protected]> Date:   Wed Jan 13 01:01:18 2010 +0800 Date:   Wed Jan 13 01:01:18 2010 +0800     [libpixelflinger] Adds UXTB16 support to Pixelflinger     [libpixelflinger] Adds UXTB16 support to Pixelflinger     ...     ...     Uses UXTB16 to extract channels for SIMD operations, rather than creating and     Uses UXTB16 to extract channels for SIMD operations, rather than creating and     ANDing with masks. Saves a register and is faster on A8, as UXTB16 result can     ANDing with masks. Saves a register and is faster on A8, as UXTB16 result can     feed into first stage of multiply, unlike AND.     feed into first stage of multiply, unlike AND.               Also, used SMULWB rather than SMULBB, which allows removal of MOVs used to     Also, used SMULWB rather than SMULBB, which allows removal of MOVs used to     rescale results.     rescale results.               Code has been scheduled for A8 pipeline, specifically aiming to allow     Code has been scheduled for A8 pipeline, specifically aiming to allow     multiplies to issue in pipeline 0, for efficient dual issue operation.     multiplies to issue in pipeline 0, for efficient dual issue operation.               Testing on SpriteMethodTest (http://code.google.com/p/apps­for­android/) gives     Testing on SpriteMethodTest (http://code.google.com/p/apps­for­android/) gives     8% improvement (12.7 vs. 13.7 fps.)     8% improvement (12.7 vs. 13.7 fps.) libpixelflinger/codeflinger/ARMAssembler.cpp libpixelflinger/codeflinger/ARMAssembler.cpp @@ ­424,5 +424,15 @@ void ARMAssembler::SMLAW(int cc, int y, @@ ­424,5 +424,15 @@ void ARMAssembler::SMLAW(int cc, int y,      *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;      *mPC++ = (cc<<28) | 0x1200080 | (Rd<<16) | (Rn<<12) | (Rs<<8) | (y<<4) | Rm;  }  }     +#if 0 +#if 0 +#pragma mark ­ +#pragma mark ­ +#pragma mark Byte/half word extract and extend (ARMv6+ only)... +#pragma mark Byte/half word extract and extend (ARMv6+ only)... +#endif +#endif + + +void ARMAssembler::UXTB16(int cc, int Rd, int Rm, int rotate) +void ARMAssembler::UXTB16(int cc, int Rd, int Rm, int rotate) +{ +{ +    *mPC++ = (cc<<28) | 0x6CF0070 | (Rd<<12) | ((rotate >> 3) << 10) | Rm; +    *mPC++ = (cc<<28) | 0x6CF0070 | (Rd<<12) | ((rotate >> 3) << 10) | Rm; opcode +} +} + +  }; // namespace android  }; // namespace android    
  • 53. libpixelflinger/codeflinger/ARMAssemblerProxy.cpp libpixelflinger/codeflinger/ARMAssemblerProxy.cpp @@ ­195,6 +195,10 @@ void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) { @@ ­195,6 +195,10 @@ void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) {      mTarget­>SMLAW(cc, y, Rd, Rm, Rs, Rn);      mTarget­>SMLAW(cc, y, Rd, Rm, Rs, Rn);  }  }     +void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) { +void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) { +    mTarget­>UXTB16(cc, Rd, Rm, rotate); +    mTarget­>UXTB16(cc, Rd, Rm, rotate); +} +} + +      }; // namespace android  }; // namespace android     libpixelflinger/codeflinger/texturing.cpp libpixelflinger/codeflinger/texturing.cpp @@ ­868,6 +869,106 @@ void GGLAssembler::filter24( @@ ­868,6 +869,106 @@ void GGLAssembler::filter24(      load(txPtr, texel, 0);      load(txPtr, texel, 0);  }  }     +#if __ARM_ARCH__ >= 6 +#if __ARM_ARCH__ >= 6 +// ARMv6 version, using UXTB16, and scheduled for Cortex­A8 pipeline +// ARMv6 version, using UXTB16, and scheduled for Cortex­A8 pipeline +void GGLAssembler::filter32( +void GGLAssembler::filter32( +        const fragment_parts_t& parts, +        const fragment_parts_t& parts, +        pixel_t& texel, const texture_unit_t& tmu, +        pixel_t& texel, const texture_unit_t& tmu, +        int U, int V, pointer_t& txPtr, +        int U, int V, pointer_t& txPtr, +        int FRAC_BITS) +        int FRAC_BITS) +{ +{ ... ... +    UXTB16(AL, temp, pixel, 0); +    UXTB16(AL, temp, pixel, 0); Reimplement filter32() +    if (round) { +    if (round) { +        ADD(AL, 0, u, u, imm(1<<(adjust­1))); +        ADD(AL, 0, u, u, imm(1<<(adjust­1))); +        MOV(AL, 0, u, reg_imm(u, LSR, adjust)); +        MOV(AL, 0, u, reg_imm(u, LSR, adjust)); +    } In optimized ASM +    } +    LDR(AL, pixellb, txPtr.reg, reg_scale_pre(offsetlb)); +    LDR(AL, pixellb, txPtr.reg, reg_scale_pre(offsetlb)); +    MUL(AL, 0, dh, temp, u); +    MUL(AL, 0, dh, temp, u); +    UXTB16(AL, temp, pixel, 8); +    UXTB16(AL, temp, pixel, 8); +    MUL(AL, 0, dl, temp, u); +    MUL(AL, 0, dl, temp, u); +    RSB(AL, 0, k, u, imm(0x100)); +    RSB(AL, 0, k, u, imm(0x100)); ... ... +#else +#else  void GGLAssembler::filter32(  void GGLAssembler::filter32(          const fragment_parts_t& parts,          const fragment_parts_t& parts,          pixel_t& texel, const texture_unit_t& tmu,          pixel_t& texel, const texture_unit_t& tmu,
  • 55. RIL → Telephony  Radio Interface Layer(RIL)  HAL  Android TelephonyManager  baseband modem  Voice, Data, SMS, SIM, SIMToolkit  Android RIL  AT command  RIL API  Android follows GSM TS 27.007 standard  RIL implementation  Qualcomm supports CDMA & CDMA-GSM Multi-mode
  • 56. OS Kernels Monolithic Kernel Micro Kernel Traditional UNIX, Linux, … Mach, L4, Symbian OS Exokernel
  • 57. L4 Microkernel • Developed by Jochen Liedtke in 1995. – German National Research Center for IT • Developed from scratch • 2nd generation microkernel • Small and Fast Kernel – 7 system calls – 12KB • In November 2005, NICTA announced that Qualcomm was deploying NICTA's L4 version on their Mobile Station Modem chipsets.
  • 59. Communications Processor L4 Interrupt Handler -> Send Message L4 microkernel RPC System- Server call Handler RPC Interrupt RPC RT task Requests from Shared Memory Application Processor to Modem
  • 61. sqlite3_prepare() /* ** Compile the UTF­8 encoded SQL statement zSql into a statement handle. */ int sqlite3_prepare(   sqlite3 *db,            /* Database handle. */   const char *zSql,       /* UTF­8 encoded SQL statement. */   int nBytes,             /* Length of zSql in bytes. */   sqlite3_stmt **ppStmt,  /* OUT: A pointer to the prepared                               statement */   const char** pzTail     /* OUT: End of parsed string */ ) { ...       sqlite3VdbeSetNumCols(sParse.pVdbe, 5);       sqlite3VdbeSetColName(sParse.pVdbe, 0, COLNAME_NAME, "addr", P3_STATIC);       sqlite3VdbeSetColName(sParse.pVdbe, 1, COLNAME_NAME, "opcode", P3_STATIC);       sqlite3VdbeSetColName(sParse.pVdbe, 2, COLNAME_NAME, "p1", P3_STATIC);       sqlite3VdbeSetColName(sParse.pVdbe, 3, COLNAME_NAME, "p2", P3_STATIC);       sqlite3VdbeSetColName(sParse.pVdbe, 4, COLNAME_NAME, "p3", P3_STATIC); … Opcode! SQLite Virtual Machine (VDBE) 61
  • 62. …And what about other platforms? The concept can be applied to all VM platforms Application virtual machines (short list) .NET (CLR) Java Virtual Machine (JVM) Dalvik virtual machine (Google Android) PHP (Zend Engine) Flash Player / AIR - ActionScript Virtual Machine (AVM) SQLite virtual machine (VDBE; Virtual DataBase Engine) Perl virtual machine
  • 65. Inspiration • Computer science concepts are applied everywhere in Android software stack. • Essential system software brings the further optimizations and feasibility of new technologies. • Advanced compiler techniques are already applied in every domain • Best Practice in Android