Upload
leonardo-kim
View
1.720
Download
4
Embed Size (px)
Citation preview
Anatomy of an Android김용욱 (@dalinaum)
Android Version
● 1.5 Cupcake● 1.6 Donut● 2.0 2.1 Eclair● 2.2 Froyo (Frozen Yogurt)● 2.3.x Gingerbread (2.3.7)● 3.x Honeycomb (3.2)
....● 4.x Ice Cream Sandwich
시작점
●Anatomy & Physiology of an Android (2008 Google IO)○ Patrick Brady (Google)
● Inside the Android Application Framework (2008 GIO)○Dan Morill (Google)
Linux Kernel
리눅스 커널
●리눅스 커널 위에 동작하지만 리눅스는 아니다.
●리눅스의 표준 유틸리티를 사용하지 않는다.
●리눅스의 커널 버전은 크게 중요하지 않음.
리눅스 커널
●메모리, 프로세스 관리가 뛰어나다.
●퍼미션 기반의 보안 모델을 가지고 있다.
●오픈소스
리눅스 커널
●Timed GPIO (Generic-purpose I/O)● Power Management●Ashmem (Anonymous shared memory)● Binder● Low Memory Killer● Kernel Debugger● Logger●Alarm
Timed GPIO(generic purpose I/O)
●Mike Lockwood (Google)
●일정 시간동안 사용자영역에서 GPIO에 접근하기 위해 열어 둔 인터페이스
●바이브레이터 등에 사용됨.
● drivers/staging/android/○ timed_output.[h|c]○ timed_gpio.[h|c]
Power Management
●작성자: Google (iSad...)
●Suspend 전에 애플리케이션의 종료 기회 제공.
● kernel/power/ 디렉토리에 위치
○ suspend.c○ userwakelock.c○ earlysuspend.c○ consoleearlysuspend.c○ fbearlysuspend.c
Ashmem (Anonymous shared memory)
● Robert Love (Google, Ex-Noveller)○ Linux Kernel Developmen의 저자
○Android의 Logger도 작성.
●여러 프로세스 간의 데이터 공유를 위함.
● pmem과의 차이점은 "익명"이라는 점.
●mm/ashmem.c
Binder (Android IPC, like RPC)
●Dianne Hackborn (Google, Ex-BeOSer)
● Binder (BeOS) -> OpenBinder (Palm)-> Binder (Android)
● RPC같은 IPC를 구현
● driver/staging/android○ binder.[h|c]
Low memory killer
●Arve Hjønnevåg (Google, Ex-BeOSer)
●리눅스 메모리관리○사용량이 많은 프로세스 희생.○다수 프로세스를 살리는 데 있음.
●안드로이드 - 포그라운드 앱 우선○프로세스마다 현재 상태 기록.
● driver/staging/android○ lowmemorykiller.c
Low memory killer example (init.rc)# Define the oom_adj values for the classes of processes that can be# killed by the kernel. These are used in ActivityManagerService. setprop ro.FOREGROUND_APP_ADJ 0 setprop ro.VISIBLE_APP_ADJ 1 setprop ro.SECONDARY_SERVER_ADJ 2 setprop ro.HIDDEN_APP_MIN_ADJ 7 setprop ro.CONTENT_PROVIDER_ADJ 14 setprop ro.EMPTY_APP_ADJ 15
# Define the memory thresholds at which the above process classes will# be killed. These numbers are in pages (4k). setprop ro.FOREGROUND_APP_MEM 1536 setprop ro.VISIBLE_APP_MEM 2048 setprop ro.SECONDARY_SERVER_MEM 4096 setprop ro.HIDDEN_APP_MEM 5120 setprop ro.CONTENT_PROVIDER_MEM 5632 setprop ro.EMPTY_APP_MEM 6144
HAL (Hardware Abstraction Layer)
HAL (Hardware Abstraction Layer)
●리눅스 커널 디바이스를 안드로이드로 부터 분리하기 위함
●라이선스 문제○리눅스 커널은 GPL - 공개해야 함.○커널만 공개하고 하드웨어 드라이버 로직을 HAL로 분리
○Google과 Apple은 자신들이 원하는 내용만 공개.
●호환성 문제○안드로이드는 리눅스 커널 드라이버 구조를 몰라도 됨.
Android Runtime
Dalvik
●Dan Bornstein (Obvious Corp, Ex-Googler)
●Dalvik - Dan이 살던 지명.
●레지스터 방식의 Java Virtual Machine.
○Oracle(Sun) VM은 스택방식
○Oracle의 특허 회피
○ARM에 최적화.
●DEX 포맷 사용
○ JAR보다 용량 효율적.
Libraries
Libraries● Bionic C (Shinichiro Kwasaki-Hitachi)
○Non-GPL Lib C, Very small●WebKit (Don Melton-Apple, Martin Jones, Torben Weis)
○ KDE (KHTML) -> Apple (Webkit)●Media Framework (StageFright)
○OpenCore (PV) -> StageFright (Google, 보다 단순함)
●SQLite (D. Richard Hipp-Hipp, Wyrick & Company, Inc.)○경량 DB (앱에 내장 되는 형태)○최근에는 LevelDB로 대체 움직임
●Native Servers○SurfaceFlinger, AudioFlinger
Native Servers
Application Framework
Application Framework
●Core Platform Services
●Hardware Services
●Application Framework
Core platform Services
●Activity Manager● Package Manager●Window Manager● Resource Manager● Content Providers● View System
What is Activity?
Intent
Intent (URL을 액티비티으로 연결)<activity android:name=".MyActivity"><intent-filter><category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="http" android:host="mysite.com android:pathPrefix="/news/articles/"/> </intent-filter></activity>
● http://mysite.com/news/articles가 보이면 저기로 연결.●웹브라우저 (링크클릭) -> (링크에 대한 인텐트) -> 우리
앱●안드로이드 앱은 액티비티로 서로 연결되어 있음.●전화가 왔을 때 인텐트를 확인하여 스팸이면 끊어버리는
앱.●카드 사 전화를 가계부 웹 서비스에 올리는 앱.
Looper & Message Queue
Fragment (Android 3.0 Honeycomb)
2 Fragments in 1 Activity
Action Bar - 현재 상태, 아이콘, 메뉴
System Bar - 뒤로가기, 홈, 창 변환 버튼, 노티파이케이션.
Hardware Services
●Telephony Service● Location Service● Bluetooth Service●WiFi Service●USB Service●Sensor Service●NFC Service (Android 2.3.3)
Application Framework
●RTFM○Read the fine manual, please :)
Layer Interaction
There are 3 main flavors of Android layer cake:
●App -> Runtime Service -> Lib
●App -> Runtime Service -> Native Service -> Lib
●App -> Runtime Service -> Native Daemon -> Lib
Layer Interaction
There are 3 main flavors of Android layer cake:
●App -> Runtime Service -> Lib
●App -> Runtime Service -> Native Service -> Lib
●App -> Runtime Service -> Native Daemon -> Lib
Layer Interaction
There are 3 main flavors of Android layer cake:
●App -> Runtime Service -> Lib
●App -> Runtime Service -> Native Service -> Lib
●App -> Runtime Service -> Native Daemon -> Lib
Make world
●Official○AOSP (Android Open Source Project)
■ http://source.android.com/● Custom
○ CyanogenMod (CM)■ http://www.cyanogenmod.com/
○ CodeAuroraForum (CAF)■ https://www.codeaurora.org/
●Groups○ http://groups.google.com/group/android-contrib○ http://groups.google.com/group/android-platform○ http://groups.google.com/group/android-building
Recommend
CyanogenMod - de facto standard custom ROM
Special Thanks to JBQ
Thanks JBQ, who moves truck-loads of source code in and out of the Googleplex
Jean-Baptiste Queru (Google)
Q&A