編輯:開發入門
在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.}
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.};
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消息。
New Message 頁面在 8.0.2 版本中,將針對用戶的個人聯系列表和企業名錄對 ultra-light 模式下發送的消息中的電子郵件地址進行檢查,如果可以的話
用Intent實現一個簡單的短信程序和電話撥號程序一樣,短信也是任何一款手機不可或缺的基本應用,是使用頻率最高的程序之一。現 在,我們再實現一個自己的短信程
簡介: Cameron Laird 用一篇對受歡迎的 Expect 工具的概述開啟了他新的月度專欄,Expect 是一種功能大大超出大多數程序員和管理員認識的
public class DraftTest extends Activity { /** Called when the activity