Android Camera子系统之进程/文件View
本文基于Android 4.2.2从进程/文件的角度审视Android Camera子系统。
AndroidCamera子系统的整体架构分成客户端(Client)和服务器(Server)两个部分,它们建立在Android的进程间通讯机制Binder的基础之上。
查看进程
root@android:/# ps
USER PID PPID VSIZE RSS WCHAN PC NAME
media 1012 1 37484 8740 ffffffff 4016bfe8 S/system/bin/mediaserver
u0_a142119 1010 162156 31244 ffffffff 4007cee4 S com.android.camera
查看线程
root@android:/# ps -t
USERPID PPID VSIZE RSS WCHAN PC NAME
media1012 1 37484 8740 ffffffff 4016bfe8 S /system/bin/mediaserver
media1191 1012 37484 8740 c0042004 4016d108 S AudioCommand
media1192 1012 37484 8740 c0042004 4016d108 S ApmCommand
media1208 1012 37484 8740 c0042004 4016d108 S AudioOut_2
media1209 1012 37484 8740 c02b2ffc 4016bfe8 S Binder_1
media1519 1012 37484 8740 c02b2ffc 4016bfe8 S Binder_2
media2055 1012 37484 8740 c02b2ffc 4016bfe8 S Binder_3
media2362 1012 37484 8740 c0042004 4016d108 S TimedEventQueue
media2363 1012 37484 8740 c0042004 4016d108 S .vorbis.decoder
media2364 1012 37484 8740 c0042004 4016d108 S OMXCallbackDisp
media2365 1012 37484 8740 c0042004 4016d108 S TimedEventQueue
media2366 1012 37484 8740 c0042004 4016d108 S .vorbis.decoder
media2367 1012 37484 8740 c0042004 4016d108 S OMXCallbackDisp
media2368 1012 37484 8740 00000000 4016d6a4 R CameraPreviewTh
media2369 1012 37484 8740 c0042004 4016d108 S CameraAutoFocus
u0_a142119 1010 162156 31244 ffffffff 4007cee4 S com.android.camera
u0_a142122 2119 162156 31244 c0042004 4007d108 S GC
u0_a142124 2119 162156 31244 c0026658 4007c9c8 S Signal Catcher
u0_a142125 2119 162156 31244 c0364f54 4007cbd0 S JDWP
u0_a142126 2119 162156 31244 c0042004 4007d108 S Compiler
u0_a142127 2119 162156 31244 c0042004 4007d108 S ReferenceQueueD
u0_a142128 2119 162156 31244 c0042004 4007d108 S FinalizerDaemon
u0_a142129 2119 162156 31244 c0042004 4007d108 S FinalizerWatchd
u0_a142130 2119 162156 31244 c02b2ffc 4007bfe8 S Binder_1
u0_a142131 2119 162156 31244 c02b2ffc 4007bfe8 S Binder_2
u0_a142134 2119 162156 31244 c0042004 4007d108 S pool-1-thread-1
u0_a142136 2119 162156 31244 c00a5004 4007cee4 S CameraHolder
u0_a142152 2119 162156 31244 c02b2ffc 4007bfe8 S Binder_3
u0_a142375 2119 162156 31244 c0042004 4007d108 S SoundPool
u0_a142376 2119 162156 31244 c0042004 4007d108 S SoundPoolThread
u0_a142377 2119 162156 31244 c0042004 4007d108 S Thread-123
列出binder service
root@android:/# service list
63media.audio_policy: [android.media.IAudioPolicyService]
64media.camera: [android.hardware.ICameraService]
65media.player: [android.media.IMediaPlayerService]
66media.audio_flinger: [android.media.IAudioFlinger]
查看进程虚拟地址空间
media 1012 1 37484 8740 ffffffff 4016bfe8 S/system/bin/mediaserver
root@android:/# cat /proc/1012/maps
401f7000-40215000r-xp 00000000 00:11 637 /system/lib/libbinder.so
40215000-4021a000r--p 0001d000 00:11 637 /system/lib/libbinder.so
4021a000-4021b000rw-p 00022000 00:11 637 /system/lib/libbinder.so
4025a000-4025b000r-xp 00000000 00:11 524 /system/lib/libhardware.so
4025b000-4025c000r--p 00000000 00:11 524 /system/lib/libhardware.so
4025c000-4025d000rw-p 00001000 00:11 524 /system/lib/libhardware.so
40451000-40467000r-xp 00000000 00:11 585 /system/lib/libcamera_client.so
40467000-40468000---p 00000000 00:00 0
40468000-4046d000r--p 00016000 00:11 585 /system/lib/libcamera_client.so
4046d000-4046e000rw-p 0001b000 00:11 585 /system/lib/libcamera_client.so
40581000-40586000r-xp 00000000 00:11 636 /system/lib/libhardware_legacy.so
40586000-40587000r--p 00004000 00:11 636 /system/lib/libhardware_legacy.so
40587000-40588000rw-p 00005000 00:11 636 /system/lib/libhardware_legacy.so
4059c000-405d4000r-xp 00000000 00:11 655 /system/lib/libcameraservice.so
405d4000-405d8000r--p 00037000 00:11 655 /system/lib/libcameraservice.so
405d8000-405d9000rw-p 0003b000 00:11 655 /system/lib/libcameraservice.so
405d9000-405dc000r-xp 00000000 00:11 582 /system/lib/libcamera_metadata.so
405dc000-405dd000r--p 00002000 00:11 582 /system/lib/libcamera_metadata.so
405dd000-405de000rw-p 00003000 00:11 582 /system/lib/libcamera_metadata.so
40b12000-40b1f000r-xp 00000000 00:11 569 /system/lib/hw/camera.sama5d3-ek.so
40b1f000-40b20000r--p 0000c000 00:11 569 /system/lib/hw/camera.sama5d3-ek.so
40b20000-40b21000rw-p 0000d000 00:11 569 /system/lib/hw/camera.sama5d3-ek.so
41eb5000-41eb7000r-xp 00000000 00:11 565 /system/lib/hw/gralloc.sama5d3-ek.so
41eb7000-41eb8000r--p 00001000 00:11 565 /system/lib/hw/gralloc.sama5d3-ek.so
41eb8000-41eb9000rw-p 00002000 00:11 565 /system/lib/hw/gralloc.sama5d3-ek.so
42264000-42426000rw-s 3f200000 00:0b 554 /dev/video1
u0_a142119 1010 162156 31244 ffffffff 4007cee4 S com.android.camera
root@android:/# cat /proc/2119/maps
40130000-4014e000r-xp 00000000 00:11 637 /system/lib/libbinder.so
4014e000-40153000r--p 0001d000 00:11 637 /system/lib/libbinder.so
40153000-40154000rw-p 00022000 00:11 637 /system/lib/libbinder.so
40154000-401e5000r-xp 00000000 00:11 598 /system/lib/libandroid_runtime.so
401e5000-401e6000---p 00000000 00:00 0
401e6000-401ea000r--p 00091000 00:11 598 /system/lib/libandroid_runtime.so
401ea000-401f0000rw-p 00095000 00:11 598 /system/lib/libandroid_runtime.so
404e9000-404ff000r-xp 00000000 00:11 585 /system/lib/libcamera_client.so
404ff000-40500000---p 00000000 00:00 0
40500000-40505000r--p 00016000 00:11 585 /system/lib/libcamera_client.so
40505000-40506000rw-p 0001b000 00:11 585 /system/lib/libcamera_client.so
44cfe000-44cff000r--s 003c4000 00:11 160 /system/framework/framework.jar
44cff000-456f2000r--p 00000000 00:12 107/data/dalvik-cache/system@framework@framework.jar@classes.dex
456f2000-457b3000rw-p 00000000 00:04 1203 /dev/ashmem/dalvik-aux-structure (deleted)
4939a000-493a2000r--s 0010c000 00:11 195 /system/app/LegacyCamera.apk
493a2000-493ef000r--s 000bc000 00:11 195 /system/app/LegacyCamera.apk
493ef000-493f7000r--s 0010c000 00:11 195 /system/app/LegacyCamera.apk
493f7000-49447000r--p 00000000 00:12 485/data/dalvik-cache/system@app@LegacyCamera.apk@classes.dex
49447000-49450000rw-p 00000000 00:04 3819 /dev/ashmem/dalvik-aux-structure (deleted)