編輯:初級開發
對於關注Android 底層的朋友來說,其具體的啟動過程應該是比較吸引我們的。但是很多啟動文件什麼的,都得adb push到host上來看,挺不方便的,都怪Android 自帶的Toolbox太簡略了。所以在深入了解Android 的啟動流程之前,我們來把Busybox安裝到android 上去,這樣,就有很多工具供我們使用了。
首先去busybox主頁 下載最新版本的源代碼,然後用arm的交叉編譯器編譯出busybox的可執行程序,編譯的時候需要注意一些設置選項,例如
Build Options —>
Build BusyBox as a static binary (no shared libs) 這個要選上,因上這樣子編譯出來的busyBox才是可以獨立運行的。
│Do you want to build BusyBox with a Cross Compiler? │ │
│ │(/HOME/toolchains/gcc-4.0.2-glibc-2.3.5/arm-9tdmi-linux-gnu/bin/arm-9tdmi-Linux-gnu│ 這是交叉編譯器的路徑,要根據具體的情況來設置。
Installation Options —>
Don’t use /usr
這樣子編譯出來的busybox才不會安裝到你主機的/usr目錄下。一定要選上。
busybox的功能選項根據需要自選,但是不要太貪心.
OK,這裡就不糾纏於編譯busybox的東西了,網上資料無數。接下來,我們把busybox安裝到模擬器上去。先在模擬器上隨便建一個busybox的文件夾,然後進入busybox可執行文件目錄,使用命令
adb push busybox.asc /data/busybox/busybox
然後進入adb shell,chmod 777 ./busybox,就可以直接使用了。但現在還是不方便,總不能每用一個命令就輸一次busybox吧?所以,我們可以先用./busybox --install將程序都安裝到當前目錄下,然後把當前目錄添加到PATH變量中即可。暫時使用export來添加吧,如果想永久添加,往下看。
好了,准備工作完成,開始研究的工作了。既然是研究啟動過程,那當然是先看看init.rc文件。去etc目錄打開它,分析一下內容,首先是對 env的定義,也就是全局環境變量的定義,接下來的建立和初始化裡面的內容目前還不清楚什麼意思,緊接著就是系統啟動時運行的初始進程信息,這個比較有意思,包括了usbd-config和qemu,qemu自不用說,而usbd-config作為初始啟動的進程,應該就是和上一篇文章猜的一樣,用來調試或者usb通信的。往下看,是在初始啟動進程完成之後開始啟動的服務進程,這些進程如果因故退出,會自動重啟。這裡面包括了console控制台,adbd監護進程,usbd監護進程,debuggerd監護進程等.除去這些守護進程,能引起我們注意的,是runtime和zygote。這兩個進程似乎掌管著其他進程以及應用程序的啟動。
現在,來讓我們做一個實驗吧,將自動調用的啟動過程變成手動,看看啟動流程具體是什麼樣的。想達到這個目的,首先就是要修改init.rc文件,當然不是在模擬器的console中改,一是不能改,二是你改了也沒用,下次加載就會給你覆蓋了。所以,我們要從原始鏡像ramdisk.img入手了。從2.6標准Linux內核開始,initrd.img都采用cpio壓縮,猜測ramdisk.img也一樣,需要使用gunzip解壓縮,然後再使用cpio解包。好,進入tools/lib/images目錄下,先用file命令看看ramdisk.img的類型,沒錯,系統提示
ramdisk.img: gzip compressed data, from Unix
很好,然後將ramdisk.img復制一份到任何其他目錄下,將其名稱改為ramdisk.img.gz,並使用命令
gunzip ramdisk.img.gz
然後新建一個文件夾,叫ramdisk吧,進入,輸入命令
cpio -i -F ../ramdisk.img
這下,你就能看見並操作ramdisk裡面的內容了。當然你也可以直接在外面進行操作,但是還是建議把cpio解壓縮出來的內容全部集中在一個文件夾裡面,因為一會我們還要將其壓縮成新的ramdisk.img。
OK,現在開始修改步驟吧。用任何一款編輯器打開init.rc,首先在PATH那裡加上你的Busybox安裝路徑,然後注釋內容,我們要手工啟動他們。
# zygote {
# exec
/
system
/
bin
/
app_process
# args {
#
0
-
Xzygote
#
1
/
system
/
bin
#
2
–zygote
# }
# autostart
1
# }# runtime {
# exec
/
system
/
bin
/
runtime
# autostart
1
# }
在這裡需要注意,不要同時把兩者都注釋了,注釋某一個,再試驗手工啟動它,如果兩者同時注釋我這裡有問題,無法啟動。
好,接下來,使用下列命令重新打包成鏡像
cpio -i -t -F ../ramdisk.img > list
cpio -o -H newc -O lk.img < list
當前目錄下生成的lk.img就是我們的新鏡像了。使用自己的鏡像啟動emulator;
emulator -console -ramdisk lk.img
如果我們注釋的是zygote,那麼在#後輸入
app_process -Xzygote /system/bin –zygote
手工啟動,命令行中輸出的信息是
Prepping: /system/app/AlarmProvider.apk:/system/app/Browser.apk:/system/app/
Calendar.apk:/system/app/Camera.apk:/system/app/Contacts.apk:
/system/app/Development.apk:/system/app/GDataFeedsProvider.apk:/system/app/
Gmail.apk:/system/app/GmailProvider.apk:/system/app/GoogleAPPS.apk:
/system/app/GoogleAPPSProvider.apk:/system/app/Home.apk:/system/app/ImProvider.apk:
/system/app/Maps.apk:/system/app/MediaPickerActivity.apk:
/system/app/MediaProvider.apk:/system/app/Phone.apk:/system/app/PimProvider.apk:/system/
app/ApiDemos.apk:/system/app/SettingsProvider.apk:
/system/app/Sms.apk:/system/app/SyncProvider.apk:/system/app/TelephonyProvider.apk:
/system/app/XmPPService.apk:/system/app/YouTube.apk
File not found: /system/app/AlarmProvider.apk
File not found: /system/app/Calendar.apk
File not found: /system/app/Camera.apk
File not found: /system/app/GDataFeedsProvider.apk
File not found: /system/app/Gmail.apk
File not found: /system/app/GmailProvider.apk
File not found: /system/app/MediaPickerActivity.apk
File not found: /system/app/PimProvider.apk
File not found: /system/app/ApiDemos.apk
File not found: /system/app/Sms.apk
File not found: /system/app/SyncProvider.apk
File not found: /system/app/YouTube.apk
Prep complete
嘿嘿,從File not found的信息中可以看到一些Google可能會即將推出的應用,比如Gmail什麼的。當然,這些都是Java框架的啟動信息,我們以後還要借助其他工具來進行進一步探索。
如果我們注釋的是runtime,那麼輸出信息是:
+++ post-zygote
老實說,沒有明白這是啥意思,呵呵,吃飯時間到了,懶得看了。
好了,今天就說到這,基本的方法就是這樣,有興趣的朋友可以進一步深入研究。我們下一篇文章見。
在android上,如果你直接用dalivik去加載framework.jar,你會發現裡面的大部分native方法無法使用。同時,在 /init.rc裡面,你也找不到dalvikvm。在ps列表,也沒有dalvikvm。那android是怎麼啟動Java程序的呢?
在android上,Java程序是通過app_process啟動的。在/init.rc裡面,有如下一段代碼:
service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
socket zygote stream 666
onrestart write /sys/android_power/request_state wake
onrestart write /sys/power/state on
app_process的命令行參數如下:
app_process [Java-options] cmd-dir start-class-name [options]
因此,init.rc裡面的各個參數的對應關系為:
-Xzygote: java-options,這些參數會傳給dalvik,這些參數必須以-開頭,一旦遇到不是以-開頭的或者--,代表Java-options結束。
/system/bin:cmd-dir,也就是當前目錄,文件操作的父路徑將為此路徑。
start-class-name:空
--zygote --start-system-server:選項。
vIEw plain copy to clipboard print ?
01.if (i < argc) {
02.arg = argv[i++];
03.if (0 == strcmp( "--zygote" , arg)) {
04.bool startSystemServer = (i < argc) ?
05.strcmp(argv[i], "--start-system-server" ) == 0 : false ;
06.setArgv0(argv0, "zygote" );
07.set_process_name("zygote" );
08.runtime.start("com.android.internal.os.ZygoteInit" ,
09.startSystemServer);
10.} else {
11.set_process_name(argv0);
12.runtime.mClassName = arg;
13.// Remainder of args get passed to startup class main()
14.runtime.mArgC = argc-i;
15.runtime.mArgV = argv+i;
16.LOGV("App process is starting with pid=%d, class=%s.\n" ,
17.getpid(), runtime.getClassName());
18.runtime.start();
19.}
20.}
vIEw plaincopy to clipboardprint?
01.if (i < argc) {
02.arg = argv[i++];
03.if (0 == strcmp("--zygote", arg)) {
04.bool startSystemServer = (i < argc) ?
05.strcmp(argv[i], "--start-system-server") == 0 : false;
06.setArgv0(argv0, "zygote");
07.set_process_name("zygote");
08.runtime.start("com.android.internal.os.ZygoteInit",
09.startSystemServer);
10.} else {
11.set_process_name(argv0);
12.runtime.mClassName = arg;
13.// Remainder of args get passed to startup class main()
14.runtime.mArgC = argc-i;
15.runtime.mArgV = argv+i;
16.LOGV("App process is starting with pid=%d, class=%s.\n",
17.getpid(), runtime.getClassName());
18.runtime.start();
19.}
20.}
if (i < argc) {
arg = argv[i++];
if (0 == strcmp("--zygote", arg)) {
bool startSystemServer = (i < argc) ?
strcmp(argv[i], "--start-system-server") == 0 : false;
setArgv0(argv0, "zygote");
set_process_name("zygote");
runtime.start("com.android.internal.os.ZygoteInit",
startSystemServer);
} else {
set_process_name(argv0);
runtime.mClassName = arg;
// Remainder of args get passed to startup class main()
runtime.mArgC = argc-i;
runtime.mArgV = argv+i;
LOGV("App process is starting with pid=%d, class=%s.\n",
getpid(), runtime.getClassName());
runtime.start();
}
}
從app_process的main函數(在app_main.cpp裡面)可以看出,app_process有兩種啟動方式:一種是 init.rc裡面的這種方式,這種方式將會以zygote模式啟動com.android.internal.os.ZygoteInit,並將進程名稱改為zygote;另外一種是以非zygote模擬啟動com.android.internal.os.RuntimeInit,並調用它的main 方法,main的最後會執行finishInit,finishInit是一個native方法,這個方法會調用app_process的 onStarted方法,在onStarted裡面將會調用真正要執行的class。
無論app_process,它都將會調用frameworks\base\core\jni\androidRuntime.cpp裡面的start
方法(496行)。這個start方法會根據android屬性系統設置dalvik的參數,並初始化java代碼的native方法,最終啟動dalvik。需要注意的是,java代碼的大部分native方法(差不多80%)都是在這裡面初始化的,這些初始化代碼會檢查java代碼的正確性(例如是否有對應的 native方法,是否有需要的屬性等),在初始化過程中,任何一步的錯誤都將導致進程退出。整個native方法初始化過程如下:start(AndroidRuntime.cpp,766行)->startReg(AndroidRuntime.cpp,1136 行)-> register_jni_procs(androidRuntime.cpp,1011行)。初始化的Java class有(androidRuntime.cpp,1018行):
vIEw plain copy to clipboard print ?
01.static const RegJNIRec gRegJNI[] = {
02.REG_JNI(register_android_debug_JNITest),
03.REG_JNI(register_com_android_internal_os_RuntimeInit),
04.REG_JNI(register_android_os_SystemClock),
05.REG_JNI(register_android_util_EventLog),
06.REG_JNI(register_android_util_Log),
07.REG_JNI(register_android_util_FloatMath),
08.REG_JNI(register_android_text_format_Time),
09.REG_JNI(register_android_pim_EventRecurrence),
10.REG_JNI(register_android_content_AssetManager),
11.REG_JNI(register_android_content_StringBlock),
12.REG_JNI(register_android_content_XMLBlock),
13.REG_JNI(register_android_emoji_EmojiFactory),
14.REG_JNI(register_android_security_Md5MessageDigest),
15.REG_JNI(register_android_text_androidCharacter),
16.REG_JNI(register_android_text_KeyCharacterMap),
17.REG_JNI(register_android_os_Process),
18.REG_JNI(register_android_os_Binder),
19.REG_JNI(register_android_os_Hardware),
20.REG_JNI(register_android_vIEw_Display),
21.REG_JNI(register_android_nio_utils),
22.REG_JNI(register_android_graphics_PixelFormat),
23.REG_JNI(register_android_graphics_Graphics),
24.REG_JNI(register_android_vIEw_Surface),
25.REG_JNI(register_android_view_VIEwRoot),
26.REG_JNI(register_com_google_android_gles_jni_EGLImpl),
27.REG_JNI(register_com_google_android_gles_jni_GLImpl),
28.REG_JNI(register_android_graphics_Bitmap),
29.REG_JNI(register_android_graphics_BitmapFactory),
30.REG_JNI(register_android_graphics_Camera),
31.REG_JNI(register_android_graphics_Canvas),
32.REG_JNI(register_android_graphics_ColorFilter),
33.REG_JNI(register_android_graphics_DrawFilter),
34.REG_JNI(register_android_graphics_Interpolator),
35.REG_JNI(register_android_graphics_LayerRasterizer),
36.REG_JNI(register_android_graphics_MaskFilter),
37.REG_JNI(register_android_graphics_Matrix),
38.REG_JNI(register_android_graphics_MovIE),
39.REG_JNI(register_android_graphics_NinePatch),
40.REG_JNI(register_android_graphics_Paint),
41.REG_JNI(register_android_graphics_Path),
42.REG_JNI(register_android_graphics_PathMeasure),
43.REG_JNI(register_android_graphics_PathEffect),
44.REG_JNI(register_android_graphics_Picture),
45.REG_JNI(register_android_graphics_PorterDuff),
46.REG_JNI(register_android_graphics_Rasterizer),
47.REG_JNI(register_android_graphics_Region),
48.REG_JNI(register_android_graphics_Shader),
49.REG_JNI(register_android_graphics_Typeface),
50.REG_JNI(register_android_graphics_Xfermode),
51.REG_JNI(register_com_android_internal_graphics_NativeUtils),
52.REG_JNI(register_android_database_CursorWindow),
53.REG_JNI(register_android_database_SQLiteDatabase),
54.REG_JNI(register_android_database_SQLiteDebug),
55.REG_JNI(register_android_database_SQLiteProgram),
56.REG_JNI(register_android_database_SQLiteQuery),
57.REG_JNI(register_android_database_SQLiteStatement),
58.REG_JNI(register_android_os_Debug),
59.REG_JNI(register_android_os_Exec),
60.REG_JNI(register_android_os_FileObserver),
61.REG_JNI(register_android_os_FileUtils),
62.REG_JNI(register_android_os_ParcelFileDescriptor),
63.REG_JNI(register_android_os_Power),
64.REG_JNI(register_android_os_StatFs),
65.REG_JNI(register_android_os_SystemPropertIEs),
66.REG_JNI(register_android_os_UEventObserver),
67.REG_JNI(register_android_net_LocalSocketImpl),
68.REG_JNI(register_android_net_NetworkUtils),
69.REG_JNI(register_android_net_wifi_WifiManager),
70.REG_JNI(register_android_os_MemoryFile),
71.REG_JNI(register_com_android_internal_os_ZygoteInit),
72.REG_JNI(register_android_hardware_Camera),
73.REG_JNI(register_android_hardware_SensorManager),
74.REG_JNI(register_android_media_AudioRecord),
75.REG_JNI(register_android_media_AudiOSystem),
76.REG_JNI(register_android_media_AudioTrack),
77.REG_JNI(register_android_media_JetPlayer),
78.REG_JNI(register_android_media_ToneGenerator),
79.REG_JNI(register_android_opengl_classes),
80.REG_JNI(register_android_bluetooth_Database),
81.REG_JNI(register_android_bluetooth_HeadsetBase),
82.REG_JNI(register_android_bluetooth_BluetoothAudioGateway),
83.REG_JNI(register_android_bluetooth_RfcommSocket),
84.REG_JNI(register_android_bluetooth_ScoSocket),
85.REG_JNI(register_android_server_BluetoothDeviceService),
86.REG_JNI(register_android_server_BluetoothEventLoop),
87.REG_JNI(register_android_server_BluetoothA2dpService),
88.REG_JNI(register_android_message_digest_sha1),
89.REG_JNI(register_android_ddm_DdmHandleNativeHeap),
90.REG_JNI(register_android_util_Base64),
91.REG_JNI(register_android_location_GpsLocationProvider),
92.};
vIEw plaincopy to clipboardprint?
01.static const RegJNIRec gRegJNI[] = {
02.REG_JNI(register_android_debug_JNITest),
03.REG_JNI(register_com_android_internal_os_RuntimeInit),
04.REG_JNI(register_android_os_SystemClock),
05.REG_JNI(register_android_util_EventLog),
06.REG_JNI(register_android_util_Log),
07.REG_JNI(register_android_util_FloatMath),
08.REG_JNI(register_android_text_format_Time),
09.REG_JNI(register_android_pim_EventRecurrence),
10.REG_JNI(register_android_content_AssetManager),
11.REG_JNI(register_android_content_StringBlock),
12.REG_JNI(register_android_content_XMLBlock),
13.REG_JNI(register_android_emoji_EmojiFactory),
14.REG_JNI(register_android_security_Md5MessageDigest),
15.REG_JNI(register_android_text_androidCharacter),
16.REG_JNI(register_android_text_KeyCharacterMap),
17.REG_JNI(register_android_os_Process),
18.REG_JNI(register_android_os_Binder),
19.REG_JNI(register_android_os_Hardware),
20.REG_JNI(register_android_vIEw_Display),
21.REG_JNI(register_android_nio_utils),
22.REG_JNI(register_android_graphics_PixelFormat),
23.REG_JNI(register_android_graphics_Graphics),
24.REG_JNI(register_android_vIEw_Surface),
25.REG_JNI(register_android_view_VIEwRoot),
26.REG_JNI(register_com_google_android_gles_jni_EGLImpl),
27.REG_JNI(register_com_google_android_gles_jni_GLImpl),
28.REG_JNI(register_android_graphics_Bitmap),
29.REG_JNI(register_android_graphics_BitmapFactory),
30.REG_JNI(register_android_graphics_Camera),
31.REG_JNI(register_android_graphics_Canvas),
32.REG_JNI(register_android_graphics_ColorFilter),
33.REG_JNI(register_android_graphics_DrawFilter),
34.REG_JNI(register_android_graphics_Interpolator),
35.REG_JNI(register_android_graphics_LayerRasterizer),
36.REG_JNI(register_android_graphics_MaskFilter),
37.REG_JNI(register_android_graphics_Matrix),
38.REG_JNI(register_android_graphics_MovIE),
39.REG_JNI(register_android_graphics_NinePatch),
40.REG_JNI(register_android_graphics_Paint),
41.REG_JNI(register_android_graphics_Path),
42.REG_JNI(register_android_graphics_PathMeasure),
43.REG_JNI(register_android_graphics_PathEffect),
44.REG_JNI(register_android_graphics_Picture),
45.REG_JNI(register_android_graphics_PorterDuff),
46.REG_JNI(register_android_graphics_Rasterizer),
47.REG_JNI(register_android_graphics_Region),
48.REG_JNI(register_android_graphics_Shader),
49.REG_JNI(register_android_graphics_Typeface),
50.REG_JNI(register_android_graphics_Xfermode),
51.REG_JNI(register_com_android_internal_graphics_NativeUtils),
52.REG_JNI(register_android_database_CursorWindow),
53.REG_JNI(register_android_database_SQLiteDatabase),
54.REG_JNI(register_android_database_SQLiteDebug),
55.REG_JNI(register_android_database_SQLiteProgram),
56.REG_JNI(register_android_database_SQLiteQuery),
57.REG_JNI(register_android_database_SQLiteStatement),
58.REG_JNI(register_android_os_Debug),
59.REG_JNI(register_android_os_Exec),
60.REG_JNI(register_android_os_FileObserver),
61.REG_JNI(register_android_os_FileUtils),
62.REG_JNI(register_android_os_ParcelFileDescriptor),
63.REG_JNI(register_android_os_Power),
64.REG_JNI(register_android_os_StatFs),
65.REG_JNI(register_android_os_SystemPropertIEs),
66.REG_JNI(register_android_os_UEventObserver),
67.REG_JNI(register_android_net_LocalSocketImpl),
68.REG_JNI(register_android_net_NetworkUtils),
69.REG_JNI(register_android_net_wifi_WifiManager),
70.REG_JNI(register_android_os_MemoryFile),
71.REG_JNI(register_com_android_internal_os_ZygoteInit),
72.REG_JNI(register_android_hardware_Camera),
73.REG_JNI(register_android_hardware_SensorManager),
74.REG_JNI(register_android_media_AudioRecord),
75.REG_JNI(register_android_media_AudiOSystem),
76.REG_JNI(register_android_media_AudioTrack),
77.REG_JNI(register_android_media_JetPlayer),
78.REG_JNI(register_android_media_ToneGenerator),
79.REG_JNI(register_android_opengl_classes),
80.REG_JNI(register_android_bluetooth_Database),
81.REG_JNI(register_android_bluetooth_HeadsetBase),
82.REG_JNI(register_android_bluetooth_BluetoothAudioGateway),
83.REG_JNI(register_android_bluetooth_RfcommSocket),
84.REG_JNI(register_android_bluetooth_ScoSocket),
85.REG_JNI(register_android_server_BluetoothDeviceService),
86.REG_JNI(register_android_server_BluetoothEventLoop),
87.REG_JNI(register_android_server_BluetoothA2dpService),
88.REG_JNI(register_android_message_digest_sha1),
89.REG_JNI(register_android_ddm_DdmHandleNativeHeap),
90.REG_JNI(register_android_util_Base64),
91.REG_JNI(register_android_location_GpsLocationProvider),
92.};
static const RegJNIRec gRegJNI[] = {
REG_JNI(register_android_debug_JNITest),
REG_JNI(register_com_android_internal_os_RuntimeInit),
REG_JNI(register_android_os_SystemClock),
REG_JNI(register_android_util_EventLog),
REG_JNI(register_android_util_Log),
REG_JNI(register_android_util_FloatMath),
REG_JNI(register_android_text_format_Time),
REG_JNI(register_android_pim_EventRecurrence),
REG_JNI(register_android_content_AssetManager),
REG_JNI(register_android_content_StringBlock),
REG_JNI(register_android_content_XMLBlock),
REG_JNI(register_android_emoji_EmojiFactory),
REG_JNI(register_android_security_Md5MessageDigest),
REG_JNI(register_android_text_androidCharacter),
REG_JNI(register_android_text_KeyCharacterMap),
REG_JNI(register_android_os_Process),
REG_JNI(register_android_os_Binder),
REG_JNI(register_android_os_Hardware),
REG_JNI(register_android_vIEw_Display),
REG_JNI(register_android_nio_utils),
REG_JNI(register_android_graphics_PixelFormat),
REG_JNI(register_android_graphics_Graphics),
REG_JNI(register_android_vIEw_Surface),
REG_JNI(register_android_view_VIEwRoot),
REG_JNI(register_com_google_android_gles_jni_EGLImpl),
REG_JNI(register_com_google_android_gles_jni_GLImpl),
REG_JNI(register_android_graphics_Bitmap),
REG_JNI(register_android_graphics_BitmapFactory),
REG_JNI(register_android_graphics_Camera),
REG_JNI(register_android_graphics_Canvas),
REG_JNI(register_android_graphics_ColorFilter),
REG_JNI(register_android_graphics_DrawFilter),
REG_JNI(register_android_graphics_Interpolator),
REG_JNI(register_android_graphics_LayerRasterizer),
REG_JNI(register_android_graphics_MaskFilter),
REG_JNI(register_android_graphics_Matrix),
REG_JNI(register_android_graphics_MovIE),
REG_JNI(register_android_graphics_NinePatch),
REG_JNI(register_android_graphics_Paint),
REG_JNI(register_android_graphics_Path),
REG_JNI(register_android_graphics_PathMeasure),
REG_JNI(register_android_graphics_PathEffect),
REG_JNI(register_android_graphics_Picture),
REG_JNI(register_android_graphics_PorterDuff),
REG_JNI(register_android_graphics_Rasterizer),
REG_JNI(register_android_graphics_Region),
REG_JNI(register_android_graphics_Shader),
REG_JNI(register_android_graphics_Typeface),
REG_JNI(register_android_graphics_Xfermode),
REG_JNI(register_com_android_internal_graphics_NativeUtils),
REG_JNI(register_android_database_CursorWindow),
REG_JNI(register_android_database_SQLiteDatabase),
REG_JNI(register_android_database_SQLiteDebug),
REG_JNI(register_android_database_SQLiteProgram),
REG_JNI(register_android_database_SQLiteQuery),
REG_JNI(register_android_database_SQLiteStatement),
REG_JNI(register_android_os_Debug),
REG_JNI(register_android_os_Exec),
REG_JNI(register_android_os_FileObserver),
REG_JNI(register_android_os_FileUtils),
REG_JNI(register_android_os_ParcelFileDescriptor),
REG_JNI(register_android_os_Power),
REG_JNI(register_android_os_StatFs),
REG_JNI(register_android_os_SystemPropertIEs),
REG_JNI(register_android_os_UEventObserver),
REG_JNI(register_android_net_LocalSocketImpl),
REG_JNI(register_android_net_NetworkUtils),
REG_JNI(register_android_net_wifi_WifiManager),
REG_JNI(register_android_os_MemoryFile),
REG_JNI(register_com_android_internal_os_ZygoteInit),
REG_JNI(register_android_hardware_Camera),
REG_JNI(register_android_hardware_SensorManager),
REG_JNI(register_android_media_AudioRecord),
REG_JNI(register_android_media_AudiOSystem),
REG_JNI(register_android_media_AudioTrack),
REG_JNI(register_android_media_JetPlayer),
REG_JNI(register_android_media_ToneGenerator),
REG_JNI(register_android_opengl_classes),
REG_JNI(register_android_bluetooth_Database),
REG_JNI(register_android_bluetooth_HeadsetBase),
REG_JNI(register_android_bluetooth_BluetoothAudioGateway),
REG_JNI(register_android_bluetooth_RfcommSocket),
REG_JNI(register_android_bluetooth_ScoSocket),
REG_JNI(register_android_server_BluetoothDeviceService),
REG_JNI(register_android_server_BluetoothEventLoop),
REG_JNI(register_android_server_BluetoothA2dpService),
REG_JNI(register_android_message_digest_sha1),
REG_JNI(register_android_ddm_DdmHandleNativeHeap),
REG_JNI(register_android_util_Base64),
REG_JNI(register_android_location_GpsLocationProvider),
};
這些初始化的native方法是Java代碼與底層服務打交道的接口,因此我們必須初始化這些方法。
以app_process啟動java class的另外一個好處是它會初始化IBinder,這樣就可以在Java代碼和jni代碼裡面接收IBinder消息。
---------首屆Google暑期大學生博客分享大賽——2010 Andriod篇接觸android也有半年了,小作品也發布了幾個,但是其中都沒有用到ServcIE
File 讀寫[功能]因為文件讀寫很平常 使用打算把這個功能寫出輔助類的形式 以便以後方便使用 就是:FileIOHelper[代碼]1. 定義指定的File 以及其上
最近正在學習android的相關知識,遇到了很多問題,其中之一就是再往sdcard卡中添加文件時會出現下面類似的問題: &
本人嘗試,裡面提供得軟件在索愛x8上失敗了 提示說不能網絡共享 。看來自己編譯x8迫在眉睫啊 (有幸下載到了x8得源代碼。。。)--------------------