﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-MEYE-文章分类-Android3D</title><link>http://www.blogjava.net/MEYE/category/46042.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 08 Feb 2012 13:30:34 GMT</lastBuildDate><pubDate>Wed, 08 Feb 2012 13:30:34 GMT</pubDate><ttl>60</ttl><item><title>Android提高启动速度的实现方法 </title><link>http://www.blogjava.net/MEYE/articles/369624.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 08 Feb 2012 12:47:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/369624.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/369624.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/369624.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/369624.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/369624.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Android提高启动速度的实现方法&nbsp;http://blog.chinaunix.net/uid-25838286-id-3066799.html首先看一下Android系统的启动流程：bootloader&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 引导程序kernel&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbs...&nbsp;&nbsp;<a href='http://www.blogjava.net/MEYE/articles/369624.html'>阅读全文</a><img src ="http://www.blogjava.net/MEYE/aggbug/369624.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-02-08 20:47 <a href="http://www.blogjava.net/MEYE/articles/369624.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android移植详解</title><link>http://www.blogjava.net/MEYE/articles/369623.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 08 Feb 2012 12:45:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/369623.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/369623.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/369623.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/369623.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/369623.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #727272; font-family: 宋体, Arial; font-size: 12px; line-height: 15px; background-color: #f5f7f8; "><a href="" style="text-decoration: none; color: #63401b; font: normal normal normal 17px/2 黑体; ">android移植详解<br /><div><a href="http://blog.chinaunix.net/uid-25838286-id-3014386.html">http://blog.chinaunix.net/uid-25838286-id-3014386.html</a></div></a></span><span class="Apple-style-span" style="font-family: 宋体, Arial; font-size: 12px; line-height: normal; background-color: #f5f7f8; "><div class="text" style="margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 17px; width: 672px; overflow-x: hidden; overflow-y: hidden; font-size: 12px; line-height: 1.3em; "><div id="detail" class="detail" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.3; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; ">主要介绍linux 内核启动过程以及挂载android 根文件系统的过程，以及介绍android 源代码中文件系统部分的浅析。<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 主要源代码目录介绍<br />Makefile （全局的Makefile）<br />bionic （Bionic 含义为仿生，这里面是一些基础的库的源代码）<br />bootable （引导加载器）<br />build （build 目录中的内容不是目标所用的代码，而是编译和配置所需要的脚本和工具）<br />dalvik （JAVA 虚拟机）<br />development （程序开发所需要的模板和工 具）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; external （目标机器使用的一些库）<br />frameworks （应用程序的框架层）<br />hardware （与硬件相关的库）<br />packages （Android 的各种应用程序）<br />prebuilt （Android 在各种平台下编译的预置脚本）<br />recovery （与目标的恢复功能相关）<br />system （Android 的底层的一些库）<br />out (编译完成后产生的目录，也就是我们移植文件系统需要的目录)</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">host 目录的结构如下所示：<br />out/host/<br />|-- common<br />| `-- obj （JAVA 库）<br />`-- linux-x86<br />|-- bin （瞥绦颍?br&gt; |-- framework （JAVA 库,＊.jar 文件）<br />|-- lib （共享库*.so）<br />`-- obj （中间生成的目标文件）<br />host 目录是一些在主机上用的工具，有一些是二进制程序,有一些是JAVA 的程序。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">target 目录的结构如下所示：<br />out/target/<br />|-- common<br />| |-- R （资源文件）<br />| |-- docs<br />| `-- obj （目标文件）<br />`-- product<br />`-- generic<br />其中common 目录表示通用的内容，product 中则是针对产品的内容。<br />在common 目录的obj 中，包含两个重要的目录：<br />APPS 中包含了JAVA 应用程序生成的目标，每个应用程序对应其中一个子目录，将结合每个应用程序的原始文件生成Android 应用程序的APK 包。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JAVA_LIBRARIES 中包含了JAVA 的库，每个库对应其中一个子目录。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">所以，我们提取文件系统主要是在/out/target/product/generic 目录下，我们可以看到里面有obj 目录，进入obj 目录看看，里面是android 文件系统非常重要的内容：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">/obj<br />APPS (文件系统下/system/apps 目录下的各种应用程序)<br />SHARED_LIBRARIES （存放所有动态库）<br />STATIC_LIBRARIES（存放所有静态库）<br />EXECUTABLES （存放各种可执行文件）</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#0000ff" style="line-height: 1.5; ">Linux 内核启动挂载android根文件系统过程分析</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">顺便罗列一下内核启动流程：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">/arch/arm/boot/compressed/head.S：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">Start:<br />Decompressed_kernel()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //在/arch/arm/boot/compressed/misc.c 中<br />Call_kernel()</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><br />Stext:<br />/init/main.c<br />Start_kernel()<br />Setup_arch()<br />&#8230;<br />Rest_init()<br />Init()<br />Do_basic_setup（）<br />Prepare_namespace()</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">看到了这里，我已激动得说不出话了，因为来到我与挂载根文件系统最重要的接口函数。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">/* This is a non __init function. Force it to be noinline otherwise gcc<br />* makes it inline to init() and it becomes part of init.text section<br />*/<br />static int noinline init_post(void)<br />{<br />free_initmem();<br />unlock_kernel();<br />mark_rodata_ro();<br />system_state = SYSTEM_RUNNING;<br />numa_default_policy();<br />if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) &lt; 0)<br />printk(KERN_WARNING "Warning: unable to open an initial console.\n");<br />(void) sys_dup(0);<br />(void) sys_dup(0);<br />current-&gt;signal-&gt;flags |= SIGNAL_UNKILLABLE;<br />if (ramdisk_execute_command) {<br />run_init_process(ramdisk_execute_command);<br />printk(KERN_WARNING "Failed to execute %s\n",ramdisk_execute_command);<br />}<br />/*<br />* We try each of these until one succeeds. *<br />* The Bourne shell can be used instead of init if we are*<br />* trying to recover a really broken machine.*/<br /><font color="#ff0000" style="line-height: 1.5; ">if (execute_command) {<br />run_init_process(execute_command);<br />printk(KERN_WARNING "Failed to execute %s. Attempting ""defaults...\n",<br />execute_command);<br />}<br />run_init_process("/sbin/init");<br />run_init_process("/etc/init");<br />run_init_process("/bin/init");<br />run_init_process("/bin/sh");<br /></font>panic("No init found. Try passing init= option to kernel.");<br />}</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">其中，我们看到行代码<font color="#ff0000" style="line-height: 1.5; ">run_init_process(execute_command);<br />execute_command&nbsp;</font>是从UBOOT 传递过来的参数，一般为/init，也就是调用文件系统里的init 初始化进程。如果找不到init 文件就会在<br /><font color="#ff0000" style="line-height: 1.5; ">run_init_process("/sbin/init");<br />run_init_process("/etc/init");<br />run_init_process("/bin/init");<br />run_init_process("/bin/sh");<br /></font>中找，否则报错。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">在这里由于我们的根文件系统是从<font color="#ff0000" style="line-height: 1.5; ">/linuxrc</font>&nbsp;开始的，所以我硬性把它改为<br />if (execute_command) {<br /><font color="#ff0000" style="line-height: 1.5; ">run_init_process("/linuxrc");<br /></font>printk(KERN_WARNING "Failed to execute %s. Attempting "<br />"defaults...\n", execute_command);<br />}</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#0000ff" style="line-height: 1.5; ">Android 文件系统初始化核心Init.c文件分析</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 上面我们说的init 这个文件是由android 源代码编译来的，编译后在/out/target/product/generic/root/</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; ">其源码在/system/core/init/init.c</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; ">Init.c 主要功能：</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; ">（1）安装SIGCHLD 信号。（如果父进程不等待子进程结束，子进程将成为僵尸进程（zombie）从而占用系统资源。因此需要对SIGCHLD 信号做出处理，回收僵尸进程的资源，避免造成不必要的资源浪费。）<br />（2）对umask 进行清零。<br />何为umask，请看<a href="http://blog.chinaunix.net/link.php?url=http://blog.chinaunix.net%2Flink.php%3Furl%3Dhttp%3A%2F%2Fwww.szstudy.cn%252FshowArticle%252F53978.shtml" target="_blank" style="text-decoration: none; color: #63401b; "><font color="#0000ff" style="line-height: 1.5; ">http://www.szstudy.cn/showArticle/53978.shtml</font></a><br />（3）为rootfs 建立必要的文件夹，并挂载适当的分区。<br />/dev （tmpfs）<br />/dev/pts (devpts)<br />/dev/socket<br />/proc (proc)<br />/sys (sysfs)<br />（4）创建/dev/null 和/dev/kmsg 节点。<br /><font color="#ff0000" style="line-height: 1.5; ">（5）解析/init.rc，将所有服务和操作信息加入链表。</font><br />（6）从/proc/cmdline 中提取信息内核启动参数,并保存到全局变量。<br />（7）先从上一步获得的全局变量中获取信息硬件信息和版本号，如果没有则从/proc/cpuinfo 中提取,并保存到全局变量。<br />（8）根据硬件信息选择一个/init.(硬件).rc，并解析，将服务和操作信息加入链表。<br />在G1 的ramdisk 根目录下有两个/init.(硬件).rc：init.goldfish.rc 和init.trout.rc，init 程序会根据上一步获得的硬件信息选择一个解析。<br />（9）执行链表中带有&#8220;early-init&#8221;触发的的命令。<br />（10）遍历/sys 文件夹，是内核产生设备添加事件（为了自动产生设备节点)。<br />（11）初始化属性系统，并导入初始化属性文件。<br />（12）从属性系统中得到ro.debuggable，若为1，則初始化keychord 監聽。<br />（13）打開console,如果cmdline 中沒有指定console 則打開默認的 /dev/console<br />（14）讀取/initlogo.rle（一張565 rle 壓縮的位圖），如果成功則在<br />/dev/graphics/fb0 顯示Logo,如果失敗則將/dev/tty0 設為TEXT 模式并打開/dev/tty0,輸出文&#8220;ANDROID&#8221;字樣。<br />（15）判斷cmdline 中的參數，并设置属性系统中的参数:<br />1、 如果 bootmode 為<br />- factory,設置ro.factorytest 值為1<br />- factory2,設置ro.factorytest 值為2<br />- 其他的設ro.factorytest 值為0<br />2、如果有serialno 参数，則設置ro.serialno，否則為""<br />3、如果有bootmod 参数，則設置ro.bootmod，否則為"unknown"<br />4、如果有baseband 参数，則設置ro.baseband，否則為"unknown"<br />5、如果有carrier 参数，則設置ro.carrier，否則為"unknown"<br />6、如果有bootloader 参数，則設置ro.bootloader，否則為"unknown"<br />7、通过全局变量（前面从/proc/cpuinfo 中提取的）設置ro.hardware 和<br />ro.version。<br />（16）執行所有触发标识为init 的action。<br />（17）開始property 服務，讀取一些property 文件，這一動作必須在前面<br />那些ro.foo 設置后做，以便/data/local.prop 不能干預到他們。<br />- /system/build.prop<br />- /system/default.prop<br />- /data/local.prop<br />- 在讀取默認的 property 后讀取 presistent propertie，在 /data/property 中<br />（18）為 sigchld handler 創建信號機制<br />（19）確認所有初始化工作完成：<br />device_fd(device init 完成)<br />property_set_fd(property server start 完成)<br />signal_recv_fd (信號機制建立)<br />（20） 執行所有触发标识为early-boot 的action<br />（21） 執行所有触发标识为boot 的action<br />（22）基于當前property 狀態，執行所有触发标识为property 的action<br />（23）注冊輪詢事件:<br />- device_fd<br />- property_set_fd<br />-signal_recv_fd<br />-如果有keychord，則注冊keychord_fd<br />（24）如果支持BOOTCHART,則初始化BOOTCHART<br />（25）進入主進程循環:<br />- 重置輪詢事件的接受狀態，revents 為0<br />- 查詢action 隊列，并执行。<br />- 重啟需要重啟的服务<br />- 輪詢注冊的事件<br />- 如果signal_recv_fd 的revents 為POLLIN，則得到一個信號，獲取并處<br />理<br />- 如果device_fd 的revents 為POLLIN,調用handle_device_fd<br />- 如果property_fd 的revents 為POLLIN,調用handle_property_set_fd<br />- 如果keychord_fd 的revents 為POLLIN,調用handle_keychord<br />到了这里，整个android 文件系统已经起来了。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#0000ff" style="line-height: 1.5; ">初始化核心的核心init.rc文件分析</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; ">在上面红色那一行<font color="#ff0000" style="line-height: 1.5; ">（5）解析/init.rc，将所有 服务和操作信息加入链表。</font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parse_config_file("/init.rc");//在init.c 中代码 （有关 /init.rc的脚本我就不贴出来了）</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">名词解 释：<br />Android 初始化語言由四大类声明组成：行为类(Actions)、命令类(Commands)、服务类(Services)、选项类(Options)。<br />初始化语言以行为单位，由以空格间隔的语言符号組成。C 风格的反斜杠转义符可以用来插入空白到语言符号。双引号也可以用来防止文本被空格分成多个语言符号。当反斜杠在行末时，作为换行符。</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * 以#开始(前面允许空格)的行为注释。<br />* Actions 和Services 隐含声明一个新的段落。所有该段落下Commands 或 Options 的声明属于该段落。第一段落前的Commands 或Options 被忽略。<br />* Actions 和Services 拥有唯一的命名。在他们之后声明相同命名的类将被当作错误并忽略。<br />Actions 是一系列命令的命名。Actions 拥有一个触发器(trigger)用来決定action 何時执行。当一个action 在符合触发条件被执行时，如果它还没被加入到待执行队列中的话，則加入到队列最后。队列中的action 依次执行，action 中的命令也依次执行。</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Init 在执行命令的中间处理其他活动(设备创建/销毁</font></font></font><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">,property 设置，进程重启)。</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Actions 的表现形式:<br />on &lt;trigger&gt;<br />&lt;command&gt;<br />&lt;command&gt;<br />&lt;command&gt;</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 重要的数据结构两个列表，一个队列。<br />static list_declare(service_list)；<br />static list_declare(action_list)；<br />static list_declare(action_queue)；</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *.rc 脚本中所有 service 关键字定义的服务将会添加到 service_list 列表中。<br />*.rc 脚本中所有 on 关键开头的项将会被会添加到 action_list 列表中。每个action 列表项都有一个列表，此列表用来保存该段落下的 Commands。</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">脚本解 析过程：<br />parse_config_file("/init.rc")<br />int parse_config_file(const char *fn)<br />{<br />char *data;<br />data = read_file(fn, 0);<br />if (!data)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return -1;<br />parse_config(fn, data);<br />DUMP();<br />return 0;<br />}<br />static void parse_config(const char *fn, char *s)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</font></font></font><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; "><br />...<br />case T_NEWLINE:<br />if (nargs) {<br />int kw = lookup_keyword(args[0]);<br />if (kw_is(kw, SECTION)) {<br />state.parse_line(&amp;state, 0, 0);<br />parse_new_section(&amp;state, kw, nargs, args);<br />} else {<br />state.parse_line(&amp;state, nargs, args);<br />}<br />nargs = 0;<br />}<br />...<br />｝</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">parse_config 会逐行对脚本进行解析，如果关键字类型为 SECTION ，那么将会执行parse_new_section();<br />类型为 SECTION 的关键字有： on 和 sevice</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">关键字 类型定义在 Parser.c (system\core\init) 文件中<br />Parser.c (system\core\init)<br />#define SECTION 0x01<br />#define COMMAND 0x02<br />#define OPTION 0x04<br />关键字&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 属性<br />capability,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />class,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />class_start,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_class_start)<br />class_stop,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_class_stop)<br />console,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />critical,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />disabled,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />domainname,&nbsp;&nbsp;&nbsp; COMMAND, 1, do_domainname)<br />exec,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_exec)<br />export,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 2, do_export)<br />group,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />hostname,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_hostname)<br />ifup,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_ifup)<br />insmod,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_insmod)<br />import,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; COMMAND, 1, do_import)<br />keycodes,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />mkdir,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_mkdir)<br />mount,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 3, do_mount)<br />on,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SECTION, 0, 0)<br />oneshot,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />onrestart,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />restart,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_restart)<br />service,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SECTION, 0, 0)<br />setenv,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 2, 0)<br />setkey,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 0, do_setkey)<br />setprop,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 2, do_setprop)<br />setrlimit,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 3, do_setrlimit)<br />socket,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />start,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; COMMAND, 1, do_start)<br />stop,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_stop)<br />trigger,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_trigger)<br />symlink,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; COMMAND, 1, do_symlink)<br />sysclktz,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 1, do_sysclktz)<br />user,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OPTION, 0, 0)<br />write,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND, 2, do_write)<br />chown,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; COMMAND, 2, do_chown)<br />chmod,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; COMMAND, 2, do_chmod)<br />loglevel,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; COMMAND, 1, do_loglevel)<br />device,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; COMMAND, 4, do_device)</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">parse_new_section() 中再分别对 service 或者 on 关键字开头的内容进行解<br />析。<br />...<br />case K_service:<br />state-&gt;context = parse_service(state, nargs, args);<br />if (state-&gt;context) {<br />state-&gt;parse_line = parse_line_service;<br />return;<br />}<br />break;<br />case K_on:<br />state-&gt;context = parse_action(state, nargs, args);<br />if (state-&gt;context) {<br />state-&gt;parse_line = parse_line_action;<br />return;<br />}<br />break;<br />...</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">对 on 关键字开头的内容进行解析<br />static void *parse_action(struct parse_state *state, int nargs, char **args)<br />{<br />...<br />act = calloc(1, sizeof(*act));<br />act-&gt;name = args[1];<br />list_init(&amp;act-&gt;commands);<br />list_add_tail(&amp;action_list, &amp;act-&gt;alist);<br />...<br />}</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">对 service 关键字开头的内容进行解析<br />static void *parse_service(struct parse_state *state, int nargs, char **args)<br />{<br />struct service *svc;<br />if (nargs &lt; 3) {<br />parse_error(state, "services must have a name and a program\n");<br />return 0;<br />}<br />if (!valid_name(args[1])) {<br />parse_error(state, "invalid service name '%s'\n", args[1]);<br />return 0;<br />}<br />//如果服务已经存在service_list 列表中将会被忽略<br />svc = service_find_by_name(args[1]);<br />if (svc) {<br />parse_error(state, "ignored duplicate definition of service '%s'\n", args[1]);<br />return 0;<br />}<br />nargs -= 2;<br />svc = calloc(1, sizeof(*svc) + sizeof(char*) * nargs);<br />if (!svc) {<br />parse_error(state, "out of memory\n");<br />return 0;<br />}<br />svc-&gt;name = args[1];<br />svc-&gt;classname = "default";<br />memcpy(svc-&gt;args, args + 2, sizeof(char*) * nargs);<br />svc-&gt;args[nargs] = 0;<br />svc-&gt;nargs = nargs;<br />svc-&gt;onrestart.name = "onrestart";<br />list_init(&amp;svc-&gt;onrestart.commands);<br />//添加该服务到 service_list 列表<br />list_add_tail(&amp;service_list, &amp;svc-&gt;slist);<br />return svc;<br />}</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">服务的 表现形式:<br />service &lt;name&gt; &lt;pathname&gt; [ &lt;argument&gt; ]*<br />&lt;option&gt;<br />&lt;option&gt;<br />...</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><font color="#000000" style="line-height: 1.5; "><font color="#ff0000" style="line-height: 1.5; "><font color="#000000" style="line-height: 1.5; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 申请一个service 结构体，然后挂接到service_list 链表上，name 为服务的名称，pathname 为执行的命令，argument为命令的参数。之后的 option 用来控制这个service 结构体的属性，parse_line_service 会对 service 关键字后的内容进行解析并填充到 service 结构中 ，当遇到下一个service 或者on 关键字的时候此service 选项解析结束。<br />例如：<br />service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server<br />socket zygote stream 666<br />onrestart write /sys/android_power/request_state wake<br />服务名称为： zygote<br />启动该服务执行的命令： /system/bin/app_process<br />命令的参数： -Xzygote /system/bin --zygote --start-system-server<br />socket zygote stream 666： 创建一个名为：/dev/socket/zygote 的 socket ，<br />类型为：stream</font></font></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="ztag m2a fc03" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" target="_blank" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">养成励志的习惯，一生励志&#8212;&#8212;文指星终极励志</font></strong></a><strong><font color="#800080" style="line-height: 1.5; ">&nbsp;</font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="ztag m2a fc03" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111145326924/" target="_blank" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">经典英语口语与英语学习资料</font></strong></a><strong><font color="#800080" style="line-height: 1.5; ">&nbsp;</font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="ztag m2a fc03" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143243761/" target="_blank" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">15本经典C、C++、MFC、VC++教程，都是pdf完整版的</font></strong></a></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="ztag m2a fc03" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111142623315/" target="_blank" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">30本经典Linux学习和开发教程和资料，都是pdf完整版的</font></strong></a><strong><font color="#800080" style="line-height: 1.5; ">&nbsp;</font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="ztag m2a fc03" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111142257943/" target="_blank" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">10本经典Java教程，都是pdf完整版的</font></strong></a><strong><font color="#800080" style="line-height: 1.5; ">&nbsp;</font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="ztag m2a fc03" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111141638960/" target="_blank" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">15本超级经典Android教程，都是pdf完整版的</font></strong></a><strong><font color="#800080" style="line-height: 1.5; ">&nbsp;</font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a href="http://blog.chinaunix.net/link.php?url=http://www.shangxueba.com%2Fshare%2Fp3071351.html" target="_blank" rel="nofollow" style="text-decoration: none; color: #63401b; "><strong><font color="#800080" style="line-height: 1.5; ">一语惊人英语口语--经典口语&nbsp;</font></strong></a><strong><font color="#800080" style="line-height: 1.5; ">&nbsp;</font></strong></p></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "></p></div></div><div class="cont5" style="margin-top: 30px; margin-right: auto; margin-bottom: 0px; margin-left: auto; width: 615px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: #d6d6d6; border-right-color: #d6d6d6; border-bottom-color: #d6d6d6; border-left-color: #d6d6d6; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; "></div></span><img src ="http://www.blogjava.net/MEYE/aggbug/369623.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-02-08 20:45 <a href="http://www.blogjava.net/MEYE/articles/369623.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android的framework层音量控制原理分析--hot(key)处理</title><link>http://www.blogjava.net/MEYE/articles/369566.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 08 Feb 2012 01:22:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/369566.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/369566.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/369566.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/369566.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/369566.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #727272; font-family: 宋体, Arial; font-size: 12px; line-height: 15px; background-color: #f5f7f8; "><a href="" style="text-decoration: underline; color: #ff0000; font: normal normal normal 17px/2 黑体; ">Android的framework层音量控制原理分析--hot(key)处理<br /></a></span><span class="Apple-style-span" style="font-family: 宋体, Arial; font-size: 12px; line-height: 18px; background-color: #f5f7f8; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">&nbsp;Android.media.AudioManager中包含了对android.media.AudioService的跨进程AIDL调用封装。<br />正常处理过程：<br />1.调整音量是通过AudioManager间接调用AudioService.adjustStreamVolume方法来完成逻辑处理;<br />2.AudioService调用VolumePanel画出音量调整界面，并发送音量变动广播消息，<br />3.StatusBarPolicy，接收广播消息判断是否在状态栏显示静音或振动图标。<br /><br />问题点：<br />1.AudioManager如何接收音量调整事件？<br /><br />答：PhoneWindowManager.interceptKeyBeforeQueueing处理的<br />WindowManagerService循环读取下面的消息再做分发到窗口接收，在消息分发前会有一个类做消息过滤处理，就是PhoneWindowManager.interceptKeyBeforeQueueing；<br />比如音量调整、Home键都在这个类里面做特殊处理，详细内容后面会在其它该当再补充<br /><br /><br />2.谁负责处理音量显示的？<br />答：AudioManager调用AudioService来显示的。事件触发在AudioManager，代码的执行实现在AudioService中。状态栏是SystemUI的APK包StatusBarPolicy中接收广播消息来处理的。<br /><br />源码位置：<br />/frameworks/base/media/java/android/media/AudioManager.java<br />/frameworks/base/media/java/android/media/AudioService.java<br />/framework/base/core/java/Android/view/VolumePanel.java<br />/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarPolicy.java<br /><br />AudioService.adjustStreamVolume方法完成以下三个功能：<br />一.音量调整<br />音量调整分为两步：先查看模式(Ring mode)是否需要调整? 然后再调用调整音量。&nbsp;<br />调整模式通过调用checkForRingerModeChange(oldIndex, direction);实现，<br />调整音量通过调用streamState.adjustIndex(direction)实现。<br /><br />二.向用户显示调整音量的界面<br />调用mVolumePanel.postVolumeChanged(streamType, flags);发送音量变动消息，向用户显示改变结果。<br />调用过程VolumePanel.postVolumeChanged-&gt;VolumePanel.onVolumeChanged-&gt;VolumePanel.onShowVolumeChanged-&gt;mToast<br /><br />三.广播音量有变动的系统事件<br />AudioService.sendVolumeUpdate(streamType);广播音量有改变的系统事件，状态栏根据这广播事件显示静音或振动图标<br /><br />状态栏的静音或振动图标显示过程<br />StatusBarPolicy主要负责在静音模式(silent mode)和振动模式(vibrate mode)下在状态栏(status bar)的右方显示一个代表相应意义的图标。<br />一.系统启动后，StatusBarPolicy会注册一个Receiver，它可以接收很多种广播，其中就有AudioService在完成每一次的模式和音量更新时发出的两个广播事件<br /><br />private BroadcastReceiver mIntentReceiver = new BroadcastReceiver()//新一个广播接收类&#8216;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);//添加接收的广播消息<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter.addAction(AudioManager.VIBRATE_SETTING_CHANGED_ACTION);<br />mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);//注册一个Receiver，接收广播消息<br /><br />二.接收广播，并调用updateVolume调整状态栏显示<br />else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; updateVolume();//调用音量状态栏显示<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><strong><font color="#5434fa" size="3" style="line-height: 1.5; "><a title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" style="text-decoration: none; color: #63401b; "><strong><font color="#5434fa" size="3" style="line-height: 1.5; "></font></strong></a><a title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" style="text-decoration: none; color: #63401b; "><font size="4" style="line-height: 1.5; ">养成励志的习惯，一生励志</font></a></font></strong><font color="#5434fa" style="line-height: 1.5; "><font size="4" style="line-height: 1.5; ">&nbsp;&nbsp;<span style="line-height: 1.5; ">&nbsp;</span></font></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a href="http://blog.chinaunix.net/link.php?url=http://huangwen200301930.blog.163.com%2Fblog%2Fstatic%2F48484981201111158204431%2F" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/48484981201111158204431/" style="text-decoration: none; color: #63401b; "><strong><font color="#ff0000" style="line-height: 1.5; "><font color="#5434fa" size="4" style="line-height: 1.5; ">22本经典英语口语教程</font></font></strong></a><strong><font color="#ff0000" style="line-height: 1.5; "><font color="#5434fa" style="line-height: 1.5; "><font size="4" style="line-height: 1.5; ">&nbsp;&nbsp;</font></font></font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/4848498120111115805736/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/4848498120111115805736/" style="text-decoration: none; color: #63401b; "><strong><font color="#ff0000" style="line-height: 1.5; "><font color="#5434fa" size="4" style="line-height: 1.5; ">技术开发海量资料下载导航</font></font></strong></a><font size="4" style="line-height: 1.5; ">&nbsp;</font></p></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="fc03 m2a" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111142623315/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/484849812011111142623315/" style="text-decoration: none; color: #63401b; "><strong><font color="#ff0000" size="4" style="line-height: 1.5; ">30本经典Linux学习和开发教程和资料</font></strong></a><strong><font color="#ff0000" size="4" style="line-height: 1.5; ">&nbsp;</font></strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="fc03 m2a" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143243761/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143243761/" style="text-decoration: none; color: #63401b; "><strong><font size="4" style="line-height: 1.5; ">15本经典C、C++、MFC、VC++教程</font></strong></a></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="fc03 m2a" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111142257943/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/484849812011111142257943/" style="text-decoration: none; color: #63401b; "><strong><font size="4" style="line-height: 1.5; ">10本经典Java教程</font></strong></a></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; "><a class="fc03 m2a" title="阅读全文" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111141638960/" target="_blank" _xhe_href="http://huangwen200301930.blog.163.com/blog/static/484849812011111141638960/" style="text-decoration: none; color: #63401b; "><strong><font color="#ff0000" size="4" style="line-height: 1.5; ">15本经典Android教程和海量Android源码</font></strong></a></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 1.5; font-size: 14px; ">&nbsp;</p></span><img src ="http://www.blogjava.net/MEYE/aggbug/369566.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-02-08 09:22 <a href="http://www.blogjava.net/MEYE/articles/369566.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu10.10安装配置tftp服务—— tftp-hpa 安装</title><link>http://www.blogjava.net/MEYE/articles/369158.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 01 Feb 2012 06:41:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/369158.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/369158.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/369158.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/369158.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/369158.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; background-color: #ffffff; "><a href="http://blog.csdn.net/zchli/article/details/6339627" style="color: #666666; text-decoration: none; ">ubuntu10.10安装配置tftp服务&#8212;&#8212; tftp-hpa 安装<br /><div><a href="http://blog.csdn.net/zchli/article/details/6339627">http://blog.csdn.net/zchli/article/details/6339627</a></div></a></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><div class="multicntwrap"><div class="multicnt"><div><p class="tdep clearfix nbw-act fc06" style="line-height: 20px; ">参考10.04的方式安装失败，按如下方式安装pass了。</p><p class="tdep clearfix nbw-act fc06" style="line-height: 20px; "><span class="pright pnt fc03"><br /></span></p></div></div></div><div></div><p><span style="font-size: large; "><span style="color: #ff0000; ">【已成功】Ubuntu 10.10下安装TFTP的步骤 t<span class="t_tag">ftp</span>&nbsp;-hpa版本<br /><br /></span></span><span style="font-size: medium; "><span style="color: #993300; "><strong>【背景】<br /></strong></span></span>由于想要在tq2440板子上用tftp下载kernel，所以要在自己的PC机的Ubuntu 10.10上安装tftp服务。<br />所以就去网上找了些教程，但是很悲剧，按照那些教程去操作，结果还都是无法正常运行tftp服务，最后还是从一个外国人的帖子中，最后解决了此问题的。现在记录一下所了解到内容。<br /><br />截至目前2011-04-04，我用的Ubuntu 10.10，Ubuntu下面关于TFTP的程序，有三种：<br /><span style="font-size: medium; "><span style="color: #993300; "><strong>1.tftp和tftpd</strong>&nbsp;</span></span><br />这个是最早的，最常用的。，其中tftp是client客户端，tftpd是<span class="t_tag">server</span>&nbsp;<span class="t_tag">服务器</span>&nbsp;端，d应该指的是daemon。<br />如果你要从别人的tftp服务器端上传/下载东西，就要用到tftp；如果你为别人提供tftp服务，供别人上传/下载东西，那就要安装tftpd服务程序。<br />如果安装tftp和tftpd，那么根据附录2说的：&#8220;因为tftp是要inetd来控制的，而debian类的<span class="t_tag">系统</span>&nbsp;，默认是没有安装inetd的，安装一下。&#8221; 所以，此处也要安装inetd，但是我这里发现Ubuntu 10.10里面，没有他们说的那个netkit-inetd:</p><div class="blockcode"><div id="code0"><ol><li>crifan@crifan-ubuntu10:~/develop$ sudo apt-get install netkit-inetd</li><li>正在读取<span class="t_tag">软件</span>&nbsp;包列表... 完成</li><li>正在分析软件包的依赖关系树</li><li>正在读取状态信息... 完成</li><li>软件包 netkit-inetd 是一个由下面的软件包提供的虚拟软件包：</li><li>inetutils-inetd 2:1.6-3</li><li>openbsd-inetd 0.<span class="t_tag">2008</span>&nbsp;0125-4ubuntu2</li><li>请您明确地选择一个来进行安装。</li><li></li><li>E: 软件包 netkit-inetd 没有可供安装的候选者</li></ol></div><em>复制代码</em></div><p><br />而只有inetutils-inetd和openbsd-inetd，此处，我自己折腾tftp和tftpd的时候，装的是inetutils- inetd，但是却也一直没弄好，所以此处忽略不说。而openbsd-inetd，是我装的，可以正常使用的。具体方法下面会详细介绍。<br /><br /><span style="font-size: medium; "><span style="color: #993300; "><strong>2.加强版的tftp： atftp和atftpd</strong>&nbsp;</span></span><br />atftp即advanced tftp，加强了一些功能。这里我没用过，不多评价。<br /><br /><span style="font-size: medium; "><strong><span style="color: #993300; ">3. hpa版本的tftp：tftp-hpa和tftpd-hpa</span>&nbsp;</strong></span><br />我最后就是用的这个hpa版本的。<br />中间折腾过程翻来覆去弄了很多次，最后参考这里：<br /><a href="http://ubuntuforums.org/showthread.php?t=1483618" target="_blank" style="color: #336699; text-decoration: none; ">http://ubuntuforums.org/showthread.<span class="t_tag">php</span>&nbsp;?t=1483618</a>&nbsp;<br />确定这样是可以安装成功的：<br /><br /><span style="font-size: small; "><span style="color: #ff0000; "><strong>【Ubuntu 10.10下安装TFTP的步骤</strong>&nbsp;</span></span><span style="font-size: small; "><span style="color: #ff0000; "><strong>tftp-hpa版本</strong>&nbsp;</span></span><span style="font-size: small; "><span style="color: #ff0000; "><strong>】</strong>&nbsp;</span></span><br /><strong><span style="color: #0000ff; ">1. 用新立得先去卸载tftp和tftpd（如果你安装的话），tftp-hpa和tftpd-pha（如果你安装的话）</span>&nbsp;</strong><br />系统 -&gt; 系统管理 -&gt; 新立得软件包管理器，即synaptic，<br />搜索 tftp，会找到和tftp相关的软件列表。<br />如果你已经装了tftp和tftpd，那么先用新立得去彻底删除他们。<br />如果也已经安装了tftp-pha和tftpd-hpa，那么也同样用新立得去彻底删除他们。<br />（注意，我之前就是用的命令行去装的tftp-hpa和tftpd-hpa，而安装他们的同时会自动卸载掉原先装过的tftp和tftpd，所以，我在新立得里面看到的是已经安装的tftp-hpa和tftpd-hpa，所以要先右键点击，选择彻底删除，然后选择<span class="t_tag">应用</span>&nbsp;，就可以去彻底删除了。）<br /><strong><span style="color: #0000ff; ">2. 用新立得去安装tftp-hpa和tftpd-pha</span>&nbsp;</strong><br />同上，进入新立得，右键选中tftp-hpa和tftpd-pha，然后安装。<br /><strong><span style="color: #0000ff; ">3. 安装openbsd-inetd</span>&nbsp;</strong><br />（此处搞不清是不是必须要装这个了，不过是反正是装了，现在的tftp是可以工作的，如果你也不确定要不要安装，那就也安装吧。。。）<br />我是用的命令行去安装的：</p><div class="blockcode"><div id="code1"><ol><li>crifan@crifan-ubuntu10:~/develop$ sudo apt-get install openbsd-inetd</li></ol></div><em>复制代码</em></div><p><br /><span style="color: #0000ff; "><strong>4.建立TFTP根目录及设置访问属性</strong>&nbsp;</span><br />去建立一个根目录，然后设置对应的访问属性：</p><div class="blockcode"><div id="code2"><ol><li>mkdir /home/crifan/develop/tftpboot</li><li>cd /home/crifan/develop/</li><li>chmod 777 tftpboot/</li></ol></div><em>复制代码</em></div><p><br /><br />其中：<br />（1）/home/crifan/develop/tftpboot是我的TFTP的根目录，你根据自己情况修改为你自己的根目录。<br />（2）chmod是去更改tftpboot这个TFTP根目录的访问属性，因为其他tftp<span class="t_tag">用户</span>&nbsp;需要使用put命令上传<span class="t_tag">文件</span>&nbsp;的话，那就需要write权限的，所以这里干脆省事，直接chmod 777，添加所有权限（读+写+执行）。<br /><br /><strong><span style="color: #0000ff; ">5. 更改配置文件/etc/default/tftpd-hpa</span>&nbsp;</strong><br />sudo gedit /etc/default/tftpd-hpa<br />去修改配置文件，修改好后，内容如下：</p><div class="blockcode"><div id="code3"><ol><li># /etc/default/tftpd-hpa</li><li>RUN_DAEMON="yes"</li><li>OPTIONS="-l -s -c /home/crifan/develop/tftpboot"</li><li>TFTP_USERNAME="crifan"</li><li>TFTP_DIRECTORY="/home/crifan/develop/tftpboot"</li><li>TFTP_ADDRESS="0.0.0.0:69"</li><li>TFTP_OPTIONS="--secure"</li></ol></div><em>复制代码</em></div><p><br />其中：<br />（1）<br />OPTIONS="-l -s -c /home/crifan/develop/tftpboot"<span style="font-size: x-small; "><br />中的参数含义为：<br />-l Run the server in standalone (listen) mode, rather than run from inetd. In listen mode, the -t option is ignored, and the -a option can be used to&nbsp;&nbsp;specify a specific local address or port to listen to.<br /><br />-a [address][:port]<br />Specify a specific address and port to listen to when called with the -l option. The default is to listen to the tftp port specified in /etc/services on all local addresses.<br /><br />-c Allow new files to be created. By default, tftpd will only allow upload of files that already exist. Files are created with default permissions allowing anyone to read or write them, unless the -p or -U options are specified.<br /><br />-s (决定tftp根目录)Change root directory on startup. This means the remote host does not need to pass along the directory as part of the trans-fer, and may add security. When -s is specified, exactly one directory should be specified on the command line. The use of this option is recommended for security as well as compatibility with some boot ROMs which cannot be easily made to include a directory name in its request.<br /></span><br />注意其中的-c, "-c为可创建新文件，若无此参数，put命令则可能出现错误提示，此时只能覆盖原有文件不能创建新文件；"<br /><br />OPTIONS参数后面跟的是你的TFTP的根目录。<br />TFTP_USERNAME是用户名，我这里的是"crifan"，你根据自己情况修改。<br />TFTP_DIRECTORY后面也是同样的根目录 "/home/crifan/develop/tftpboot"，你根据自己情况修改。<br /><br />（2）ubuntu10.04下的tftp-hpa配置文件和之前不一样，之前的是类似这种：</p><div class="blockcode"><div id="code4"><ol><li>#Defaults for tftpd-hpa</li><li>RUN_DAEMON="yes"</li><li>OPTIONS="-l -c -s /tftpboot"</li></ol></div><em>复制代码</em></div><p><br />Ubuntu 10.10中安装之后的是这种：</p><div class="blockcode"><div id="code5"><ol><li># /etc/default/tftpd-hpa</li><li>TFTP_USERNAME="tftp"</li><li>TFTP_DIRECTORY="/tftpboot"</li><li>TFTP_ADDRESS="0.0.0.0:69"</li><li>TFTP_OPTIONS="-l -c -s /tftpboot"</li></ol></div><em>复制代码</em></div><p><br />而此处上面所用的配置，既有新的也有旧的，具体为何是这样，偶也不太清楚，只是参考上面那人的帖子而已。其他人有兴趣可以自己测试，删除旧的配置后是否同样可以工作。<br /><br /><strong><span style="color: #0000ff; ">6.重启tftp服务</span></strong></p><div class="blockcode"><div id="code6"><ol><li>crifan@crifan-ubuntu10:~/develop$ sudo service tftpd-hpa restart</li><li>tftpd-hpa start/running, process 3907</li></ol></div><em>复制代码</em></div><p>其中：<br />（1）关于重启 某个服务，之前的Linux（Ubuntu是10.10之前）都是这样操作的：<br />sudo /etc/init.d/XXX reload<br />对于inetd来说，就是：<br />sudo /etc/init.d/inetd reload<br />现在新的LUbuntu 10.10中，是统一成调用service来操作了：<br />sudo service XXX restart<br />其中，启动和停止对应的是start和stop。<br />（2）记得不要少了sudo，否则&#8220;stop: Rejected send message&#8221;的错误。<br />（3）【确认tftp服务是否已经开启】<br />查看tftp相关进程：</p><div class="blockcode"><div id="code7"><ol><li>crifan@crifan-ubuntu10:~/develop$ ps aux |grep tftp</li><li>root 3826 0.0 0.0 2352 120 ? Ss 14:27 0:00 /usr/sbin/in.tftpd --listen --user crifan --address 0.0.0.0:69 --secure /home/crifan/develop/tftpboot</li><li>crifan 3828 0.0 0.0 5628 768 pts/0 S+ 14:27 0:00 grep --color=auto tftp</li></ol></div><em>复制代码</em></div><p><br />如果能看到像上面的 /usr/sbin/in.tftpd已经启动，就说明tftp服务已经开启了。<br />此处可以看到：<br />--listen就是对应的配置文件中的参数 -l<br />--user crifan就是对应配置文件中的参数 TFTP_USERNAME="crifan"<br />/home/crifan/develop/tftpboot就是对应的配置文件中的参数 TFTP_DIRECTORY=" /home/crifan/develop/tftpboot"<br /><br /><span style="color: #0000ff; "><strong>7.验证tftp是否生效</strong></span></p><div class="blockcode"><div id="code8"><ol><li>crifan@crifan-ubuntu10:~/develop$ tftp 192.168.1.101</li><li>tftp&gt;get u-boot.bin</li><li>tftp&gt;quit</li></ol></div><em>复制代码</em></div><p><br /><br />其中：<br />（1）192.168.1.101是我的机子的ip，可以通过ifconfig查得。你此处要改为你自己的机子的IP。当然你也可以直接写127.0.0.1，这个地址始终代表了你的本机IP。<br />（2）get是tftp的命令，即从tftp服务器中下载获得文件。你可以输入？查看其他命令。常见的命令有get下载文件，put上传文件等等。u-boot.bin是我已经存在在tftp根目录下面的文件。<br />（3）quit是退出tftp。<br /><br /><strong><span style="font-size: medium; "><span style="color: #993300; ">【总结】</span>&nbsp;</span></strong><br />看着步骤很复杂，实际归纳起来很简单，那就是用新立得synaptic去安装tftp-pha和tftpd-hpa，然后改一下配置，重启一下服务，然后验证一下tftp是否工作即可。<br /><strong><span style="font-size: medium; "><span style="color: #800000; ">【后续】</span>&nbsp;</span></strong><br />经过验证tftp已经生效，然后回到<span class="t_tag">开发</span>&nbsp;板上就可以用tftp下载文件了：</p><div class="blockcode"><div id="code9"><ol><li>EmbedSky&gt; tftp 0x30010000 u-boot.bin</li><li>dm9000 i/o: 0x20000300, id: 0x90000a46</li><li>MAC: 0a:1b:2c:3d:4e:5f</li><li>TFTP from server 192.168.1.101; our IP address is 192.168.1.120</li><li>Filename 'u-boot.bin'.</li><li>Load address: 0x30010000</li><li>Loading: T ###############</li><li>done</li><li>Bytes transferred = 207396 (32a24 hex)</li></ol></div><em>复制代码</em></div><p><br /><br /><strong><span style="font-size: medium; "><span style="color: #800000; ">【另外】</span>&nbsp;</span></strong><br />关于Linux下的图形界面GUI版本的TFTP，网上找到了这个：<br /><a href="http://code.google.com/p/tftpgui/" target="_blank" style="color: #336699; text-decoration: none; "><span style="color: #666666; ">tftpgui</span>&nbsp;</a><br /><a href="http://code.google.com/p/tftpgui/" target="_blank" style="color: #336699; text-decoration: none; "><span style="color: #229739; ">http://code.<span class="t_tag">google</span>&nbsp;.com/p/tftpgui/</span>&nbsp;</a><br />暂未试用，有机会试试。<br /><br /><span style="color: #993300; "><strong><span style="font-size: medium; ">【引用】</span>&nbsp;</strong></span><br /><span style="color: #ff0000; "><strong>1. TFTP will not start (command returns a "rejected send message")</strong>&nbsp;</span><br /><a href="http://ubuntuforums.org/showthread.php?t=1483618" target="_blank" style="color: #336699; text-decoration: none; "><span style="color: #229739; ">http://ubuntuforums.org/showthread.php?t=1483618</span>&nbsp;</a><br />2.ubuntu中配置tftp服务<br /><a href="http://hi.baidu.com/wangy0919/blog/item/3808eaa1388bd389471064c2.html" target="_blank" style="color: #336699; text-decoration: none; "><span style="color: #229739; ">http://hi.baidu.com/wangy0919/blog/item/3808eaa1388bd389471064c2.html</span>&nbsp;</a><br />3.Tftpd-hpa<br /><a href="http://wiki.ubuntu.org.cn/Tftpd-hpa" target="_blank" style="color: #336699; text-decoration: none; "><span style="color: #229739; ">http://wiki.ubuntu.org.cn/Tftpd-hpa</span>&nbsp;</a><br />4.ubuntu10.04下的tftp-hpa配置文件不一样了，如何修改阿？<br /><a href="http://forum.ubuntu.org.cn/viewtopic.php?t=265239" target="_blank" style="color: #336699; text-decoration: none; "><span style="color: #229739; ">http://forum.ubuntu.org.cn/viewtopic.php?t=265239</span></a></p><p><br /><br /><br />下面是网上总结出来的常见错误及解决方法：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">现象一：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">tftp&gt; get file</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">Transfer timed out.</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">原因：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">tftpd服务没有启动</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">解决方法：启动服务</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">sudo /etc/init.d/xinetd restart</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">sudo /etc/init.d/tftpd-hpa restart</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">现象二：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">tftp&gt; get file</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">Error code 2: Only absolute filenames allowed</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">原因：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">在/etc/xinetd.d/tftpd中设置的server_args为/etc/default/tftpd-hpa</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">下面是我的机器上/etc/default/tftpd-hpa配置</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; "># /etc/default/tftpd-hpa<br />RUN_DAEMON="yes"<br />TFTP_ADDRESS="0.0.0.0:69"<br />OPTIONS="-s /home/tftpd -c -p -U 077 -u tftpd"</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">&nbsp;</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">现象三：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">tftp&gt; put file</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">Error code 1: File not found</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">原因：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">指定的文件不存在；或tftpd启动参数中没有指定-c选项，允许上传文件～上传的时候一定要确保文件先存在于上传目录下。</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">&nbsp;</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">现象四：</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">tftp&gt; get file</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">tftp:&nbsp; : Permission denied</p><p style="margin-top: 0in; margin-right: 0in; margin-bottom: 0in; margin-left: 0in; font-family: SimSun; font-size: 10pt; ">原因：权限不足</p><p>请查看chmod 是不是配置好</p></span><img src ="http://www.blogjava.net/MEYE/aggbug/369158.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-02-01 14:41 <a href="http://www.blogjava.net/MEYE/articles/369158.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>贡献15本pdf完整版经典Android教程和海量Android源码  </title><link>http://www.blogjava.net/MEYE/articles/367981.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 06 Jan 2012 01:45:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/367981.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/367981.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/367981.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/367981.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/367981.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #38463e; font-family: Arial, Helvetica, simsun, u5b8bu4f53; font-size: 12px; line-height: normal; background-color: #ccced0; "><h3 class="title pre fs1" style="overflow-x: hidden; overflow-y: hidden; text-align: left; white-space: normal; word-wrap: break-word; word-break: break-all; font-size: 14px; margin-top: 30px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 24px; "><span class="tcnt" style="font-size: 20px; font-family: 微软雅黑, 黑体, Arial, Helvetica, sans-serif; ">贡献15本pdf完整版经典Android教程和海量Android源码</span>&nbsp;&nbsp;<br /><div><a href="http://huangwen200301930.blog.163.com/blog/static/484849812011111141638960/">http://huangwen200301930.blog.163.com/blog/static/484849812011111141638960/</a></div></h3></span><span class="Apple-style-span" style="color: #38463e; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; background-color: #ccced0; "><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4" style="line-height: 32px; ">贡献15本超级经典Android教程，都是pdf完整版的</font></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "></p><table id="gv_data" cellspacing="0" cellpadding="0" rules="all" border="0" style="line-height: 25px; "><tbody style="line-height: 25px; "><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873410.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android开发编程从入门到精通&#8212;&#8212;Android程序员必备</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873410.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048318.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#ff0000" style="line-height: 25px; ">Android应用程序开发36技（pdf完整版359页）</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048318.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048301.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android新手开发教程</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048301.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048284.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android2.3用户手册</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048284.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048270.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android开发教程笔记pdf完全版</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048270.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048261.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android SDK 中文开发文档</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3048261.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890952.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Linux内核阅读心得体会&#8212;&#8212;pdf高清版</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890952.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890950.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">linux Android基础知识总结</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890950.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890949.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android系统移植技术详解</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890949.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890948.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android-Google手持设备应用程式设计入门</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890948.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890946.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android编程入门教程</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890946.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890914.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#ff0000" style="line-height: 25px; ">Android驱动开发入门及手机案例开发分析教程</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2890914.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873434.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android开发手册&#8212;&#8212;API函数详解</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873434.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873408.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#ff0000" style="line-height: 25px; ">深入浅出Android&#8212;&#8212;Android开发经典教材</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873408.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873379.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">Android 开发环境搭建步骤详细图解</strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; ">&nbsp;</strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p2873379.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">点击下载</strong></a></td></tr></tbody></table><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&nbsp;</p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">海量源码</font></strong></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "></p><table id="gv_data" cellspacing="0" cellpadding="0" rules="all" border="0" style="line-height: 25px; "><tbody style="line-height: 25px; "><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138254.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">Android 贪吃蛇 程序代码源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138254.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138253.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">7个经典Android应用程序实例源代码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138253.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138252.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">安卓Android俄罗斯方块游戏--完整游戏项目源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138252.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138251.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">安卓Android中国象棋Chess程序项目源码源代码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; "></font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138251.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138250.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#ff0000" style="line-height: 25px; ">Android应用开发详解教材源码（上册）--10个单元40多个实例源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138250.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138249.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">Android应用开发详解教材源码（下册）--8个单元30多个实例源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138249.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138248.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">Mp3播放器源码Android实战项目源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138248.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138247.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#ff0000" style="line-height: 25px; ">Android 培训示例大全--18个单项功能实例源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138247.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138246.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#ff0000" style="line-height: 25px; ">Android 小项目开发示例大全--20个通用具体应用程序实例源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138246.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138245.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">Android 文件下载功能Java多线程下载功能的例子实例源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138245.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr><tr style="line-height: 25px; "><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138244.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">安卓Android开源小说阅读器CoolReader源码</font></strong></a></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">&nbsp;</font></strong></td><td style="line-height: 25px; "><a target="_blank" rel="nofollow" href="http://www.shangxueba.com/share/p3138244.html" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; "><font color="#0000ff" style="line-height: 25px; ">点击下载</font></strong></a></td></tr></tbody></table><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&nbsp;<wbr style="line-height: 25px; "></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; ">&nbsp;</p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><wbr style="line-height: 25px; "></p><wbr style="line-height: 25px; "><br style="line-height: 25px; " /><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><a title="阅读全文" target="_blank" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "></a></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><a target="_blank" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">14本名师经典励志教程</strong></a><strong style="line-height: 25px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><a target="_blank" href="http://huangwen200301930.blog.163.com/blog/static/48484981201111158204431/" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">22本经典英语口语教程</strong></a><a title="阅读全文" target="_blank" href="http://huangwen200301930.blog.163.com/blog/static/484849812011111143112828/" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">&nbsp;&nbsp;</strong></a></p><p style="line-height: 25px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 2em; "><a title="阅读全文" target="_blank" href="http://huangwen200301930.blog.163.com/blog/static/4848498120111115805736/" style="color: #3b5a4a; line-height: 25px; text-decoration: none; "><strong style="line-height: 25px; ">技术开发海量资料下载导航</strong></a></p></span><img src ="http://www.blogjava.net/MEYE/aggbug/367981.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-01-06 09:45 <a href="http://www.blogjava.net/MEYE/articles/367981.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>android4.0源码下载 编译 系统体验～图解</title><link>http://www.blogjava.net/MEYE/articles/367939.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Thu, 05 Jan 2012 09:57:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/367939.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/367939.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/367939.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/367939.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/367939.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: Verdana, sans-serif, 宋体; font-size: 13px; line-height: normal; background-color: #f2f2f2; "><h1 style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14pt; color: #000000; "><a href="http://my.oschina.net/u/152840/blog/36391" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #000000; outline-width: 0px; outline-style: initial; outline-color: initial; text-decoration: none; "><span class="Apple-style-span" style="outline-style: initial; outline-color: initial;">android4.0源码下载 编译 系统体验～图解</span><br /></a></h1></span><span class="Apple-style-span" style="font-family: Verdana, sans-serif, 宋体; line-height: normal; background-color: #f9f9f9; "><dl style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 18px; ">android4.0源码下载 编译 系统体验～图解</span></p></dd><dt style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#8212;&#8212;转自&nbsp;<a target="_blank" href="http://www.2cto.com/kf/201111/111551.html" rel="nofollow" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #4466bb; outline-width: 0px; outline-style: initial; outline-color: initial; ">http://www.2cto.com/kf/201111/111551.html</a>&nbsp;<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /></dt></dl><dl style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 近来着眼于ANDROID4.0的关注与研究，第一时间把ANDROID4.0<a href="http://www.2cto.com/ym" target="_blank" rel="nofollow" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #4466bb; outline-width: 0px; outline-style: initial; outline-color: initial; ">源码</a>下 下来了，只是时间问题，所以没能第一时间把过程记录下来，今天算是富裕点时间就给写下来，希望能给灼热于ANDROID继续平台研究而又未及时获得相关资 源的热机友们做个简单的参考，好了，废话不多说，我就直接贴图吧，现在很简单，只要你是LINUX系统，一直并使其开发，那就不必要考虑之前JDK环境的 问题，直接从基本环境确定下入手吧，首先打开http://www.android.com进入：</p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024706176.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; ">看到<span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; ">&nbsp;<a href="http://source.android.com/source/downloading.html" rel="nofollow" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #4466bb; outline-width: 0px; outline-style: initial; outline-color: initial; ">Getting the Source</a>,点击进入</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024706984.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; ">，进入页面后，里面有详细的<a href="http://www.2cto.com/soft" target="_blank" rel="nofollow" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: #4466bb; outline-width: 0px; outline-style: initial; outline-color: initial; ">下载</a>描述，不用说，一步步来，很简单的，与之前一样，首先创建目录: mkdir ~/bin,其次设置目录路径环境: PATH=~/bin:$PATH,然后就是下载REPO脚本来执行下面需要下载的任务:</span></p><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo &gt; ~/bin/repo</code></pre><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; ">然后就是赋予权限：chmod a+x ~/bin/repo ，准备要执行的任务OK了，下面，我们需要来创建一个目录单独存放其下咋的文件：mkdir WORKING_DIRECTORY(根据官方来吧，自己命名是OK的)，再就是进入其目录: cd WORKING_DIRECTORY,现在我来初始化要执行的是哪个版本吧，咋就直接吧主版本一起DOWN下来吧：</p><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">repo init -u https://android.googlesource.com/platform/manifest</code></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">如果你执行这个命令的话：</span></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1</code></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">上面就只能下载ANDROID4.0的内源码了，</span></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">所以我们还是执行前面的命令，把整个4.0的源码都DOWN下来吧，上面OK后，咋就可以开始把源码数据开始同步下来了：</span></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">repo sync</span></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">我截了些图，观察下吧，如果你有报错的话：</span></pre><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024707620.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">这是开始同步数据的截图，</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024707320.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">，下载基本不报错，没问题，速度也好行，但是完后很大，要注意的空间收否可岑收，OK，下载完后，先不要急，使用一下命令：</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024708493.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">我就直接截图了，其实就是根据GOOGLE官方的一次命令与操作来进行，这部是做相应的校验，</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024708212.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">好了，不多说了，以上工作完成后，基本可以开始编译了，编译很简单，GOOGLE这次简化了编译操作，先要初始化环境，我就直接截图了:</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024709313.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">,然后，通过 make -j4就可以开始编译了，</span></p><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">编译的过程比较慢，而且CPU基本成满状态，</span>我之前的版本基本不会超过3个小时，但是这个版本我竟然编译了12小时之多（我没到12点就睡觉了，看来我的机子需要升级了，IBM的笔记本还是i3的），过程中就简单那的截了些图：</pre><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024709970.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">，不知道各位 在编译源码的时候，有没有去看相应的编译过程或在编译后的日志，你注意观察的话，上面会有些简单的编译中遇到不严紧的CODE会做出提示，上面这个图的提 示：在external/icu4c/i18n/calendar.cpp：在成员函数'void icu_46::Calendar::setWeekData(const icu_46::Locale&amp;,const char*,UErrorCode&amp;)中：3260：88：警告：建议在'||'的操作数中出现的'&amp;&amp;'前面加上括号 【-Wparentheses】'，别看这简单的提示，作为程序员，它意味着什么，我在这里就不对其进行分解了，编码的养成一个好的习惯，我认为还是必须 的，OK，下面我就简单截几张编译过程的图吧，就不进行详细分解了，如果你有时间的话，介意你还是去把其日志找出来，好好的再看一下：</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024713381.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">，</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024713973.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">，当你看到这张图后，也就是宣告，编译结束:</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024714548.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">编译产生了相应的APK，与其systen,img,好了，如果你有设备的话，可以对其进行&#8216;烧鸡&#8217;了，不过在这里，我就直接启动模拟器来操作，就不烧了，如果你爱烧，你就自己烧去吧，启动模拟器，很简单：</span></pre><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">$ emulator</code></pre><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">启动后截图:</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024714240.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " />&nbsp;,</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">看到界面了吧，再截几张图</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024715772.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">，</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">欣赏下: ,现在的照相功能可以直接在模拟器中使用</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">:<img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024716925.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " />&nbsp;,</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">而且搜索操作更方便了，界面也更清晰：</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024717243.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " />&nbsp;</span></p></dd><dd style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /></p><pre style="padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; margin-top: 10px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 9pt; font-family: 'Courier New', Arial; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-top-color: #dddddd; border-right-color: #dddddd; border-bottom-color: #dddddd; border-left-width: 5px; border-left-style: solid; border-left-color: #6ce26c; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f6f6f6; background-position: initial initial; background-repeat: initial initial; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">Ok就截这点图先欣赏下吧，正在研究源码过程中，等研究透了，如果有时间，我会依次分享出来，希望能供其部分学者提供及时的帮助，先截个源码编译后的简单结构图吧:</span></pre><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; "><img alt="\" src="http://www.2cto.com/uploadfile/2011/1118/20111118024728363.gif" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; max-width: 540px; " /></span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; "><span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: 'Lucida Console', Monaco, monospace; ">部分图，但是是最后一张显示了文件数与目录数，这数字还是挺惊人的，好了，发烧友们，还等什么呢，赶快行动吧</span></p><p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; line-height: 20px; ">&nbsp;</p></dd></dl></span><span class="Apple-style-span" style="font-family: Verdana, sans-serif, 宋体; font-size: 13px; line-height: normal; background-color: #f2f2f2; "><h1 style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 14pt; color: #000000; "><a href="http://my.oschina.net/u/152840/blog/36391"></a></h1></span><img src ="http://www.blogjava.net/MEYE/aggbug/367939.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-01-05 17:57 <a href="http://www.blogjava.net/MEYE/articles/367939.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android 4.0 事件输入(Event Input)系统</title><link>http://www.blogjava.net/MEYE/articles/367928.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Thu, 05 Jan 2012 08:33:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/367928.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/367928.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/367928.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/367928.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/367928.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Android 4.0 事件输入(Event Input)系统http://blog.csdn.net/myarrow/article/details/7091061&nbsp;1. TouchScreen功能在Android4.0下不工作&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 原来在Android2.3.5下能正常工作的TouchScreen功能，移植到Andr...&nbsp;&nbsp;<a href='http://www.blogjava.net/MEYE/articles/367928.html'>阅读全文</a><img src ="http://www.blogjava.net/MEYE/aggbug/367928.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-01-05 16:33 <a href="http://www.blogjava.net/MEYE/articles/367928.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android4.0 与 android2.3 差异</title><link>http://www.blogjava.net/MEYE/articles/367924.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Thu, 05 Jan 2012 08:17:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/367924.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/367924.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/367924.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/367924.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/367924.html</trackback:ping><description><![CDATA[<div><font color="#666666" face="'Microsoft YaHei'" style="color: #666666; text-decoration: none; font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; text-align: left; background-color: #ffffff; "><span style="font-size: 20px; line-height: 30px; text-align: left; background-color: #ffffff;"><a href="http://blog.csdn.net/andyhuabing/article/details/7095834" title="Android4.0 与  android2.3 差异" style="color: #666666; text-decoration: none; font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; text-align: left; background-color: #ffffff; ">Android4.0 与 android2.3 差异</a></span></font><a href="http://blog.csdn.net/andyhuabing/article/details/7095834" style="background-color: #ffffff; font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; text-align: left; ">http://blog.csdn.net/andyhuabing/article/details/7095834</a><div style="text-align: left; text-decoration: none; background-color: #ffffff; "><div><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-size: 16px; ">自从2011-10-19 google公司发布了android4.0版本，下载源码后，一直没有时间看下，正好需要看下JoyStick(游戏手柄)框架代码，所以两者代码进行对比浏览看看。</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-size: 16px; "><br /></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-size: 16px; "><span style="font-family: sans-serif; line-height: 22px; ">Android系统差不多每半年一次的升级步伐，每代Android系统都以甜点命名，</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-size: 16px; "><span style="font-family: sans-serif; ">1.5版叫做Cupcake</span><span style="font-family: SimSun; ">（<a href="http://zh.wikipedia.org/wiki/%E7%BA%B8%E6%9D%AF%E8%9B%8B%E7%B3%95" title="纸杯蛋糕" style="color: #336699; text-decoration: none; background-color: initial; ">纸杯蛋糕</a>）</span></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-family: SimSun; font-size: 16px; ">1.6版为Donut（<a href="http://zh.wikipedia.org/wiki/%E7%94%9C%E7%94%9C%E5%9C%88" title="甜甜圈" style="color: #336699; text-decoration: none; background-color: initial; ">甜甜圈</a>）</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-family: SimSun; font-size: 16px; ">2.0/2.1叫&#201;clair（<a href="http://zh.wikipedia.org/w/index.php?title=%E9%97%AA%E7%94%B5%E6%B3%A1%E8%8A%99&amp;action=edit&amp;redlink=1" title="闪电泡芙" style="color: #336699; text-decoration: none; background-color: initial; ">闪电泡芙</a>，一种法式奶油夹心甜点）</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-family: SimSun; font-size: 16px; ">2.2版为Froyo（<a href="http://zh.wikipedia.org/wiki/%E5%86%BB%E9%85%B8%E5%A5%B6" title="冻酸奶" style="color: #336699; text-decoration: none; background-color: initial; ">冻酸奶</a>）</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-family: SimSun; font-size: 16px; ">2.3版为Gingerbread（<a href="http://zh.wikipedia.org/wiki/%E8%96%91%E9%A5%BC" title="姜饼" style="color: #336699; text-decoration: none; background-color: initial; ">姜饼</a>）</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-family: SimSun; font-size: 16px; ">3.0版叫Honeycomb（<a href="http://zh.wikipedia.org/wiki/%E8%9C%82%E7%AA%A9" title="蜂窝" style="color: #336699; text-decoration: none; background-color: initial; ">蜂窝</a>）及</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="line-height: 22px; "><span style="font-family: SimSun; font-size: 16px; ">4.0版称为Ice Cream Sandwich （<a href="http://zh.wikipedia.org/w/index.php?title=%E5%86%B0%E6%B7%87%E6%B7%8B%E4%B8%89%E6%98%8E%E6%B2%BB&amp;action=edit&amp;redlink=1" title="冰激凌三明治" style="color: #336699; text-decoration: none; background-color: initial; ">冰激凌三明治</a>）。以C D E F G H字头顺序排列</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: SimSun; font-size: 16px; "><span style="line-height: 22px; "><br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: SimSun; font-size: 16px; "><span style="line-height: 22px; ">=======================================================================================================<br /></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: SimSun; font-size: 16px; "><span style="line-height: 22px; ">从网上搜到的信息：（转自&nbsp;<a href="http://www.enet.com.cn/article/2011/1130/A20111130943222.shtml" style="color: #336699; text-decoration: none; ">http://www.enet.com.cn/article/2011/1130/A20111130943222.shtml</a>&nbsp;）</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: SimSun; "><span style="line-height: 22px; "></span></span></p><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 10px; margin-bottom: 10px; font-family: 宋体; line-height: 25px; "><strong>1.新的UI界面更加的人性化<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>相信关注安卓系统的朋友都看过了早些时候网上发布的Android4 .0系统界面。这次看看发布会上的照片吧。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />&nbsp;<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>2.新的通知系统<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>Android 4.0的通知系统有了很大的改进，用户可以自己决定哪些应用可以发送通知。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />Android 4.0的通知系统现在可以直接向侧面滑动删去通知条目，这样的操作也出现在应用管理列表中。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>3.语音输入系统和面部识别功能<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>Duarte说新系统的键盘在纠错、精度方面有了很大改进。他还演示了语音输入系统，说&#8220;smiley face&#8221;直接在输入框中插入一个笑脸。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>4.新的安卓浏览器<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>Android 4.0的浏览器现在直接支持将完整网页离线保存。比第三方应用更好的是该功能现在与默认浏览器完全集成。实现实时预览功能，单一手势关闭所有浏览器标签，快速访问台式机版网站。能够自动与Chrome浏览器实现数据同步。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>5.大幅强化了GMail<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />Android 4.0的Gmail大幅强化，浏览邮件时左右滑动直接切换上一封/下一封邮件。同时增加了离线搜索功能，可访问过去30天内收到的邮件。新的 GMail 界面，完全集成会话模式，大幅强化了GMail。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>6.数据使用管理功能<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>Android 4.0集成的数据追踪系统可以追踪、分析移动数据流量，设置移动数据使用上限，它集成于系统内部，功能非常齐全，第三方的数据流量管理工具前途堪忧。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />每月总是怕流量超过的朋友这回不用担心了，流量管理工具还能具体查看每个应用产生的流量。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>7.拍照模式的强化<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />Android 4.0所拍照片只需三次点击就能分享到G+、Facebook、Twitter等任意SNS服务，如果国行引入的话肯定会增加人人网，新浪微博等分享。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />Android 4.0新的照片应用现在可以像Instagram一样加滤镜，并且还能加相框、进行全景拍摄。并且相机可以识别人脸，集成 Zero Shutter 技术，快门反应极快，连拍很快。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>8.新加入的people应用<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />People应用是通讯录的进化，以联系人照片为核心，界面偏重滑动而非点击。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />People应用集成了其它通信工具，比如Twitter、Linkedin、Google+，不出意外的话还会支持自己添加第三方服务。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " />people应用与Gmail整合，点击邮件里的头像就能弹出附有大照片的快捷联系方式，通过Gmail、信息、第三方服务快速联系对方。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>9.Android Beam应用<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>Android Beam是基于NFC的分享方式，两部支持NFC的Android手机背靠背碰一下就能分享机上内容。该功能还会向第三方开放。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><strong>10.其他一些功能<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /><br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></strong>Android 4.0可以通过长按电源键和音量键截图，不再需要其它软件。<br style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; " /></p><p style="padding-top: 0px; padding-bottom: 0px; margin-top: 10px; margin-bottom: 10px; font-family: 宋体; line-height: 25px; ">加入新型&#8220;Roboto&#8221;字体，适用于高清显示屏，实时墙纸功能。</p><div style="color: #333333; font-family: Arial; line-height: 26px; font-size: 16px; ">=======================================================================================================</div><a href="http://www.enet.com.cn/" style="color: #000000; text-decoration: none; line-height: 26px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; font-family: 宋体; "></a><a href="http://www.enet.com.cn/" style="color: #000000; text-decoration: none; line-height: 26px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12px; font-family: 宋体; "></a><span style="color: #333333; font-family: Arial; line-height: 26px; ">其实一句话就搞定了：</span><span style="color: #333333; background-color: #f5f8fd; font-family: Simsun; line-height: 23px; ">谷歌新一代Android 4.0系统拥有全新设计的UI，界面简化，运行速度能力提升。系统内置全新的壁纸，在使用手机上的触摸按钮时会出现发光效果，并且增加了语音输入、人脸识别、照片编辑、流量监测、Android Beam功能。</span><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: SimSun; "><span style="line-height: 22px; "><span style="font-family: Simsun; line-height: 23px; background-color: #f5f8fd; "><br /></span></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: SimSun; "><span style="line-height: 22px; "><span style="font-family: Simsun; line-height: 23px; background-color: #f5f8fd; ">三个设计准则：取悦用户，简化生活，与众不同，Android4.0在设计中遵循了这样的准则，因此是一个幅度很大的升级。<br /></span></span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; line-height: 23px; ">=================================================================================================================================</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; "><span style="line-height: 23px; ">&nbsp; 但对于数字电视开发者来说，关心重点是如下几大亮点：</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; "><span style="line-height: 23px; ">&nbsp; &nbsp;<span style5"="">&nbsp;1、</span>全新设计的UI，拥有一流的新UI ，并且界面简化，运行速度提升</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2、运行速度大幅度提升</p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; ">&nbsp; &nbsp; &nbsp;3、系统对硬件没有要求</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; "><span style="line-height: 23px; ">&nbsp; &nbsp; 4、游戏支持能力提升</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; "><span style="line-height: 23px; ">&nbsp; &nbsp; 它们是怎么完成的，这些靠字面意思是搞不定的，那么就让我们一起来阅读其frameworks代码解读一下吧,大致了解一下吧。</span></span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; line-height: 23px; ">&nbsp; &nbsp; hardware 代码: 增加了hwcomposer.h（Hints are set by the HAL and read by SurfaceFlinger）；定义增加了audio及camera这块，以前2.3是没有这块的；对gralloc分成gpu及fb单独处理的模块，更清晰了。</span></p><p style="color: #333333; font-family: Arial; line-height: 26px; "><span style="font-family: Simsun; "><span style="line-height: 23px; ">&nbsp; &nbsp; bionic 标C代码： 虽然有393个文件发生变更，但主体功能上没有变动<br />&nbsp; &nbsp; build 这涉及到整个android系统的编译规则，差异达到82个文件，没有一个个的比较查看，后面开发编译过程中就会涉及到<br />&nbsp; &nbsp; frameworks 核心框架代码：这一块肯定是涉及到变化最大的点，从全新设计UI这块特性可以看出,差异文件达到3100个文件，并增加了9000个文件左右，这块变动相当大，就应该就是真正升级的核心点了。<br />&nbsp; &nbsp; libcore : 与媒体播放框架代码相关，后面再深入研究一下<br />&nbsp; &nbsp; dalvik虚拟机: 总共有671个文件发生变更，这一块的话我正在看2.3的虚拟机设计代码，后面再单独写出来<br />&nbsp; &nbsp; libcore : 与媒体播放框架代码相关，后面再深入研究一下<br />&nbsp; &nbsp; system：其中core是关于最小化可启动的环境代码，extras是针对底层调试及检查工具的代码，差异文件达到257个<br />&nbsp; &nbsp; prebuild: 工具链与以前的版本基本一致，不过ARM使用的arm-eabi-4.4.3进行了修改，具体点不得而知<br />&nbsp; &nbsp; external ： 增加了一些开源库代码<br />&nbsp; &nbsp; 对于SDK及NDK与移植无关，所以暂时没有关注它<br />&nbsp; &nbsp;&nbsp;<br />&nbsp; &nbsp; 整个代码量太大，从原来的2.3版本的1G左右到目前达到1.7G左右代码，这些增加及修改的代码够学习很久了，最好的方式还是边做边看边学吧，自然就熟悉起来了。</span></span></p></div></div><a href="http://blog.csdn.net/andyhuabing/article/details/7095834" title="Android4.0 与  android2.3 差异"></a></div><img src ="http://www.blogjava.net/MEYE/aggbug/367924.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-01-05 16:17 <a href="http://www.blogjava.net/MEYE/articles/367924.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> Android源码分析系列-整理篇</title><link>http://www.blogjava.net/MEYE/articles/367818.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 04 Jan 2012 02:12:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/367818.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/367818.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/367818.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/367818.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/367818.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; background-color: #ffffff; "><span class="ico ico_type_Original" style="display: inline-block; width: 19px; height: 19px; margin-top: 0px; margin-right: 2px; margin-bottom: 0px; margin-left: 0px; background-image: url(http://static.blog.csdn.net/images/ico_Original.gif); background-attachment: initial; background-origin: initial; background-clip: initial; vertical-align: middle; background-color: initial; background-position: 0px 0px; background-repeat: no-repeat no-repeat; "><span style="color: #333333; font-family: Arial, Console, Verdana, 'Courier New'; font-size: 12px; "><h1><a href="http://blog.csdn.net/hongtao_liu" style="color: #ddeeff; text-decoration: none; ">刘洪涛的专栏</a></h1></span></span>&nbsp;<h3 style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: inline; font: normal normal normal 20px/30px 'Microsoft YaHei'; vertical-align: middle; "><span class="link_title"><a href="http://blog.csdn.net/gzshun/article/details/7172389" title="Android源码分析系列-整理篇" style="color: #666666; text-decoration: none; ">Android源码分析系列-整理篇<br /></a></span></h3></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><strong><span style="font-size: 18px; ">作者：gzshun. 原创作品，转载请标明出处！<br />来源：<a href="http://blog.csdn.net/gzshun" style="color: #336699; text-decoration: none; ">http://blog.csdn.net/gzshun</a></span></strong><br /><br />本系列主要走了一下Android挂载SD卡的流程，从Vold到Framework，再从Framework到UI。也熟悉了谷歌写的C/C++源代码，提高一下自己的类的设计与代码的技巧，很感谢谷歌提供这么一个手机的开源操作系统Android，让鄙人也有机会来了解一下智能终端系统的实现原理。<br /><br />只要有C/C++的基础，就能够很流畅地分析完这一块代码，比较重要的还是Android的实现架构，代码倒没什么难题。<br />Android系统也出来好几年，这系列文章讲解的是Android-2.2源码，那时候还没有足够的成熟，通过这种没有足够的成熟<br />的系统，分析起来也相对容易一些，一个系统都会慢慢地发展，越来越规范，代码质量越高，但分析起来可能越吃力。<br /><br /><p>以下是所有文章的索引，供Android源码的兴趣爱好者查看，欢迎浏览。</p><p><a href="http://blog.csdn.net/gzshun/article/details/7096763" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android磁盘管理-系统源码分析(1)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7096802" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android磁盘管理-之vold源码分析(2)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7100547" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android磁盘管理-之vold源码分析(3)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7104340" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android磁盘管理-之vold源码分析(4)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7107351" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之handleBlockEvent(5)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7110296" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之startListener(6)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7163468" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之runCommand(7)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7163476" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之挂载SD卡(8)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7169421" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之卸载SD卡(9)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7170017" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之格式化SD卡(10)</span></strong></a><br /><br /><a href="http://blog.csdn.net/gzshun/article/details/7171781" style="color: #220000; text-decoration: none; "><strong><span style="font-size: 16px; ">Android-vold源码分析之连接电脑OTG(11)</span></strong></a><br /><br /><strong style="color: #336699; text-decoration: none; "><span style="font-size: 16px; "><a href="http://blog.csdn.net/gzshun/article/details/7172182" style="color: #336699; text-decoration: none; ">Android-Vold, Framework和UI的通信-大结局(12)<br /><br /><br /></a></span></strong></p></span><span class="Apple-style-span" style="color: #ffffff; font-family: 'Microsoft YaHei'; font-size: 30px; font-weight: bold; line-height: 30px; "><a href="http://blog.csdn.net/billowszpt" style="color: #ddeeff; text-decoration: none; ">billowszpt的专栏</a></span><span class="Apple-style-span" style="color: #333333; font-family: Arial, Console, Verdana, 'Courier New'; font-size: 12px; line-height: normal; "><span class="Apple-style-span" style="color: #ffffff; font-family: 'Microsoft YaHei'; font-size: 18px; line-height: 30px; "><a href="http://blog.csdn.net/billowszpt">http://blog.csdn.net/billowszpt<br /></a></span></span><span class="Apple-style-span" style="color: #414141; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 16px; background-color: #ffffff; "><h1 style="font-size: 1.7em; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; text-decoration: none; color: #333333; padding-top: 40px; "><a href="http://blog.donews.com/21cnbao/" style="color: #333333; text-decoration: none; ">Inside SW,FW and HW R&amp;D<br /></a><div><a href="http://blog.donews.com/21cnbao/">http://blog.donews.com/21cnbao/</a></div><a href="http://blog.donews.com/21cnbao/"></a></h1></span><span class="Apple-style-span" style="color: #333333; font-family: Arial, Console, Verdana, 'Courier New'; font-size: 12px; line-height: normal; "><div id="header" style="width: 980px; height: 30px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 50px; text-align: left; "><div class="header"><div id="blog_title"><div class="clear"></div></div><div class="clear"></div></div></div></span><span class="Apple-style-span" style="color: #333333; font-family: Arial, Console, Verdana, 'Courier New'; font-size: 12px; line-height: normal; "><h1 style="margin-top: 0px; margin-right: 20px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: inline-block; color: #ffffff; font: normal normal bold 30px/30px 'Microsoft YaHei'; "><font class="Apple-style-span" color="#ddeeff"><a href="http://blog.csdn.net/hongtao_liu" style="color: #ddeeff; text-decoration: none; ">刘洪涛的专栏</a></font></h1></span><span class="Apple-style-span" style="color: #333333; font-family: Arial, Console, Verdana, 'Courier New'; font-size: 12px; line-height: normal; "><a href="http://blog.csdn.net/hongtao_liu">http://blog.csdn.net/hongtao_liu</a><div id="navigator" style="display: block; clear: both; width: 980px; height: 42px; margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding-top: 22px; text-align: left; "><div class="navigator_bg"></div><div class="navigator" style="text-align: right; "><ul style="float: right; "></ul></div></div></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><p><a href="http://blog.csdn.net/gzshun/article/details/7172182" style="color: #336699; text-decoration: none; "><strong><span style="font-size: 16px; "><br /><br /></span></strong></a><br /></p></span><img src ="http://www.blogjava.net/MEYE/aggbug/367818.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2012-01-04 10:12 <a href="http://www.blogjava.net/MEYE/articles/367818.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android签名机制</title><link>http://www.blogjava.net/MEYE/articles/364503.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Tue, 22 Nov 2011 03:08:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/364503.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/364503.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/364503.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/364503.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/364503.html</trackback:ping><description><![CDATA[<div><h1>Android签名机制<br /><br /><div><a href="http://www.goafter.info/2011/07/24/26.html">http://www.goafter.info/2011/07/24/26.html</a></div><br /><br /><div><div><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">Android签名机制可划分为两部分：（1）ROM签名机制；（2）第三方APK签名机制。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">Android APK实际上是一个jar包，而jar包又是一个zip包。APK包的签名实际上使用的是jar包的签名机制：在zip中添加一个META的子目录，其中存放签名信息；而签名方法是为zip包中的每个文件计算其HASH值，得到签名文件(*.sf)，然后对签名文件(.sf)进行签名并把签名保存在签名块文件(*.dsa)中。<br /></p><h1><strong style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; font-weight: bold; background-position: initial initial; background-repeat: initial initial; ">ROM签名机制</strong></h1><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">在编译Android源码生成ROM的过程中，会使用build/target/product/security目录中的4个key（media, platform, shared, testkey）来对apk进行签名。其中，*.pk8是二进制形式（DER）的私钥，*.x509.pem是对应的X509公钥证书（BASE64编码）。build/target/product/security目录中的这几个默认key是没有密码保护的，只能用于debug版本的ROM。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">要生成Release版本的ROM，可先生成TargetFiles，再使用带密码的key对TargetFiles重新签名，最后由重签名的TargetFiles来生成最终的ROM。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">可以使用Android源码树中自带的工具&#8220;development/tools/make_key&#8221;来生成带密码的RSA公私钥对（实际上是通过openssl来生成的）:<br />$ development/tools/make_key media &#8216;/C=CN/ST=Sichuan/L=Chengdu/O=MyOrg/OU=MyDepartment/CN=MyName&#8217;<br />上面的命令将生成一个二进制形式（DER）的私钥文件&#8220;media.pk8&#8221;和一个对应的X509公钥证书文件&#8220;media.x509.pem&#8221;。其中，/C表示&#8220;Country Code&#8221;，/ST表示&#8220;State or Province&#8221;，/L表示&#8220;City or Locality&#8221;，/O表示&#8220;Organization&#8221;，/OU表示&#8220;Organizational Unit&#8221;，/CN表示&#8220;Name&#8221;。前面的命令生成的RSA公钥的e值为3，可以修改development/tools/make_key脚本来使用F4 (0&#215;10001)作为e值（openssl genrsa的-3参数改为-f4）。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">也可以使用JDK中的keytool来生成公私钥对，第三方APK签名一般都是通过keytool来生成公私钥对的。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">可以使用openssl x509命令来查看公钥证书的详细信息：<br />$ openssl x509 -in media.x509.pem -text -noout<br />or,<br />$ openssl x509 -in media.x509.pem -inform PEM -text -noout</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">还可以使用JDK中的keytool来查看公钥证书内容，但其输出内容没有openssl x509全面：<br />$ keytool -printcert -v -file media.x509.pem</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">有了key之后，可以使用工具&#8220;build/tools/releasetools/sign_target_files&#8221;来对TargetFiles重新签名：<br />$ build/tools/releasetools/sign_target_files_apks -d new_keys_dir -o target_files.zip target_files_resigned.zip<br />其中，new_keys_dir目录中需要有四个key（media, platform, shared, releasekey）。注意：这里的releasekey将代替默认的testkey（请参考build/tools/releasetools/sign_target_files脚本实现），也就是说，如果某个apk的Android.mk文件中的LOCAL_CERTIFICATE为testkey，那么在生成TargetFiles时是使用的build/target/product/security/testkey来签名的，这里重新签名时将使用new_keys_dir/releasekey来签名。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">build/tools/releasetools/sign_target_files_apks是通过host/linux-x86/framework/signapk.jar来完成签名的。也可以直接使用host/linux-x86/framework/signapk.jar来对某个apk进行签名：<br />$ java -jar signapk [-w] publickey.x509[.pem] privatekey.pk8 input.jar output.jar<br />其中，&#8221;-w&#8221;表示还对整个apk包(zip包）进行签名，并把签名放在zip包的comment中。</p><h1><strong style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; font-weight: bold; background-position: initial initial; background-repeat: initial initial; ">第三方APK签名机制</strong></h1><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">对于第三方应用开发者而言，对APK签名相对要简单得多。第三方应用开发一般采用JDK中的keytool和jarsigner来完成签名密钥的管理和APK的签名。</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">使用keytool来生成存储有公私钥对的keystore：<br />$ keytool -genkey -v -keystore my-release-key.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 10000</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">查看生成的密钥信息：<br />$ keytool -list -keystore my-release-key.keystore -alias mykey -v<br />or,<br />$ keytool -list -keystore my-release-key.keystore -alias mykey -rfc<br />（注：获取Base64格式的公钥证书，RFC 1421）</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">导出公钥证书：<br />$ keytool -export -keystore mystore -alias mykey -file my.der<br />（注：二进制格式公钥证书，DER）<br />$ keytool -export -keystore mystore -alias mykey -file my.pem -rfc<br />（注：Base64格式公钥证书，PEM）</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">对APK进行签名：<br />$ jarsigner -verbose -keystore my-release-key.keystore my_application.apk mykey</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">验证签名：<br />$ jarsigner -verify -verbose -certs my_application.apk</p><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; ">在进行Android二次开发时，有时需要把build/target/product/security下面的公私钥对转换为keystore的形式，可以参考这篇文章：<a href="http://www.goafter.info/2011/07/09/36.html" title="把Android源码中的密码对转换为keystore的方法" target="_blank" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #0066cc; background-position: initial initial; background-repeat: initial initial; ">把Android源码中的密码对转换为keystore的方法</a>。</p></div><div><p style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #ffffff; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 24px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline; color: #333333; font-family: Georgia, 'Bitstream Charter', serif; font-size: 16px; font-weight: normal; line-height: 24px; "></p></div></div></h1></div><img src ="http://www.blogjava.net/MEYE/aggbug/364503.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-11-22 11:08 <a href="http://www.blogjava.net/MEYE/articles/364503.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>property_get/property_set</title><link>http://www.blogjava.net/MEYE/articles/359773.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Thu, 29 Sep 2011 03:33:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/359773.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/359773.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/359773.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/359773.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/359773.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="color: #333333; font-family: 'AR PL UKai CN'; font-size: 12px; line-height: normal; background-color: #ffffff; "><h2 class="entry-title" style="margin-top: 10px; margin-right: 0px; margin-bottom: 0px; margin-left: 70px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 2.6em; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; color: #006699; "><a href="http://my.unix-center.net/~Simon_fu/?p=957" rel="bookmark" title="Permanent link to " style="color: #336699; text-decoration: none; outline-style: none; outline-width: initial; outline-color: initial; ">Android属性系统</a></h2></span><span class="Apple-style-span" style="color: #006699; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; font-size: 36px; font-weight: bold; line-height: normal; background-color: #ffffff; "><a href="http://my.unix-center.net/~Simon_fu/?p=957" rel="bookmark" title="Permanent link to " style="color: #333333; text-decoration: none; outline-style: none; outline-width: initial; outline-color: initial; ">(翻译)Android属性系统</a></span><span class="Apple-style-span" style="font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; background-color: #ffffff; "><a href="http://blog.csdn.net/xujianqun/article/details/6363318" title="property_get/property_set" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; "></a><div><a href="http://blog.csdn.net/xujianqun/article/details/6363318" title="property_get/property_set" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; "><br /></a><a href="http://my.unix-center.net/~Simon_fu/?p=957">http://my.unix-center.net/~Simon_fu/?p=957</a></div></span><span class="Apple-style-span" style="color: #333333; line-height: normal; background-color: #ffffff; "><div class="entry-content" style="font-family: 'AR PL UKai CN'; font-size: 12px; margin-bottom: 2em; font: normal normal normal 1.25em/normal Tahoma, Verdana, Arial, sans-serif; line-height: 1.5; letter-spacing: 0.1em; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4"><br />&nbsp; &nbsp; 属性（property）系统对Android来说是一个重要的功能。他作为一个系统服务管理着系统的配置和状态，所有的这些系统配置和状态都是属性（property）。属性（property）是一对键/值（key/value）组合，键和值都是字符串类型。总体感觉属性系统非常像Windows的注册表的功能。Androd中非常多的应用程序和库直接或者间接的依赖于属性系统，并由此决定其运行期的行为。例如：adbd进程通过属性来决定是否当前运行在模拟器中。再比如：</font><a href="http://developer.android.com/reference/java/io/File.html#pathSeparator" style="color: #006699; text-decoration: underline; outline-style: none; outline-width: initial; outline-color: initial; font-style: normal; "><font size="4">java.io.File.pathSeparator</font></a><font size="4">方法返回存储在属性服务中的值。</font></p><h3 style="margin-top: 1.1em; margin-right: 0px; margin-bottom: 0.4em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.5em; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; "><font size="4">属性系统怎样工作</font></h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 属性系统宏观的结构图如下所示：</font><img src="http://api.photoshop.com/v1.0/accounts/a6dba90e84ba45f8aa3ec8f7953a00d0/assets/3895cb2ea2cd46e89c4e155b85efcbdf" width="576" height="496" style="margin-top: 0.6em; margin-right: auto; margin-bottom: 0.6em; margin-left: auto; display: block; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccc99; border-right-color: #cccc99; border-bottom-color: #cccc99; border-left-color: #cccc99; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; float: none; " alt="" /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 从图中我们可以看出Android属性系统由有三个进程，一组属性文件和一块共享内存组成。这块共享内存保存着系统中所有的属性记录，只有Property service能写这块共享内存，并且Property service负责将属性文件中的属性记录加载到共享内存中。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 属性读取进程（property consumer）把这块共享内存映射到自己的进程空间，然后直接读取它。属性设置进程（property setter）也加载这块共享到他的进程空间，但是他不能直接写这块共享内存。当他需要增加或者修改属性的时候，通过Unix Socket发生属性给Property service，Property service将代表设置进程写入共享内存和属性文件。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; Property service运行于init进程中。init进程首先创建一块共享内存，并把他的句柄fd存放在这块内存中，init进程通过mmap带MAP_SHARE标志的系统调用，把这块内存映射到他的虚拟空间中，最终这块内存所有的更新将会被所有映射这块共享内存的进程看到。共享内存句柄fd和共享内存大小存储在系统环境变量&#8220;ANDROID_PROPERTY_WORKSPACE&#8221;中，所有的进程包括属性设置进程和属性读取进程都将通过这个系统环境变量获得共享内存的句柄fd和大小，然后把这块内存映射到他们自己的虚拟空间。共享内存布局如下：<img src="http://api.photoshop.com/v1.0/accounts/a6dba90e84ba45f8aa3ec8f7953a00d0/assets/ff3cbb3cbd2e41a79b91f99dd69b0a7a" width="720" height="502" style="margin-top: 0.6em; margin-right: auto; margin-bottom: 0.6em; margin-left: auto; display: block; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccc99; border-right-color: #cccc99; border-bottom-color: #cccc99; border-left-color: #cccc99; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; float: none; " alt="" /></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 然后，init进程将会从以下文件中加载属性：</font></p><div id="codeSnippetWrapper" style="border-bottom-color: silver; border-bottom-width: 1px; border-bottom-style: solid; text-align: left; border-left-color: silver; border-left-width: 1px; border-left-style: solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin-top: 20px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-left: 4px; width: 797px; padding-right: 4px; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow-x: auto; overflow-y: auto; border-top-color: silver; border-top-width: 1px; border-top-style: solid; cursor: text; border-right-color: silver; border-right-width: 1px; border-right-style: solid; padding-top: 4px; "><div id="codeSnippet" style="border-bottom-style: none; text-align: left; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; width: 797px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow-x: visible; overflow-y: visible; "><pre style="background-color: white; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #6699cc; border-right-color: #6699cc; border-bottom-color: #6699cc; border-left-color: #6699cc; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; font-size: 8pt; overflow-x: visible; overflow-y: visible; text-align: left; line-height: 12pt; width: 797px; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; "><span id="lnum1" style="color: #606060; ">   1:</span> /<span style="color: #0000ff; ">default</span>.prop</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></p><pre style="background-color: #f4f4f4; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #6699cc; border-right-color: #6699cc; border-bottom-color: #6699cc; border-left-color: #6699cc; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: -10px; margin-right: 0em; margin-bottom: -10px; margin-left: 0em; font-size: 8pt; overflow-x: visible; overflow-y: visible; text-align: left; line-height: 10pt; width: 797px; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; "><span id="lnum2" style="color: #606060; ">   2:</span> /system/build.prop</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></p><pre style="background-color: white; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #6699cc; border-right-color: #6699cc; border-bottom-color: #6699cc; border-left-color: #6699cc; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0em; margin-right: 0em; margin-bottom: 0em; margin-left: 0em; font-size: 8pt; overflow-x: visible; overflow-y: visible; text-align: left; line-height: 12pt; width: 797px; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; "><span id="lnum3" style="color: #606060; ">   3:</span> /system/<span style="color: #0000ff; ">default</span>.prop</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></p><pre style="background-color: #f4f4f4; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-top-color: #6699cc; border-right-color: #6699cc; border-bottom-color: #6699cc; border-left-color: #6699cc; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: -10px; margin-right: 0em; margin-bottom: -10px; margin-left: 0em; font-size: 8pt; overflow-x: visible; overflow-y: visible; text-align: left; line-height: 10pt; width: 797px; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; "><span id="lnum4" style="color: #606060; ">   4:</span> /data/<span style="color: #0000ff; ">local</span>.prop</pre><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "></p></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 下一步是启动Property service。这步中，将会创建一个Unix Socket服务器，这个Socket有一个闻名的名称&#8220;/dev/socket/property_service&#8221;。最后init进入死循环，等待socket的连接请求。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 在读取进程中，当它初始化libc库的时候，将会获得属性系统共享内存的句柄和大小（bionic/libc/bionic/libc_init_common.c __libc_init_common函数）。并把这块共享内存映射到自己的进程虚拟空间中(bionic/libc/bionic/system_properties.c __system_properties_init函数)。这样读取进程将会向访问普通内存一样访问属性系统的共享内存了。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 当前，属性不能被删除。也就是说一旦属性被创建，将不可以被删除，但是它们可以被修改。</font></p><h3 style="margin-top: 1.1em; margin-right: 0px; margin-bottom: 0.4em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.5em; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; "><font size="4">怎样获得和设置属性</font></h3><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 在Android中有三种方式来设置和获取属性：</font></p><h4 style="margin-top: 1.1em; margin-right: 0px; margin-bottom: 0.4em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.4em; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; "><font size="4">1、Native代码</font></h4><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 当编写Native的程序时，可以使用property_get和property_set API来获得和设置属性。使用这两个API必须要包含头文件</font><a href="http://android.git.kernel.org/?p=platform/system/core.git;a=blob_plain;f=include/cutils/properties.h;hb=HEAD" style="color: #006699; text-decoration: underline; outline-style: none; outline-width: initial; outline-color: initial; font-style: normal; "><font size="4">cutils/properties.h</font></a><font size="4">和链接libcutil库。</font></p><h4 style="margin-top: 1.1em; margin-right: 0px; margin-bottom: 0.4em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.4em; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; "><font size="4">2、Java代码</font></h4><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; Android在Java库中提供System.getProperty和System.setProperty方法，我们Java程序可以通过他们来设置和获得属性。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp;&nbsp; 但是请注意！虽然从语法上面看Java的代码和Native代码非常相近，但是Java版本存储把属性存在其他地方，而不是我们上面提到的属性系统中。在JVM中有一个hash表来维护Java的属性。所以Java属性和Android属性是不同的，不能用Java API（System.getProperty和System.setProperty）来设置系统属性。也不能通过Native的方法（property_get和property_set）设置Java的属性。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><em><font size="4">更新：</font></em><a href="http://www.blogger.com/profile/05994145452840699653" style="color: #006699; text-decoration: underline; outline-style: none; outline-width: initial; outline-color: initial; font-style: normal; "><em><font size="4">Andrew</font></em></a><em><font size="4">指出android.os.SystemProperties可以操作Android系统属性（虽然这个类倾向于内部使用）。这个类通过JNI调用Native的property_get和property_set方法来获得和设置属性。</font></em></p><h4 style="margin-top: 1.1em; margin-right: 0px; margin-bottom: 0.4em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.4em; font-family: Georgia, Garamond, 'Times New Roman', sans-serif; "><font size="4">3、Shell脚本</font></h4><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4">&nbsp;&nbsp; Android提供了命令行工具setprop和getprop来设置和获取属性，他们可以在脚本中被使用。</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="4"></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><font size="2">原文：</font><a href="http://rxwen.blogspot.com/2010/01/android-property-system.html" style="color: #006699; text-decoration: underline; outline-style: none; outline-width: initial; outline-color: initial; font-style: normal; "><font size="2">http://rxwen.blogspot.com/2010/01/android-property-system.html</font></a></p></div></span><span class="Apple-style-span" style="font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; background-color: #ffffff; "><a href="http://blog.csdn.net/xujianqun/article/details/6363318" title="property_get/property_set" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; "></a><div><a href="http://blog.csdn.net/xujianqun/article/details/6363318" title="property_get/property_set" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; "></a><a href="http://my.unix-center.net/~Simon_fu/?p=957"><br /></a></div></span><span class="Apple-style-span" style="color: #333333; font-family: Arial; line-height: 26px; background-color: #ffffff; "><p class="MsoListParagraph" style="padding-left: 30px; ">以上翻译自http://rxwen.blogspot.com/2010/01/android-property-system.html，有修正。</p><p class="MsoListParagraph" style="padding-left: 30px; "><span style="font-family: mceinline; "><br /><br /><div><a href="http://blog.csdn.net/jackyu613/article/details/6136620">http://blog.csdn.net/jackyu613/article/details/6136620</a></div></span></p><p class="MsoNormal"><span lang="EN-US"><span style="font-family: mceinline; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: mceinline; ">补充：通过查看</span><span lang="EN-US"><span style="font-family: mceinline; ">property_service.c</span></span><span style="font-family: mceinline; ">，我们可以明确以下事实：</span></p><p class="MsoListParagraph" style="padding-left: 30px; "><span lang="EN-US"><span style="font-family: mceinline; ">1、&nbsp;&nbsp;</span></span><span style="font-family: mceinline; ">属性名不是随意取的。在</span><span lang="EN-US"><span style="font-family: mceinline; ">property_perms</span></span><span style="font-family: mceinline; ">数组中定义了当前系统上可用的所有属性的前缀，以及相对应的存取权限</span><span lang="EN-US"><span style="font-family: mceinline; ">UID</span></span><span style="font-family: mceinline; ">。对属性的设置要满足权限要求，同时命名也要在这些定义的范围内。</span></p><p class="MsoListParagraph" style="padding-left: 30px; "><span lang="EN-US"><span style="font-family: mceinline; ">2、&nbsp;&nbsp;</span></span><span lang="EN-US"><span style="font-family: mceinline; ">PA_COUNT_MAX</span></span><span style="font-family: mceinline; ">指定了系统（共享内存区域中）最多能存储多少个属性。</span></p><p class="MsoListParagraph" style="padding-left: 30px; "><span lang="EN-US"><span style="font-family: mceinline; ">3、&nbsp;&nbsp;</span></span><span lang="EN-US"><span style="font-family: mceinline; ">PROP_NAME_MAX</span></span><span style="font-family: mceinline; ">指定了一个属性的</span><span lang="EN-US"><span style="font-family: mceinline; ">key</span></span><span style="font-family: mceinline; ">最大允许长度；</span><span lang="EN-US"><span style="font-family: mceinline; ">PROP_VALUE_MAX</span></span><span style="font-family: mceinline; ">则指定了</span><span lang="EN-US"><span style="font-family: mceinline; ">value</span></span><span style="font-family: mceinline; ">的最大允许长度。</span></p><p class="MsoListParagraph" style="padding-left: 30px; "><span style="font-family: mceinline; ">此外，http://blog.csdn.net/tekkamanitachi/archive/2009/06/18/4280982.aspx 这篇文章翻译了Android的官方文档，从另一个角度叙述了属性系统，需要者请参看。</span></p></span><span class="Apple-style-span" style="font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; background-color: #ffffff; "><div><a href="http://my.unix-center.net/~Simon_fu/?p=957"><br /><br /></a></div><br /><font class="Apple-style-span" color="#333333" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; ">property_get/property_set</font><br /><br /></span><div><a href="http://blog.csdn.net/xujianqun/article/details/6363318">http://blog.csdn.net/xujianqun/article/details/6363318<br /><br /></a><span class="Apple-style-span" style="font-family: Arial; line-height: 26px; background-color: #ffffff; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">每个属性都有一个名称和值，他们都是字符串格式。属性被大量使用在Android系统中，用来记录系统设置或进程之间的信息交换。属性是在整个系统中全局可见的。每个进程可以get/set属性。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>在系统初始化时，Android将分配一个共享内存区来存储的属性。这些是由&#8220;init&#8221;守护进程完成的，其源代码位于：device/system/init。&#8220;init&#8221;守护进程将启动一个属性服务。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>属性服务在&#8220;init&#8221;守护进程中运行。每一个客户端想要设置属性时，必须连接属性服务，再向其发送信息。属性服务将会在共享内存区中修改和创建属性。任何客户端想获得属性信息，可以从共享内存直接读取。这提高了读取性能。 客户端应用程序可以调用libcutils中的API函数以GET/SET属性信息。libcutils的源代码位于：device/libs/cutils。API函数是：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">int property_get(const char *key, char *value, const char *default_value);</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">int property_set(const char *key, const char *value);</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>而libcutils又调用libc中的 __system_property_xxx 函数获得共享内存中的属性。libc的源代码位于：device/system/bionic。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>属性服务调用libc中的__system_property_init函数来初始化属性系统的共享内存。当启动属性服务时，将从以下文件中加载默认属性：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">/default.prop</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">/system/build.prop</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">/system/default.prop</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">/data/local.prop</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>属性将会以上述顺序加载。后加载的属性将覆盖原先的值。这些属性加载之后，最后加载的属性会被保持在/data/property中。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>特别属性 如果属性名称以&#8220;ro.&#8221;开头，那么这个属性被视为只读属性。一旦设置，属性值不能改变。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>如果属性名称以&#8220;persist.&#8221;开头，当设置这个属性时，其值也将写入/data/property。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>如果属性名称以&#8220;net.&#8221;开头，当设置这个属性时，&#8220;net.change&#8221;属性将会自动设置，以加入到最后修改的属性名。（这是很巧妙的。 netresolve模块的使用这个属性来追踪在net.*属性上的任何变化。）</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>属性&#8220; ctrl.start &#8221;和&#8220; ctrl.stop &#8221;是用来启动和停止服务。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; white-space: pre; ">	</span>每一项服务必须在/init.rc中定义.系统启动时，与init守护进程将解析init.rc和启动属性服务。一旦收到设置&#8220; ctrl.start &#8221;属性的请求，属性服务将使用该属性值作为服务名找到该服务，启动该服务。这项服务的启动结果将会放入&#8220; init.svc.&lt;服务名&gt;&#8220;属性中 。客户端应用程序可以轮询那个属性值，以确定结果</p></span><a href="http://blog.csdn.net/xujianqun/article/details/6363318"></a></div><img src ="http://www.blogjava.net/MEYE/aggbug/359773.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-09-29 11:33 <a href="http://www.blogjava.net/MEYE/articles/359773.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android Recoveryの流程分析</title><link>http://www.blogjava.net/MEYE/articles/359771.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Thu, 29 Sep 2011 03:24:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/359771.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/359771.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/359771.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/359771.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/359771.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; background-color: #ffffff; "><a href="http://blog.csdn.net/xujianqun/article/details/6652531" title="Android Recoveryの流程分析" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; ">Android Recoveryの流程分析<br /></a></span><div><a href="http://blog.csdn.net/xujianqun/article/details/6652531">http://blog.csdn.net/xujianqun/article/details/6652531<br /></a><span class="Apple-style-span" style="font-family: Arial; line-height: 26px; background-color: #ffffff; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">关于recovery的代码分析，见另一篇</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Microsoft YaHei'; font-size: 20px; line-height: 30px; "><a href="http://blog.csdn.net/xujianqun/article/details/6662624" title="Android Recoveryの代码分析" target="_blank" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; ">Android Recoveryの代码分析</a></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><a href="http://blog.csdn.net/xujianqun/article/details/6662624" title="Android Recoveryの代码分析" target="_blank" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #333333; text-decoration: none; "></a><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 'Microsoft YaHei'; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 20px; line-height: 30px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></span></span>做个升级程序，支持SD卡、U盘、Flash三种路径升级</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">该升级应用程序要和/recovery/sbin/下的recovery配套使用，</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">固件共有boot.img，recovery.img，system.img，</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">其中system.img是空的，system.img打包格式要和recovery.img匹配</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">使用此程序：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">先把librecovery.so是添加到rootfs文件系统库中，</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">再把应用程序recovery_sample添加到某目录下，</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">然后执行recovery_sample就可以实现update功能</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">文档包括四部分：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;update<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; ">库和应用文件</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;update<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; ">使用及命令</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;输入命令格式例子</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;update/recovery<span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; ">界面</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: 宋体; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">1、Update库和应用文件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">文件一：Recovery</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">是存在于/gingerbread/bootable/，用于生成recovery可执行文件，生成完将其拷贝到UpdateRecoveryfs/recoveryfs/sbin/目录下</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">文件二：UpdateLibSample</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">用于生成update应用的库文件librecovery.so和可执行文件recovery_sample</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">文件三：UpdateRecoveryfs</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">用于生成recovery.img，有ramdisk和cramfs两种格式</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">文件四：UpdateRootfs</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">用于生成boot.img，有ramdisk和cramfs两种格式</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />ramdisk 格式：<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />./mkbootfs recoveryfs | ./minigzip &gt; ramdisk-recovery.img &amp;&amp; \<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./mkkrnlimg ramdisk-recovery.img recovery.img</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">rm ramdisk-recovery.img</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />Cramfs 格式：<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />./mkfs.cramfs -n v1.01 recoveryfs recovery.img<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Boot.img和recovery.img打包格式要一致，统一为ramdisk或者cramfs</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">流程图</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img src="http://hi.csdn.net/attachment/201108/3/0_1312335954OOnp.gif" alt="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img src="http://hi.csdn.net/attachment/201108/3/0_13123359600s4b.gif" alt="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img src="http://hi.csdn.net/attachment/201108/3/0_1312335966EzHe.gif" alt="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">两种打包格式</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">ramdisk格式：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./mkbootfs&nbsp;recoveryfs&nbsp;|&nbsp;./minigzip&nbsp;&gt;&nbsp;ramdisk-recovery.img&nbsp;&amp;&amp;&nbsp;\</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./mkkrnlimg&nbsp;ramdisk-recovery.img&nbsp;recovery.img</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">rm&nbsp;ramdisk-recovery.img</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Cramfs格式：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./mkfs.cramfs&nbsp;-n&nbsp;v1.01&nbsp;recoveryfs&nbsp;recovery.img</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2、update使用及命令</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">输入&nbsp;./recovery_sample可以查看帮助</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">==============================================================</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">快捷方式&nbsp;&nbsp;等效命令</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2 --wipe_cache格式化cache</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">3 --wipe_userdata格式化用户数据</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">4 --wipe_udisk格式化U盘数据</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">6 --recover_image=BACKUP:update.img恢复出厂设置，从backup还原所有固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">7 --update_image=SDCARD:update.img默认路径，从SD卡根目录下固件update.img升级</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">9 --update_kernel单独升级kernel，从SD卡update.img中取得kernel固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">10 --update_boot单独升级boot，从SD卡update.img中取得boot固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">11 --update_system单独升级system，从SD卡update.img中取得system固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">12 --update_recovery单独升级recovery，从SD卡update.img中取得recovery固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">13 --update_backup单独升级backup分区，拷贝SD卡的update.img到backup</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">14 --update_parameter单独升级parameter，从SD卡update.img中取得parameter</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">15 --update_loader单独升级loader，从SD卡update.img中取得loader</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">16 (user&nbsp;define&nbsp;path&nbsp;name)&nbsp;手动输入升级固件路径及固件名</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">==============================================================</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img src="http://hi.csdn.net/attachment/201108/2/0_1312246342Zhi0.gif" alt="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;2-4三个功能实现单独或者同时擦除cache&nbsp;userdata&nbsp;udisk内容</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;6&nbsp;功能recover_image=BACKUP:update.img是从BACKUP分区获取update.img，然后取出recovery-script脚本命令并执行，还原固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;9-15七个功能分别实现升级kernel、boot、system、recovery、backup、parameter和loader，如果没有指定升级固件路径和名称，默认是SDCARD:update.img。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">l&nbsp;16&nbsp;功能是自定义升级固件的路径和名称</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">3、输入命令格式例子</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&#216;&nbsp;格式化cache</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./recovery_sample 2</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&#216;&nbsp;从backup还原所有固件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./recovery_sample 6</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&#216;&nbsp;格式化和升级混合,用空格隔开</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./recovery_sample 2&nbsp;3&nbsp;4&nbsp;12</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&#216;&nbsp;手动输入升级命令，自定义升级固件路径和名称</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./recovery_sample&nbsp;--update_image=BACKUP:update.img<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />./recovery_sample&nbsp;--update_image=SDCARD:/rockchip/rkdroid.img&nbsp;9<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />./recovery_sample&nbsp;--update_image=CACHE:/cache/update.img&nbsp;9&nbsp;14&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">./recovery_sample&nbsp;--update_image=uDisk:update.img&nbsp;11</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">注意，在从mtd分区升级之前需要把分区mount到某个文件，然后把固件拷贝到这个文件目录下</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">10个MTD分区对应名字和信息如下：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">#cat proc/mtd</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">dev:&nbsp;&nbsp;&nbsp;&nbsp;size&nbsp;&nbsp;&nbsp;erasesize&nbsp;&nbsp;name</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd0:&nbsp;00400000&nbsp;00001000&nbsp;"misc"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd1:&nbsp;00800000&nbsp;00001000&nbsp;"kernel"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd2:&nbsp;00400000&nbsp;00001000&nbsp;"boot"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd3:&nbsp;00800000&nbsp;00001000&nbsp;"recovery"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd4:&nbsp;10000000&nbsp;00001000&nbsp;"system"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd5:&nbsp;10400000&nbsp;00001000&nbsp;"backup"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd6:&nbsp;07400000&nbsp;00001000&nbsp;"cache"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd7:&nbsp;10000000&nbsp;00001000&nbsp;"userdata"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd8:&nbsp;00400000&nbsp;00001000&nbsp;"kpanic"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">mtd9:&nbsp;3dd00000&nbsp;00001000&nbsp;"user"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">例如从cache升级，需要把cache挂接到/dev/mtdblock6，就可以从cache升级了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img src="http://hi.csdn.net/attachment/201108/2/0_1312246329Xo1y.gif" alt="" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">4、recovery界面说明</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Reset以后按住home+power组合键，可直接进入recovery/update界面。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">在log中如果看到</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">RECOVERY&nbsp;key&nbsp;is&nbsp;pressed</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">COMBINATION&nbsp;key&nbsp;is&nbsp;pressed</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">说明将要进入recovery模式</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><table style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><tbody style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">按键：</p></td><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">说明：</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">vol+&nbsp;</p></td><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">向下，支持菜单循环选择</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">vol&nbsp;-&nbsp;</p></td><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">向上，支持菜单循环选择</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Play&nbsp;</p></td><td valign="top" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">确认当前选择</p></td></tr></tbody></table><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">按键可以自己定义，修改gingerbread/bootable/recovery/etc/int.rc</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">菜单说明：</p><table style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><tbody style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Options</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">名称</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Description</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Reboot&nbsp;system&nbsp;now</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">重启系统</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">立即重启系统</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Factory&nbsp;reset</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">恢复出厂设置</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">1.&nbsp;从backup分区获取update.img&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2.&nbsp;还原除了backup以外所有分区固件<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />3.&nbsp;格式化USERDATA&nbsp;<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />4.&nbsp;格式化CACHE</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Update&nbsp;from&nbsp;SDCard</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">从SD卡升级</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">1.&nbsp;从&#8220;update-script&#8221;获取升级命令&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2.&nbsp;从SD卡根目录获取升级固件update.im<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />3.&nbsp;升级所有固件，除了BACKUP分区<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />4.&nbsp;不擦除用户数据</p></td></tr><tr style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Update&nbsp;from&nbsp;uDisk</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">从U盘升级</p></td><td valign="middle" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">1.&nbsp;从&#8220;update-script&#8221;获取升级命令&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">2.&nbsp;从uDisk根目录获取升级固update.img<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />3.&nbsp;升级所有固件，除了BACKUP分区<br style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " />4.&nbsp;不擦除用户数据</p></td></tr></tbody></table></span><a href="http://blog.csdn.net/xujianqun/article/details/6652531"></a></div><img src ="http://www.blogjava.net/MEYE/aggbug/359771.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-09-29 11:24 <a href="http://www.blogjava.net/MEYE/articles/359771.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>创建一个刷机包，update-script脚本语法说明</title><link>http://www.blogjava.net/MEYE/articles/359006.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Mon, 19 Sep 2011 09:47:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/359006.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/359006.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/359006.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/359006.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/359006.html</trackback:ping><description><![CDATA[<span style="font-family: Verdana, Helvetica, Arial, sans-serif; ">创建一个刷机包，update-script脚本语法说明</span><div><span style="font-family: Verdana, Helvetica, Arial, sans-serif; "><a href="http://products.mobileuncle.com/viewthread.php?action=printable&amp;tid=65251">http://products.mobileuncle.com/viewthread.php?action=printable&amp;tid=65251</a></span></div><div></div><div></div><div><span style="font-family: Verdana, Helvetica, Arial, sans-serif; "><br />目前有好几种方法来安装软件或是库文件到你的Android手机上。你可以使用市场程序来查找并安装软件，也可以使用adb命令行工具来安装或是发送文件到你的Android文件系统中。这些方法对于操作单个文件来说都挺方便的，但是如果你需要一次性安装多个软件或是库文件时，那么最为方便的方法大概就是使用update.zip（也就是刷机包）文件了。Android系统使用恢复工具（recovery）来安装这个update.zip文件中的软件或库文件到Android文件系统中。而一个ROM或是主题开发者通常都是使用这个方式来发布他们的作品（刷机包）。<br />&nbsp; &nbsp;&nbsp; &nbsp;创建一个update.zip文件是很简单的事情，你所需要做的就是将文件放置到与Android文件系统中相对应的文件夹中，然后编写一个用来复制这些文件到手机对应位置的updater-script, 文件。作为举例，本文会安装Calculator.apk到system/app文件夹，复制libsec-ril.so文件到system/lib文件夹：新建一个空文件夹(本文例：C:\android)新建用来放置Calculator.apk的文件夹C:\android\system\app以及用来放置libsec-ril.so的文件夹C:\android\system\lib。创建用来放置update-script文件的文件夹C:\android\META-INF\com\google\android。<br />&nbsp; &nbsp;&nbsp; &nbsp;创建一个名为updater-script的文件，其内容如下：<br />show_progress 0.1 0<br /><br />copy_dir PACKAGE:system SYSTEM:<br /><br />show_progress 0.1 10<br />复制代码<br />行1和行5：显示进度条<br />行3：复制刷机包中的system文件夹到Android的/system<br />注意：你应该在文件的最末尾多添加一个空行（也就是行6）将C:\android压缩中的所有内容压缩为zip包（千万记住：是压缩android这个文件夹中的内容，不是android文件夹本身）为android.zip签名<br />注意：你可以在这个帖子中找到为刷机包签名的教程和工具将update.zip文件复制到SD卡中，然后手机进入recovery界面来刷入这个刷机包<br /><br />一. 基础语法篇<br />1.copy_dir<br />语法：copy_dir &lt;src-dir&gt; &lt;dst-dir&gt; [&lt;times**p&gt;]<br />&lt;src-dir&gt;表示原文件夹，&lt;dst-dir&gt;表示目的文件夹，[&lt;times**p&gt;]表示时间戳<br />作用：将&lt;src-dir&gt;文件夹中的内容复制到&lt;dst-dir&gt;文件夹中。&lt;dst-dir&gt;文件夹中的原始内容将会保存不变，除非&lt;src-dir&gt;文件夹中有相同的内容，这样&lt;dst-dir&gt;中的内容将被覆盖<br />举例：copy_dir PACKAGE:system SYSTEM:（将升级包中的system文件夹复制到手机中）<br /><br />2.format<br />语法：format &lt;root&gt;<br />&lt;root&gt;表示要格式化的分区<br />作用：格式化一个分区<br />举例：format SYSTEM:（将手机/system分区完全格式化）<br />注意：格式化之后的数据是不可以恢复的<br /><br />3.delete<br />语法：delete &lt;file1&gt; [... &lt;fileN&gt;]<br />&lt;file1&gt; [... &lt;fileN&gt;]表示要格式化的文件，可以是多个文件用空格隔开<br />作用：删除文件1，2到n<br />举例：delete SYSTEM:app/Calculator.apk（删除手机systen文件夹中app中的Calculator.apk文件）<br /><br />4.delete_recursive<br />语法：delete_recursive &lt;file-or-dir1&gt; [... &lt;file-or-dirN&gt;]<br />&lt;file-or-dir1&gt; [... &lt;file-or-dirN&gt;]表示要删除的文件或文件夹，可以使多个，中间用空格隔开<br />作用：删除文件或者目录，删除目录时会将目录中的所有内容全部删除<br />举例：delete_recursive DATA:dalvik-cache（删除/data/dalvik-cache文件夹下的所有内容）<br /><br />5.run_program<br />语法：run_program &lt;program-file&gt; [&lt;args&gt; ...]<br />&lt;program-file&gt;表示要运行的程序，[&lt;args&gt; ...]表示运行程序所加的参数<br />作用：运行终端程序<br />举例：run_program PACKAGE:install_busybox.sh（执行升级包中的install_busybox.sh脚本）<br /><br />6.set_perm<br />语法：set_perm &lt;uid&gt; &lt;gid&gt; &lt;mode&gt; &lt;path&gt; [... &lt;pathN&gt;]<br />&lt;uid&gt;表示用户名称，&lt;gid&gt;表示用户组名称，&lt;mode&gt;，表示权限模式，&lt;path&gt; [... &lt;pathN&gt;]表示文件路径，可以使多个，用空格隔开<br />作用：设置单个文件或目录的所有者和权限，像linux中的chmod、chown或chgrp命令一样，只是集中在了一个命令当中<br />举例：set_perm 0 2000 0550 SYSTEM:etc/init.goldfish.sh（设置手机system中的etc/init.goldfish.sh的用户为root，用户组为shell，所有者以及所属用户组成员可以进行读取和执行操作，其他用户无操作权限）<br /><br />7.set_perm_recursive<br />语法：set_perm_recursive &lt;uid&gt; &lt;gid&gt; &lt;dir-mode&gt; &lt;file-mode&gt; &lt;path&gt; [... &lt;pathN&gt;]<br />&lt;uid&gt;表示用户，&lt;gid&gt;表示用户组，&lt;dir-mode&gt;表示文件夹的权限，&lt;file-mode&gt;表示文件的权限，&lt;path&gt; [... &lt;pathN&gt;]表示文件夹的路径，可以多个，用空格分开<br />作用：设置文件夹及文件夹中的文件的所有者和用户组<br />举例：set_perm_recursive 0 0 0755 0644 SYSTEM:app（设置手机system/app文件夹及其中文件的用户为root，用户组为root，app文件夹权限为所有者可以进行读、写、执行操作，其他用户可以进行读取和执行操作，其中的文件的权限为所有者可以进行读写操作，其他用户可以进行读取操作）<br /><br />8.show_progress<br />语法：show_progress &lt;fraction&gt; &lt;duration&gt;<br />&lt;表示一个小部分&gt; &lt;表示一个小部分的持续时间&gt;<br />作用：为下面进行的程序操作显示进度条，进度条会根据&lt;duration&gt;进行前进，当操作时间是确定的时候会更快<br />举例：show_progress 0.1 0（显示进度条当操作完成后前进10%）<br /><br />9.symlink<br />语法：symlink &lt;link-target&gt; &lt;link-path&gt;<br />&lt;link-target&gt;表示链接到的目标，&lt;link-path&gt;表示快捷方式的路径<br />作用：相当于linux中的ln命令，将&lt;link-target&gt;在&lt;link-path&gt;处创建一个软链接，&lt;link-target&gt;的格式应为绝对路径（或许相对路径也可以），&lt;link-path&gt;为&#8220;根目录：路径&#8221;的形式<br />举例：symlink /system/bin/su SYSTEM:xbin/su（在手机中system中的xbin中建立一个/system/bin/su的快捷方式）<br />10.assert&nbsp;<br />语法：assert &lt;boolexpr&gt;<br />作用：此命令用来判断表达式boolexpr的正确与否，当表达式错误时程序终止执行&#8251;此作用有待验证<br /><br />11.package_extract_file/dir语法：package_extract_file(file/dir,file/dir)<br />作用：提取包中文件/路径<br />举例：package_extract_dir("system", "/system");<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;package_extract_file("system/bin/modelid_cfg.sh", "/tmp/modelid_cfg.sh");<br /><br /><br />12.write_radio_image<br />语法：write_radio_image &lt;src-image&gt;<br />作用：将基带部分的镜像写入手机，&lt;src-image&gt;表示镜像文件<br />举例：write_radio_image PACKAGE:radio.img<br /><br />13.write_hboot_image<br />语法：write_hboot_image &lt;src-image&gt;<br />作用：将系统bootloader镜像写入手机，&lt;src-image&gt;表示镜像位置，此命令在直到在所有的程序安装结束之后才会起作用<br />举例：write_hboot_image PACKAGE:hboot.img<br />14.write_raw_image语法：write_raw_image &lt;src-image&gt; &lt;dest-root&gt;<br />作用：将boot.img写入手机，里面包含了内核和ram盘<br />举例：write_raw_image PACKAGE:boot.img BOOT:<br /><br /><br />二、根目录以及分区的定义（在Android源代码的root.c文件中定义）<br />根目录:&nbsp; &nbsp; &nbsp; &nbsp; Linux 块设备&nbsp; &nbsp; &nbsp; &nbsp; /挂载点/&nbsp; &nbsp; &nbsp; &nbsp; 文件系统&nbsp; &nbsp; &nbsp; &nbsp; 大小&nbsp; &nbsp; &nbsp; &nbsp; 描述<br />BOOT:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mtdblock[?]&nbsp; &nbsp; &nbsp; &nbsp; /&nbsp; &nbsp; &nbsp; &nbsp; (RAM)&nbsp; &nbsp; &nbsp; &nbsp; Raw&nbsp; &nbsp; &nbsp; &nbsp; 内核、内存盘和引导配置。<br />DATA:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mtdblock5&nbsp; &nbsp; &nbsp; &nbsp; /data/&nbsp; &nbsp; &nbsp; &nbsp; yaffs2&nbsp; &nbsp; &nbsp; &nbsp; 91904kb&nbsp; &nbsp; &nbsp; &nbsp; 用户、系统配置，软件配置以及软件（没有a2sd的话）<br />CACHE:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mtdblock4&nbsp; &nbsp; &nbsp; &nbsp; /cache/&nbsp; &nbsp; &nbsp; &nbsp; yaffs2&nbsp; &nbsp; &nbsp; &nbsp; 30720kb&nbsp; &nbsp; &nbsp; &nbsp; OTA缓存，recovery/更新配置及临时文件夹<br />MISC:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mtdblock[?]&nbsp; &nbsp; &nbsp; &nbsp; N/A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Raw,[?]kb&nbsp; &nbsp; &nbsp; &nbsp; （等待添加）<br />PACKAGE:&nbsp; &nbsp; &nbsp; &nbsp; （相对于刷机包）&nbsp; &nbsp; &nbsp; &nbsp; N/A&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 刷机包的伪文件系统。<br />RECOVERY:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mtdblock[?]&nbsp; &nbsp; &nbsp; &nbsp; /&nbsp; &nbsp; &nbsp; &nbsp; (RAM)&nbsp; &nbsp; &nbsp; &nbsp; Raw,[?]kb&nbsp; &nbsp; &nbsp; &nbsp; recovery和更新环境的内核和内存盘。类似于BOOT:。<br />SDCARD:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mmcblk0(p1)&nbsp; &nbsp; &nbsp; &nbsp; /sdcard/&nbsp; &nbsp; &nbsp; &nbsp; fat32&nbsp; &nbsp; &nbsp; &nbsp; 32MB-32GB&nbsp; &nbsp; &nbsp; &nbsp; TF卡。通常刷机包就放在这里。<br />SYSTEM:&nbsp; &nbsp; &nbsp; &nbsp; /dev/mtdblock3&nbsp; &nbsp; &nbsp; &nbsp; /system/&nbsp; &nbsp; &nbsp; &nbsp; yaffs2&nbsp; &nbsp; &nbsp; &nbsp; 92160kb&nbsp; &nbsp; &nbsp; &nbsp; 系统分区，静态且是只读的。<br />TMP:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /tmp/&nbsp; &nbsp; &nbsp; &nbsp; (RAM)&nbsp; &nbsp; &nbsp; &nbsp; 标准的Linux临时文件夹&nbsp; &nbsp; &nbsp; &nbsp; 在关机/重启时清空。<br /><br />三. 实例分析进阶篇<br /><br />呵呵，大家来看看这段代码是不是有种熟悉的感觉啊<br />assert(getprop("ro.product.device") == "swift" || getprop("ro.build.product") == "swift" || getprop("ro.product.board") == "swift");<br />package_extract_file("system/bin/backuptool.sh", "/tmp/backuptool.sh");<br />set_perm(0, 0, 0777, "/tmp/backuptool.sh");<br />run_program("/tmp/backuptool.sh", "backup");<br />show_progress(0.500000, 0);<br />format("yaffs2", "MTD", "system");<br />mount("yaffs2", "MTD", "system", "/system");<br />package_extract_dir("recovery", "/system");<br />package_extract_dir("system", "/system");<br />symlink("busybox", "/system/xbin/[", "/system/xbin/[[",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/arp", "/system/xbin/ash", "/system/xbin/awk",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/basename", "/system/xbin/bbconfig", "/system/xbin/brctl",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/bunzip2", "/system/xbin/bzcat", "/system/xbin/bzip2",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/cal", "/system/xbin/cat", "/system/xbin/catv",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/chgrp", "/system/xbin/chmod", "/system/xbin/chown",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/chroot", "/system/xbin/cksum", "/system/xbin/clear",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/cmp", "/system/xbin/cp", "/system/xbin/cpio",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/cut", "/system/xbin/date", "/system/xbin/dc",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/dd", "/system/xbin/depmod", "/system/xbin/devmem",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/df", "/system/xbin/diff", "/system/xbin/dirname",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/dmesg", "/system/xbin/dnsd", "/system/xbin/dos2unix",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/du", "/system/xbin/echo", "/system/xbin/ed",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/egrep", "/system/xbin/env", "/system/xbin/expr",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/false", "/system/xbin/fdisk", "/system/xbin/fgrep",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/find", "/system/xbin/fold", "/system/xbin/free",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/freeramdisk", "/system/xbin/fuser", "/system/xbin/getopt",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/grep", "/system/xbin/gunzip", "/system/xbin/gzip",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/head", "/system/xbin/hexdump", "/system/xbin/id",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/ifconfig", "/system/xbin/insmod", "/system/xbin/install",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/ip", "/system/xbin/kill", "/system/xbin/killall",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/killall5", "/system/xbin/length", "/system/xbin/less",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/ln", "/system/xbin/losetup", "/system/xbin/ls",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/lsmod", "/system/xbin/lspci", "/system/xbin/lsusb",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/lzop", "/system/xbin/lzopcat", "/system/xbin/md5sum",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/mkdir", "/system/xbin/mke2fs", "/system/xbin/mkfifo",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/mkfs.ext2", "/system/xbin/mknod", "/system/xbin/mkswap",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/mktemp", "/system/xbin/modprobe", "/system/xbin/more",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/mount", "/system/xbin/mountpoint", "/system/xbin/mv",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/netstat", "/system/xbin/nice", "/system/xbin/nohup",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/nslookup", "/system/xbin/ntpd", "/system/xbin/od",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/patch", "/system/xbin/pgrep", "/system/xbin/pidof",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/ping", "/system/xbin/pkill", "/system/xbin/printenv",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/printf", "/system/xbin/ps", "/system/xbin/pwd",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/rdev", "/system/xbin/readlink", "/system/xbin/realpath",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/renice", "/system/xbin/reset", "/system/xbin/rm",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/rmdir", "/system/xbin/rmmod", "/system/xbin/route",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/run-parts", "/system/xbin/sed", "/system/xbin/seq",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/setsid", "/system/xbin/sh", "/system/xbin/sha1sum",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/sha256sum", "/system/xbin/sha512sum",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/sleep", "/system/xbin/sort", "/system/xbin/split",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/stat", "/system/xbin/strings", "/system/xbin/stty",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/swapoff", "/system/xbin/swapon", "/system/xbin/sync",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/sysctl", "/system/xbin/tac", "/system/xbin/tail",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/tar", "/system/xbin/tee", "/system/xbin/telnet",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/test", "/system/xbin/tftp", "/system/xbin/time",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/top", "/system/xbin/touch", "/system/xbin/tr",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/traceroute", "/system/xbin/true", "/system/xbin/tty",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/tune2fs", "/system/xbin/umount", "/system/xbin/uname",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/uniq", "/system/xbin/unix2dos", "/system/xbin/unlzop",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/unzip", "/system/xbin/uptime", "/system/xbin/usleep",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/uudecode", "/system/xbin/uuencode", "/system/xbin/vi",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/watch", "/system/xbin/wc", "/system/xbin/wget",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/which", "/system/xbin/whoami", "/system/xbin/xargs",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/yes",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/zcat");<br />symlink("iwmulticall", "/system/xbin/iwconfig", "/system/xbin/iwgetid",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/iwlist", "/system/xbin/iwpriv",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/xbin/iwspy");<br />symlink("toolbox", "/system/bin/cat", "/system/bin/cmp",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/date", "/system/bin/dd", "/system/bin/dmesg",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/getevent", "/system/bin/getprop", "/system/bin/hd",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/id", "/system/bin/ifconfig", "/system/bin/iftop",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/insmod", "/system/bin/ioctl", "/system/bin/ionice",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/kill", "/system/bin/log", "/system/bin/lsmod",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/mkdir", "/system/bin/nandread", "/system/bin/netstat",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/newfs_msdos", "/system/bin/notify", "/system/bin/printenv",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/ps", "/system/bin/reboot", "/system/bin/renice",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/rmdir", "/system/bin/rmmod", "/system/bin/route",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/schedtop", "/system/bin/sendevent",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/setconsole", "/system/bin/setprop", "/system/bin/sleep",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/smd", "/system/bin/start", "/system/bin/stop",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/sync", "/system/bin/top", "/system/bin/uptime",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/vmstat", "/system/bin/watchprops",<br />&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"/system/bin/wipe");<br />set_perm_recursive(0, 0, 0755, 0644, "/system");<br />set_perm_recursive(0, 2000, 0755, 0755, "/system/bin");<br />set_perm(0, 3003, 02750, "/system/bin/netcfg");<br />set_perm(0, 3004, 02755, "/system/bin/ping");<br />set_perm(0, 2000, 06750, "/system/bin/run-as");<br />set_perm_recursive(1002, 1002, 0755, 0440, "/system/etc/bluetooth");<br />set_perm(0, 0, 0755, "/system/etc/bluetooth");<br />set_perm(1000, 1000, 0640, "/system/etc/bluetooth/auto_pairing.conf");<br />set_perm(3002, 3002, 0444, "/system/etc/bluetooth/blacklist.conf");<br />set_perm(1002, 1002, 0440, "/system/etc/dbus.conf");<br />set_perm(1014, 2000, 0550, "/system/etc/dhcpcd/dhcpcd-run-hooks");<br />set_perm_recursive(0, 2000, 0755, 0750, "/system/etc/init.d");<br />set_perm(0, 0, 0755, "/system/etc/init.d");<br />set_perm(0, 2000, 0550, "/system/etc/init.goldfish.sh");<br />set_perm(0, 0, 0544, "/system/etc/install-recovery.sh");<br />set_perm_recursive(0, 0, 0755, 0555, "/system/etc/ppp");<br />set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");<br />set_perm(0, 0, 06755, "/system/xbin/hcitool");<br />set_perm(0, 0, 06755, "/system/xbin/librank");<br />set_perm(0, 0, 06755, "/system/xbin/procmem");<br />set_perm(0, 0, 06755, "/system/xbin/procrank");<br />set_perm(0, 0, 06755, "/system/xbin/su");<br />set_perm(0, 0, 06755, "/system/xbin/tcpdump");<br />show_progress(0.200000, 0);<br />show_progress(0.200000, 10);<br />package_extract_file("system/bin/backuptool.sh", "/tmp/backuptool.sh");<br />set_perm(0, 0, 0777, "/tmp/backuptool.sh");<br />run_program("/tmp/backuptool.sh", "restore");<br />package_extract_file("system/bin/modelid_cfg.sh", "/tmp/modelid_cfg.sh");<br />set_perm(0, 0, 0777, "/tmp/modelid_cfg.sh");<br />run_program("/tmp/modelid_cfg.sh");<br />package_extract_file("system/bin/verify_cache_partition_size.sh", "/tmp/verify_cache_partition_size.sh");<br />set_perm(0, 0, 0777, "/tmp/verify_cache_partition_size.sh");<br />run_program("/tmp/verify_cache_partition_size.sh");<br />show_progress(0.200000, 10);<br />assert(package_extract_file("boot.img", "/tmp/boot.img"),<br />&nbsp; &nbsp;&nbsp; &nbsp; write_raw_image("/tmp/boot.img", "boot"),<br />&nbsp; &nbsp;&nbsp; &nbsp; delete("/tmp/boot.img"));<br />show_progress(0.100000, 0);<br />unmount("/system");<br /><br /></span></div><img src ="http://www.blogjava.net/MEYE/aggbug/359006.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-09-19 17:47 <a href="http://www.blogjava.net/MEYE/articles/359006.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android通过源码编译apk获得系统权限</title><link>http://www.blogjava.net/MEYE/articles/357175.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 24 Aug 2011 03:23:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/357175.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/357175.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/357175.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/357175.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/357175.html</trackback:ping><description><![CDATA[<div>Android通过源码编译apk获得系统权限</div><div>http://www.ziyouku.com/archives/android-source-code-compiled-by-apk-to-obtain-system-privileges.html</div><div><p>Android中的应用程序如何获得系统权限？</p> <p>在&nbsp;android&nbsp;的 API中有提供  SystemClock.setCurrentTimeMillis()函数来修改系统时间，可惜无论你怎么调用这个函数都是没用的，无论模拟器还是真  机，在logcat中总会得到"Unable to open alarm driver: Permission denied  ".这个函数需要root权限或者运行与系统进程中才可以用。</p> <p>本来以为就没有办法在应用程序这一层改系统时间了，后来在网上搜了好久，知道这个目的还是可以达到的。</p> <p>第一个方法简单点，不过需要在Android系统源码的环境下用make来编译：</p> <p>1. 在应用程序的AndroidManifest.xml中的manifest节点中加入</p> <p>android:sharedUserId="android.uid.system"这个属性。</p> <p>2. 修改Android.mk文件，加入LOCAL_CERTIFICATE := platform这一行</p> <p>3. 使用mm命令来编译，生成的apk就有修改系统时间的权限了。</p> <p>&nbsp;</p> <p>第二个办法麻烦点，不过不用开虚拟机跑到源码环境下用make来编译：</p> <p>eclipse源码编译，无需用make来编译（android源码目&lt;D:\myandroid_mx27&gt;）：<br /> 1、首先，AndroidManifest.xml中manifest节点中加入android:sharedUserId="android.uid.system"这个属性</p> <p>2、用eclipse编译出apk(ClockSetting.apk)文件，但这个文件不能用，删掉META-INF目录下的CERT.SF和CERT.RSA两个文件</p> <p>3、使用当前android系统（android系统可能不同）的platform密钥来重新给apk文件签名（可能还未用用户米要签名）。<br /> 首先,找到密钥文件，在我的Android源码目录中的位置是"build\target\product\security",下面的platform.pk8和platform.x509.pem两个文件。<br /> 然后，用Android提供的SignApk工具来签名，signapk的源代码是在"build\tools\signapk"下，这时得为下面的编译工作做些准备：<br /> &lt;1&gt;、编译jar<br /> 命令行cd到signapk.java代码目录下，<br /> javac signapk.java<br /> 获取SignApk$SignatureOutputStream.class和SignApk.class</p> <p>建立目录s\com\android\signapk,将两个class文件放入目录下<br /> jar cvfm signapk.jar SignApk.mf -C s\ .<br /> 注意："s\"后面的"."前面有空格<br /> 生成signapk.jar文件，得到了Android提供的签名程序signapk.jar<br /> &lt;2&gt;、用目标系统的platform密钥签名<br /> 将platform.pk8和platform.x509.pem文件复制到"D:\myandroid_mx27\build\tools\signapk"目录下，即signapk.jar和SignApk.mf所在的目录。<br /> java -jar signapk.jar platform.x509.pem platform.pk8 D:\ClockSetting.apk D:\ClockSettingSigned.apk<br /> 我的未签名（ClockSetting.apk）和已签名(ClockSettingSigned.apk)apk文件都放在D盘,这样就得到了用Android源码编译的文件。</p> <p>&lt;3&gt;、打开真机，安装。</p> <p>&nbsp;</p> <p>最 后解释一下原理，首先加入android:sharedUserId="android.uid.system"这个属性。通过Shared  User id,拥有同一个User  id的多个APK可以配置成运行在同一个进程中。那么把程序的UID配成android.uid.system，也就是要让程序运行在系统进程中，这样就  有权限来修改系统时间了。</p> <p>只是加入UID还不够，如果这时候安装APK的话发现无法安装，提示签名不符，原因是程序想要运行在系统进程中还要有目标系统的platform</p> <p>key，  就是上面第二个方法提到的platform.pk8和platform.x509.pem两个文件。用这两个key签名后apk才真正可以放入系统进程  中。第一个方法中加入LOCAL_CERTIFICATE :=  platform其实就是用这两个key来签名。　　这也有一个问题，就是这样生成的程序只有在原始的Android系统或者是自己编译的系统中才可以  用，因为这样的系统才可以拿到  platform.pk8和platform.x509.pem两个文件。要是别家公司做的Android上连安装都安装不了。试试原始的Android  中的key来签名，程序在模拟器上运行OK，不过放到G3上安装直接提示"Package ... has no signatures that  match those in shared user  android.uid.system"，这样也是保护了系统的安全。　　最最后还说下，这个android:sharedUserId属性不只可以把  apk放到系统进程中，也可以配置多个APK运行在一个进程中，这样可以共享数据，应该会很有用的。</p></div><img src ="http://www.blogjava.net/MEYE/aggbug/357175.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-24 11:23 <a href="http://www.blogjava.net/MEYE/articles/357175.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android  制作 升级包</title><link>http://www.blogjava.net/MEYE/articles/357111.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Tue, 23 Aug 2011 06:22:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/357111.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/357111.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/357111.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/357111.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/357111.html</trackback:ping><description><![CDATA[<div>Android&nbsp; 制作 升级包</div><div><br />http://hi.baidu.com/j_fo/blog/item/81ae650953ea5ec13ac76312.html<br /><div>http://hi.baidu.com/j_fo/blog/item/53a45b82206837af0df4d21a.html</div><br /></div><div><div>  如何制作自己的android升级包(update.zip)</div>  <div>2010-09-04  19:34</div>     <table style="table-layout: fixed; width: 100%;"><tbody><tr><td><div id="blog_text"><div>手动制作update.zip包的过程：</div> <div><br /> 1.创建一个update目录，<wbr>该目录包含自己想要升级或替换的内容</div> <div>例如：</div> <div style="background-color: #cccccc;">update/</div> <div style="background-color: #cccccc;">update/system</div> <div style="background-color: #cccccc;">update/system/app</div> <div style="background-color: #cccccc;">update/system/app/doodle_jump.<wbr>apk</div> <div style="background-color: #cccccc;">update/META-INF</div> <div style="background-color: #cccccc;">update/META-INF/com</div> <div style="background-color: #cccccc;">update/META-INF/com/google</div> <div style="background-color: #cccccc;">update/META-INF/com/google/<wbr>android</div> <div style="background-color: #cccccc;">update/META-INF/com/google/<wbr>android/update-script</div> <div> </div> <div>该目录包含doodle_jump游戏，<wbr>升级后该apk将出现在手机的/system/app/目录下。</div> <div>META-INF目录下包含升级脚本，update-script脚本的内容如下：</div> <div style="background-color: #cccccc;">show_progress 0.500000 0</div> <div style="background-color: #cccccc;">copy_dir PACKAGE:system SYSTEM:</div> <div style="background-color: #cccccc;">show_progress 0.100000 0</div> <div>大家可以根据自己的升级内容添加相应的命令。</div> <div> </div> <div>2.创建压缩包</div> <div>在update/目录下运行：</div> <div style="background-color: #cccccc;">$ zip -qry ../update.unsigned.zip ./</div> <div>将在update/的父目录下产生update.<wbr>unsigned.zip 压缩包</div> <div> </div> <div>3.签名</div> <div style="background-color: #cccccc;">$ java -Xmx512m -jar signapk.jar -w key.x509.pem key.pk8 update.unsigned.zip update.zip</div> <div>生成签过名的update.zip包，其中</div> <div>signapk.jar，key.x509.pem，<wbr>key.pk8与具体手机系统相关</div> <div> </div> <div>4.将签过名的update.<wbr>zip包放入手机sdcard根目录，<wbr><br /> 重启系统进入recovery模式，选择</div> <div>apply update.zip，成功后重启手机</div> <div> </div> <div>ok，现在手机上已经有doodle_jump游戏了，<wbr>并且它无法被删除～<br /> <br /> <br /> refer:<br /> <a href="http://hi.baidu.com/j_fo/blog/item/53a45b82206837af0df4d21a.html" target="_blank">http://hi.baidu.com/j_fo/blog/item/53a45b82206837af0df4d21a.html</a><br /><br /><div><h1><a href="http://www.londatiga.net/it/how-to-create-android-update-zip-package/" rel="bookmark" title="Permanent Link to How to Create Android Update Zip Package">How to Create Android Update Zip Package</a></h1> <p>There are several ways to install applications or&nbsp; library files to an <a title="Android" href="http://www.android.com/" target="_blank">Android</a> <a href="http://www.londatiga.net/it/samsung-i5700-galaxy-spica-android-2-1-flashing-guide/" target="_blank">Phone</a>. You can use <em>Market</em> application to find and install or <a title="Android ADB Tool" href="http://www.londatiga.net/it/how-to-create-android-update-zip-package/developer.android.com/guide/developing/tools/adb.html" target="_blank">adb</a>   command line tool to install or push the files to Android file system.   These are all easy to implement for&nbsp; single&nbsp; file but if you have   several applications or library files to install at once, it might be   better to use <strong>update zip</strong> file. The update zip file is   Android advanced system to install applications or lib files to Android   file system using recovery tool. This method is commonly used by rom or   theme developers to distribute their package.</p> <p>Creating an update zip file is quite easy, all you have to do is put   the files in corresponding directory in Android file system and an <span style="color: #008000;">update-script</span> file to copy the files. For example, to install <span style="color: #008000;">Calculator.apk </span>into<span style="color: #008000;"> system/app</span> and copy <span style="color: #008000;">libsec-ril.so</span> file into<span style="color: #008000;"> system/lib</span> :</p> <ul><li>Create an empty folder (eg. C:\myupdate)</li><li>Create <span style="color: #008000;">C:\myupdate\system\app</span> folder for <span style="color: #008000;">Calculator.apk</span> and&nbsp;<span style="color: #008000;"> C:\myupdate\system\lib</span> folder for <span style="color: #008000;">libsec-ril.so</span></li><li>Create <span style="color: #008000;">C:\myupdate\META-INF\com\google\android</span> folder for <span style="color: #008000;">update-script</span> file.</li><li>Create the<span style="color: #008000;"> update-script</span> file with the following syntax:</li><pre plain;="">show_progress 0.1 0<br /><br />copy_dir PACKAGE:system SYSTEM:<br /><br />show_progress 0.1 10</pre><p>Line 1&amp;5 : show progress bar<br />     Line 3: copy <span style="color: #008000;">s<span style="color: #008000;">ystem</span></span> folder from update package to Android&#8217;s<span style="color: #008000;"> /system</span></p><p>Note: you should add one extra&nbsp; line at the end of the file (Line 6)</p><li>Compress the entire contents of <span style="color: #008000;">C:\myupdate</span> folder to zip (not the <span style="color: #008000;">myupdate </span>folder itself)</li><li>Sign the <span style="color: #008000;">myupdate.zip</span> file</li><p><span style="color: #008000;">java -jar signapk.jar certificate.pem key.pk8 myupdate.zip update.zip</span></p><p>Note: you can find tutorial on how to sign the update.zip file <a title="How to sign android update.zip file" href="http://www.londatiga.net/it/how-to-sign-apk-zip-files/" target="_blank">here</a></p><li>Copy the <span style="color: #008000;">update.zip</span> file to sdcard and apply it from recovery console</li></ul> <p>update-script syntax reference (definitions from recovery.c android source code):</p> <ul><li><strong>copy_dir</strong></li><p>Syntax:<span style="color: #008000;"> copy_dir &lt;src-dir&gt; &lt;dst-dir&gt; [&lt;timestamp&gt;]</span><br />     Copy the contents  of &lt;src-dir&gt; to&nbsp; &lt;dst-dir&gt;. The  original  contents of &lt;dst-dir&gt; are preserved unless something in    &lt;src-dir&gt; overwrote them.<br />     Ex: <span style="color: #008000;">copy_dir PACKAGE:system SYSTEM:</span></p><li><strong>format</strong></li><p>Syntax: format &lt;root&gt;<br />     Format a partiti0n<br />     Ex:<strong> </strong><span style="color: #008000;">format SYSTEM:</span>, will format entire<span style="color: #008000;"> /system</span> . Note: formatting erases data irreversibly.</p><li><strong>delete</strong></li><p>Syntax: <span style="color: #008000;">delete  &lt;file1&gt; [... &lt;fileN&gt;]</span><br />     Delete&nbsp; file.<br />     EX: <span style="color: #008000;">delete SYSTEM:app/Calculator.apk</span>, will delete <span style="color: #008000;">Calculator.apk</span> from <span style="color: #008000;">system/app</span> directory.</p><li><strong>delete_recursive</strong></li><p>Syntax: <span style="color: #008000;">delete_recursive  &lt;file-or-dir1&gt; [... &lt;file-or-dirN&gt;]</span><br />     Delete a file or directory with all of it&#8217;s contents recursively<br />     Ex: <span style="color: #008000;">delete_recursive DATA:dalvik-cache</span>, will delete<span style="color: #008000;"> /data/dalvik-cache</span> directory with all of it&#8217;s contents</p><li><strong>run_program</strong></li><p>Syntax:<span style="color: #008000;"> run_program &lt;program-file&gt; [&lt;args&gt; ...]</span><br />     Run an external program included in the update package.<br />     Ex: <span style="color: #008000;">run_program PACKAGE:install_busybox.sh</span>, will run<span style="color: #008000;"> install_busybox.sh</span> script (shell command) included in the update package.</p><li><strong>set_perm</strong></li><p>Syntax: <span style="color: #008000;">set_perm &lt;uid&gt; &lt;gid&gt; &lt;mode&gt; &lt;path&gt; [... &lt;pathN&gt;]</span><br />     Set ownership and permission of single file or entire directory trees, like &#8216;chmod&#8217;, &#8216;chown&#8217;, and &#8216;chgrp&#8217; all in one<br />     Ex:<span style="color: #008000;"> set_perm 0 2000 0550 SYSTEM:etc/init.goldfish.sh</span></p><li><strong>set_perm_recursive</strong></li><p>Syntax: <span style="color: #008000;">set_perm_recursive &lt;uid&gt; &lt;gid&gt; &lt;dir-mode&gt; &lt;file-moe&gt; &lt;path&gt; [... &lt;pathN&gt;]</span><br />     Set ownership and permission of a directory with all of it&#8217;s contents recursively</p><p>Ex: <span style="color: #008000;">set_perm_recursive 0 0 0755 0644 SYSTEM:app</span></p><li><strong>show_progress </strong></li><p>Syntax: <span style="color: #008000;">show_progress</span> <span style="color: #008000;">&lt;fraction&gt; &lt;duration&gt;</span><br />     Use  of the on-screen progress meter for the next operation,   automatically advancing the meter over  &lt;duration&gt; seconds (or   more rapidly if the actual rate of progress can be determined).<br />     Ex: <span style="color: #008000;">show_progress 0.1 0</span></p><li><strong>symlink</strong></li><p>Syntax: <span style="color: #008000;">symlink &lt;link-target&gt; &lt;link-path&gt;</span></p><p>Create a symlink (like &#8216;ln-s&#8217;). The &lt;link-path&gt; is in root:path format, but &lt;link-target&gt; is<br />     for the target filesystem (and may be relative)</p><p> </p></ul> <h1>----------</h1></div><br /><div><div> 	      <div> 	      	<div> 		      <h3>用Android自带的signapk.jar + .x509.pem + .pk8签名应用程序&nbsp; <br /></h3><br /><div>http://lmdy2001.blog.163.com/blog/static/8423891020114262323816/</div><br /> 		      <p clearfix="" nbw-act="" fc06="" style="line-height: 20px;"> 		        <span><br /> 		           		          </span><span pnt="" fc03="" id="$_blog_subscribe"><a></a></span> 		      </p> 		    </div> 	      </div>         </div>                  <div>                  </div>                  <div fc05="" fc11="" nbw-blog="" ztag="" js-fs2="">文件位置：可以在platform/build/target/product/security/中找到platform.pk8 platform.x509.pem等签名文件，对应不同的权限。<br />signapk.jar：由/platform/build/tools/signapk/编译产出,可以在/out/host/linux-x86/framework/中找到。<br /><br />签名：<br />java -jar signapk.jar platform.x509.pem platform.pk8 MyDemo.apk MyDemo_signed.apk 得到具有对应权限的APK<br /><br />优化APK：<br />zipalign -v 4 MyDemo_signed.apk MyDemo_new.apk<br /><br />查循APK是否优化过：<br />zipalign -c -v 4 MyDemo.apk</div></div><br /><br /></div> <div> </div></div></td></tr></tbody></table>  </div><img src ="http://www.blogjava.net/MEYE/aggbug/357111.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-23 14:22 <a href="http://www.blogjava.net/MEYE/articles/357111.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android OTA 升级之一：编译升级包</title><link>http://www.blogjava.net/MEYE/articles/357094.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Tue, 23 Aug 2011 01:58:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/357094.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/357094.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/357094.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/357094.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/357094.html</trackback:ping><description><![CDATA[<div><div>          <h3>         <a href="http://blog.csdn.net/zjujoe/article/details/6206010" title="Android OTA 升级之一：编译升级包">Android OTA 升级之一：编译升级包</a>              </h3> </div></div><div>http://blog.csdn.net/zjujoe/article/details/6206010</div><div><div>     <p style="margin: 12pt 0cm 3pt;"><strong><span style="font-size: large;"><span style="font-family: Cambria;">Android OTA </span><span style="font-family: 宋体;">升级之一：编译升级包</span></span></strong></p> <p align="center"><span style="font-size: small; font-family: 宋体;">作者： 宋立新</span></p> <p align="center"><span style="font-size: small;"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">Email</span><span style="font-family: 宋体;">：</span><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#122;&#106;&#117;&#106;&#111;&#101;&#64;&#121;&#97;&#104;&#111;&#111;&#46;&#99;&#111;&#109;"><span style="font-family: &quot;Times New Roman&quot;,&quot;serif&quot;;">zjujoe@yahoo.com</span></a></span></p> <h1><span style="font-family: 宋体;"><span style="font-size: x-large;">前言</span></span></h1> <p><span style="font-size: small;"><span style="font-family: Times New Roman;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OTA </span></span><span style="font-family: 宋体;">升级是</span><span style="font-family: Times New Roman;"> Android </span><span style="font-family: 宋体;">系统提供的标准软件升级方式。</span> <span style="font-family: 宋体;">它功能强大，提供了完全升级、增量升级模式，可以通过</span><span style="font-family: Times New Roman;"> SD </span><span style="font-family: 宋体;">卡升级，也可以通过网络升级。</span></span></p> <p><span style="font-size: small;"><span><span style="font-family: Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体;">这里，我们先研究最简单的情况，通过</span><span style="font-family: Times New Roman;"> SD </span><span style="font-family: 宋体;">卡进行完全升级。</span></span></p> <p><span style="font-size: small;"><span><span style="font-family: Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体;">如何执行升级就不多说了，网上有很多资料。（比如，介绍</span><span style="font-family: Times New Roman;">HTC</span><span style="font-family: 宋体;">手机如何升级）。我们感兴趣的是它是如何实现的，作为开发者，如何修改它以符合我们的定制化需求。</span></span></p> <p><span style="font-size: small;"><span><span style="font-family: Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体;">首先，我们研究一下</span><span style="font-family: Times New Roman;"> ota </span><span style="font-family: 宋体;">升级包的编译过程。</span></span></p> <h1><span style="font-size: x-large; font-family: Times New Roman;">Quick start</span></h1> <p><span style="font-size: small;"><span><span style="font-family: Times New Roman;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体;">首先编译出</span><span style="font-family: Times New Roman;">android, </span><span style="font-family: 宋体;">然后执行：</span> </span></p> <p style="margin: 0cm 0cm 0pt 21pt; text-indent: 21pt;"><span style="font-size: small;"><span style="font-family: &quot;MS Gothic&quot;;">make otapackage</span></span></p> <p><span style="font-size: small;"><span style="font-family: &quot;MS Gothic&quot;;">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体;">即可获得：</span><span style="font-family: &quot;MS Gothic&quot;;">out/target/product/{product_name}/</span><span style="font-family: Times New Roman;"> {product_name}</span><span style="font-family: &quot;MS Gothic&quot;;">-ota-eng.{uid}.zip</span></span></p> <p><span style="font-size: small;"><span style="font-family: &quot;MS Gothic&quot;;">&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体;">将该文件改名为</span><span style="font-family: &quot;MS Gothic&quot;;">update.zip</span><span style="font-family: 宋体;">放到</span><span style="font-family: &quot;MS Gothic&quot;;">T</span><span style="font-family: 宋体;">卡根目录</span><span style="font-family: &quot;MS Gothic&quot;;">, </span><span style="font-family: 宋体;">即可开始</span><span style="font-family: &quot;MS Gothic&quot;;">recovery</span><span style="font-family: 宋体;">模式下的</span><span style="font-family: &quot;MS Gothic&quot;;"> OTA </span><span style="font-family: 宋体;">升级。</span></span></p> <h1><span style="font-family: 宋体;"><span style="font-size: x-large;">编译过程研究</span></span></h1> <p>&nbsp;</p> <p><span style="font-size: small;"><span style="font-family: 宋体;">主要分两步，第一步，</span> <span style="font-family: 宋体;">会准备一个包，其中包含升级需要的内容</span><span style="font-family: Times New Roman;">(</span><span style="font-family: 宋体;">原材料</span><span style="font-family: Times New Roman;">)</span><span style="font-family: 宋体;">，比如，</span><span style="font-family: Times New Roman;">system </span><span style="font-family: 宋体;">目录。</span></span></p> <p><span style="font-size: small;"><span style="font-family: 宋体;">第二步，运行</span><span style="font-family: Times New Roman;">python </span><span style="font-family: 宋体;">脚本</span><span style="font-family: Times New Roman;"> ./build/tools/releasetools/ota_from_target_files</span><span style="font-family: 宋体;">，以步骤一准备的</span><span style="font-family: Times New Roman;">ZIP</span><span style="font-family: 宋体;">包作为输入，最终生成需要的升级包。</span></span></p> <p>&nbsp;</p> <h2><span style="font-family: 黑体;"><span style="font-size: large;">步骤一</span></span></h2> <p><span style="font-size: small;"><span style="font-family: 宋体;">编译脚本如下</span><span style="font-family: Times New Roman;">:</span></span></p> <p><span style="font-size: small; font-family: Times New Roman;">(From: build/core/Makefile)</span></p> <p>&nbsp;</p> <p><span style="font-size: small; font-family: Times New Roman;">&nbsp;<div nogutter="" bg_c-sharp:nogutter:nocontrols=""><ol start="1"><li><span><span>1073&nbsp;#&nbsp;Depending&nbsp;on&nbsp;the&nbsp;various&nbsp;images&nbsp;guarantees&nbsp;that&nbsp;the&nbsp;underlying&nbsp;&nbsp;</span></span></li><li>1074&nbsp;#&nbsp;directories&nbsp;are&nbsp;up-to-date.&nbsp;&nbsp;</li><li>1075&nbsp;$(BUILT_TARGET_FILES_PACKAGE):&nbsp;/&nbsp;&nbsp;</li><li>1076&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_BOOTIMAGE_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1077&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_RADIOIMAGE_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1078&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_RECOVERYIMAGE_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1079&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_FACTORYIMAGE_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1080&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_SYSTEMIMAGE)&nbsp;/&nbsp;&nbsp;</li><li>1081&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_USERDATAIMAGE_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1082&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_SECROIMAGE_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1083&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_ANDROID_INFO_TXT_TARGET)&nbsp;/&nbsp;&nbsp;</li><li>1084&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(built_ota_tools)&nbsp;/&nbsp;&nbsp;</li><li>1085&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(APKCERTS_FILE)&nbsp;/&nbsp;&nbsp;</li><li>1086&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(HOST_OUT_EXECUTABLES)/fs_config&nbsp;/&nbsp;&nbsp;</li><li>1087&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;$(ACP)&nbsp;&nbsp;</li><li>1088&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@echo&nbsp;<span>"Package&nbsp;target&nbsp;files:&nbsp;$@"&nbsp;&nbsp;</span></li><li>1089&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;rm&nbsp;-rf&nbsp;$@&nbsp;$(zip_root)&nbsp;&nbsp;</li><li>1090&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;mkdir&nbsp;-p&nbsp;$(dir&nbsp;$@)&nbsp;$(zip_root)&nbsp;&nbsp;</li><li>1091&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Components&nbsp;of&nbsp;the&nbsp;recovery&nbsp;image&nbsp;&nbsp;</li><li>1092&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;mkdir&nbsp;-p&nbsp;$(zip_root)/RECOVERY&nbsp;&nbsp;</li><li>1093&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(call&nbsp;package_files-copy-root,&nbsp;/&nbsp;&nbsp;</li><li>1094&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK)&nbsp;&nbsp;</li><li>1095&nbsp;ifdef&nbsp;INSTALLED_KERNEL_TARGET&nbsp;&nbsp;</li><li>1096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(INSTALLED_KERNEL_TARGET)&nbsp;$(zip_root)/RECOVERY/kernel&nbsp;&nbsp;</li><li>1097&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(recovery_ramdisk)&nbsp;$(zip_root)/RECOVERY/ramdisk&nbsp;&nbsp;</li><li>1098&nbsp;endif&nbsp;&nbsp;</li><li>1099&nbsp;ifdef&nbsp;INSTALLED_2NDBOOTLOADER_TARGET&nbsp;&nbsp;</li><li>1100&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;/&nbsp;&nbsp;</li><li>1101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_2NDBOOTLOADER_TARGET)&nbsp;$(zip_root)/RECOVERY/second&nbsp;&nbsp;</li><li>1102&nbsp;endif&nbsp;&nbsp;</li><li>1103&nbsp;ifdef&nbsp;BOARD_KERNEL_CMDLINE&nbsp;&nbsp;</li><li>1104&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(BOARD_KERNEL_CMDLINE)"&nbsp;&gt;&nbsp;$(zip_root)/RECOVERY/cmdline&nbsp;&nbsp;</span></li><li>1105&nbsp;endif&nbsp;&nbsp;</li><li>1106&nbsp;ifdef&nbsp;BOARD_KERNEL_BASE&nbsp;&nbsp;</li><li>1107&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(BOARD_KERNEL_BASE)"&nbsp;&gt;&nbsp;$(zip_root)/RECOVERY/base&nbsp;&nbsp;</span></li><li>1108&nbsp;endif&nbsp;&nbsp;</li><li>1109&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Components&nbsp;of&nbsp;the&nbsp;factory&nbsp;image&nbsp;&nbsp;</li><li>1110&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;mkdir&nbsp;-p&nbsp;$(zip_root)/FACTORY&nbsp;&nbsp;</li><li>1111&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(call&nbsp;package_files-copy-root,&nbsp;/&nbsp;&nbsp;</li><li>1112&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(TARGET_FACTORY_ROOT_OUT),$(zip_root)/FACTORY/RAMDISK)&nbsp;&nbsp;</li><li>1113&nbsp;ifdef&nbsp;INSTALLED_KERNEL_TARGET&nbsp;&nbsp;</li><li>1114&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(INSTALLED_KERNEL_TARGET)&nbsp;$(zip_root)/FACTORY/kernel&nbsp;&nbsp;</li><li>1115&nbsp;endif&nbsp;&nbsp;</li><li>1116&nbsp;ifdef&nbsp;INSTALLED_2NDBOOTLOADER_TARGET&nbsp;&nbsp;</li><li>1117&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;/&nbsp;&nbsp;</li><li>1118&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_2NDBOOTLOADER_TARGET)&nbsp;$(zip_root)/FACTORY/second&nbsp;&nbsp;</li><li>1119&nbsp;endif&nbsp;&nbsp;</li><li>1120&nbsp;ifdef&nbsp;BOARD_KERNEL_CMDLINE&nbsp;&nbsp;</li><li>1121&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(BOARD_KERNEL_CMDLINE)"&nbsp;&gt;&nbsp;$(zip_root)/FACTORY/cmdline&nbsp;&nbsp;</span></li><li>1122&nbsp;endif&nbsp;&nbsp;</li><li>1123&nbsp;ifdef&nbsp;BOARD_KERNEL_BASE&nbsp;&nbsp;</li><li>1124&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(BOARD_KERNEL_BASE)"&nbsp;&gt;&nbsp;$(zip_root)/FACTORY/base&nbsp;&nbsp;</span></li><li>1125&nbsp;endif&nbsp;&nbsp;</li><li>1126&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Components&nbsp;of&nbsp;the&nbsp;boot&nbsp;image&nbsp;&nbsp;</li><li>1127&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;mkdir&nbsp;-p&nbsp;$(zip_root)/BOOT&nbsp;&nbsp;</li><li>1128&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(call&nbsp;package_files-copy-root,&nbsp;/&nbsp;&nbsp;</li><li>1129&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK)&nbsp;&nbsp;</li><li>1130&nbsp;ifdef&nbsp;INSTALLED_KERNEL_TARGET&nbsp;&nbsp;</li><li>1131&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(INSTALLED_KERNEL_TARGET)&nbsp;$(zip_root)/BOOT/kernel&nbsp;&nbsp;</li><li>1132&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(INSTALLED_RAMDISK_TARGET)&nbsp;$(zip_root)/BOOT/ramdisk&nbsp;&nbsp;</li><li>1133&nbsp;endif&nbsp;&nbsp;</li><li>1134&nbsp;ifdef&nbsp;INSTALLED_2NDBOOTLOADER_TARGET&nbsp;&nbsp;</li><li>1135&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;/&nbsp;&nbsp;</li><li>1136&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(INSTALLED_2NDBOOTLOADER_TARGET)&nbsp;$(zip_root)/BOOT/second&nbsp;&nbsp;</li><li>1137&nbsp;endif&nbsp;&nbsp;</li><li>1138&nbsp;ifdef&nbsp;BOARD_KERNEL_CMDLINE&nbsp;&nbsp;</li><li>1139&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(BOARD_KERNEL_CMDLINE)"&nbsp;&gt;&nbsp;$(zip_root)/BOOT/cmdline&nbsp;&nbsp;</span></li><li>1140&nbsp;endif&nbsp;&nbsp;</li><li>1141&nbsp;ifdef&nbsp;BOARD_KERNEL_BASE&nbsp;&nbsp;</li><li>1142&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(BOARD_KERNEL_BASE)"&nbsp;&gt;&nbsp;$(zip_root)/BOOT/base&nbsp;&nbsp;</span></li><li>1143&nbsp;endif&nbsp;&nbsp;</li><li>1144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(<span>foreach&nbsp;t,$(INSTALLED_RADIOIMAGE_TARGET),/&nbsp;&nbsp;</span></li><li>1145&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mkdir&nbsp;-p&nbsp;$(zip_root)/RADIO;&nbsp;/&nbsp;&nbsp;</li><li>1146&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(ACP)&nbsp;$(t)&nbsp;$(zip_root)/RADIO/$(notdir&nbsp;$(t));)&nbsp;&nbsp;</li><li>1147&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Contents&nbsp;of&nbsp;the&nbsp;system&nbsp;image&nbsp;&nbsp;</li><li>1148&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(call&nbsp;package_files-copy-root,&nbsp;/&nbsp;&nbsp;</li><li>1149&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)&nbsp;&nbsp;</li><li>1150&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Contents&nbsp;of&nbsp;the&nbsp;data&nbsp;image&nbsp;&nbsp;</li><li>1151&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(call&nbsp;package_files-copy-root,&nbsp;/&nbsp;&nbsp;</li><li>1152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(TARGET_OUT_DATA),$(zip_root)/DATA)&nbsp;&nbsp;</li><li>1153&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Extra&nbsp;contents&nbsp;of&nbsp;the&nbsp;OTA&nbsp;package&nbsp;&nbsp;</li><li>1154&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;mkdir&nbsp;-p&nbsp;$(zip_root)/OTA/bin&nbsp;&nbsp;</li><li>1155&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(INSTALLED_ANDROID_INFO_TXT_TARGET)&nbsp;$(zip_root)/OTA/&nbsp;&nbsp;</li><li>1156&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(PRIVATE_OTA_TOOLS)&nbsp;$(zip_root)/OTA/bin/&nbsp;&nbsp;</li><li>1157&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Files&nbsp;that&nbsp;<span>do&nbsp;not&nbsp;end&nbsp;up&nbsp;in&nbsp;any&nbsp;images,&nbsp;but&nbsp;are&nbsp;necessary&nbsp;to&nbsp;&nbsp;</span></li><li>1158&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;build&nbsp;them.&nbsp;&nbsp;</li><li>1159&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;mkdir&nbsp;-p&nbsp;$(zip_root)/META&nbsp;&nbsp;</li><li>1160&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;$(ACP)&nbsp;$(APKCERTS_FILE)&nbsp;$(zip_root)/META/apkcerts.txt&nbsp;&nbsp;</li><li>1161&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(PRODUCT_OTA_PUBLIC_KEYS)"&nbsp;&gt;&nbsp;$(zip_root)/META/otakeys.txt&nbsp;&nbsp;</span></li><li>1162&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(PRIVATE_RECOVERY_API_VERSION)"&nbsp;&gt;&nbsp;$(zip_root)/META/recovery-api-version.txt&nbsp;&nbsp;</span></li><li>1163&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"blocksize&nbsp;$(BOARD_FLASH_BLOCK_SIZE)"&nbsp;&gt;&nbsp;$(zip_root)/META/imagesizes.txt&nbsp;&nbsp;</span></li><li>1164&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"boot&nbsp;$(call&nbsp;image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))"&nbsp;&gt;&gt;&nbsp;$(zip_root)/META/imagesizes.txt&nbsp;&nbsp;</span></li><li>1165&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"recovery&nbsp;$(call&nbsp;image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))"&nbsp;&gt;&gt;&nbsp;$(zip_root)/META/imagesizes.txt&nbsp;&nbsp;</span></li><li>1166&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"system&nbsp;$(call&nbsp;image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))"&nbsp;&gt;&gt;&nbsp;$(zip_root)/META/imagesizes.txt&nbsp;&nbsp;</span></li><li>1167&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"secro&nbsp;$(call&nbsp;image-size-from-data-size,$(BOARD_SECROIMAGE_PARTITION_SIZE))"&nbsp;&gt;&gt;&nbsp;$(zip_root)/META/imagesizes.txt&nbsp;&nbsp;</span></li><li>1168&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"userdata&nbsp;$(call&nbsp;image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))"&nbsp;&gt;&gt;&nbsp;$(zip_root)/META/imagesizes.txt&nbsp;&nbsp;</span></li><li>1169&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;echo&nbsp;<span>"$(tool_extensions)"&nbsp;&gt;&nbsp;$(zip_root)/META/tool-extensions.txt&nbsp;&nbsp;</span></li><li>1170&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Zip&nbsp;everything&nbsp;up,&nbsp;preserving&nbsp;symlinks&nbsp;&nbsp;</li><li>1171&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;(cd&nbsp;$(zip_root)&nbsp;&amp;&amp;&nbsp;zip&nbsp;-qry&nbsp;../$(notdir&nbsp;$@)&nbsp;.)&nbsp;&nbsp;</li><li>1172&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@#&nbsp;Run&nbsp;fs_config&nbsp;on&nbsp;all&nbsp;the&nbsp;system&nbsp;files&nbsp;<span>in&nbsp;the&nbsp;zip,&nbsp;and&nbsp;save&nbsp;the&nbsp;output&nbsp;&nbsp;</span></li><li>1173&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;zipinfo&nbsp;-1&nbsp;$@&nbsp;|&nbsp;awk&nbsp;-F/&nbsp;<span>'BEGIN&nbsp;{&nbsp;OFS="/"&nbsp;}&nbsp;/^SYSTEM///&nbsp;{$$1&nbsp;=&nbsp;"system";&nbsp;print}'&nbsp;|&nbsp;$(HOST_OUT_EXECUTABLES)/fs_config&nbsp;&gt;&nbsp;$(zip_root)/META/filesystem_config.txt&nbsp;&nbsp;</span></li><li>1174&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;(cd&nbsp;$(zip_root)&nbsp;&amp;&amp;&nbsp;zip&nbsp;-q&nbsp;../$(notdir&nbsp;$@)&nbsp;META/filesystem_config.txt)&nbsp;&nbsp;</li></ol></div><textarea style="display: none;" cols="50" rows="15" name="code">1073  # Depending on the various images guarantees that the underlying 1074 # directories are up-to-date. 1075 $(BUILT_TARGET_FILES_PACKAGE): / 1076                 $(INSTALLED_BOOTIMAGE_TARGET) / 1077                 $(INSTALLED_RADIOIMAGE_TARGET) / 1078                 $(INSTALLED_RECOVERYIMAGE_TARGET) / 1079                 $(INSTALLED_FACTORYIMAGE_TARGET) / 1080                 $(INSTALLED_SYSTEMIMAGE) / 1081                 $(INSTALLED_USERDATAIMAGE_TARGET) / 1082                 $(INSTALLED_SECROIMAGE_TARGET) / 1083                 $(INSTALLED_ANDROID_INFO_TXT_TARGET) / 1084                 $(built_ota_tools) / 1085                 $(APKCERTS_FILE) / 1086                 $(HOST_OUT_EXECUTABLES)/fs_config / 1087                 | $(ACP) 1088         @echo "Package target files: $@" 1089         $(hide) rm -rf $@ $(zip_root) 1090         $(hide) mkdir -p $(dir $@) $(zip_root) 1091         @# Components of the recovery image 1092         $(hide) mkdir -p $(zip_root)/RECOVERY 1093         $(hide) $(call package_files-copy-root, / 1094                  $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK) 1095 ifdef INSTALLED_KERNEL_TARGET 1096         $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET)  $(zip_root)/RECOVERY/kernel 1097         $(hide) $(ACP) $(recovery_ramdisk)  $(zip_root)/RECOVERY/ramdisk 1098 endif 1099 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1100         $(hide) $(ACP) / 1101                 $(INSTALLED_2NDBOOTLOADER_TARGET)  $(zip_root)/RECOVERY/second 1102 endif 1103 ifdef BOARD_KERNEL_CMDLINE 1104         $(hide) echo "$(BOARD_KERNEL_CMDLINE)" &gt;  $(zip_root)/RECOVERY/cmdline 1105 endif 1106 ifdef BOARD_KERNEL_BASE 1107         $(hide) echo "$(BOARD_KERNEL_BASE)" &gt;  $(zip_root)/RECOVERY/base 1108 endif 1109         @# Components of the factory image 1110         $(hide) mkdir -p $(zip_root)/FACTORY 1111         $(hide) $(call package_files-copy-root, / 1112                  $(TARGET_FACTORY_ROOT_OUT),$(zip_root)/FACTORY/RAMDISK) 1113 ifdef INSTALLED_KERNEL_TARGET 1114         $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET)  $(zip_root)/FACTORY/kernel 1115 endif 1116 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1117         $(hide) $(ACP) / 1118                 $(INSTALLED_2NDBOOTLOADER_TARGET)  $(zip_root)/FACTORY/second 1119 endif 1120 ifdef BOARD_KERNEL_CMDLINE 1121         $(hide) echo "$(BOARD_KERNEL_CMDLINE)" &gt;  $(zip_root)/FACTORY/cmdline 1122 endif 1123 ifdef BOARD_KERNEL_BASE 1124         $(hide) echo "$(BOARD_KERNEL_BASE)" &gt;  $(zip_root)/FACTORY/base 1125 endif 1126         @# Components of the boot image 1127         $(hide) mkdir -p $(zip_root)/BOOT 1128         $(hide) $(call package_files-copy-root, / 1129                 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) 1130 ifdef INSTALLED_KERNEL_TARGET 1131         $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET)  $(zip_root)/BOOT/kernel 1132         $(hide) $(ACP) $(INSTALLED_RAMDISK_TARGET)  $(zip_root)/BOOT/ramdisk 1133 endif 1134 ifdef INSTALLED_2NDBOOTLOADER_TARGET 1135         $(hide) $(ACP) / 1136                 $(INSTALLED_2NDBOOTLOADER_TARGET)  $(zip_root)/BOOT/second 1137 endif 1138 ifdef BOARD_KERNEL_CMDLINE 1139         $(hide) echo "$(BOARD_KERNEL_CMDLINE)" &gt;  $(zip_root)/BOOT/cmdline 1140 endif 1141 ifdef BOARD_KERNEL_BASE 1142         $(hide) echo "$(BOARD_KERNEL_BASE)" &gt;  $(zip_root)/BOOT/base 1143 endif 1144         $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),/ 1145                     mkdir -p $(zip_root)/RADIO; / 1146                     $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));) 1147         @# Contents of the system image 1148         $(hide) $(call package_files-copy-root, / 1149                 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) 1150         @# Contents of the data image 1151         $(hide) $(call package_files-copy-root, / 1152                 $(TARGET_OUT_DATA),$(zip_root)/DATA) 1153         @# Extra contents of the OTA package 1154         $(hide) mkdir -p $(zip_root)/OTA/bin 1155         $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET)  $(zip_root)/OTA/ 1156         $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ 1157         @# Files that do not end up in any images, but are  necessary to 1158         @# build them. 1159         $(hide) mkdir -p $(zip_root)/META 1160         $(hide) $(ACP) $(APKCERTS_FILE)  $(zip_root)/META/apkcerts.txt 1161         $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" &gt;  $(zip_root)/META/otakeys.txt 1162         $(hide) echo "$(PRIVATE_RECOVERY_API_VERSION)" &gt;  $(zip_root)/META/recovery-api-version.txt 1163         $(hide) echo "blocksize $(BOARD_FLASH_BLOCK_SIZE)" &gt;  $(zip_root)/META/imagesizes.txt 1164         $(hide) echo "boot $(call  image-size-from-data-size,$(BOARD_BOOTIMAGE_PARTITION_SIZE))" &gt;&gt;  $(zip_root)/META/imagesizes.txt 1165         $(hide) echo "recovery $(call  image-size-from-data-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))"  &gt;&gt; $(zip_root)/META/imagesizes.txt 1166         $(hide) echo "system $(call  image-size-from-data-size,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))" &gt;&gt;  $(zip_root)/META/imagesizes.txt 1167         $(hide) echo "secro $(call  image-size-from-data-size,$(BOARD_SECROIMAGE_PARTITION_SIZE))" &gt;&gt;  $(zip_root)/META/imagesizes.txt 1168         $(hide) echo "userdata $(call  image-size-from-data-size,$(BOARD_USERDATAIMAGE_PARTITION_SIZE))"  &gt;&gt; $(zip_root)/META/imagesizes.txt 1169         $(hide) echo "$(tool_extensions)" &gt;  $(zip_root)/META/tool-extensions.txt 1170         @# Zip everything up, preserving symlinks 1171         $(hide) (cd $(zip_root) &amp;&amp; zip -qry ../$(notdir $@)  .) 1172         @# Run fs_config on all the system files in the zip, and  save the output 1173         $(hide) zipinfo -1 $@ | awk -F/ 'BEGIN { OFS="/" }  /^SYSTEM/// {$$1 = "system"; print}' | $(HOST_OUT_EXECUTABLES)/fs_config  &gt; $(zip_root)/META/filesystem_config.txt 1174         $(hide) (cd $(zip_root) &amp;&amp; zip -q ../$(notdir $@)  META/filesystem_config.txt) </textarea> </span></p> <p>&nbsp;</p> <p><span style="font-family: 宋体;"><span style="font-size: small;">可见往里面添加了很多内容。</span></span></p> <p><span style="font-size: small;"><span style="font-family: Times New Roman;">L1089-1090 , </span><span style="font-family: 宋体;">造一个目录。</span></span></p> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1091-1108，填充 RECOVERY 子目录的内容。用于生成recovery.img。包括：kernel 的image, recovery 根文件系统的 image, recovery 根文件系统的内容：</span></span></pre> <pre><span style="font-size: small; font-family: 宋体;">RECOVERY$ tree -L 2</span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; kernel</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; ramdisk</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9492;&#9472;&#9472; RAMDISK</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; advanced_meta_init.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; data</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; default.prop</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; dev</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; etc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.factory.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.goldfish.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.mt6516.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; meta_init.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; proc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; res</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; sbin</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; sys</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; system</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9492;&#9472;&#9472; tmp<strong></strong></span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1109-1125, 填充 FACTORY 子目录的内容， 没有用到，包括：kernel 的image </span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1126-1143, 填充 BOOT子目录的内容，用于生成boot.img。和 RECOVERY目录类似，包括：kernel 的image,根文件系统的 image,根文件系统的内容：</span></span></pre> <pre><span style="font-size: small; font-family: 宋体;">BOOT$ tree -L 2</span></pre> <pre><span style="font-size: small; font-family: 宋体;">.</span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; kernel</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; ramdisk</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9492;&#9472;&#9472; RAMDISK</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; advanced_meta_init.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; data</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; default.prop</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; dev</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.factory.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.goldfish.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.mt6516.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; init.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; meta_init.rc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; proc</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; res -&gt; /system/res</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; sbin</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9500;&#9472;&#9472; sys</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp; </span>&#9492;&#9472;&#9472; system</span></span></pre> <pre>&nbsp;</pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1144-1146, 填充 RADIO子目录的内容， 没有用到。</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1147-1149, 填充 SYSTEM子目录的内容。 这是升级的主要内容。</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1150-1152, 填充 DATA子目录的内容。缺省没有用到。</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1153-1156, 填充 OTA/bin子目录的内容,这是OTA升级自己使用的程序。后面会遇到。</span></span></pre> <pre><span style="font-size: small; font-family: 宋体;">OTA/bin$ tree</span></pre> <pre><span style="font-size: small; font-family: 宋体;">.</span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; applypatch</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; applypatch_static</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9500;&#9472;&#9472; check_prereq</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">&#9492;&#9472;&#9472; updater</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1159-1169, 填充 META子目录的内容,这里包含了OTA脚本需要的一些附加信息。</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1170-1171,将所有内容打包。供下一阶段使用。</span></span></pre> <pre><span style="font-size: small;"><span style="font-family: 宋体;">L1173-1174,生成 META/filesystem_config.txt 并将其加入到 zip 包中。该文件保存了 system 目录下各目录、文件的权限及 owner.</span></span></pre> <pre><span style="font-size: small; font-family: 宋体;">$ head META/filesystem_config.txt </span></pre> <pre><span style="font-size: small; font-family: 宋体;">system 0 0 755</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr 0 0 755</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec 0 0 755</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config 0 0 755</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config/en.us 0 0 755</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config/en.us/grammars 0 0 755</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config/en.us/grammars/phone_type_choice.g2g 0 0 644</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config/en.us/grammars/VoiceDialer.g2g 0 0 644</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config/en.us/grammars/boolean.g2g 0 0 644</span></pre> <pre><span style="font-size: small; font-family: 宋体;">system/usr/srec/config/en.us/g2p 0 0 755</span></pre> <pre>&nbsp;</pre> <pre><span style="font-size: small; font-family: 宋体;">这里，目录由 zipinfo &#8211;l 提供， 而权限则由 fs_config 设定。此程序的源码位于：build/tools/fs_config, 其中fs_config 包含了一个头文件：</span></pre> <pre><a name="L54"></a><a href="http://192.168.1.169/lxr/http/source/build/tools/fs_config/fs_config.c#L54"><span style="font-size: small;"><span style="font-family: 宋体;"><span>54</span></span></span></a><span style="font-size: small; font-family: 宋体;"> #include "<a href="http://192.168.1.169/lxr/http/source/build/tools/fs_config/private/android_filesystem_config.h"><span style="font-size: small; font-family: 宋体;">private/android_filesystem_config.h</span></a><span style="font-size: small; font-family: 宋体;">"</span></span></pre> <pre><span style="font-size: small; font-family: 宋体;">这个文件(<strong><span style="background: none repeat scroll 0% 0% lime;">system/core/include/private/android_filesystem_config.h</span></strong>)</span>以hardcoding 的方式设定了 system 下各目录、文件的权限、属主。比如：</pre> <pre><a name="L152"></a><a href="http://192.168.1.169/lxr/http/source/system/core/include/private/android_filesystem_config.h#L152"><span style="font-size: small;"><span style="font-family: 宋体;"><span>152</span></span></span></a><span style="font-size: small; font-family: 宋体;"> <span>&nbsp;&nbsp;&nbsp;&nbsp;{ 00440, </span><a href="http://192.168.1.169/lxr/http/ident?i=AID_ROOT"><span style="font-size: small; font-family: 宋体;">AID_ROOT</span></a><span style="font-size: small;"><span style="font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_SHELL"><span style="font-size: small; font-family: 宋体;">AID_SHELL</span></a><span style="font-size: small; font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp; <em>"system/etc/init.goldfish.rc"</em> },</span></span></pre> <pre><a name="L153"></a><a href="http://192.168.1.169/lxr/http/source/system/core/include/private/android_filesystem_config.h#L153"><span style="font-size: small;"><span style="font-family: 宋体;"><span>153</span></span></span></a><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp;&nbsp; { 00550, </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_ROOT"><span style="font-size: small; font-family: 宋体;">AID_ROOT</span></a><span style="font-size: small;"><span style="font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_SHELL"><span style="font-size: small; font-family: 宋体;">AID_SHELL</span></a><span style="font-size: small; font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp; <em>"system/etc/init.goldfish.sh"</em> },</span></span></pre> <pre><a name="L154"></a><a href="http://192.168.1.169/lxr/http/source/system/core/include/private/android_filesystem_config.h#L154"><span style="font-size: small;"><span style="font-family: 宋体;"><span>154</span></span></span></a><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp;&nbsp; { 00440, </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_ROOT"><span style="font-size: small; font-family: 宋体;">AID_ROOT</span></a><span style="font-size: small;"><span style="font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_SHELL"><span style="font-size: small; font-family: 宋体;">AID_SHELL</span></a><span style="font-size: small; font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp; <em>"system/etc/init.trout.rc"</em> },</span></span></pre> <pre><a name="L155"></a><a href="http://192.168.1.169/lxr/http/source/system/core/include/private/android_filesystem_config.h#L155"><span style="font-size: small;"><span style="font-family: 宋体;"><span>155</span></span></span></a><span style="font-size: small;"><span style="font-family: 宋体;"><span>&nbsp;&nbsp;&nbsp;&nbsp; { 00550, </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_ROOT"><span style="font-size: small; font-family: 宋体;">AID_ROOT</span></a><span style="font-size: small;"><span style="font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="http://192.168.1.169/lxr/http/ident?i=AID_SHELL"><span style="font-size: small; font-family: 宋体;">AID_SHELL</span></a><span style="font-size: small; font-family: 宋体;">,&nbsp;&nbsp;&nbsp;&nbsp; <em>"system/etc/init.ril"</em> },</span></span></pre> <pre>&nbsp;</pre> <pre><span style="font-size: small; font-family: 宋体;">如果需要升级其它内容，比如 bootloader, 则可以在这里加入。</span></pre> <pre>&nbsp;</pre> <h2><span style="font-family: 黑体;"><span style="font-size: large;">步骤二</span></span></h2> <p><a name="L1186"><span style="font-size: small;"><span style="font-family: 宋体;">编译脚本如下</span><span style="font-family: Times New Roman;">:</span></span></a></p> <p><span><span style="font-size: small; font-family: Times New Roman;">(From: build/core/Makefile)</span></span></p> <p><span><span style="font-size: small; font-family: Times New Roman;"><div nogutter="" bg_c-sharp:nogutter:nocontrols=""><ol start="1"><li><span><span>1186&nbsp;name&nbsp;:=&nbsp;$(TARGET_PRODUCT)&nbsp;&nbsp;</span></span></li><li>1187&nbsp;ifeq&nbsp;($(TARGET_BUILD_TYPE),debug)&nbsp;&nbsp;</li><li>1188&nbsp;&nbsp;&nbsp;name&nbsp;:=&nbsp;$(name)_debug&nbsp;&nbsp;</li><li>1189&nbsp;endif&nbsp;&nbsp;</li><li>1190&nbsp;name&nbsp;:=&nbsp;$(name)-ota-$(FILE_NAME_TAG)&nbsp;&nbsp;</li><li>1191&nbsp;&nbsp;&nbsp;</li><li>1192&nbsp;INTERNAL_OTA_PACKAGE_TARGET&nbsp;:=&nbsp;$(PRODUCT_OUT)/$(name).zip&nbsp;&nbsp;</li><li>1193&nbsp;&nbsp;&nbsp;</li><li>1194&nbsp;$(INTERNAL_OTA_PACKAGE_TARGET):&nbsp;KEY_CERT_PAIR&nbsp;:=&nbsp;$(DEFAULT_KEY_CERT_PAIR)&nbsp;&nbsp;</li><li>1195&nbsp;&nbsp;&nbsp;</li><li>1196&nbsp;ifeq&nbsp;($(TARGET_OTA_SCRIPT_MODE),)&nbsp;&nbsp;</li><li>1197&nbsp;#&nbsp;<span>default&nbsp;to&nbsp;"auto"&nbsp;&nbsp;</span></li><li>1198&nbsp;$(INTERNAL_OTA_PACKAGE_TARGET):&nbsp;scriptmode&nbsp;:=&nbsp;auto&nbsp;&nbsp;</li><li>1199&nbsp;<span>else&nbsp;&nbsp;</span></li><li>1200&nbsp;$(INTERNAL_OTA_PACKAGE_TARGET):&nbsp;scriptmode&nbsp;:=&nbsp;$(TARGET_OTA_SCRIPT_MODE)&nbsp;&nbsp;</li><li>1201&nbsp;endif&nbsp;&nbsp;</li><li>1202&nbsp;&nbsp;&nbsp;</li><li>1203&nbsp;$(INTERNAL_OTA_PACKAGE_TARGET):&nbsp;$(BUILT_TARGET_FILES_PACKAGE)&nbsp;$(OTATOOLS)&nbsp;&nbsp;</li><li>1204&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@echo&nbsp;<span>"Package&nbsp;OTA:&nbsp;$@"&nbsp;&nbsp;</span></li><li>1205&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(hide)&nbsp;./build/tools/releasetools/ota_from_target_files&nbsp;/&nbsp;&nbsp;</li><li>1206&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-m&nbsp;$(scriptmode)&nbsp;/&nbsp;&nbsp;</li><li>1207&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-p&nbsp;$(HOST_OUT)&nbsp;/&nbsp;&nbsp;</li><li>1208&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-k&nbsp;$(KEY_CERT_PAIR)&nbsp;/&nbsp;&nbsp;</li><li>1209&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(BUILT_TARGET_FILES_PACKAGE)&nbsp;$@&nbsp;&nbsp;</li></ol></div><textarea style="display: none;" cols="50" rows="15" name="code">1186 name := $(TARGET_PRODUCT) 1187 ifeq ($(TARGET_BUILD_TYPE),debug) 1188   name := $(name)_debug 1189 endif 1190 name := $(name)-ota-$(FILE_NAME_TAG) 1191  1192 INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1193  1194 $(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) 1195  1196 ifeq ($(TARGET_OTA_SCRIPT_MODE),) 1197 # default to "auto" 1198 $(INTERNAL_OTA_PACKAGE_TARGET): scriptmode := auto 1199 else 1200 $(INTERNAL_OTA_PACKAGE_TARGET): scriptmode := $(TARGET_OTA_SCRIPT_MODE) 1201 endif 1202  1203 $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS) 1204         @echo "Package OTA: $@" 1205         $(hide) ./build/tools/releasetools/ota_from_target_files / 1206            -m $(scriptmode) / 1207            -p $(HOST_OUT) / 1208            -k $(KEY_CERT_PAIR) / 1209            $(BUILT_TARGET_FILES_PACKAGE) $@ </textarea> </span></span></p> <p>&nbsp;</p> <p><span style="font-size: 12pt; font-family: 宋体;">核心是一个python脚本: ota_from_target_files, 它以前一步骤生成的ZIP包作为输入，生成可用于OTA升级的zip包。 具体内容我们后文继续分析。</span></p> </div></div><img src ="http://www.blogjava.net/MEYE/aggbug/357094.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-23 09:58 <a href="http://www.blogjava.net/MEYE/articles/357094.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Recovery界面的中文详细说明</title><link>http://www.blogjava.net/MEYE/articles/356607.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Tue, 16 Aug 2011 02:00:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/356607.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/356607.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/356607.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/356607.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/356607.html</trackback:ping><description><![CDATA[<div><h1>Recovery界面的中文详细说明</h1></div><div><strong>首先，介绍下进入Recovery的方式<br /> 	1：</strong>完全关机，按住音量下+电源键开机，进入bootloader界面<br /> 	<strong>2：</strong>按音量键移动光标到Recovery那一行<br /> 	<strong>3：</strong>按电源键（之后机器会重启进入Recovery）<br /> 	<strong>音量键为光标选择键，可以用来移动光标，电源键为确认键！<br /> 	一：Recovery主界面<br /> 	*reboot system now：</strong>重启手机（刷机完毕选择此项就能重新启动系统）<br /> 	<strong>*apply SDcard：update.zip：</strong>安装存储卡中的update.zip升级包（你可以把刷机包命名为update.zip然后用这个选项直接升级）<br /> 	<strong>*wipe data/factory reset：</strong>清除用户数据并恢复出厂设置（刷机前必须执行的选项）<br /> 	<strong>*wipe cache partition：</strong>清除系统缓存（刷机前执行）（系统出问题也可尝试此选项，一般能够解决）<br /> 	<strong>*install zip from SDcard：</strong>从SDcard上安装zip升级包（可以执行任意名称的zip升级包，不限制升级包名称）<br /> 	<strong>*backup and restore：</strong>备份和还原系统（作用和原理如同电脑上的chost一键备份和还原）<br /> 	<strong>*mounts and storage：</strong>挂载和存储选项（详细功能见下面的解释）<br /> 	<strong>*advanced：</strong>高级设置<br /> 	<strong>二：backup and restore功能详解<br /> 	*Backup：</strong>备份当前系统<br /> 	<strong>*Restore：</strong>还原上一个系统<br /> 	<strong>*Advanced Restore：</strong>高级还原选项（用户可以自选之前备份的系统，然后进行恢复）<br /> 	<strong>三：mounts and storage功能详解<br /> 	*mount&nbsp; /system：</strong>挂载system文件夹（基本用不到）<br /> 	<strong>*mount&nbsp; /data：</strong>挂载data文件夹（基本用不到）<br /> 	<strong>*unmount&nbsp; /cache：</strong>取消cache文件夹挂载（基本用不到）<br /> 	<strong>*unmount&nbsp; /sdcard：</strong>取消内存卡挂载（基本用不到）<br /> 	<strong>*mount&nbsp; /sd-ext：</strong>挂载内存卡Ext分区（基本用不到）<br /> 	<strong>*format&nbsp; boot：</strong>格式化boot（刷机前最好执行一下）<br /> 	<strong>*format&nbsp; system：</strong>格式化system（刷机前最好执行一下）<br /> 	<strong>*format&nbsp; data：</strong>格式化data（刷机前最好执行一下）<br /> 	<strong>*format&nbsp; cache：</strong>格式化cache（刷机前最好执行一下）<br /> 	<strong>*format&nbsp; sdcard：</strong>格式化内储卡(执行此项你会后悔的)<br /> 	<strong>*format&nbsp; sd-ext：</strong>格式化内存卡Ext分区(执行此项你会后悔的)<br /> 	<strong>*mount USB storage：</strong>开启Recovery模式下的USB大容量存储功能（也就是说可以在Recovery下对内存卡进行读写操作）<br /> 	<strong>四：Advance 功能详解<br /> 	*Reboot&nbsp; Recovery：</strong>重启Recovery（重启手机并再次进入Recovery）&nbsp;<br /> 	<strong>*Wipe&nbsp; Dalvik&nbsp; Cache：</strong>清空虚拟机缓存（可以解决一些程序FC的问题）<strong>&nbsp;&nbsp;<br /> 	*Wipe&nbsp; Battery&nbsp; Stats: </strong>清空电池调试记录数据（刷机前做下这个，会比较好，感觉自己电量有问题的机油也可以试试）<br /> 	<strong>*Report&nbsp; Error：</strong>错误报告（配合固件管家用的，不是开发者请无视）<br /> 	<strong>*Key&nbsp; Test：</strong>按键测试（基本没撒用的功能！）<br /> 	<strong>*Partition&nbsp; SD&nbsp; Card：</strong>对内存卡分区（个人觉得DHD不需要分区，一来耗电、二来影响速度！）<br /> 	<strong>*Fix&nbsp; Permissions：</strong>修复Root权限（如果你的手机Root权限出问题了，可以用这个功能）<br /><br /><div><h1><a href="http://www.zydroid.com/forum.php?mod=forumdisplay&amp;fid=6&amp;filter=typeid&amp;typeid=7">[资料]</a> <a href="http://www.zydroid.com/thread-335-1-1.html" id="thread_subject">&#9670;Android系统名词解释，详解recovery模式下各种指令&#9670;</a></h1></div><br /><br /><div><strong>APK：<br /> <br /> </strong>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;APK 是Android Package 的缩写，即Android安装包。APK 相当于电脑上的exe文件或者塞班上的sis文件。<br /> <br /> <strong>ROM、RUU：</strong><br /> <strong></strong><br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; ROM，是用来刷你手机系统的数据文件，也就是Android 系统的封装包，通过手机的工程模式解压安装到手机中形成你手机的操作系统。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;简单来说就是手机固件，相当于电脑的系统，我们刷机也就是重新安装这部分。<br /> &nbsp; &nbsp;&nbsp; &nbsp; 官方原版ROM 就是RUU，（相当于原版Windows XP）首先他是一个最安全的升级工具，可以让我们安全的升级ROM (一定要对应的机型)。<br /> &nbsp; &nbsp;&nbsp; &nbsp; 当我们在刷机过程中由于不当的操作或版本选择的错误，导致无法启动，可以使用官方的RUU 程序来恢复系统，等于说，这是一个救命道具。<br /> <br /> <strong>Radio：</strong><br /> <strong></strong><br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;  Radio指代的是通讯模块，就是手机里面负责信号部分的模块，PDA类型的手机，基本都强调这么个概念。一个是PDA，一个是手机（貌似是句废话-  -），举个很简单的例子，以三星的PPC手机为例，比如i718.比如i908，他们在刷机的时候（所谓刷机就是重装系统）一般都是分两部分，第一部分刷 手机部分，第二部分刷PDA部分，而且两部分基本不相干。<br /> <br /> <strong>app2sd：</strong><br /> <strong></strong><br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Google 手机的软件为了安全性和稳定性都是默认安装到手机内存里，但是手机内存有限，所以我们会做app2sd  操作，来让我们安装的软件放到sd卡上，而Google 的android 系统是基于Linux 的，所以存储卡上本身的Fat  格式是不会被识别的，所以我们要分区（第二分区）出来，格式成Linux 认识的ext2 或3 或4  格式，在用链接命令，把这个分区映射成一个系统文件夹system/sd（大概这个意思），把所有的软件装到这个&#8220;文件夹&#8221;下，这就是app2sd  的操作。需要ROM 支持并开启app2sd 功能。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;app2sd  的操作其实是牺牲了一部分软件的速度和稳定性来换取更多的手机内存安装更多的软件。另外，app2sd只是把软件放到了sd卡上，运行软件还是需要占用手 机的内存的，所以，你装了软件之后，一般手机内存还是会减少一些。你如果安装的软件在70个以内，个人觉得没有必要，呵呵，如果很多游戏软件除外。此外， 使用app2sd 最大的好处就是，刷一个带app2sd 的rom  之后，以后升级这个rom（依然带app2sd）的时候，你的软件都会完整保存（个别除外，比如htc input  chinese需要重新添加几个文件到system/lib下），不过很多ROM 是需要Wipe ext 分区的，也就不能保留了。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;目前来看我们现在所使用的Android 各种软件暂时还没有进行app2sd 的必要。<br /> &nbsp; &nbsp;&nbsp; &nbsp; 简单来说就是把程序安装到内存卡里面<br /> 注：为了适应用户需求，从android 2.2开始 android系统已经支持安装软件到sd卡。<br /> <br /> <strong>root：</strong><br /> <strong></strong><br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;root 就是你手机的boss，它可以访问和修改你手机几乎所有的文件，这些东西可能是制作手机的人不愿意你修改和触碰的东西，因为他们有可能影响到手机的稳定，还容易被一些hacker 有机会入侵你的手机（貌似还没有出来这类黑客）。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;既然root 这么危险，我们为什么还要去获取它？其实用root  的权限主要是因为我们生在天朝，我们很多东西是受限制的，我们只能利用这些权限来做我们被限制的去做的事情，比如Google  禁止我们看到市场里很多免费或付费软件，我们可以用marketenabler 来进去看；再比如国庆以来GFW  把我们的市场干掉了，很多朋友只能看不能下，不能绑定gmail，我们可以修改hosts 来搞定他们，但这些都需要root权限。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;比如目前所有在hero 上截屏的软件都需要root 权限，没有root  权限，像Drocap、Shootme、Picme等等这类截屏软件就不能使用（当然，我们可以连线电脑，使用 91助手在电脑上截取自己想要的hero  屏图）。个人觉得，除非必要，不要总是去想着获取root。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ROOT就是手机的最高权限，相当于塞班的XX权限，可以对系统文件进行操作。<br /> <br /> <strong>SPL：</strong><br /> <strong></strong><br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; SPL全称&#8220;Secondary Program Loader&#8221;，中文名叫做二次程序载入器，负责检测ROM和硬件，寻找系统启动分区并装载ROM的其它部分。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 简单来说，就是俗称的刷机安全套件，保证您在刷机失败时也不会变砖头，通常可分为&#8220;Hard-SPL&#8221;和&#8220;Soft-SPL&#8221;两种。XX手机也就是XX的这个部分。<br /> <br /> <strong>recovery：</strong><br /> <br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;recovery 就是你用 home 键+开机键 开机后能进入的一个界面（工程模式），在这个界面你可以直接用sd  卡上的zip 的rom 升级或者备份你的系统，老版本的recovery  只有三个选项，无法备份系统，只能用update.zip这个文件名的文件升级，不能用任何文件名的zip文件升级。新版本已经多出很多选项可以供你操 作。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;此外，一般刷rom 之前最好wipe一下（wipe只是抹除rom 以外的个人数据，不会影响rom  本身），也就是返回出厂设置一下比较好，但是这样就会丢失你的所有软件，短信彩信，联系人（备份在google上没有关系）和设置等等，备份或者不 wipe 都可以。<br /> 目前最新版为：RA-hero-v1.6.2<br /> 说说RA-hero-v1.6.2里的对应的说明：<br /> 1、Reboot system now&#8212;&#8212;重启<br /> 2、USB-MS toggle&#8212;&#8212;在recovery 模式下直接连接USB而不需要退出该模式<br /> 3、Backup/Restore&#8212;&#8212;备份和还原<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;3-1、Nand backup&#8212;&#8212;Nand 备份<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;3-2、Nand + ext backup&#8212;&#8212;Nand 备份（系统和ext 分区一同备份）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;3-3、Nand restore&#8212;&#8212;还原（就是还原3-1、3-2 的最后一次备份）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;3-4、BART backup&#8212;&#8212;BART 备份 （包括系统和ext 分区）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;3-5、BART restore&#8212;&#8212;还原最后一次的BART备份<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Nand 备份类似于系统的备份 而BART 则像是PC 上ghost 的备份。<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Nand 备份 它不会备份ext 分区（就是第二分区 没有分区的可以不管这个） <br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;所以你的如果app2sd 了 那么装在第二分区的程序用Nand 恢复是办不到的<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;BAR T则可以备份到ext 分区 用BART 恢复则可以恢复整个系统 可以使它和你备份前一模一样，<br /> &nbsp; &nbsp;&nbsp; &nbsp; 不会有一点文件信息的丢失（包括联系人、短信、图片、影音等，所以如果你装的东西比较多，那么备份和恢复会比较慢）<br /> 4、Flash zip from sdcard&#8212;&#8212;从sd卡根目录的.zip ROM 刷机包刷机<br /> 5、Wipe&#8212;&#8212;清除<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;5-1、Wipe data/factory reset&#8212;&#8212;清除内存数据和缓存数据（刷机前建议清除此项）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;5-2、Wipe Dalvik-cache&#8212;&#8212;清除缓存数据 + ext 分区内数据（刷机前建议清除此项）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;5-3、Wipe SD：ext partition&#8212;&#8212;只清除ext 分区内数据（刷机前建议清除此项）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;5-4、Wipe battery stats&#8212;&#8212;清除电池数据（刷机前建议清除此项）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;5-5、Wipe rotate settings&#8212;&#8212;清除传感器内设置的数据（刷机前建议清除此项）<br /> 6、Partition sdcard&#8212;&#8212;分区sd 卡<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;6-1、Partition SD&#8212;&#8212;自动为sd 卡分区<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;6-2、Repair SD:ext&#8212;&#8212;修复ext 分区<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;6-3、SD:ext2 to ext3&#8212;&#8212;将ext2 分区转换为ext3 分区（推荐）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;6-4、SD:ext3 to ext4&#8212;&#8212;将ext3 分区转换为ext4 分区（C4 卡不推荐，C6 卡推荐）<br /> 7、Other&#8212;&#8212;其它<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;7-1、Fix apk uid mismatches&#8212;&#8212;修复apk 程序<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;7-2、Move apps+dalv to SD&#8212;&#8212;移动程序和虚拟缓存到sd 卡（这个可不是 app2sd）<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;7-3、Move recovery.log to SD&#8212;&#8212;移动刷机日志文件到sd 卡<br /> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; （执行此操作后，sd 卡根目录会出现一个&#8220;recovery.log&#8221; 文件 即为刷机日志文件）<br /> <br /> 8、Power off&#8212;&#8212;关机<br /> <br /> <strong>fastboot:</strong><br /> <strong><br /> </strong>从字面上来看是【快速启动】的意思，也算是一个刷机界面，不过比recovery更加底层.这个底层是更加接近硬件层的意思.<br /> 两个都很重要，不过fastboot更为主要.当你不能进入recovery的时候，不要紧张，你还能进fastboot挽救，不过当你连fastboot都不能进入的时候，那可真就是砖了.<br /> 通俗的说 recovery就好比外套，fastboot就好比内裤.当你的外套没了的时候，你还有内裤，这个时候顶多被人说成是臭流氓.不过当你内裤都没了的时候，那可就是耍流氓了，到时会有警察叔叔请你喝茶的.<br /> 为了使用Fastboot功能.您必须root您的设备.并获得S-OFF的SPL.你的电脑还必须装有ADB驱动.<br /> 进入Fastboot的方式是关机状态下按返回+开机.<br /> <br /> <strong>Fastboot使用方式: fastboot [ &lt;选项&gt; ] &lt;命令&gt;</strong><br /> 解释:<br /> []括起来表示这个是可选的.<br /> &lt;&gt;括起来表示这个是必须的.<br /> <br /> <strong><strong>可用命令</strong>:</strong><br /> update &lt;文件名&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;从官方update.zip升级系统.该update.zip必须是官方的<br /> flashall&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;'flash boot' + 'flash system'<br /> flash &lt;分区名&gt; [ &lt;文件名&gt; ]&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;将文件写入分区.文件必须正确的格式.分区名有但不限于system,recovery,boot,splash1,hboot,radio,userdata,cache<br /> erase &lt;分区名&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;清空一个分区.<br /> getvar &lt;参数名&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;显示一个启动参数<br /> boot &lt;内核文件&gt; [ &lt;ramdisk文件&gt; ]&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;将电脑上的内核下载到手机并用该内核启动系统.<br /> flash:raw boot &lt;内核文件&gt; [ &lt;ramdisk文件&gt; ]&nbsp; &nbsp; 创建boot.img并下载到手机启动系统.<br /> devices&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 列出所有与电脑连接的设备.<br /> reboot&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;正常启动系统<br /> reboot-bootloader&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;启动系统到hboot<br /> <br /> <strong>选项:</strong><br /> -w&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;清空用户数据分区和缓存分区.相当于recvery中的"wipe data/factory reset"<br /> -s &lt;串口号&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;置顶要操作的设备的串口号<br /> -p &lt;产品名&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;指定要操作的设备的产品名.比如hero,bravo,dream...<br /> -c &lt;命令行&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;用命令行替换系统的启动命令行.<br /> <br /> <strong>分区解释:</strong><br /> system:系统分区.我们刷机器一般就是刷的这个分区.<br /> userdata:数据分区.<br /> cache:缓存分区<br /> recovery:Recovery分区.<br /> boot:存放内核和ramdisk的分区.<br /> hboot:这个是SPL所在的分区.很重要哦.也是fastboot所在的分区.刷错就真的变砖了.<br /> splash1:这个就是开机第一屏幕了.<br /> radio:这个是无线所在的分区.<br /> misc:其他分区.放的是htc的一些东西.]<br /><br /><div><h3><a href="http://leox.iteye.com/blog/975303">[转]Android Recovery模式</a></h3></div><br /><div>http://leox.iteye.com/blog/975303<br /><div><div id="blog_content">     <p><a href="http://blogold.chinaunix.net/u/14459/showart_1911144.html">http://blogold.chinaunix.net/u/14459/showart_1911144.html</a></p> <p>&nbsp;</p> <p> </p> <p align="center"><span style="color: #ff0000;"><span style="font-family: 'AR PL UMing CN',serif;"><span style="font-size: small;"><strong>(muddogxp&nbsp;</strong></span></span><span style="font-size: small;"><strong>原创，转载请注明</strong></span><span style="font-family: 'AR PL UMing CN',serif;"><span style="font-size: small;"><strong>)</strong></span></span></span></p> <p><span style="font-family: 'AR PL UMing HK'; font-size: 19px; font-style: italic; font-weight: bold;"><span style="font-family: 'AR PL UMing HK',sans-serif;">Recovery</span>简介</span></p> <p><span style="font-family: 'AR PL UMing CN',serif;">Android</span>利用<span style="font-family: 'AR PL UMing CN',serif;">Recovery</span>模式，进行恢复出厂设置，<span style="font-family: 'AR PL UMing CN',serif;">OTA</span>升级，<span style="font-family: 'AR PL UMing CN',serif;">patch</span>升级及<span style="font-family: 'AR PL UMing CN',serif;">firmware</span>升级。</p> <p>升级一般通过运行升级包中的<span style="font-family: 'AR PL UMing CN',serif;">META-INF/com/google/android/update-script</span>脚本来执行自定义升级，脚本中是一组<span style="font-family: 'AR PL UMing CN',serif;">recovery</span>系统能识别的<span style="font-family: 'AR PL UMing CN',serif;">UI</span>控制，文件系统操作命令，例如<span style="font-family: 'AR PL UMing CN',serif;">write_raw_image</span>（写<span style="font-family: 'AR PL UMing CN',serif;">FLASH</span>分区），<span style="font-family: 'AR PL UMing CN',serif;">copy_dir</span>（复制目录）。该包一般被下载至<span style="font-family: 'AR PL UMing CN',serif;">SDCARD</span>和<span style="font-family: 'AR PL UMing CN',serif;">CACHE</span>分区下。如果对该包内容感兴趣，可以从<span style="font-family: 'AR PL UMing CN',serif;">http://forum.xda-developers.com/showthread.php?t=442480</span>下载<span style="font-family: 'AR PL UMing CN',serif;">JF</span>升级包来看看。</p> <p>升级中还涉及到包的数字签名，签名方式和普通<span style="font-family: 'AR PL UMing CN',serif;">JAR</span>文件签名差不错。公钥会被硬编译入<span style="font-family: 'AR PL UMing CN',serif;">recovery</span>，编译时生成在：<span style="font-family: 'AR PL UMing CN',serif;">out/target/product/XX/obj/PACKAGING/ota_keys_inc_intermediates/keys.inc</span></p> <h2> <span style="font-family: 'AR PL UMing HK',sans-serif;">G1</span>中的三种启动模式</h2> <p><span style="font-family: 'AR PL UMing CN',serif;">MAGIC KEY:</span></p> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li> <p><span style="font-family: 'AR PL UMing CN',serif;">camera + power</span>：<span style="font-family: 'AR PL UMing CN',serif;">bootloader</span>模式，<span style="font-family: 'AR PL UMing CN',serif;">ADP</span>里则可以使用<span style="font-family: 'AR PL UMing CN',serif;">fastboot</span>模式</p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">home + power</span>：<span style="font-family: 'AR PL UMing CN',serif;">recovery</span>模式</p> </li><li> <p>正常启动</p> </li></ul> <p><span style="font-family: 'AR PL UMing CN',serif;">Bootloader</span>正常启动，又有三种方式，按照<span style="font-family: 'AR PL UMing CN',serif;">BCB</span>（<span style="font-family: 'AR PL UMing CN',serif;">Bootloader Control Block,&nbsp;</span>下节介绍）中的<span style="font-family: 'AR PL UMing CN',serif;">command</span>分类：</p> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li> <p><span style="font-family: 'AR PL UMing CN',serif;">command == 'boot-recovery' &#8594;&nbsp;</span>启动<span style="font-family: 'AR PL UMing CN',serif;">recovery.img</span>。<span style="font-family: 'AR PL UMing CN',serif;">recovery</span>模式</p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">command == 'update-radio/hboot' &#8594;&nbsp;</span>更新<span style="font-family: 'AR PL UMing CN',serif;">firmware</span>（<span style="font-family: 'AR PL UMing CN',serif;">bootloader)</span></p> </li><li> <p>其他 &#8594; 启动<span style="font-family: 'AR PL UMing CN',serif;">boot.img</span></p> </li></ul> <h2> <span style="font-family: 'AR PL UMing HK',sans-serif;">Recovery</span>涉及到的其他系统及文件</h2> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li> <h3> <span style="font-family: 'AR PL UMing HK',sans-serif;">CACHE</span>分区文件</h3> </li></ul> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li>&nbsp; <ul><li> <p><span style="font-family: 'Times New Roman',serif;">/cache/recovery/command</span><span style="font-family: 'Times New Roman',serif;">：&nbsp;</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">命令，由主系统写入。所有命令如下：</span></p> <ul><li> <p><span style="font-family: 'Times New Roman',serif;">--send_intent=anystring - write the text out to recovery.intent</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">--update_package=root:path - verify install an OTA package file</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">--wipe_data - erase user data (and cache), then reboot</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">--wipe_cache - wipe cache (but not user data), then reboot</span></p> </li></ul> </li><li> <p><span style="font-family: 'Times New Roman',serif;">/cache/recovery/log</span><span style="font-family: 'Times New Roman',serif;">：</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">过程日志，由主系统读出</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">/cache/recovery/intent</span><span style="font-family: 'Times New Roman',serif;">：</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">输出的</span><span style="font-family: 'Times New Roman',serif;">intent</span></p> </li></ul> </li><p><span style="font-family: 'Times New Roman',serif;">Recovery&nbsp;</span><span style="font-family: 'Times New Roman',serif;">工具通过</span><span style="font-family: 'Times New Roman',serif;">NAND cache</span><span style="font-family: 'Times New Roman',serif;">分区上的三个文件和主系统打交道。主系统（包括恢复出厂设置和</span><span style="font-family: 'Times New Roman',serif;">OTA</span><span style="font-family: 'Times New Roman',serif;">升级）可以写入</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">所需的命令，读出</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">过程中的</span><span style="font-family: 'Times New Roman',serif;">LOG</span><span style="font-family: 'Times New Roman',serif;">和</span><span style="font-family: 'Times New Roman',serif;">intent</span><span style="font-family: 'Times New Roman',serif;">。</span></p><li> <h3> <span style="font-family: 'Times New Roman',serif;">MISC</span><span style="font-family: 'Times New Roman',serif;">分区内容</span> </h3> <p><span style="font-family: 'Times New Roman',serif;">Bootloader Control Block (BCB)&nbsp;</span><span style="font-family: 'Times New Roman',serif;">存放</span><span style="font-family: 'Times New Roman',serif;">recovery bootloader message</span><span style="font-family: 'Times New Roman',serif;">。结构如下：</span></p> <p><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #999999; background-position: 0% 0%;">struct bootloader_message {</span></span></p> <ul><p><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #999999; background-position: 0% 0%;">char command[32];</span></span></p><p><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #999999; background-position: 0% 0%;">char status[32]; //&nbsp;</span></span><span style="background-image: none; background-color: #999999; background-position: 0% 0%;"><span style="font-family: 'Times New Roman',serif;">未知用途</span></span></p><p><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #999999; background-position: 0% 0%;">char recovery[1024];</span></span></p></ul> <p><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #999999; background-position: 0% 0%;">};</span></span></p> <ul><li> <p><span style="font-family: 'Times New Roman',serif;">command</span><span style="font-family: 'Times New Roman',serif;">可以有以下两个值</span></p> <p>&#8220;<span style="font-family: 'Times New Roman',serif;">boot-recovery&#8221;</span><span style="font-family: 'Times New Roman',serif;">：标示</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">正在进行，或指示</span><span style="font-family: 'Times New Roman',serif;">bootloader</span><span style="font-family: 'Times New Roman',serif;">应该进入</span><span style="font-family: 'Times New Roman',serif;">recovery mode</span></p> <p>&#8220;<span style="font-family: 'Times New Roman',serif;">update-hboot/radio&#8221;</span><span style="font-family: 'Times New Roman',serif;">：指示</span><span style="font-family: 'Times New Roman',serif;">bootloader</span><span style="font-family: 'Times New Roman',serif;">更新</span><span style="font-family: 'Times New Roman',serif;">firmware</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">内容</span></p> <p>&#8220;<span style="font-family: 'AR PL UMing CN',serif;"><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #ffff00; background-position: 0% 0%;">recovery\n</span></span></span></p> <p><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #ffff00; background-position: 0% 0%;">&lt;recovery command&gt;\n</span></span></p> <p><span style="font-family: 'AR PL UMing CN',serif;"><span style="font-family: 'Times New Roman',serif;"><span style="background-image: none; background-color: #ffff00; background-position: 0% 0%;">&lt;recovery command&gt;</span></span><span style="font-family: 'Times New Roman',serif;">&#8221;</span></span></p> <p><span style="font-family: 'Times New Roman',serif;">其中</span><span style="font-family: 'Times New Roman',serif;">recovery command</span><span style="font-family: 'Times New Roman',serif;">为</span><span style="font-family: 'Times New Roman',serif;">CACHE:/recovery/command</span><span style="font-family: 'Times New Roman',serif;">命令</span></p> </li></ul> </li></ul> <p><br /></p> <h2>两种<span style="font-family: 'AR PL UMing HK',sans-serif;">Recovery Case</span> </h2> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li> <h3> <span style="font-family: 'AR PL UMing HK',sans-serif;">FACTORY RESET</span>（恢复出厂设置）</h3> </li></ul> <ol style="font-family: song,Verdana; border-collapse: collapse;"><li> <p><span style="font-family: 'Times New Roman',serif;">用户选择&#8220;恢复出厂设置&#8221;</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">设置系统将</span><span style="font-family: 'Times New Roman',serif;">"--wipe_data"</span><span style="font-family: 'Times New Roman',serif;">命令写入</span><span style="font-family: 'Times New Roman',serif;">/cache/recovery/command</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">系统重启，并进入</span><span style="font-family: 'Times New Roman',serif;">recover</span><span style="font-family: 'Times New Roman',serif;">模式（</span><span style="font-family: 'Times New Roman',serif;">/sbin/recovery</span><span style="font-family: 'Times New Roman',serif;">）</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">get_args()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">将&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"boot-recovery"</span><span style="font-family: 'Times New Roman',serif;">和</span><span style="font-family: 'Times New Roman',serif;">"--wipe_data"</span><span style="font-family: 'Times New Roman',serif;">写入</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">erase_root()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">格式化（擦除）</span><span style="font-family: 'Times New Roman',serif;">DATA</span><span style="font-family: 'Times New Roman',serif;">分区</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">erase_root()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">格式化（擦除）</span><span style="font-family: 'Times New Roman',serif;">CACHE</span><span style="font-family: 'Times New Roman',serif;">分区</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">finish_recovery()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">擦除</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">重启系统</span></p> </li></ol> <p>&nbsp;</p> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li> <h3> <span style="font-family: 'AR PL UMing HK',sans-serif;">OTA INSTALL</span><span style="font-family: 'AR PL UMing HK';">（</span><span style="font-family: 'AR PL UMing HK',sans-serif;">OTA</span><span style="font-family: 'AR PL UMing HK';">升级）</span> </h3> </li></ul> <ol style="font-family: song,Verdana; border-collapse: collapse;"><li> <p><span style="font-family: 'Times New Roman',serif;">升级系统下载&nbsp;</span><span style="font-family: 'Times New Roman',serif;">OTA</span><span style="font-family: 'Times New Roman',serif;">包到</span><span style="font-family: 'Times New Roman',serif;">/cache/some-filename.zip</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">升级系统写入</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">命令</span><span style="font-family: 'Times New Roman',serif;">"--update_package=CACHE:some-filename.zip"</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">重启，并进入</span><span style="font-family: 'Times New Roman',serif;">recovery</span><span style="font-family: 'Times New Roman',serif;">模式</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">get_args()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">将</span><span style="font-family: 'Times New Roman',serif;">"boot-recovery"&nbsp;</span><span style="font-family: 'Times New Roman',serif;">和&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"--update_package=..."&nbsp;</span><span style="font-family: 'Times New Roman',serif;">写入</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">install_package()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">作升级</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">finish_recovery()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">擦除&nbsp;</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">**&nbsp;</span><span style="font-family: 'Times New Roman',serif;">如果安装包失败&nbsp;</span><span style="font-family: 'Times New Roman',serif;">** prompt_and_wait()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">等待用户操作，选择</span><span style="font-family: 'Times New Roman',serif;">ALT+S</span><span style="font-family: 'Times New Roman',serif;">或</span><span style="font-family: 'Times New Roman',serif;">ALT+W&nbsp;</span><span style="font-family: 'Times New Roman',serif;">升级或恢复出厂设置</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">main()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">调用&nbsp;</span><span style="font-family: 'Times New Roman',serif;">maybe_install_firmware_update()</span></p> <ol><li> <p><span style="font-family: 'Times New Roman',serif;">如果包里有</span><span style="font-family: 'Times New Roman',serif;">hboot/radio</span><span style="font-family: 'Times New Roman',serif;">的</span><span style="font-family: 'Times New Roman',serif;">firmware</span><span style="font-family: 'Times New Roman',serif;">则继续，否则返回</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">将&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"boot-recovery"&nbsp;</span><span style="font-family: 'Times New Roman',serif;">和&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"--wipe_cache"&nbsp;</span><span style="font-family: 'Times New Roman',serif;">写入</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">将&nbsp;</span><span style="font-family: 'Times New Roman',serif;">firmware image</span><span style="font-family: 'Times New Roman',serif;">写入</span><span style="font-family: 'Times New Roman',serif;">cache</span><span style="font-family: 'Times New Roman',serif;">分区</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">将&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"update-radio/hboot"&nbsp;</span><span style="font-family: 'Times New Roman',serif;">和&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"--wipe_cache"&nbsp;</span><span style="font-family: 'Times New Roman',serif;">写入</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">重启系统</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">bootloader</span><span style="font-family: 'Times New Roman',serif;">自身更新</span><span style="font-family: 'Times New Roman',serif;">firmware</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">bootloader&nbsp;</span><span style="font-family: 'Times New Roman',serif;">将&nbsp;</span><span style="font-family: 'Times New Roman',serif;">"boot-recovery"&nbsp;</span><span style="font-family: 'Times New Roman',serif;">写入</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">erase_root()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">擦除</span><span style="font-family: 'Times New Roman',serif;">CACHE</span><span style="font-family: 'Times New Roman',serif;">分区</span></p> </li><li> <p><span style="font-family: 'Times New Roman',serif;">清除&nbsp;</span><span style="font-family: 'Times New Roman',serif;">BCB</span></p> </li></ol> </li><li> <p><span style="font-family: 'Times New Roman',serif;">main()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">调用&nbsp;</span><span style="font-family: 'Times New Roman',serif;">reboot()&nbsp;</span><span style="font-family: 'Times New Roman',serif;">重启系统</span></p> </li></ol> <p><br /></p> <h2> <span style="font-family: 'AR PL UMing HK',sans-serif;">Recovery</span>模式流程</h2> <p><br /></p> <p><span style="font-family: 'AR PL UMing CN',serif;">/init&nbsp;<span style="font-family: 'Times New Roman',serif;">&#8594;</span>&nbsp;init.rc&nbsp;<span style="font-family: 'Times New Roman',serif;">&#8594;</span>&nbsp;/sbin/recovery&nbsp;<span style="font-family: 'Times New Roman',serif;">&#8594;</span></span></p> <p><span style="font-family: 'AR PL UMing CN',serif;">main():recovery.c</span></p> <p><br /></p> <ul style="font-family: song,Verdana; border-collapse: collapse;"><li> <p><span style="font-family: 'AR PL UMing CN',serif;">ui_init():ui.c&nbsp;</span>［<span style="font-family: 'AR PL UMing CN',serif;">UI initialize</span>］</p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">gr_init():minui/graphics.c&nbsp;</span>［<span style="font-family: 'AR PL UMing CN',serif;">set tty0 to graphic mode, open fb0]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">ev_init():minui/events.c [open /dev/input/event*]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">res_create_surface:minui/resource.c [create surfaces for all bitmaps used later, include icons, bmps]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">create 2 threads: progress/input_thread [create progress show and input event handler thread]</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">get_args():recovery.c</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">get_bootloader_message():bootloader.c [read mtdblock0(misc partition) 2<sup>nd</sup>&nbsp;page for commandline]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">check if nand misc partition has boot message. If yes, fill argc/argv.</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">If no, get arguments from /cache/recovery/command, and fill argc/argv.</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">set_bootloader_message():bootloader.c [set bootloader message back to mtdblock0]</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">Parser argv[] filled above</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">register_update_commands():commands.c [ register all commands with name and hook function ]</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">registerCommand():commands.c</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">Register command with name, hook, type, cookie.</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">Commands, e.g: assert, delete, copy_dir, symlink, write_raw_image.</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">registerFunction():commands.c</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">Register function with name, hook, cookie.</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">Function, e.g: get_mark, matches, getprop, file_contains</span></p> </li></ul> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">install_package():</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">translate_root_path():roots.c [ "SYSTEM:lib" and turns it into a string like "/system/lib", translate the updater.zip path ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">mzOpenZipArchive():zip.c [ open updater.zip file (uncompass) ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">handle_update_package():install.c</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">verify_jar_signature():verifier.c [ verify signature with keys.inc key; verify manifest and zip package archive ]</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">verifySignature() [ verify the signature file: CERT.sf/rsa. ]</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">digestEntry():verifier.c [ get SHA-1 digest of CERT.sf file ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">RSA_verify(public  key:keys.inc, signature:CERT.rsa, CERT.sf's digest):libc/rsa.c [ Verify  a 2048 bit RSA PKCS1.5 signature against an expected SHA-1 hash. Use  public key to decrypt the CERT.rsa to get original SHA digest, then  compare to digest of CERT.sf ]</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">verifyManifest() [ Get manifest SHA1-Digest from CERT.sf. Then do digest to MANIFEST.MF. Compare them ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">verifyArchive() [ verify all the files in update.zip with digest listed in MANIFEST.MF ]</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">find_update_script():install.c [ find META-INF/com/google/android/update-script updater script ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">handle_update_script():install.c [ read cmds from script file, and do parser, exec ]</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">parseAmendScript():amend.c [ call yyparse() to parse to command ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">exeCommandList():install.c</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">exeCommand():execute.c [ call command hook function ]</span></p> </li></ul> </li></ul> </li></ul> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">erase DATA/CACHE partition</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">prompt_and_wait():recovery.c [ wait for user input: 1) reboot 2) update.zip 3) wipe data ]</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">ui_key_xxx get ALT+x keys</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">1) do nothing</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">2) install_package('SDCARD:update.zip')</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">3) erase_root()&nbsp;<span style="font-family: 'Times New Roman',serif;">&#8594;</span>&nbsp;format_root_device() DATA/CACHE</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">may_install_firmware_update():firmware.c  [ remember_firmware_update() is called by write_hboot/radio_image  command, it stores the bootloader image to CACHE partition, and write  update-hboot/radio command to MISC partition for bootloader message to  let bootloader update itself after reboot ]</span></p> <ul><li> <p><span style="font-family: 'AR PL UMing CN',serif;">set_bootloader_message()</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">write_update_for_bootloader():bootloader.c  [ write firmware image into CACHE partition with update_header,  busyimage and failimage ]</span></p> </li></ul> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">finish_recovery():recovery.c  [ clear the recovery command and prepare to boot a (hopefully working)  system, copy our log file to cache as well (for the system to read), and  record any intent we were asked to communicate back to the system. ]</span></p> </li><li> <p><span style="font-family: 'AR PL UMing CN',serif;">reboot()</span></p> </li></ul> <p><br /></p> <h2> <span style="font-family: 'Times New Roman',serif;">Recovery</span><span style="font-family: 'Times New Roman',serif;">模式流程图</span> </h2> <p><span style="font-family: 'Times New Roman',serif;">以下流程图绘制了系统从启动加载</span><span style="font-family: 'AR PL UMing CN',serif;"><span style="font-family: 'Times New Roman',serif;">bootloader</span></span><span style="font-family: 'Times New Roman',serif;">后的行为流程。</span></p> <p>没有床，见blog吧~</p> <p>&nbsp;</p> <p>实际使用的例子：</p> <p> </p> <p><span style="border-collapse: collapse;">adb shell "echo \"send_intent=xxx\" &gt; /cache/recovery/command"</span></p> <p><span style="border-collapse: collapse;">adb shell "echo \"--update_package=SDCARD:update.zip\" &gt;&gt; /cache/recovery/command"</span></p> <p><span style="border-collapse: collapse;">adb shell sync</span></p> <p><span style="border-collapse: collapse;">adb reboot recovery</span></p>  <p>&nbsp;</p>    </div></div></div></div></div><img src ="http://www.blogjava.net/MEYE/aggbug/356607.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-16 10:00 <a href="http://www.blogjava.net/MEYE/articles/356607.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LiveWallPaper 让您的壁纸动起来 连载（三）——OpenGL ES特辑</title><link>http://www.blogjava.net/MEYE/articles/356605.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Tue, 16 Aug 2011 01:44:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/356605.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/356605.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/356605.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/356605.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/356605.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: LiveWallPaper 让您的壁纸动起来 连载（三）&#8212;&#8212;OpenGL ES特辑http://www.cnblogs.com/ClassroomStudio/archive/2010/08/15/CS_wallpaper_3OpenGLES.html&nbsp;  CS&#8212;&#8212;LiveWallPaper&nbsp; 动态壁纸程序开发(三)之 OpenG...&nbsp;&nbsp;<a href='http://www.blogjava.net/MEYE/articles/356605.html'>阅读全文</a><img src ="http://www.blogjava.net/MEYE/aggbug/356605.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-16 09:44 <a href="http://www.blogjava.net/MEYE/articles/356605.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android： 打败system,自己监听Home键</title><link>http://www.blogjava.net/MEYE/articles/356603.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Tue, 16 Aug 2011 01:23:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/356603.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/356603.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/356603.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/356603.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/356603.html</trackback:ping><description><![CDATA[<div><div><h3><a href="http://blog.csdn.net/yiyaaixuexi/article/details/6604430" title="Android： 打败system,自己监听Home键">Android： 打败system,自己监听Home键</a></h3></div><br />http://blog.csdn.net/yiyaaixuexi/article/details/6604430</div><div><p align="center">&nbsp;&nbsp;&nbsp;&nbsp;<strong>&nbsp;&nbsp;&nbsp; <span style="font-size: 32px;">这是一篇关于Home键的Android学习笔记</span></strong></p><h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ✿问题的提出</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Android Home键系统负责监听，捕获后系统自动处理。有时候，系统的处理往往不随我们意，想自己处理点击Home后的事件，那怎么办？</p><p>&nbsp;</p><h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ✿问题的解决</h1><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 先禁止Home键，再在onKeyDown里处理按键值，点击Home键的时候就把程序关闭，或者随你XXOO。</p><p>&nbsp;</p><p>@Override</p><p>&nbsp;<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">boolean</span><span style="color: #000000;"> onKeyDown(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> keyCode, KeyEvent event) </span></p><p><span style="color: #000000;">{ </span><span style="color: #008000;">//</span><span style="color: #008000;"> TODO Auto-generated method stub</span> </p><p>&nbsp; <span style="color: #0000ff;">if</span><span style="color: #000000;">(KeyEvent.KEYCODE_HOME</span><span style="color: #000000;">==</span><span style="color: #000000;">keyCode) </span></p><p><span style="color: #000000;">&nbsp;&nbsp;&nbsp; android.os.Process.killProcess(android.os.Process.myPid()); </span></p><p>&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">super</span><span style="color: #000000;">.onKeyDown(keyCode, event); </span></p><p><span style="color: #000000;">&nbsp; } </span></p><p>&nbsp;</p><p><span style="color: #000000;">@Override</span></p><p>&nbsp;<span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> onAttachedToWindow()</span></p><p><span style="color: #000000;">&nbsp;{ </span><span style="color: #008000;">//</span><span style="color: #008000;"> TODO Auto-generated method stub</span> </p><p>&nbsp;&nbsp;&nbsp; <span style="color: #0000ff;">this</span><span style="color: #000000;">.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);</span></p><p><span style="color: #000000;">&nbsp;&nbsp; &nbsp;</span><span style="color: #0000ff;">super</span><span style="color: #000000;">.onAttachedToWindow();</span></p><p><span style="color: #000000;">&nbsp;} </span></p><p>&nbsp;</p><p>&nbsp;</p><p><span style="color: #000000;">加权限禁止Home键 </span></p><span style="color: #000000;">&lt;</span><span style="color: #000000;">uses</span><span style="color: #000000;">-</span><span style="color: #000000;">permission android:name</span><span style="color: #000000;">=</span><span style="color: #000000;">"</span><span style="color: #000000;">android.permission.DISABLE_KEYGUARD</span><span style="color: #000000;">"</span><span style="color: #000000;">&gt;&lt;/</span><span style="color: #000000;">uses</span><span style="color: #000000;">-</span><span style="color: #000000;">permission</span><span style="color: #000000;">&gt;</span></div><img src ="http://www.blogjava.net/MEYE/aggbug/356603.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-16 09:23 <a href="http://www.blogjava.net/MEYE/articles/356603.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android 源码编译</title><link>http://www.blogjava.net/MEYE/articles/355722.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Thu, 04 Aug 2011 01:20:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/355722.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/355722.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/355722.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/355722.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/355722.html</trackback:ping><description><![CDATA[<div><h3><a href="http://quanminchaoren.iteye.com/blog/837333">Android 源码编译<div>http://quanminchaoren.iteye.com/blog/837333</div><div><div id="blog_content">     <p><span style="font-size: medium;">安装虚拟机时建议设置空间为16G左右，否则后面编译源代码可能会导致空间不够</span> </p> <div> <span style="font-size: medium;">编译环境：Ubuntu8.10</span> </div> <div> <span style="font-size: medium;">1、安装一些环境<br /> &nbsp;sudo apt-get install build-essential  make gcc g++ libc6-dev patch texinfo libncurses-dev git-core gnupg flex  bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip  curl ncurses-dev zlib1g-dev valgrind python2.5 sun-java5-jdk<br /><br /> 不要用 sun-java6-jdk，否则会有问题<br /> 2、设置环境变量<br /> vim ~/.bashrc&nbsp; <br /> 在.bashrc中新增或整合PATH变量，如下</span> </div> <div> <span style="font-size: medium;">#java 程序开发/运行的一些环境变量<br /> 在home/你的用户名/.bashrc中加入下面一些，有些是后面运行编译后的模拟器而用的<br /> export JAVA_HOME=usr/lib/jvm/java-1.5.0-sun<br /> export JRE_HOME=usr/lib/jvm/java-1.5.0-sun/jre<br /> export PATH=$PATH:$JAVA_HOME/bin<br /> export PATH=$PATH:~/mydroid/out/host/linux-x86/bin<br /> export ANDROID_PRODUCT_OUT=~/mydroid/out/target/product/generic<br /> export CLASSPATH=.:${JAVA_HOME}/lib:$JRE_HOME/lib:$CLASSPATH<br /> export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin<br /> HOME_BIN=~/bin/<br /> export PATH=${PATH}:${JAVA_PATH}:${JRE_PATH}:${HOME_BIN};</span> </div> <div> <br /><span style="font-size: medium;">3、安装repo（用来更新android源码）<br /> 创建~/bin目录，用来存放repo程序，如下：<br /> $ cd ~<br /> $ mkdir bin<br /> 注意：下载后的.repo也许并不在这个文件夹中，请返回上一级目录找到后拷贝至此<br /> 下载repo脚本并使其可执行：<br /> $ curl </span> <a href="http://android.git.kernel.org/repo"><span style="font-size: medium;">http://android.git.kernel.org/repo</span> </a> <span style="font-size: medium;"> &gt;~/bin/repo<br /> $ chmod a+x ~/bin/repo<br /> &nbsp;<br /> 4、下载 android源码并更新之<br /> $ mkdir mydroid <br /> $ cd mydroid <br /> 方式一<br /> 建 议不要用repo来下载（android源码超过1G，非常慢），直接在网上下载http:  //www.androidin.com/bbs/pub/cupcake.tar.gz。而且解压出来的  cupcake下也有.repo文件夹，可以通过repo sync来更新cupcake代码：<br /> tar -xvf&nbsp; cupcake.tar.gz <br /> repo sync（更新很慢，用了3个小时）<br /> 方式二<br /> $ repo init -u git://android.git.kernel.org/platform/manifest.git <br /> 运行到这里将出现 repo initialized in /home/&lt;your_home&gt;/mydroid 信息，这时可以认为环境设置已完成 <br /> 下载Android代码 ，运行如下命令 <br /> $ repo sync <br /> 我是用的方式二，当然如果之前有下载源码的话，直接将源码拷贝到mydroid文件夹就可以了<br /> 5、编译android源码,并得到~/mydroid/out 目录<br /> 进入mydroid源码目录：<br /> make<br /> 这一过程很久（2个多小时）</span> </div> <div> <span style="font-size: medium;">6、在模拟器上运行编译好android</span> </div> <div> <span style="font-size: medium;">android  SDK的emulator程序在android-sdk-linux_x86-1.0_r2/tools/下，emulator是需要加载一些image  的，默认加载android-sdk-linux_x86-1.0_r2/tools/lib/images下的kernel-qemu（内核）  ramdisk.img&nbsp; system.img&nbsp; userdata.img</span> </div> <div> <span style="font-size: medium;">编译好android之后，emulator在  ~/project/android/cupcake/out/host/linux-x86/bin下， ramdisk.img&nbsp;  system.img&nbsp;  userdata.img则在~/project/android/cupcake/out/target/product/generic下<br /> cd ~/project/android/cupcake/out/host/linux-x86/bin</span> </div> <div> <span style="font-size: medium;">增加环境变量<br /> vim ~/.bashrc<br /> 在.bashrc中新增环境变量，如下<br /> #java 程序开发/运行的一些环境变量<br /> export ANDROID_PRODUCT_OUT=~/project/android/cupcake2/out/target/product/generic<br /> ANDROID_PRODUCT_OUT_BIN=~/project/android/cupcake2/out/host/linux-x86/bin<br /> export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN};</span> </div> <div> <span style="font-size: medium;">最后，同步这些变化：<br /> source ~/.bashrc</span> </div> <div> <span style="font-size: medium;">emulator -image system.img -data userdata.img -ramdisk ramdisk.img<br /> 最后进入android桌面，就说明成功了。<br /> out/host/linux-x86/bin下生成许多有用工具（包括android SDK/tools的所有工具），因此，可以把eclipse中android SDK的路径指定到out/host/linux-x86/bin进行开发</span> </div> <div> <span style="font-size: medium;">7、编译linux kernel<br /> 直接make android源码时，并没有make linux kernel。因此是在运行模拟器，所以不用编译 linux kernel。如果要移值android，或增删驱动，则需要编译 linux kernel<br /> linux kernel的编译将在以后的文章中介绍。</span> </div> <div> <span style="font-size: medium;">8、编译模块<br /> android中的一个应用程序可以单独编译，编译后要重新生成system.img<br /> 在源码目录下执行<br /> . build/envsetup.sh （.后面有空格）<br /> 就多出一些命令：<br /> - croot:&nbsp;&nbsp; Changes directory to the top of the tree.<br /> - m:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Makes from the top of the tree.<br /> - mm:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Builds all of the modules in the current directory.<br /> - mmm:&nbsp;&nbsp;&nbsp;&nbsp; Builds all of the modules in the supplied directories.<br /> - cgrep:&nbsp;&nbsp; Greps on all local C/C++ files.<br /> - jgrep:&nbsp;&nbsp; Greps on all local Java files.<br /> - resgrep: Greps on all local res/*.xml files.<br /> - godir:&nbsp;&nbsp; Go to the directory containing a file.<br /> 可以加&#8212;help查看用法<br /> 我们可以使用mmm来编译指定目录的模块，如编译联系人：<br /> &nbsp;mmm packages/apps/Contacts/<br /> 编完之后生成两个文件：<br /> out/target/product/generic/data/app/ContactsTests.apk<br /> out/target/product/generic/system/app/ Contacts.apk<br /> 可以使用make snod重新生成system.img<br /> 再运行模拟器</span> </div> <div> <span style="font-size: medium;">9、编译SDK<br /> 直接执行make是不包括make sdk的。make sdk用来生成SDK，这样，我们就可以用与源码同步的SDK来开发 android了。</span> </div> <div> <span style="font-size: medium;">1）修改/frameworks/base/include/utils/Asset.h<br /> &#8216;UNCOMPRESS_DATA_MAX = 1 * 1024 * 1024&#8217; 改为 &#8216;UNCOMPRESS_DATA_MAX = 2 * 1024 * 1024&#8217;<br /> 原因是Eclipse编译工程需要大于1.3M的buffer</span> </div> <div> <span style="font-size: medium;">2）编译ADT。<br /> 注意，我们是先执行2），再执行3）。因为在执行./build_server.sh时，会把生成的SDK清除了。<br /> 用上了新的源码，adt这个调试工具也得自己来生成，步骤如下：<br /> 进入cupcake源码的development/tools/eclipse/scripts目录，执行：<br /> export ECLIPSE_HOME=你的eclipse路径<br /> ./build_server.sh 你想放ADT的路径</span> </div> <div> <span style="font-size: medium;">3）执行make sdk。<br /> 注意，这里需要的javadoc版本为1.5，所以你需要在步骤1中同时安装sun-java5-jdk<br /> make sdk<br /> 编 译很慢。编译后生成的SDK存放在out/host/linux-x86/sdk/，此目录下有android-sdk_eng.xxx_linux-  x86.zip和android-sdk_eng.xxx_linux-x86目录。android-sdk_eng.xxx_linux-x86就是  SDK目录<br /> 实际上，当用mmm命令编译模块时，一样会把SDK的输出文件清除，因此，最好把android-sdk_eng.xxx_linux-x86移出来</span> </div> <div> <span style="font-size: medium;">4）关于环境变量、android工具的选择<br /> 目前的android工具有：<br /> A、我们从网上下载的SDK（ tools下有许多android工具，lib/images下有img映像）<br /> B、我们用make sdk编译出来的SDK（ tools下也有许多android工具，lib/images下有img映像）<br /> C、我们用make编译出来的out目录（ tools下也有许多android工具，lib/images下有img映像）<br /> 那么我们应该用那些工具和img呢？<br /> 首先，我们不会用A选项的工具和img，因为一般来说它比较旧，也源码不同步。测试发现，如果使用B选项的工具和img，android模拟器窗口变小（可能是skin加载不了），而用C选项的工具和img则不会有此问题。<br /> 有 些android工具依赖android.jar（比如android），因此，我们在eclipse中使用B选项的工具（SDK），使用C选项的  img。其实，从emulator  -help-build-images也可以看出，ANDROID_PRODUCT_OUT是指向C选项的img目录的<br /> 不过，除了用A选项的工具和img，用B或C的模拟器都不能加载sdcard，原因还不清楚。</span> </div> <div> <span style="font-size: medium;">5）安装、配置ADT<br /> 安装、配置ADT请参考官方文档</span> </div> <div> <span style="font-size: medium;">6）创建Android Virtual Device<br /> 编译出来的SDK是没有AVD（Android Virtual Device）的，我们可以通过android工具查看：<br /> android list<br /> 输出为：<br /> Available Android targets:<br /> [1] Android 1.5<br /> &nbsp;&nbsp;&nbsp;&nbsp; API level: 3<br /> &nbsp;&nbsp;&nbsp;&nbsp; Skins: HVGA-P, QVGA-L, HVGA-L, HVGA (default), QVGA-P<br /> Available Android Virtual Devices:<br /> 表明没有AVD。如果没有AVD，eclipse编译工程时会出错（Failed to find a AVD compatible with target 'Android 1.5'. Launch aborted.）<br /> 创建AVD：<br /> android create avd -t 1 -c ~/sdcard.img -n myavd<br /> 可以android &#8211;help来查看上面命令选项的用法。创建中有一些选项，默认就行了<br /> 再执行android list，可以看到AVD存放的位置<br /> 以后每次运行emulator都要加-avd myavd或@myavd选项，这里eclipse才会在你打开的emulator中调试程序</span> </div> <div> <br /><span style="font-size: medium;">注意：<br /> 这样，SDK和ADT就生成了，就按照官方文档把他们整合到Eclipse，这里不再细说了。<br /> 建个android的新工程，试试你自己编译的sdk。</span> </div>   </div></div></a></h3></div><img src ="http://www.blogjava.net/MEYE/aggbug/355722.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-04 09:20 <a href="http://www.blogjava.net/MEYE/articles/355722.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用Git和Repo获取Android源码</title><link>http://www.blogjava.net/MEYE/articles/355673.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 03 Aug 2011 06:21:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/355673.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/355673.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/355673.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/355673.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/355673.html</trackback:ping><description><![CDATA[<div><h1><div>http://source.android.com/source/downloading.html</div></h1><br /><br /><h1><a id="ctl02_TitleUrl" href="http://www.cnblogs.com/chunhui588/archive/2010/07/04/Using-Git-Repo-To-Get-Android-SourceCode.html">使用Git和Repo获取Android源码</a></h1></div><div>http://www.cnblogs.com/chunhui588/archive/2010/07/04/Using-Git-Repo-To-Get-Android-SourceCode.html</div><div> 	<div id="cnblogs_post_body"><p>在某些情况下我们需要查看Android的源码或对其进行重新编译，目前只支持在Linux或者Mac OS上编译Android源码，暂不支持Windows.所以本篇介绍一下如何在Ubuntu上获取Android源码。</p> <p>&nbsp;</p> <p>Android源码大约有2.1GB，在<a target="_blank" href="http://android.git.kernel.org/">这里</a>可以看到它的结构和更新记录。</p> <p>&nbsp;</p> <p>下载Android源码需要用到Git和Repo。Git是一个开源的分布式版本控制软件，它非常适合管理很大的项目，项目文件可以分布储存在多个 Git repositories(仓库), 这样可以很方便地创建分支，进行版本比较等，所以Android也用它来进行源码管理。  Repo是基于Git的工具，它可以让我们更方便地管理Git repositories.</p> <p>&nbsp;</p> <p>接下来我们要在Ubuntu上面安装这两个工具, 在安装之前要先安装一些必要的Linux Packages: JDK 5.0(Java  6不支持因为@Override的不兼容), lex, bison, gperf, libsdl-dev, libesd0-dev,  libwxgtk2.6-dev (optional), build-essential, zip, curl.</p> <p>&nbsp;</p> <p>在Ubuntu的Terminal运行以下命令: $ sudo apt-get install git-core gnupg flex  bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip  curl libncurses5-dev zlib1g-dev </p> <p>&nbsp;</p> <p>这里需要注意的是sun-java5-jdk的源在Ubuntu9.10后就没有了, 所以安装sun-java5-jdk 要切换Sources.list才能安装，具体可以参考这篇<a target="_blank" href="http://blog.csdn.net/sunrock/archive/2010/04/29/5542989.aspx">Blog</a>.</p> <p>&nbsp;</p> <p>Git(上面的git-core)装完了,接下来装Repo, 在home目录创建bin目录，然后获取Repo并授于它执行的权限:</p> <p>$ cd ~<br />$ mkdir bin<br />$ curl <a href="http://android.git.kernel.org/repo">http://android.git.kernel.org/repo</a> &gt;~/bin/repo<br />$ chmod a+x ~/bin/repo </p> <p>接下来把bin目录加入$PATH:</p> <p>$ export PATH=$HOME/bin:$PATH</p> <p>&nbsp;</p> <p>再接着在home目录创建mydroid目录用来存放Android源码</p> <p>$ mkdir mydroid<br />$ cd mydroid </p> <p>最后下载Android源码: </p> <p>$ repo init -u git://android.git.kernel.org/platform/manifest.git<br />$ repo sync </p></div></div><img src ="http://www.blogjava.net/MEYE/aggbug/355673.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-08-03 14:21 <a href="http://www.blogjava.net/MEYE/articles/355673.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>手机RAM,Flash ROM、内存概念的困惑</title><link>http://www.blogjava.net/MEYE/articles/342816.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 12 Jan 2011 01:50:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/342816.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/342816.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/342816.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/342816.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/342816.html</trackback:ping><description><![CDATA[<div>
<span style="font-family: simsun; line-height: 23px; font-size: 16.8px; "><span style="line-height: 21px; color: #ff0000; ">Flash其实也算ROM的一种</span>，要知道ROM随着发展已出现很多种不同的类型，最早的是掩模ROM，这一类就像你买的D版光盘一样，数据已经用专门的工具压在里面了，你除了读数据其他什么也不能干。<br />
&nbsp; 然后是可编程的ROM，就像你买的CD-R光盘一样，只能写一次（当然，如果没有关闭光盘的话，你可以继续写，但同一块数据区你只能写一次），然后就不能写只能读。<br />
&nbsp; 后来又出现了可擦除可编程的ROM，其中又出现三种：<br />
1、可擦除可编程ROM，这类是用紫外光照射擦除。<br />
2、电可擦除可编程，这类虽然可擦除，但擦除电压跟写入电压不一样，也就是说，你给用专门的设备擦除。<br />
3、快擦型存储器，这类即Flash，不用我多说了吧。<br />
&nbsp; 至于<span style="line-height: 21px; color: #ff0000; ">手机的RAM</span>，像智能机一般都有参数给出，这类就像电脑内存，直接与你手机性能、运行速度快慢相关，你插到电脑里不可能访问这块区域<br />
&nbsp;&nbsp;<span style="line-height: 21px; color: #ff0000; ">手机内存</span>则是个很笼统的说法，我觉得应该指手机的RAM，但事实上很多人用它来指Flash的大小，比如有人说手机内存8G什么的，这肯定是指Flash，手机RAM有256M已经很不错的，现在高端的，比如里程碑2，也就512M，<br />
</span><span style="font-family: simsun; line-height: 19px; font-size: 16.8px; ">不光是ROM和RAM，比如FLASH就是可读写并且关机不丢的，只是速度没有内存快，无法替代内存。FLASH 和ROM的确不是一个东西，FLASH不是只读的。</span></div>
<div>
<span style="font-family: simsun; line-height: 19px; font-size: 14.4px; ">手机中<br />
Ram：运行代码，存数据（可读写数据掉电不保存），<br />
Rom：存储代码、只读数据等，只读不可写。<br />
Flash：可读写（读写速度比ram慢很多），存放文件、代码，数据等。需要说明的是Nor flash上也能运行代码（简单理解为扩展ram）；而nand flash不能运行代码。</span></div>
<div><span style="font-family: simsun; line-height: 19px; font-size: 14.4px; "><span style="line-height: 21px; font-size: 16.8px; color: #ff9900; ">
<span style="color: #000000; line-height: 23px; font-size: 16.8px; ">不同的手机配置不一样<br />
有的手机配置是 SRAM加上nor flash<br />
有的配置是 sram加上 nand flash<br />
一般说手机内存主要说的是flash存储器，又分为nor flash和nand flash<br />
一般如果手机内存很大的话，就是nand flash，如果内存比较小的话用的是nor flash<br />
nor flash的读速度比nand flash 要快，nand flash 成本低 &nbsp;&nbsp;</span></span></span><span style="font-family: simsun; line-height: 19px; font-size: 16.8px; ">flash分nor flash 和nand flash，nor flash可以当成ram内存使用。</span></div>
<div><span style="font-family: simsun; line-height: 19px; font-size: 16.8px; ">
<span style="line-height: 23px; font-size: 16.8px; ">Ram：运行代码，存数据（可读写数据掉电不保存），<br />
Rom：存储代码、只读数据等，只读不可写。<br />
Flash：可读写（读写速度比ram慢很多），存放文件、代码，数据等。需要说明的是Nor flash上也能运行代码（简单理解为扩展ram）；而nand flash不能运行代码。&nbsp;</span></span><span style="font-family: simsun; line-height: 19px; font-size: 16.8px; ">可读写（读写速度比ram慢很多），存放文件、代码，数据等 &nbsp;</span><span style="font-family: simsun; line-height: 19px; font-size: 16.8px; ">flash是可读可写的，rom是只读的（虽然有的也可以写）。手机里的存储文件的东西就是flash，有nand，tf卡等，通过文件系统和底层驱动，就可以让你看到盘符，并管理文件。</span></div>
<div><span style="font-family: simsun; line-height: 19px; font-size: 14.4px; ">
<span style="line-height: 21px; font-size: 16.8px; color: #ff9900; ">那你的手机上总要装个操作系统吧，什么android、ios、wp7、sysbian、，那就要用ROM了，一般现在都用flash做ROM，这部分空间操作系统会禁止一般用户访问，那余下的ROM空间怎么办呢，提供给用户用用吧，于是你就可以把相册啊之类的东西放进去了（可是记得flash是有读写次数的哦，每做一次就物理性伤害flash一次，一般flash的读写次数是10万次以上，数据储存年限是10年以上，所以大家用吧，用吧，不是罪），anyway，再分享一点，操作系统其实就是一个好大好大的程序而已</span></span></div>
<img src ="http://www.blogjava.net/MEYE/aggbug/342816.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2011-01-12 09:50 <a href="http://www.blogjava.net/MEYE/articles/342816.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>主题：线程同步</title><link>http://www.blogjava.net/MEYE/articles/339545.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Wed, 01 Dec 2010 12:38:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/339545.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/339545.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/339545.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/339545.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/339545.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 主题：线程同步http://www.javaeye.com/topic/164905http://hxraid.javaeye.com/blog/667437线程同步&nbsp;作者 : buaawhl&nbsp;我们可以在计算机上运行各种计算机软件程序。每一个运行的程序可能包括多个独立运行的线程（Thread）。&nbsp;线程（Thread）是一份独立运...&nbsp;&nbsp;<a href='http://www.blogjava.net/MEYE/articles/339545.html'>阅读全文</a><img src ="http://www.blogjava.net/MEYE/aggbug/339545.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-12-01 20:38 <a href="http://www.blogjava.net/MEYE/articles/339545.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3DS 文件格式</title><link>http://www.blogjava.net/MEYE/articles/335855.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:48:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335855.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335855.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335855.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335855.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335855.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><a href="http://dev.gameres.com/Program/Visual/3D/3DSformat.htm">http://dev.gameres.com/Program/Visual/3D/3DSformat.htm</a>
<div>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="border-collapse: collapse; color: #ffffff; font-family: Arial; ">
<table border="0" cellpadding="0" cellspacing="0" width="85%" id="AutoNumber2" style="border-collapse: collapse; ">
    <tbody>
        <tr>
            <td width="100%">
            <p align="center"><font color="#FFFFEE"><strong>3DS 文件格式</strong></font></p>
            </td>
        </tr>
        <tr>
            <td width="100%">　</td>
        </tr>
        <tr>
            <td width="100%"><font size="2"><strong>1、读取规则</strong><br />
            3ds文件的读取规则如下：<br />
            字节：直接读取；<br />
            字：先读低位字节，后读高位字节，如ed 3c读出后的字为3c ed；<br />
            双字：先读低位字，后读高位字，如ed 3c 25 43读出后的双字为43 25 3c ed；<br />
            浮点数：直接读取四个字节。<br />
            <br />
            <strong>2、CHUNK</strong><br />
            chunk是3ds文件的基本构成单位。每一个chunk包括一个头和一个主体。chunk是相互嵌套的，这就决定了你必须以递归的方式读取它们。chunk的头又由两部分组成：ID长一个字，chunk的长度（以字节为单位，包括头）长一个双字。ID表示chunk的含义。事实上有上千个chunk，它们构成了一个复杂但灵活的文件系统，你不需要知道所有的就可以顺利的读完整个文件。我基本搞清楚的chunk有：<br />
            <br />
            0x4D4D：根chunk，每一个3ds文件都起自它，它的长度也就是文件的长度。它包含了两个chunk：编辑器，和关键帧。<br />
            父chunk：无<br />
            子chunk：0x3D3D、0xB000<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0x3D3D：编辑器主chunk，它包含有：网格信息、灯光信息、摄象机信息和材质信息。<br />
            父chunk：0x4D4D<br />
            子chunk：0x4000、0xafff<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0x4000：网格主chunk，它包含了所有的网格。<br />
            父chunk：0x3D3D<br />
            子chunk：0x4100<br />
            长度：头长度+子chunk长度+内容长度<br />
            内容：<br />
            名称（以空字节结尾的字符串）<br />
            <br />
            0x4100：网格信息，包含网格名称、顶点、面、纹理坐标等。<br />
            父chunk：0x4000<br />
            子chunk：0x4110、0x4120、0x4140、0x4160<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0x4110：顶点信息。<br />
            父chunk：0x4100<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            顶点个数（一个字）<br />
            顶点坐标（三个浮点数一个坐标x、y、z，个数*3*浮点数）<br />
            <br />
            0x4120：面信息。<br />
            父chunk：0x4100<br />
            子chunk：0x4130<br />
            长度：头长度+子chunk长度+内容长度<br />
            内容：<br />
            面个数（一个字）<br />
            顶点索引（三个字一个索引1、2、3，个数*3*字）<br />
            <br />
            0x4130：与网格相关的材质信息。<br />
            父chunk：0x4120<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            名称（以空字节结尾的字符串）<br />
            与材质相连的面的个数（一个字）<br />
            与材质相连的面的索引（个数*字）<br />
            <br />
            0x4140：纹理坐标。<br />
            父chunk：0x4100<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            坐标个数（一个字）<br />
            坐标（两个浮点数一个坐标u、v，个数*2*浮点数）<br />
            <br />
            0x4160：转换矩阵。<br />
            父chunk：0x4100<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            x轴的向量（三个浮点数u、v、n）<br />
            y轴的向量（三个浮点数u、v、n）<br />
            z轴的向量（三个浮点数u、v、n）<br />
            源点坐标（三个浮点数x、y、z）<br />
            <br />
            0xafff：材质信息。<br />
            父chunk：0x4D4D<br />
            子chunk：0xa000、0xa020、0xa200<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0xa000：材质名称。<br />
            父chunk：0xafff<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            名称（以空字节结尾的字符串）<br />
            <br />
            <br />
            0xa020：满射色。<br />
            父chunk：0xafff<br />
            子chunk：0x0011、0x0012<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            <br />
            0xa200：纹理帖图。<br />
            父chunk：0xafff<br />
            子chunk：0xa300<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0xa300：帖图名称。<br />
            父chunk：0xa200<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            名称（以空字节结尾的字符串）<br />
            <br />
            0xB000：关键帧主chunk，包含所有的关键帧信息。<br />
            父chunk：0x4D4D<br />
            子chunk：0xB008、0xB002<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0xB008：关键帧的起点和终点。<br />
            父chunk：0xB000<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            起始帧（一个双字）<br />
            结尾帧（一个双字）<br />
            <br />
            0xB002：网格的关键帧信息。<br />
            父chunk：0xB000<br />
            子chunk：0xB010、0xB011、0xB013、0xB020、0xB021、0xB022、0xB030<br />
            长度：头长度+子chunk长度<br />
            内容：无<br />
            <br />
            0xB010：关键帧的层次信息，包括名称和上一级关键帧的索引，名称与它指向的网格名称一致。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            名称（以空字节结尾的字符串）<br />
            两个未知的字<br />
            上一级关键帧的索引（一个字）<br />
            <br />
            0xB011：关键帧的dummy名称，我不知道dummy在这里的具体含义，但只要你在上一个chunk中读到的名称是&#8220;$$$DUMMY&#8221;那么你就要到这里来读它真正的名称。因为这说明它指向的不是网格而是虚拟的组。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            名称（以空字节结尾的字符串）<br />
            <br />
            0xB013：支点坐标。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            三个浮点数x,y,z<br />
            <br />
            0xB020：移动的关键帧信息。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            五个未知的字<br />
            帧个数（一个字）<br />
            一个个数那么多的循环结构{<br />
            帧索引（一个字）<br />
            一个未知的双字<br />
            移动的向量（三个浮点数x,y,z）<br />
            }<br />
            <br />
            0xB021：转动的关键帧信息。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            五个未知的字<br />
            帧个数（一个字）<br />
            一个个数那么多的循环结构{<br />
            帧索引（一个字）<br />
            一个未知的双字<br />
            转动角度（一个浮点数）<br />
            绕之转动的向量（三个浮点数x,y,z）<br />
            }<br />
            <br />
            0xB022：缩放的关键帧信息。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            五个未知的字<br />
            帧个数（一个字）<br />
            一个个数那么多的循环结构{<br />
            帧索引（一个字）<br />
            一个未知的双字<br />
            伸缩的向量（三个浮点数x,y,z）<br />
            }<br />
            <br />
            0xB030：关键帧的索引。<br />
            父chunk：0xB002<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            关键帧的索引（一个字）<br />
            <br />
            以下的chunk可能出现在任何chunk中：<br />
            0x0010：浮点数格式的颜色。<br />
            父chunk：任何可能的chunk<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            颜色（三个浮点数red,green,blue）<br />
            <br />
            <br />
            0x0011：字节格式的颜色。<br />
            父chunk：任何可能的chunk<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            颜色（三个字节red,green,blue）<br />
            <br />
            0x0012：字节格式的gamma矫正。<br />
            父chunk：任何可能的chunk<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            颜色（三个字节red,green,blue）<br />
            <br />
            0x0013：浮点数格式的gamma矫正。<br />
            父chunk：任何可能的chunk<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            颜色（三个浮点数red,green,blue）<br />
            <br />
            0x0030：字格式的百分比。<br />
            父chunk：任何可能的chunk<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            百分比（一个字0~100）<br />
            <br />
            0x0031：浮点数格式的百分比。<br />
            父chunk：任何可能的chunk<br />
            子chunk：无<br />
            长度：头长度+内容长度<br />
            内容：<br />
            百分比（一个浮点数0~100）<br />
            <br />
            <strong>3、例程</strong><br />
            作为一个程序的处学者，我深知例子的重要性。这里提供一个我自己编写的程序，它可以读出以上提到的所有内容，并可以扩充。它的结构受到了Andrea Ingegneri的启发，他的主页是http://www.tsrevolution.com/。<br />
            程序的核心思想是编写一个了解3ds文件结构的类，但没有具体的数据结构。具体的数据结构有它的子类提供，这样就不受到文件结构的限制。<br />
            c3DS就是这样一个类，它提供一系列的虚函数来读数据，但并不保存数据，你必须自己写一个类来继承它，并覆盖这些虚函数。我在例程中写了一个叫做c3DSMODEL的类，它只读网格数据，并渲染。<br />
            <br />
            <a href="3dsformat.rar">本文档案下载</a>&nbsp;(80KB)</font></td>
        </tr>
    </tbody>
</table>
</span></div>
<img src ="http://www.blogjava.net/MEYE/aggbug/335855.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:48 <a href="http://www.blogjava.net/MEYE/articles/335855.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android JNI详述</title><link>http://www.blogjava.net/MEYE/articles/335854.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:47:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335854.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335854.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335854.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335854.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335854.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="border-collapse: collapse; color: #2b3714; font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 19px; font-size: 14.4px; ">
<div id="threadtitle" style="word-wrap: break-word; line-height: normal; margin-bottom: 8px; ">
<h1 style="word-wrap: break-word; margin-top: 8px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.17em; line-height: normal; ">Android JNI详述</h1>
</div>
<div class="t_msgfontfix" style="word-wrap: break-word; line-height: normal; min-height: 100px; ">
<table cellspacing="0" cellpadding="0" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 720px; table-layout: fixed; margin-left: 1px; ">
    <tbody style="word-wrap: break-word; line-height: normal; ">
        <tr style="word-wrap: break-word; line-height: normal; ">
            <td class="t_msgfont" id="postmessage_1080" style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; ">题目有点大，呵呵。前边是高老师的东东，后边是我的小实践。话说当时Android还是1.5的。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            Android JNI知识简介<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            Java Native Interface (JNI)标准是java平台的一部分，它允许Java代码和其他语言写的代码进行交互。JNI 是本地编程接口，它使得在 Java 虚拟机 (VM) 内部运行的 Java 代码能够与用其它编程语言(如 C、C++ 和汇编语言)编写的应用程序和库进行交互操作。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            1.从如何载入.so档案谈起<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; 由于Android的应用层的类都是以Java写的，这些Java类编译为Dex型式的Bytecode之后，必须靠Dalvik虚拟机(VM: Virtual Machine)来执行。VM在Android平台里，扮演很重要的角色。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; 此外，在执行Java类的过程中，如果Java类需要与C组件沟通时，VM就会去载入C组件，然后让Java的函数顺利地调用到C组件的函数。此时，VM扮演着桥梁的角色，让Java与C组件能通过标准的JNI介面而相互沟通。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; 应用层的Java类是在虚拟机(VM: Vitual Machine)上执行的，而C件不是在VM上执行，那么Java程式又如何要求VM去载入(Load)所指定的C组件呢? 可使用下述指令：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;System.loadLibrary(*.so的档案名);&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; 例如，Android框架里所提供的MediaPlayer.java类，含指令：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;public class MediaPlayer{&nbsp; &nbsp;&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;static {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; System.loadLibrary("media_jni");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;}<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;这要求VM去载入Android的/system/lib/libmedia_jni.so档案。载入*.so之后，Java类与*.so档案就汇合起来，一起执行了。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            2.如何撰写*.so的入口函数<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; ---- JNI_OnLoad()与JNI_OnUnload()函数的用途<br style="word-wrap: break-word; line-height: normal; " />
            当Android的VM(Virtual Machine)执行到System.loadLibrary()函数时，首先会去执行C组件里的JNI_OnLoad()函数。它的用途有二：&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            (1)告诉VM此C组件使用那一个JNI版本。如果你的*.so档没有提供JNI_OnLoad()函数，VM会默认该*.so档是使用最老的JNI 1.1版本。由于新版的JNI做了许多扩充，如果需要使用JNI的新版功能，例如JNI 1.4的java.nio.ByteBuffer,就必须藉由JNI_OnLoad()函数来告知VM。<br style="word-wrap: break-word; line-height: normal; " />
            (2)由于VM执行到System.loadLibrary()函数时，就会立即先呼叫JNI_OnLoad()，所以C组件的开发者可以藉由JNI_OnLoad()来进行C组件内的初期值之设定(Initialization) 。<br style="word-wrap: break-word; line-height: normal; " />
            例如，在Android的/system/lib/libmedia_jni.so档案里，就提供了JNI_OnLoad()函数，其程式码片段为：<br style="word-wrap: break-word; line-height: normal; " />
            //#define LOG_NDEBUG 0<br style="word-wrap: break-word; line-height: normal; " />
            #define LOG_TAG "MediaPlayer-JNI"<br style="word-wrap: break-word; line-height: normal; " />
            jint JNI_OnLoad(JavaVM* vm, void* reserved)<br style="word-wrap: break-word; line-height: normal; " />
            {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; JNIEnv* env = NULL;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; jint result = -1;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (vm-&gt;GetEnv((void**) &amp;env, JNI_VERSION_1_4) != JNI_OK) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: GetEnv failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            assert(env != NULL);<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (register_android_media_MediaPlayer(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: MediaPlayer native registration failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (register_android_media_MediaRecorder(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: MediaRecorder native registration failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (register_android_media_MediaScanner(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: MediaScanner native registration failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (register_android_media_MediaMetadataRetriever(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: MediaMetadataRetriever native registration failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; /* success -- return valid version number */<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; result = JNI_VERSION_1_4;<br style="word-wrap: break-word; line-height: normal; " />
            bail:<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; return result;<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            此函数回传JNI_VERSION_1_4值给VM，于是VM知道了其所使用的JNI版本了。此外，它也做了一些初期的动作(可呼叫任何本地函数)，例如指令：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;if (register_android_media_MediaPlayer(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: MediaPlayer native registration failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            就将此组件提供的各个本地函数(Native Function)登记到VM里，以便能加快后续呼叫本地函数的效率。<br style="word-wrap: break-word; line-height: normal; " />
            JNI_OnUnload()函数与JNI_OnLoad()相对应的。在载入C组件时会立即呼叫JNI_OnLoad()来进行组件内的初期动作；而当VM释放该C组件时，则会呼叫JNI_OnUnload()函数来进行善后清除动作。当VM呼叫JNI_OnLoad()或JNI_Unload()函数时，都会将VM的指针(Pointer)传递给它们，其参数如下：<br style="word-wrap: break-word; line-height: normal; " />
            jint JNI_OnLoad(JavaVM* vm, void* reserved) {&nbsp; &nbsp;&nbsp;&nbsp;}<br style="word-wrap: break-word; line-height: normal; " />
            jint JNI_OnUnload(JavaVM* vm, void* reserved){&nbsp; &nbsp;&nbsp;&nbsp;}<br style="word-wrap: break-word; line-height: normal; " />
            在JNI_OnLoad()函数里，就透过VM之指标而取得JNIEnv之指标值，并存入env指标变数里，如下述指令：<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            jint JNI_OnLoad(JavaVM* vm, void* reserved){<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;JNIEnv* env = NULL;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;jint result = -1;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (vm-&gt;GetEnv((void**) &amp;env, JNI_VERSION_1_4) != JNI_OK) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; LOGE("ERROR: GetEnv failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            由于VM通常是多执行绪(Multi-threading)的执行环境。每一个执行绪在呼叫JNI_OnLoad()时，所传递进来的JNIEnv指标值都是不同的。为了配合这种多执行绪的环境，C组件开发者在撰写本地函数时，可藉由JNIEnv指标值之不同而避免执行绪的资料冲突问题，才能确保所写的本地函数能安全地在Android的多执行绪VM里安全地执行。基于这个理由，当在呼叫C组件的函数时，都会将JNIEnv指标值传递给它，如下：<br style="word-wrap: break-word; line-height: normal; " />
            jint JNI_OnLoad(JavaVM* vm, void* reserved)<br style="word-wrap: break-word; line-height: normal; " />
            {<br style="word-wrap: break-word; line-height: normal; " />
            JNIEnv* env = NULL;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (register_android_media_MediaPlayer(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;}<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            这JNI_OnLoad()呼叫register_android_media_MediaPlayer(env)函数时，就将env指标值传递过去。如此，在register_android_media_MediaPlayer()函数就能藉由该指标值而区别不同的执行绪，以便化解资料冲突的问题。<br style="word-wrap: break-word; line-height: normal; " />
            例如，在register_android_media_MediaPlayer()函数里，可撰写下述指令：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; if ((*env)-&gt;MonitorEnter(env, obj) != JNI_OK) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            查看是否已经有其他执行绪进入此物件，如果没有，此执行绪就进入该物件里执行了。还有，也可撰写下述指令：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; if ((*env)-&gt;MonitorExit(env, obj) != JNI_OK) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br style="word-wrap: break-word; line-height: normal; " />
            查看是否此执行绪正在此物件内执行，如果是，此执行绪就会立即离开。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            3.registerNativeMethods()函数的用途<br style="word-wrap: break-word; line-height: normal; " />
            应用层级的Java类别透过VM而呼叫到本地函数。一般是仰赖VM去寻找*.so里的本地函数。如果需要连续呼叫很多次，每次都需要寻找一遍，会多花许多时间。此时，组件开发者可以自行将本地函数向VM进行登记。例如，在Android的/system/lib/libmedia_jni.so档案里的代码段如下：<br style="word-wrap: break-word; line-height: normal; " />
            //#define LOG_NDEBUG 0<br style="word-wrap: break-word; line-height: normal; " />
            #define LOG_TAG "MediaPlayer-JNI"<br style="word-wrap: break-word; line-height: normal; " />
            static JNINativeMethod gMethods[] = {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"setDataSource",&nbsp; &nbsp;"(Ljava/lang/String;)V",<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;&nbsp;(void *)android_media_MediaPlayer_setDataSource},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"setDataSource",&nbsp; &nbsp; "(Ljava/io/FileDescriptor;JJ)V",&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            (void *)android_media_MediaPlayer_setDataSourceFD},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"prepare",&nbsp; &nbsp;"()V",&nbsp; &nbsp;&nbsp;&nbsp;(void *)android_media_MediaPlayer_prepare},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"prepareAsync",&nbsp; &nbsp;"()V",&nbsp; &nbsp;(void *)android_media_MediaPlayer_prepareAsync},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"_start",&nbsp; &nbsp;"()V",&nbsp; &nbsp;(void *)android_media_MediaPlayer_start},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"_stop",&nbsp; &nbsp;"()V",&nbsp; &nbsp; (void *)android_media_MediaPlayer_stop},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"getVideoWidth",&nbsp; &nbsp;"()I",&nbsp; &nbsp;&nbsp; &nbsp;(void *)android_media_MediaPlayer_getVideoWidth},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"getVideoHeight",&nbsp; &nbsp;"()I",&nbsp; &nbsp;&nbsp; &nbsp;(void *)android_media_MediaPlayer_getVideoHeight},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"seekTo",&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; "(I)V",&nbsp; &nbsp;&nbsp; &nbsp;(void *)android_media_MediaPlayer_seekTo},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"_pause",&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; "()V",&nbsp; &nbsp;&nbsp; &nbsp; (void *)android_media_MediaPlayer_pause},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"isPlaying",&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"()Z",&nbsp; &nbsp;&nbsp; &nbsp; (void *)android_media_MediaPlayer_isPlaying},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"getCurrentPosition", "()I",&nbsp;&nbsp;(void *)android_media_MediaPlayer_getCurrentPosition},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"getDuration",&nbsp; &nbsp;&nbsp; &nbsp;"()I",&nbsp; &nbsp;&nbsp;&nbsp;(void *)android_media_MediaPlayer_getDuration},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"_release",&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;"()V",&nbsp; &nbsp;&nbsp; &nbsp;(void *)android_media_MediaPlayer_release},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"_reset",&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;"()V",&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;(void *)android_media_MediaPlayer_reset},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"setAudioStreamType","(I)V", (void *)android_media_MediaPlayer_setAudioStreamType},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"setLooping",&nbsp; &nbsp;&nbsp; &nbsp;"(Z)V",&nbsp; &nbsp;&nbsp; &nbsp;(void *)android_media_MediaPlayer_setLooping},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"setVolume",&nbsp; &nbsp;&nbsp; &nbsp;"(FF)V",&nbsp; &nbsp;&nbsp;&nbsp;(void *)android_media_MediaPlayer_setVolume},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"getFrameAt",&nbsp; &nbsp;&nbsp;&nbsp;"(I)Landroid/graphics/Bitmap;",&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;(void *)android_media_MediaPlayer_getFrameAt},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"native_setup",&nbsp; &nbsp; "(Ljava/lang/Object;)V",&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;(void *)android_media_MediaPlayer_native_setup},<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; {"native_finalize",&nbsp; &nbsp;&nbsp;&nbsp;"()V",&nbsp; &nbsp; (void *)android_media_MediaPlayer_native_finalize},<br style="word-wrap: break-word; line-height: normal; " />
            };<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            static int register_android_media_MediaPlayer(JNIEnv *env){<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; return AndroidRuntime::registerNativeMethods(env,<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; "android/media/MediaPlayer", gMethods, NELEM(gMethods));<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            jint JNI_OnLoad(JavaVM* vm, void* reserved){<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; if (register_android_media_MediaPlayer(env) &lt; 0) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGE("ERROR: MediaPlayer native registration failed\n");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;goto bail;<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            当VM载入libmedia_jni.so档案时，就呼叫JNI_OnLoad()函数。接着，JNI_OnLoad()呼叫register_android_media_MediaPlayer()函数。此时，就呼叫到AndroidRuntime::registerNativeMethods()函数，向VM(即AndroidRuntime)登记gMethods[]表格所含的本地函数了。简而言之，registerNativeMethods()函数的用途有二：<br style="word-wrap: break-word; line-height: normal; " />
            (1)更有效率去找到函数。<br style="word-wrap: break-word; line-height: normal; " />
            (2)可在执行期间进行抽换。由于gMethods[]是一个&lt;名称，函数指针&gt;对照表，在程序执行时，可多次呼叫registerNativeMethods()函数来更换本地函数之指针，而达到弹性抽换本地函数之目的。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            4.Andoird 中使用了一种不同传统Java JNI的方式来定义其native的函数。其中很重要的区别是Andorid使用了一种Java 和 C 函数的映射表数组，并在其中描述了函数的参数和返回值。这个数组的类型是JNINativeMethod，定义如下：<br style="word-wrap: break-word; line-height: normal; " />
            typedef struct {<br style="word-wrap: break-word; line-height: normal; " />
            const char* name;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;/*Java中函数的名字*/&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            const char* signature;&nbsp; &nbsp;&nbsp; &nbsp;/*描述了函数的参数和返回值*/<br style="word-wrap: break-word; line-height: normal; " />
            void* fnPtr;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;/*函数指针，指向C函数*/<br style="word-wrap: break-word; line-height: normal; " />
            } JNINativeMethod;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            其中比较难以理解的是第二个参数，例如<br style="word-wrap: break-word; line-height: normal; " />
            "()V"<br style="word-wrap: break-word; line-height: normal; " />
            "(II)V"<br style="word-wrap: break-word; line-height: normal; " />
            "(Ljava/lang/String;Ljava/lang/String;)V"<br style="word-wrap: break-word; line-height: normal; " />
            实际上这些字符是与函数的参数类型一一对应的。<br style="word-wrap: break-word; line-height: normal; " />
            "()" 中的字符表示参数，后面的则代表返回值。例如"()V" 就表示void Func();<br style="word-wrap: break-word; line-height: normal; " />
            "(II)V" 表示 void Func(int, int);<br style="word-wrap: break-word; line-height: normal; " />
            具体的每一个字符的对应关系如下<br style="word-wrap: break-word; line-height: normal; " />
            字符&nbsp; &nbsp;Java类型&nbsp; &nbsp;&nbsp;&nbsp;C类型<br style="word-wrap: break-word; line-height: normal; " />
            V&nbsp; &nbsp;&nbsp; &nbsp;void&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;void<br style="word-wrap: break-word; line-height: normal; " />
            Z&nbsp; &nbsp;&nbsp; &nbsp;jboolean&nbsp; &nbsp;&nbsp;&nbsp;boolean<br style="word-wrap: break-word; line-height: normal; " />
            I&nbsp; &nbsp;&nbsp; &nbsp; jint&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;int<br style="word-wrap: break-word; line-height: normal; " />
            J&nbsp; &nbsp;&nbsp; &nbsp; jlong&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;long<br style="word-wrap: break-word; line-height: normal; " />
            D&nbsp; &nbsp;&nbsp; &nbsp;jdouble&nbsp; &nbsp;&nbsp; &nbsp; double<br style="word-wrap: break-word; line-height: normal; " />
            F&nbsp; &nbsp;&nbsp; &nbsp;jfloat&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;float<br style="word-wrap: break-word; line-height: normal; " />
            B&nbsp; &nbsp;&nbsp; &nbsp;jbyte&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;byte<br style="word-wrap: break-word; line-height: normal; " />
            C&nbsp; &nbsp;&nbsp; &nbsp;jchar&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;char<br style="word-wrap: break-word; line-height: normal; " />
            S&nbsp; &nbsp;&nbsp; &nbsp;jshort&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; short<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            数组则以"["开始，用两个字符表示<br style="word-wrap: break-word; line-height: normal; " />
            [I&nbsp; &nbsp;&nbsp;&nbsp;jintArray&nbsp; &nbsp;&nbsp; &nbsp; int[]<br style="word-wrap: break-word; line-height: normal; " />
            [F&nbsp; &nbsp;&nbsp;&nbsp;jfloatArray&nbsp; &nbsp;&nbsp;&nbsp;float[]<br style="word-wrap: break-word; line-height: normal; " />
            [B&nbsp; &nbsp;&nbsp;&nbsp;jbyteArray&nbsp; &nbsp;&nbsp;&nbsp;byte[]<br style="word-wrap: break-word; line-height: normal; " />
            [C&nbsp; &nbsp; jcharArray&nbsp; &nbsp;&nbsp; &nbsp;char[]<br style="word-wrap: break-word; line-height: normal; " />
            [S&nbsp; &nbsp; jshortArray&nbsp; &nbsp;&nbsp; &nbsp;short[]<br style="word-wrap: break-word; line-height: normal; " />
            [D&nbsp; &nbsp; jdoubleArray&nbsp; &nbsp; double[]<br style="word-wrap: break-word; line-height: normal; " />
            [J&nbsp; &nbsp;&nbsp;&nbsp;jlongArray&nbsp; &nbsp;&nbsp; &nbsp;long[]<br style="word-wrap: break-word; line-height: normal; " />
            [Z&nbsp; &nbsp; jbooleanArray&nbsp; &nbsp; boolean[]<br style="word-wrap: break-word; line-height: normal; " />
            上面的都是基本类型。如果Java函数的参数是class，则以"L"开头，以";"结尾，中间是用"/" 隔开的包及类名。而其对应的C函数名的参数则为jobject. 一个例外是String类，其对应的类为jstring<br style="word-wrap: break-word; line-height: normal; " />
            Ljava/lang/String; String jstring<br style="word-wrap: break-word; line-height: normal; " />
            Ljava/net/Socket; Socket jobject<br style="word-wrap: break-word; line-height: normal; " />
            如果JAVA函数位于一个嵌入类，则用$作为类名间的分隔符。<br style="word-wrap: break-word; line-height: normal; " />
            例如 "(Ljava/lang/String;Landroid/os/FileUtils$FileStatus;)Z"<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            Android JNI编程实践<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            一、直接使用java本身jni接口（windows/ubuntu）<br style="word-wrap: break-word; line-height: normal; " />
            1.在Eclipsh中新建一个android应用程序。两个类：一个继承于Activity，UI显示用。另一个包含native方法。编译生成所有类。<br style="word-wrap: break-word; line-height: normal; " />
            jnitest.java文件：<br style="word-wrap: break-word; line-height: normal; " />
            package com.hello.jnitest;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            import android.app.Activity;<br style="word-wrap: break-word; line-height: normal; " />
            import android.os.Bundle;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            public class jnitest extends Activity {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; /** Called when the activity is first created. */<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; @Override<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; public void onCreate(Bundle savedInstanceState) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;super.onCreate(savedInstanceState);<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;setContentView(R.layout.main);<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;Nadd cal = new Nadd();<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;setTitle("The Native Add Result is " + String.valueOf(cal.nadd(10, 19)));<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            Nadd.java文件：<br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">package</strong>&nbsp;com.hello.jnitest;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">public</strong>&nbsp;<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">class</strong>&nbsp;Nadd {<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">static</strong>&nbsp;{<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;System.<em style="word-wrap: break-word; line-height: normal; ">loadLibrary</em>("Nadd");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">public</strong>&nbsp;<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">native</strong>&nbsp;<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">int</strong>&nbsp;nadd(<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">int</strong>&nbsp;a,&nbsp;<strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">int</strong>&nbsp;b);<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            以上在windows中完成。<br style="word-wrap: break-word; line-height: normal; " />
            2.使用javah命令生成C/C++的.h文件。注意类要包含包名，路径文件夹下要包含所有包中的类，否则会报找不到类的错误。classpath参数指定到包名前一级文件夹，文件夹层次结构要符合java类的组织层次结构。<br style="word-wrap: break-word; line-height: normal; " />
            javah -classpath ../jnitest/bin com.hello.jnitest.Nadd<br style="word-wrap: break-word; line-height: normal; " />
            com_hello_jnitest_Nadd .h文件：<br style="word-wrap: break-word; line-height: normal; " />
            /* DO NOT EDIT THIS FILE - it is machine generated */<br style="word-wrap: break-word; line-height: normal; " />
            #include &lt;jni.h&gt;<br style="word-wrap: break-word; line-height: normal; " />
            /* Header for class com_hello_jnitest_Nadd */<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            #ifndef _Included_com_hello_jnitest_Nadd<br style="word-wrap: break-word; line-height: normal; " />
            #define _Included_com_hello_jnitest_Nadd<br style="word-wrap: break-word; line-height: normal; " />
            #ifdef __cplusplus<br style="word-wrap: break-word; line-height: normal; " />
            extern "C" {<br style="word-wrap: break-word; line-height: normal; " />
            #endif<br style="word-wrap: break-word; line-height: normal; " />
            /*<br style="word-wrap: break-word; line-height: normal; " />
            * Class:&nbsp; &nbsp;&nbsp;&nbsp;com_hello_jnitest_Nadd<br style="word-wrap: break-word; line-height: normal; " />
            * Method:&nbsp; &nbsp; nadd<br style="word-wrap: break-word; line-height: normal; " />
            * Signature: (II)I<br style="word-wrap: break-word; line-height: normal; " />
            */<br style="word-wrap: break-word; line-height: normal; " />
            JNIEXPORT jint JNICALL Java_com_hello_jnitest_Nadd_nadd<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp;&nbsp;(JNIEnv *, jobject, jint, jint);<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            #ifdef __cplusplus<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            #endif<br style="word-wrap: break-word; line-height: normal; " />
            #endif<br style="word-wrap: break-word; line-height: normal; " />
            3.编辑.c文件实现native方法。<br style="word-wrap: break-word; line-height: normal; " />
            com_hello_jnitest_Nadd.c文件：<br style="word-wrap: break-word; line-height: normal; " />
            #include &lt;stdlib.h&gt;<br style="word-wrap: break-word; line-height: normal; " />
            #include "com_hello_jnitest_Nadd.h"<br style="word-wrap: break-word; line-height: normal; " />
            JNIEXPORT jint JNICALL Java_com_hello_jnitest_Nadd_nadd(JNIEnv * env, jobject c, jint a, jint b)<br style="word-wrap: break-word; line-height: normal; " />
            {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;return (a+b);<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            4.编译.c文件生存动态库。<br style="word-wrap: break-word; line-height: normal; " />
            arm-none-linux-gnueabi-gcc -I/home/a/work/android/jdk1.6.0_17/include -I/home/a/work/android/jdk1.6.0_17/include/linux -fpic -c com_hello_jnitest_Nadd.c<br style="word-wrap: break-word; line-height: normal; " />
            arm-none-linux-gnueabi-ld -T/home/a/CodeSourcery/Sourcery_G++_Lite/arm-none-linux-gnueabi/lib/ldscripts/armelf_linux_eabi.xsc -share -o libNadd.so com_hello_jnitest_Nadd.o<br style="word-wrap: break-word; line-height: normal; " />
            得到libNadd.so文件。<br style="word-wrap: break-word; line-height: normal; " />
            以上在ubuntu中完成。<br style="word-wrap: break-word; line-height: normal; " />
            5.将相应的动态库文件push到avd的system/lib中:adb push libNadd.so /system/lib。若提示Read-only file system错误，运行adb remount命令，即可。<br style="word-wrap: break-word; line-height: normal; " />
            Adb push libNadd.so /system/lib<br style="word-wrap: break-word; line-height: normal; " />
            6.在eclipsh中运行原应用程序即可。<br style="word-wrap: break-word; line-height: normal; " />
            以上在windows中完成。<br style="word-wrap: break-word; line-height: normal; " />
            对于一中生成的so文件也可采用二中的方法编译进apk包中。只需在工程文件夹中建libs\armeabi文件夹（其他文件夹名无效，只建立libs文件夹也无效），然后将so文件拷入，编译工程即可。<br style="word-wrap: break-word; line-height: normal; " />
            二.使用NDK生成本地方法（ubuntu and windows）<br style="word-wrap: break-word; line-height: normal; " />
            1.安装NDK：解压，然后进入NDK解压后的目录，运行build/host-setup.sh（需要Make 3.81和awk）。若有错，修改host-setup.sh文件：将#!/bin/sh修改为#!/bin/bash，再次运行即可。<br style="word-wrap: break-word; line-height: normal; " />
            2.在apps文件夹下建立自己的工程文件夹，然后在该文件夹下建一文件Application.mk和项project文件夹。<br style="word-wrap: break-word; line-height: normal; " />
            Application.mk文件：<br style="word-wrap: break-word; line-height: normal; " />
            APP_PROJECT_PATH := $(call my-dir)/project<br style="word-wrap: break-word; line-height: normal; " />
            APP_MODULES&nbsp; &nbsp;&nbsp; &nbsp;:= myjni<br style="word-wrap: break-word; line-height: normal; " />
            3.在project文件夹下建一jni文件夹，然后新建Android.mk和myjni.c。这里不需要用javah生成相应的.h文件，但函数名要包含相应的完整的包、类名。<br style="word-wrap: break-word; line-height: normal; " />
            4.编辑相应文件内容。<br style="word-wrap: break-word; line-height: normal; " />
            Android.mk文件：<br style="word-wrap: break-word; line-height: normal; " />
            # Copyright (C) 2009 The Android Open Source Project<br style="word-wrap: break-word; line-height: normal; " />
            #<br style="word-wrap: break-word; line-height: normal; " />
            # Licensed under the Apache License, Version 2.0 (the "License");<br style="word-wrap: break-word; line-height: normal; " />
            # you may not use this file except in compliance with the License.<br style="word-wrap: break-word; line-height: normal; " />
            # You may obtain a copy of the License at<br style="word-wrap: break-word; line-height: normal; " />
            #<br style="word-wrap: break-word; line-height: normal; " />
            #&nbsp; &nbsp;&nbsp; &nbsp;<a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank" style="word-wrap: break-word; text-decoration: none; color: #8bd00b; line-height: normal; "><font color="#0000ff" style="word-wrap: break-word; line-height: normal; ">http://www.apache.org/licenses/LICENSE-2.0</font></a><br style="word-wrap: break-word; line-height: normal; " />
            #<br style="word-wrap: break-word; line-height: normal; " />
            # Unless required by applicable law or agreed to in writing, software<br style="word-wrap: break-word; line-height: normal; " />
            # distributed under the License is distributed on an "AS IS" BASIS,<br style="word-wrap: break-word; line-height: normal; " />
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br style="word-wrap: break-word; line-height: normal; " />
            # See the License for the specific language governing permissions and<br style="word-wrap: break-word; line-height: normal; " />
            # limitations under the License.<br style="word-wrap: break-word; line-height: normal; " />
            #<br style="word-wrap: break-word; line-height: normal; " />
            LOCAL_PATH := $(call my-dir)<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            include $(CLEAR_VARS)<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            LOCAL_MODULE&nbsp; &nbsp; := myjni<br style="word-wrap: break-word; line-height: normal; " />
            LOCAL_SRC_FILES := myjni.c<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            include $(BUILD_SHARED_LIBRARY)<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            myjni.c文件：<br style="word-wrap: break-word; line-height: normal; " />
            #include &lt;string.h&gt;<br style="word-wrap: break-word; line-height: normal; " />
            #include &lt;jni.h&gt;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            jstring<br style="word-wrap: break-word; line-height: normal; " />
            Java_com_hello_NdkTest_NdkTest_stringFromJNI( JNIEnv* env,<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;jobject thiz )<br style="word-wrap: break-word; line-height: normal; " />
            {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; return (*env)-&gt;NewStringUTF(env, "Hello from My-JNI !");<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            myjni文件组织：<br style="word-wrap: break-word; line-height: normal; " />
            a@ubuntu:~/work/android/ndk-1.6_r1/apps$ tree myjni<br style="word-wrap: break-word; line-height: normal; " />
            myjni<br style="word-wrap: break-word; line-height: normal; " />
            |-- Application.mk<br style="word-wrap: break-word; line-height: normal; " />
            `-- project<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; |-- jni<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; |&nbsp; &nbsp;|-- Android.mk<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; |&nbsp; &nbsp;`-- myjni.c<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; `-- libs<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;`-- armeabi<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;`-- libmyjni.so<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            4 directories, 4 files<br style="word-wrap: break-word; line-height: normal; " />
            5.编译：make APP=myjni.<br style="word-wrap: break-word; line-height: normal; " />
            以上内容在ubuntu完成。以下内容在windows中完成。当然也可以在ubuntu中完成。<br style="word-wrap: break-word; line-height: normal; " />
            6.在eclipsh中创建android application。将myjni中自动生成的libs文件夹拷贝到当前工程文件夹中，编译运行即可。<br style="word-wrap: break-word; line-height: normal; " />
            NdkTest.java文件：<br style="word-wrap: break-word; line-height: normal; " />
            package com.hello.NdkTest;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            import android.app.Activity;<br style="word-wrap: break-word; line-height: normal; " />
            import android.os.Bundle;<br style="word-wrap: break-word; line-height: normal; " />
            import android.widget.TextView;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            public class NdkTest extends Activity {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; /** Called when the activity is first created. */<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; @Override<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; public void onCreate(Bundle savedInstanceState) {<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;super.onCreate(savedInstanceState);<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;TextView&nbsp;&nbsp;tv = new TextView(this);<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;tv.setText( stringFromJNI() );<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;setContentView(tv);<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; public native String&nbsp;&nbsp;stringFromJNI();<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; static {<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;System.loadLibrary("myjni");<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; }<br style="word-wrap: break-word; line-height: normal; " />
            }<br style="word-wrap: break-word; line-height: normal; " />
            对于二中生成的so文件也可采用一中的方法push到avd中运行。</td>
        </tr>
    </tbody>
</table>
</div>
</span>
<img src ="http://www.blogjava.net/MEYE/aggbug/335854.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:47 <a href="http://www.blogjava.net/MEYE/articles/335854.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>分析Android 根文件系统启动过程（init守护进程分析）</title><link>http://www.blogjava.net/MEYE/articles/335852.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:46:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335852.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335852.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335852.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335852.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335852.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="border-collapse: collapse; color: #2b3714; font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 19px; font-size: 14.4px; ">
<div id="threadtitle" style="word-wrap: break-word; line-height: normal; margin-bottom: 8px; ">
<h1 style="word-wrap: break-word; margin-top: 8px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.17em; line-height: normal; ">分析Android 根文件系统启动过程（init守护进程分析）</h1>
</div>
<div class="t_msgfontfix" style="word-wrap: break-word; line-height: normal; min-height: 100px; ">
<table cellspacing="0" cellpadding="0" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 720px; table-layout: fixed; margin-left: 1px; ">
    <tbody style="word-wrap: break-word; line-height: normal; ">
        <tr style="word-wrap: break-word; line-height: normal; ">
            <td class="t_msgfont" id="postmessage_1051" style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; ">
            <table cellspacing="0" class="t_table" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 719px; table-layout: fixed; margin-left: 1px; ">
                <tbody style="word-wrap: break-word; line-height: normal; ">
                    <tr style="word-wrap: break-word; line-height: normal; ">
                        <td style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; overflow-x: hidden; overflow-y: hidden; ">今天开始分析Android 根文件系统启动过程。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        在Android系统启动时，内核引导参数上一般都会设置&#8220;init=/init&#8221;,这样的话，如果内核成功挂载了这个文件系统之后，首先运行的就是这个根目录下的init程序。这个程序所了什么呢？ 我们只有RFSC（Readthe Fucking Source code）!!<br style="word-wrap: break-word; line-height: normal; " />
                        init程序源码在Android官方源码的system/core/init中，main在init.c里。我们的分析就从main开始。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">init：</strong><br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （1）安装SIGCHLD信号。（如果父进程不等待子进程结束，子进程将成为僵尸进程（zombie）从而占用系统资源。因此需要对SIGCHLD信号做出处理，回收僵尸进程的资源，避免造成不必要的资源浪费。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （2）对umask进行清零。<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp; 何为umask，请看<a href="http://www.szstudy.cn/showArticle/53978.shtml" target="_blank" style="word-wrap: break-word; text-decoration: none; color: #8bd00b; line-height: normal; "><font color="#108ac6" style="word-wrap: break-word; line-height: normal; ">http://www.szstudy.cn/showArticle/53978.shtml</font></a><br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （3）为rootfs建立必要的文件夹，并挂载适当的分区。<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp; /dev （tmpfs）<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/dev/pts (devpts)<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/dev/socket<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp; /proc (proc)<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp; /sys&nbsp;&nbsp;(sysfs)<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp;&nbsp;(4)创建/dev/null和/dev/kmsg节点。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （5）解析/init.rc，将所有服务和操作信息加入链表。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp;&nbsp;(6)从/proc/cmdline中提取信息内核启动参数,并保存到全局变量。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （7）先从上一步获得的全局变量中获取信息硬件信息和版本号，如果没有则从/proc/cpuinfo中提取,并保存到全局变量。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （8）根据硬件信息选择一个/init.(硬件).rc，并解析，将服务和操作信息加入链表。<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;在G1的ramdisk根目录下有两个/init.(硬件).rc：init.goldfish.rc和init.trout.rc，init程序会根据上一步获得的硬件信息选择一个解析。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （9）执行链表中带有&#8220;early-init&#8221;触发的的命令。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （10）遍历/sys文件夹，是内核产生设备添加事件（为了自动产生设备节点)。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （11）初始化属性系统，并导入初始化属性文件。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （12）从属性系统中得到ro.debuggable，若为1，則初始化keychord監聽。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （13）打開console,如果cmdline中沒有指定console則打開默認的/dev/console。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （14）讀取/initlogo.rle（一張565 rle 壓縮的位圖），如果成功則在/dev/graphics/fb0顯示Logo,如果失敗則將/dev/tty0設為TEXT模式并打開/dev/tty0,輸出文本&#8220;ANDROID&#8221;字樣。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （15）判斷cmdline 中的參數，并设置属性系统中的参数:<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;1、 如果 bootmode為<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- factory,設置ro.factorytest值為1<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- factory2,設置ro.factorytest值為2<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- 其他的設ro.factorytest值為0<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp; 2、如果有serialno参数，則設置ro.serialno，否則為""<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp; 3、如果有bootmod参数，則設置ro.bootmod，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp; 4、如果有baseband参数，則設置ro.baseband，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp; 5、如果有carrier参数，則設置ro.carrier，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp; 6、如果有bootloader参数，則設置ro.bootloader，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp; 7、通过全局变量（前面从/proc/cpuinfo中提取的）設置ro.hardware和ro.version。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （16）執行所有触发标识为init的action。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （17）開始property服務，讀取一些property文件，這一動作必須在前面那些ro.foo設置后做，以便/data/local.prop不能干預到他們。<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- /system/build.prop<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- /system/default.prop<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- /data/local.prop<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- 在讀取默認的property后讀取presistent propertie，在/data/property中<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （18）為sigchld handler創建信號機制。<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （19）確認所有初始化工作完成：<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; device_fd(device init 完成)<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; property_set_fd(property server start 完成)<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; signal_recv_fd (信號機制建立)<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （20） 執行所有触发标识为early-boot的action<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （21） 執行所有触发标识为boot的action<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （22）基于當前property狀態，執行所有触发标识为property的action<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （23）注冊輪詢事件:<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;- device_fd<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;- property_set_fd<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-signal_recv_fd<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-如果有keychord，則注冊keychord_fd<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （24）如果支持BOOTCHART,則初始化BOOTCHART<br style="word-wrap: break-word; line-height: normal; " />
                        <br style="word-wrap: break-word; line-height: normal; " />
                        （25）進入主進程循環:<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- 重置輪詢事件的接受狀態，revents為0<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- 查詢action隊列，并执行。<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- 重啟需要重啟的服务<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;- 輪詢注冊的事件<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果signal_recv_fd的revents為POLLIN，則得到一個信號，獲取并處理<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果device_fd的revents為POLLIN,調用handle_device_fd<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果property_fd的revents為POLLIN,調用handle_property_set_fd<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果keychord_fd的revents為POLLIN,調用handle_keychord<br style="word-wrap: break-word; line-height: normal; " />
                        <table cellspacing="0" class="t_table" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 709px; table-layout: fixed; margin-left: 1px; ">
                            <tbody style="word-wrap: break-word; line-height: normal; ">
                                <tr style="word-wrap: break-word; line-height: normal; ">
                                    <td style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; overflow-x: hidden; overflow-y: hidden; ">今天开始分析Android 根文件系统启动过程。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    在Android系统启动时，内核引导参数上一般都会设置&#8220;init=/init&#8221;,这样的话，如果内核成功挂载了这个文件系统之后，首先运行的就是这个根目录下的init程序。这个程序所了什么呢？ 我们只有RFSC（Readthe Fucking Source code）!!<br style="word-wrap: break-word; line-height: normal; " />
                                    init程序源码在Android官方源码的system/core/init中，main在init.c里。我们的分析就从main开始。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">init：</strong><br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （1）安装SIGCHLD信号。（如果父进程不等待子进程结束，子进程将成为僵尸进程（zombie）从而占用系统资源。因此需要对SIGCHLD信号做出处理，回收僵尸进程的资源，避免造成不必要的资源浪费。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （2）对umask进行清零。<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp; 何为umask，请看<a href="http://www.szstudy.cn/showArticle/53978.shtml" target="_blank" style="word-wrap: break-word; text-decoration: none; color: #8bd00b; line-height: normal; "><font color="#108ac6" style="word-wrap: break-word; line-height: normal; ">http://www.szstudy.cn/showArticle/53978.shtml</font></a><br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （3）为rootfs建立必要的文件夹，并挂载适当的分区。<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp; /dev （tmpfs）<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/dev/pts (devpts)<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/dev/socket<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp; /proc (proc)<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp; /sys&nbsp;&nbsp;(sysfs)<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp;&nbsp;(4)创建/dev/null和/dev/kmsg节点。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （5）解析/init.rc，将所有服务和操作信息加入链表。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp;&nbsp;(6)从/proc/cmdline中提取信息内核启动参数,并保存到全局变量。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （7）先从上一步获得的全局变量中获取信息硬件信息和版本号，如果没有则从/proc/cpuinfo中提取,并保存到全局变量。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （8）根据硬件信息选择一个/init.(硬件).rc，并解析，将服务和操作信息加入链表。<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;在G1的ramdisk根目录下有两个/init.(硬件).rc：init.goldfish.rc和init.trout.rc，init程序会根据上一步获得的硬件信息选择一个解析。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （9）执行链表中带有&#8220;early-init&#8221;触发的的命令。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （10）遍历/sys文件夹，是内核产生设备添加事件（为了自动产生设备节点)。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （11）初始化属性系统，并导入初始化属性文件。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （12）从属性系统中得到ro.debuggable，若为1，則初始化keychord監聽。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （13）打開console,如果cmdline中沒有指定console則打開默認的/dev/console。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （14）讀取/initlogo.rle（一張565 rle 壓縮的位圖），如果成功則在/dev/graphics/fb0顯示Logo,如果失敗則將/dev/tty0設為TEXT模式并打開/dev/tty0,輸出文本&#8220;ANDROID&#8221;字樣。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （15）判斷cmdline 中的參數，并设置属性系统中的参数:<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;1、 如果 bootmode為<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- factory,設置ro.factorytest值為1<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- factory2,設置ro.factorytest值為2<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- 其他的設ro.factorytest值為0<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp; 2、如果有serialno参数，則設置ro.serialno，否則為""<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp; 3、如果有bootmod参数，則設置ro.bootmod，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp; 4、如果有baseband参数，則設置ro.baseband，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp; 5、如果有carrier参数，則設置ro.carrier，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp; 6、如果有bootloader参数，則設置ro.bootloader，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp; 7、通过全局变量（前面从/proc/cpuinfo中提取的）設置ro.hardware和ro.version。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （16）執行所有触发标识为init的action。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （17）開始property服務，讀取一些property文件，這一動作必須在前面那些ro.foo設置后做，以便/data/local.prop不能干預到他們。<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- /system/build.prop<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- /system/default.prop<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- /data/local.prop<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- 在讀取默認的property后讀取presistent propertie，在/data/property中<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （18）為sigchld handler創建信號機制。<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （19）確認所有初始化工作完成：<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; device_fd(device init 完成)<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; property_set_fd(property server start 完成)<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; signal_recv_fd (信號機制建立)<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （20） 執行所有触发标识为early-boot的action<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （21） 執行所有触发标识为boot的action<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （22）基于當前property狀態，執行所有触发标识为property的action<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （23）注冊輪詢事件:<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;- device_fd<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;- property_set_fd<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-signal_recv_fd<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-如果有keychord，則注冊keychord_fd<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （24）如果支持BOOTCHART,則初始化BOOTCHART<br style="word-wrap: break-word; line-height: normal; " />
                                    <br style="word-wrap: break-word; line-height: normal; " />
                                    （25）進入主進程循環:<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- 重置輪詢事件的接受狀態，revents為0<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- 查詢action隊列，并执行。<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- 重啟需要重啟的服务<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;- 輪詢注冊的事件<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果signal_recv_fd的revents為POLLIN，則得到一個信號，獲取并處理<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果device_fd的revents為POLLIN,調用handle_device_fd<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果property_fd的revents為POLLIN,調用handle_property_set_fd<br style="word-wrap: break-word; line-height: normal; " />
                                    &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果keychord_fd的revents為POLLIN,調用handle_keychord<br style="word-wrap: break-word; line-height: normal; " />
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </td>
                    </tr>
                </tbody>
            </table>
            今天开始分析Android 根文件系统启动过程。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            在Android系统启动时，内核引导参数上一般都会设置&#8220;init=/init&#8221;,这样的话，如果内核成功挂载了这个文件系统之后，首先运行的就是这个根目录下的init程序。这个程序所了什么呢？ 我们只有RFSC（Readthe Fucking Source code）!!<br style="word-wrap: break-word; line-height: normal; " />
            init程序源码在Android官方源码的system/core/init中，main在init.c里。我们的分析就从main开始。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">init：</strong><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （1）安装SIGCHLD信号。（如果父进程不等待子进程结束，子进程将成为僵尸进程（zombie）从而占用系统资源。因此需要对SIGCHLD信号做出处理，回收僵尸进程的资源，避免造成不必要的资源浪费。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （2）对umask进行清零。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; 何为umask，请看<a href="http://www.szstudy.cn/showArticle/53978.shtml" target="_blank" style="word-wrap: break-word; text-decoration: none; color: #8bd00b; line-height: normal; "><font color="#108ac6" style="word-wrap: break-word; line-height: normal; ">http://www.szstudy.cn/showArticle/53978.shtml</font></a><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （3）为rootfs建立必要的文件夹，并挂载适当的分区。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; /dev （tmpfs）<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/dev/pts (devpts)<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/dev/socket<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; /proc (proc)<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; /sys&nbsp;&nbsp;(sysfs)<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp;&nbsp;(4)创建/dev/null和/dev/kmsg节点。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （5）解析/init.rc，将所有服务和操作信息加入链表。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            &nbsp;&nbsp;(6)从/proc/cmdline中提取信息内核启动参数,并保存到全局变量。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （7）先从上一步获得的全局变量中获取信息硬件信息和版本号，如果没有则从/proc/cpuinfo中提取,并保存到全局变量。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （8）根据硬件信息选择一个/init.(硬件).rc，并解析，将服务和操作信息加入链表。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;在G1的ramdisk根目录下有两个/init.(硬件).rc：init.goldfish.rc和init.trout.rc，init程序会根据上一步获得的硬件信息选择一个解析。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （9）执行链表中带有&#8220;early-init&#8221;触发的的命令。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （10）遍历/sys文件夹，是内核产生设备添加事件（为了自动产生设备节点)。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （11）初始化属性系统，并导入初始化属性文件。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （12）从属性系统中得到ro.debuggable，若为1，則初始化keychord監聽。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （13）打開console,如果cmdline中沒有指定console則打開默認的/dev/console。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （14）讀取/initlogo.rle（一張565 rle 壓縮的位圖），如果成功則在/dev/graphics/fb0顯示Logo,如果失敗則將/dev/tty0設為TEXT模式并打開/dev/tty0,輸出文本&#8220;ANDROID&#8221;字樣。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （15）判斷cmdline 中的參數，并设置属性系统中的参数:<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;1、 如果 bootmode為<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- factory,設置ro.factorytest值為1<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- factory2,設置ro.factorytest值為2<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;- 其他的設ro.factorytest值為0<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; 2、如果有serialno参数，則設置ro.serialno，否則為""<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; 3、如果有bootmod参数，則設置ro.bootmod，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; 4、如果有baseband参数，則設置ro.baseband，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; 5、如果有carrier参数，則設置ro.carrier，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; 6、如果有bootloader参数，則設置ro.bootloader，否則為"unknown"<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp; 7、通过全局变量（前面从/proc/cpuinfo中提取的）設置ro.hardware和ro.version。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （16）執行所有触发标识为init的action。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （17）開始property服務，讀取一些property文件，這一動作必須在前面那些ro.foo設置后做，以便/data/local.prop不能干預到他們。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- /system/build.prop<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- /system/default.prop<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- /data/local.prop<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- 在讀取默認的property后讀取presistent propertie，在/data/property中<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （18）為sigchld handler創建信號機制。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （19）確認所有初始化工作完成：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; device_fd(device init 完成)<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; property_set_fd(property server start 完成)<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; signal_recv_fd (信號機制建立)<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （20） 執行所有触发标识为early-boot的action<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （21） 執行所有触发标识为boot的action<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （22）基于當前property狀態，執行所有触发标识为property的action<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （23）注冊輪詢事件:<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;- device_fd<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;- property_set_fd<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-signal_recv_fd<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;-如果有keychord，則注冊keychord_fd<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （24）如果支持BOOTCHART,則初始化BOOTCHART<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            （25）進入主進程循環:<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- 重置輪詢事件的接受狀態，revents為0<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- 查詢action隊列，并执行。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- 重啟需要重啟的服务<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;- 輪詢注冊的事件<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果signal_recv_fd的revents為POLLIN，則得到一個信號，獲取并處理<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果device_fd的revents為POLLIN,調用handle_device_fd<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果property_fd的revents為POLLIN,調用handle_property_set_fd<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; - 如果keychord_fd的revents為POLLIN,調用handle_keychord</td>
        </tr>
    </tbody>
</table>
</div>
</span>
<img src ="http://www.blogjava.net/MEYE/aggbug/335852.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:46 <a href="http://www.blogjava.net/MEYE/articles/335852.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android内核和驱动篇-Android内核介绍</title><link>http://www.blogjava.net/MEYE/articles/335851.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:45:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335851.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335851.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335851.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335851.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335851.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="border-collapse: collapse; color: #2b3714; font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 19px; font-size: 14.4px; ">
<div id="threadtitle" style="word-wrap: break-word; line-height: normal; margin-bottom: 8px; ">
<h1 style="word-wrap: break-word; margin-top: 8px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.17em; line-height: normal; ">Android内核和驱动篇-Android内核介绍</h1>
</div>
<div class="t_msgfontfix" style="word-wrap: break-word; line-height: normal; min-height: 100px; ">
<table cellspacing="0" cellpadding="0" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 720px; table-layout: fixed; margin-left: 1px; ">
    <tbody style="word-wrap: break-word; line-height: normal; ">
        <tr style="word-wrap: break-word; line-height: normal; ">
            <td class="t_msgfont" id="postmessage_975" style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; "><font size="2" style="word-wrap: break-word; line-height: normal; "><font color="#0000ff" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><em style="word-wrap: break-word; line-height: normal; ">节选自EasyAndroid.com原创图书，敬请期待</em></strong><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            </font>已经有一些的文章介绍Android内核了，本系列篇将从Linux内核的角度来分析Android的内核，希望给初学者提够有用的信息。本章将简单的介绍Android内核的全貌，起到一个抛砖引玉的作用。从下一篇开始将详细介绍每一个Android内核驱动程序及其作用。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            </font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; "><font style="word-wrap: break-word; line-height: normal; font-size: 12pt; "><font size="2" style="word-wrap: break-word; line-height: normal; ">Android内核是基于Linux 2.6内核的（目前最新开发版本是2.6.31），它是一个增强内核版本，除了修改部分Bug外，它提供了用于支持Android平台的设备驱动，其核心驱动主要包括：</font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android Binder</strong>，基于OpenBinder框架的一个驱动，用于提供Android平台的进程间通讯（IPC，inter-process communication）。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/staging/android/binder.c</em></font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android电源管理（PM）</strong>，一个基于标准Linux电源管理系统的轻量级的Android电源管理驱动，针对嵌入式设备做了很多优化。<br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; 源代码位于kernel/power/earlysuspend.c</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;kernel/power/consoleearlysuspend.c</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;kernel/power/fbearlysuspend.c</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;kernel/power/wakelock.c</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;kernel/power/userwakelock.c</em></font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">低内存管理器（Low Memory Killer）</strong>，相对于Linux标准OOM（Out Of Memory）机制更加灵活，它可以根据需要杀死进程来释放需要的内存。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/staging/android/lowmemorykiller.c</em></font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">匿名共享内存（ashmem）</strong>，为进程间提供大块共享内存，同时为内核提供回收和管理这个内存的机制。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于mm/ashmem.c</em></font><br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android PMEM（Physical）</strong>，PMEM用于向用户空间提供连续的物理内存区域，DSP和某些设备只能工作在连续的物理内存上。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/misc/pmem.c</em><br style="word-wrap: break-word; line-height: normal; " />
            </font><font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android Logger</strong>，一个轻量级的日志设备，用于抓取Android系统的各种日志。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">&nbsp;&nbsp;源代码位于drivers/staging/android/logger.c</em></font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android Alarm</strong>，提供了一个定时器用于把设备从睡眠状态唤醒，同时它也提供了一个即使在设备睡眠时也会运行的时钟基准，<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/rtc/alarm.c</em><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">USB Gadget驱动</strong>，一个基于标准Linux USB gadget驱动框架的设备驱动，Android的USB驱动是基于gaeget框架的，<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/usb/gadget/</em></font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android Ram Console</strong>，为了提供调试功能，Android允许将调试日志信息写入一个被称为RAM Console的设备里，它是一个基于RAM的Buffer。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/staging/android/ram_console.c。</em><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Android timed device</strong>，提供了对设备进行定时控制功能，目前支持vibrator和LED设备。<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp;&nbsp;<em style="word-wrap: break-word; line-height: normal; ">源代码位于drivers/staging/android/timed_output.c(timed_gpio.c)。</em><br style="word-wrap: break-word; line-height: normal; " />
            </font><font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; ">Yaffs2文件系统</strong>，Android采用Yaffs2作为MTD nand flash文件系统，源代码位于fs/yaffs2/目录下。Yaffs2是一个快速稳定的应用于NAND和NOR Flash的跨平台的嵌入式设备文件系统，同其他Flash文件系统相比，Yaffs2使用更小的内存来保存他的运行状态，因此它占用内存小；Yaffs2的垃圾回收非常简单而且快速，因此能达到更好的性能；Yaffs2在大容量的NAND Flash上性能表现尤为明显，非常适合大容量的Flash存储。</font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <font size="2" style="word-wrap: break-word; line-height: normal; ">Android内核添加或修改的文件很多，下面的列表描述了Android Emulator内核的文件：</font>&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            <blockquote style="word-wrap: break-word; line-height: normal; "><font size="1" style="word-wrap: break-word; line-height: normal; ">drivers/misc/kernel_debugger.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/misc/pmem.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/misc/qemutrace/qemu_trace_sysfs.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/misc/qemutrace/qemu_trace.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/misc/qemutrace/qemu_trace.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/misc/uid_stat.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/lowmemorykiller.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/logger.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/timed_output.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/ram_console.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/timed_gpio.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/logger.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/binder.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/binder.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/timed_output.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/staging/android/timed_gpio.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/rtc/alarm.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/rtc/rtc-goldfish.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/net/pppolac.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/net/ppp_mppe.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/net/pppopns.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/video/goldfishfb.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/switch/switch_class.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/switch/switch_gpio.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/char/dcc_tty.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/char/goldfish_tty.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/watchdog/i6300esb.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/misc/gpio_event.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/misc/gpio_input.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/misc/gpio_output.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/misc/keychord.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/misc/gpio_axis.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/misc/gpio_matrix.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/keyreset.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/keyboard/goldfish_events.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/input/touchscreen/synaptics_i2c_rmi.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/usb/gadget/android.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/usb/gadget/f_adb.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/usb/gadget/f_mass_storage.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/usb/gadget/f_adb.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/usb/gadget/f_mass_storage.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/mmc/host/goldfish.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/power/goldfish_battery.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/leds/ledtrig-sleep.c<br style="word-wrap: break-word; line-height: normal; " />
            drivers/mtd/devices/goldfish_nand_reg.h<br style="word-wrap: break-word; line-height: normal; " />
            drivers/mtd/devices/goldfish_nand.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/power/earlysuspend.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/power/consoleearlysuspend.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/power/fbearlysuspend.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/power/wakelock.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/power/userwakelock.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/cpuset.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/cgroup_debug.c<br style="word-wrap: break-word; line-height: normal; " />
            kernel/cgroup.c<br style="word-wrap: break-word; line-height: normal; " />
            mm/ashmem.c<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/ashmem.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/switch.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/keychord.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/earlysuspend.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/android_aid.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/uid_stat.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/if_pppolac.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/usb/android.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/wifi_tiwlan.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/android_alarm.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/keyreset.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/synaptics_i2c_rmi.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/android_pmem.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/kernel_debugger.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/gpio_event.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/wakelock.h<br style="word-wrap: break-word; line-height: normal; " />
            include/linux/if_pppopns.h<br style="word-wrap: break-word; line-height: normal; " />
            net/ipv4/sysfs_net_ipv4.c<br style="word-wrap: break-word; line-height: normal; " />
            net/ipv4/af_inet.c<br style="word-wrap: break-word; line-height: normal; " />
            net/ipv6/af_inet6.c<br style="word-wrap: break-word; line-height: normal; " />
            net/bluetooth/af_bluetooth.c<br style="word-wrap: break-word; line-height: normal; " />
            security/commoncap.c<br style="word-wrap: break-word; line-height: normal; " />
            fs/proc/base.c<font size="2" style="word-wrap: break-word; line-height: normal; "></font></font></blockquote><font size="1" style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            </font></font><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font size="2" style="word-wrap: break-word; line-height: normal; ">Android内核配置</font><br style="word-wrap: break-word; line-height: normal; " />
            </strong></font></font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Android</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">是基于</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Linux</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">的</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">，</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">对于一个新的设备，我们</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">首先要</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">编译一个支持</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Android</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">的</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Kernel</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">，那么如何</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">使</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">你的</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Kernel Android</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">化呢？除了要移植前面提到的驱动之外，就是如何配置你的</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Kernel</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">来支持</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Android</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">平台，这可以参考</font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">Goldfish</font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">的内核配置文件</font></font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">&nbsp;- arch/arm/configs/goldfish_defconfig</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">。</font></font><font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            </font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">一般来说，我们会基于一个平台标准内核配置选项来配置</font></font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">Android</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">内核，你可以根据具体的硬件平台来选择</font></font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">Android</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">内核的配置选项，可以参考下面的</font></font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">Android</font></font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; ">内核配置列表：</font></font><font size="2" style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            </font><br style="word-wrap: break-word; line-height: normal; " />
            </font><font face="宋体 " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><em style="word-wrap: break-word; line-height: normal; ">一般需要支持的内核选项</em></strong></font></font><font size="2" style="word-wrap: break-word; line-height: normal; ">&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            <blockquote style="word-wrap: break-word; line-height: normal; "><font size="1" style="word-wrap: break-word; line-height: normal; ">ANDROID_PARANOID_NETWORK<br style="word-wrap: break-word; line-height: normal; " />
            ASHMEM<br style="word-wrap: break-word; line-height: normal; " />
            CONFIG_FB_MODE_HELPERS<br style="word-wrap: break-word; line-height: normal; " />
            CONFIG_FONT_8x16<br style="word-wrap: break-word; line-height: normal; " />
            CONFIG_FONT_8x8<br style="word-wrap: break-word; line-height: normal; " />
            CONFIG_YAFFS_SHORT_NAMES_IN_RAM<br style="word-wrap: break-word; line-height: normal; " />
            DAB<br style="word-wrap: break-word; line-height: normal; " />
            EARLYSUSPEND<br style="word-wrap: break-word; line-height: normal; " />
            FB<br style="word-wrap: break-word; line-height: normal; " />
            FB_CFB_COPYAREA<br style="word-wrap: break-word; line-height: normal; " />
            FB_CFB_FILLRECT<br style="word-wrap: break-word; line-height: normal; " />
            FB_CFB_IMAGEBLIT<br style="word-wrap: break-word; line-height: normal; " />
            FB_DEFERRED_IO<br style="word-wrap: break-word; line-height: normal; " />
            FB_TILEBLITTING<br style="word-wrap: break-word; line-height: normal; " />
            HIGH_RES_TIMERS<br style="word-wrap: break-word; line-height: normal; " />
            INOTIFY<br style="word-wrap: break-word; line-height: normal; " />
            INOTIFY_USER<br style="word-wrap: break-word; line-height: normal; " />
            INPUT_EVDEV<br style="word-wrap: break-word; line-height: normal; " />
            INPUT_GPIO<br style="word-wrap: break-word; line-height: normal; " />
            INPUT_MISC<br style="word-wrap: break-word; line-height: normal; " />
            LEDS_CLASS<br style="word-wrap: break-word; line-height: normal; " />
            LEDS_GPIO<br style="word-wrap: break-word; line-height: normal; " />
            LOCK_KERNEL<br style="word-wrap: break-word; line-height: normal; " />
            LkOGGER<br style="word-wrap: break-word; line-height: normal; " />
            LOW_MEMORY_KILLER<br style="word-wrap: break-word; line-height: normal; " />
            MISC_DEVICES<br style="word-wrap: break-word; line-height: normal; " />
            NEW_LEDS<br style="word-wrap: break-word; line-height: normal; " />
            NO_HZ<br style="word-wrap: break-word; line-height: normal; " />
            POWER_SUPPLY<br style="word-wrap: break-word; line-height: normal; " />
            PREEMPT<br style="word-wrap: break-word; line-height: normal; " />
            RAMFS<br style="word-wrap: break-word; line-height: normal; " />
            RTC_CLASS<br style="word-wrap: break-word; line-height: normal; " />
            RTC_LIB<br style="word-wrap: break-word; line-height: normal; " />
            SWITCH<br style="word-wrap: break-word; line-height: normal; " />
            SWITCH_GPIO<br style="word-wrap: break-word; line-height: normal; " />
            TMPFS<br style="word-wrap: break-word; line-height: normal; " />
            UID_STAT<br style="word-wrap: break-word; line-height: normal; " />
            UID16<br style="word-wrap: break-word; line-height: normal; " />
            USB_FUNCTION<br style="word-wrap: break-word; line-height: normal; " />
            USB_FUNCTION_ADB<br style="word-wrap: break-word; line-height: normal; " />
            USER_WAKELOCK<br style="word-wrap: break-word; line-height: normal; " />
            VIDEO_OUTPUT_CONTROL<br style="word-wrap: break-word; line-height: normal; " />
            WAKELOCK<br style="word-wrap: break-word; line-height: normal; " />
            YAFFS_AUTO_YAFFS2<br style="word-wrap: break-word; line-height: normal; " />
            YAFFS_FS<br style="word-wrap: break-word; line-height: normal; " />
            YAFFS_YAFFS1<br style="word-wrap: break-word; line-height: normal; " />
            YAFFS_YAFFS2</font></blockquote><br style="word-wrap: break-word; line-height: normal; " />
            但是Android推荐不要支持下面两个功能：<br style="word-wrap: break-word; line-height: normal; " />
            </font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="1" style="word-wrap: break-word; line-height: normal; "><font style="word-wrap: break-word; line-height: normal; font-size: 9pt; ">CONFIG_YAFFS_DISABLE_LAZY_LOAD</font></font></font><font size="1" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            </font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="1" style="word-wrap: break-word; line-height: normal; "><font style="word-wrap: break-word; line-height: normal; font-size: 9pt; ">DNOTIFY</font></font></font><font size="2" style="word-wrap: break-word; line-height: normal; "><br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            </font><font face="&amp;quot; " style="word-wrap: break-word; line-height: normal; "><font size="2" style="word-wrap: break-word; line-height: normal; "><font style="word-wrap: break-word; line-height: normal; font-size: 9pt; ">配置好后，就可以用Toolchain来编译内核了。编译内核比较简单，以Emulator的kernel为例：<br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - git clone git://android.kernel.org/kernel/common.git kernel-emulator</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - cd kernel-emulator</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - export ARCH=arm</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - export CROSS_COMPILE=arm-eabi-</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - export PATH=&lt;CROSS_COMPIL_TOOLCHAIN_PATH_DIR&gt;:$PATH</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - make goldfish_defconfig</em><br style="word-wrap: break-word; line-height: normal; " />
            <em style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp; - make</em><br style="word-wrap: break-word; line-height: normal; " />
            </font></font></font></td>
        </tr>
    </tbody>
</table>
</div>
<div id="post_rate_div_975" style="word-wrap: break-word; line-height: normal; "></div>
<div class="useraction" style="word-wrap: break-word; line-height: normal; height: 50px; width: 165px; clear: both; display: block; margin-top: 20px; margin-right: auto; margin-bottom: 20px; margin-left: auto; "></div>
</span>
<img src ="http://www.blogjava.net/MEYE/aggbug/335851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:45 <a href="http://www.blogjava.net/MEYE/articles/335851.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android 调试桥(adb)是多种用途的工具</title><link>http://www.blogjava.net/MEYE/articles/335849.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:44:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335849.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335849.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335849.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335849.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Android 调试桥(adb)是多种用途的工具                        Android 调试桥http://www.androidin.com/docs/reference/adb.html#sqlite&nbsp;                        Android 调试桥(adb)是多种用途的工具，该工具可以帮助你你管理设备或模...&nbsp;&nbsp;<a href='http://www.blogjava.net/MEYE/articles/335849.html'>阅读全文</a><img src ="http://www.blogjava.net/MEYE/aggbug/335849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:44 <a href="http://www.blogjava.net/MEYE/articles/335849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Android实用小工具</title><link>http://www.blogjava.net/MEYE/articles/335850.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:44:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335850.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335850.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335850.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335850.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335850.html</trackback:ping><description><![CDATA[<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="border-collapse: collapse; color: #2b3714; font-family: Verdana, Helvetica, Arial, sans-serif; line-height: 19px; font-size: 14.4px; ">
<div id="threadtitle" style="word-wrap: break-word; line-height: normal; margin-bottom: 8px; ">
<h1 style="word-wrap: break-word; margin-top: 8px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.17em; line-height: normal; ">Android实用小工具</h1>
</div>
<div class="t_msgfontfix" style="word-wrap: break-word; line-height: normal; min-height: 100px; ">
<table cellspacing="0" cellpadding="0" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 720px; table-layout: fixed; margin-left: 1px; ">
    <tbody style="word-wrap: break-word; line-height: normal; ">
        <tr style="word-wrap: break-word; line-height: normal; ">
            <td class="t_msgfont" id="postmessage_845" style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; ">有时候修改了<u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">android</font></strong></u><u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">系统</font></strong></u>的某个<u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">文件</font></strong></u>，这个文件所在的模块和别的模块没有依赖关系，这个时候又不想让整个系统重新<u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">编译</font></strong></u>，可以采取如下方式。<br style="word-wrap: break-word; line-height: normal; " />
            . build/envsetup.sh<br style="word-wrap: break-word; line-height: normal; " />
            进入到某个模块的源<u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">代码</font></strong></u>根<u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">目录</font></strong></u>下,编译这个模块<br style="word-wrap: break-word; line-height: normal; " />
            mm showcommands<br style="word-wrap: break-word; line-height: normal; " />
            然后退回到整个android的原代码根目录下<br style="word-wrap: break-word; line-height: normal; " />
            cd -<br style="word-wrap: break-word; line-height: normal; " />
            因为mm只编译不重新生成system.img，所以需要手动重新生成system.img<br style="word-wrap: break-word; line-height: normal; " />
            ./out/host/linux-x86/bin/mkyaffs2image -f out/target/product/generic/system out/target/product/generic/system.img<br style="word-wrap: break-word; line-height: normal; " />
            在<u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">使用</font></strong></u><u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">脚本</font></strong></u>启动模拟器，脚本示例如下：<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <table cellspacing="0" class="t_table" bgcolor="#f1f1f1" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 683px; table-layout: fixed; margin-left: 1px; ">
                <tbody style="word-wrap: break-word; line-height: normal; ">
                    <tr style="word-wrap: break-word; line-height: normal; ">
                        <td style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; padding-top: 4px; padding-right: 4px; padding-bottom: 4px; padding-left: 4px; overflow-x: hidden; overflow-y: hidden; "><font color="#000" style="word-wrap: break-word; line-height: normal; "><font face="新宋体 " style="word-wrap: break-word; line-height: normal; ">ANDROID_HOME<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">=</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">.</font><br style="word-wrap: break-word; line-height: normal; " />
                        ANDROID_EMULATOR<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">=</font><font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_HOME</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>out<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>host<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font><u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">linux</font></strong></u><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>x86<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>bin<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>emulator<br style="word-wrap: break-word; line-height: normal; " />
                        ANDROID_SYSTEM<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">=</font><font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_HOME</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>out<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>target<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>product<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>generic<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font><br style="word-wrap: break-word; line-height: normal; " />
                        ANDROID_KERNEL<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">=</font><font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_HOME</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>prebuilt<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>android<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font><u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">arm</font></strong></u><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>kernel<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>kernel<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>qemu<br style="word-wrap: break-word; line-height: normal; " />
                        ANDROID_SKIN<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">=</font><font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_HOME</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>development<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>emulator<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>skins<br style="word-wrap: break-word; line-height: normal; " />
                        <font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_EMULATOR</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>kernel<font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_KERNEL</font>\<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>sysdir<font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_SYSTEM</font>\<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>show<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>kernel \<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font><u style="word-wrap: break-word; line-height: normal; "><strong style="word-wrap: break-word; text-align: left; font-style: normal; line-height: normal; font-weight: bold; "><font color="#800080" style="word-wrap: break-word; line-height: normal; ">shell</font></strong></u>&nbsp;\<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>data<font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_SYSTEMuserdata</font><font color="#00cc" style="word-wrap: break-word; line-height: normal; ">.</font>img \<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>partition<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>size 128 \<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>skindir<font color="#00ff" style="word-wrap: break-word; line-height: normal; ">$</font><font color="#08080" style="word-wrap: break-word; line-height: normal; ">ANDROID_SKIN</font>\<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>skin WQVGA432 \<br style="word-wrap: break-word; line-height: normal; " />
                        &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">-</font>sdcard<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>work<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">/</font>sdcard<font color="#00cc" style="word-wrap: break-word; line-height: normal; ">.</font>img \</font></font><br style="word-wrap: break-word; line-height: normal; " />
                        <font color="#000" style="word-wrap: break-word; line-height: normal; "><font face="新宋体 " style="word-wrap: break-word; line-height: normal; ">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-wipe-data</font><br style="word-wrap: break-word; line-height: normal; " />
                        </font></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<meta http-equiv="content-type" content="text/html; charset=utf-8" /><span  style="font-size: 14.4px; line-height: 19px; ">
<div id="threadtitle" style="word-wrap: break-word; line-height: normal; margin-bottom: 8px; ">
<h1 style="word-wrap: break-word; margin-top: 8px; margin-right: 0px; margin-bottom: 8px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 1.17em; line-height: normal; ">使用eclipse开发android源码</h1>
</div>
<div class="t_msgfontfix" style="word-wrap: break-word; line-height: normal; min-height: 100px; ">
<table cellspacing="0" cellpadding="0" style="word-wrap: break-word; empty-cells: show; border-collapse: collapse; line-height: normal; width: 720px; table-layout: fixed; margin-left: 1px; ">
    <tbody style="word-wrap: break-word; line-height: normal; ">
        <tr style="word-wrap: break-word; line-height: normal; ">
            <td class="t_msgfont" id="postmessage_858" style="word-wrap: break-word; color: #2b3714; font: normal normal normal 12px/1.6em Verdana, Helvetica, Arial, sans-serif; line-height: 1.6em; font-size: 14px; "><font size="3" style="word-wrap: break-word; line-height: normal; ">1、android的文件系统结构是怎样的，我们安装的程序放在那里？<br style="word-wrap: break-word; line-height: normal; " />
            编译android源码之后，在out/target/product/generic一些文件：<br style="word-wrap: break-word; line-height: normal; " />
            ramdisk.img、system.img、userdata.img、 system、 data、root<br style="word-wrap: break-word; line-height: normal; " />
            其中， system.img是由 system打包压缩得到的， userdata.img是由 data打包压缩得到的。<br style="word-wrap: break-word; line-height: normal; " />
            ramdisk.img是模拟器的文件系统，把ramdisk.img解压出来可知道，ramdisk.img里的文件跟root文件夹的文件基本一样。<br style="word-wrap: break-word; line-height: normal; " />
            模拟器装载ramdisk.img并解压到内存，接着分别把system.img和userdata.img挂载到 ramdisk下的system和data目录。我们编译出来的应用程序就是放在system/app下的。用户安装的程序则是放在data/app下。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            2、android SDK和android源码能为我们提供什么工具？<br style="word-wrap: break-word; line-height: normal; " />
            android SDK提供有很多工具，如adb,ddms,emulator,aapt等，并提供kernel-qemu、ramdisk.img、 system.img、userdata.img。因此，只要有android SDK，我们就可以在模拟器上把android跑起来。<br style="word-wrap: break-word; line-height: normal; " />
            android源码可以编译出android SDK、adb等工具、android文件系统，以及ADT插件，也就是说，我们可以从android源码编译出所有android相关的东西。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            3、 把android源码&#8221;make&#8221;之后会生成许多工具和android文件系统（system.img等），我们又可以使用&#8220;make sdk&#8221;来生成android SDK，android SDK也包括有工具和android文件系统（system.img等），而原来安装的时候我们也安装了android SDK，那么我们在开发时应该使用那些工具和android文件系统呢？<br style="word-wrap: break-word; line-height: normal; " />
            这个问题在后面回答。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            4、官方推荐我们使用 eclipse+adt进入开发应用程序，我们的HelloActivity程序也是这里开发的。当我们把android源码/packages /apps/下的工程导入eclipse时，一般都会出现找不到包的错误。那么我们怎样修改、编译、调试android源码呢？Google又是用什么工 具来开发android的？<br style="word-wrap: break-word; line-height: normal; " />
            这个问题在后面回答。<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            下面系统地讲述android开发环境建立以及开发工具的使用<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            一、android SDK和eclipse的安装以及android开发环境建立<br style="word-wrap: break-word; line-height: normal; " />
            android工具链比较完善，需要外部的工具比较少。具体的安装过程可参考官方文档或&lt;&lt;android模拟器在ubuntu8.10的安装&gt;&gt;和&lt;&lt;android源码的编译&gt;&gt;。<br style="word-wrap: break-word; line-height: normal; " />
            这 里需要注意的是，用&#8221;make&#8221;来编译android源码时，我们可以使用JDK5或JDK6；用&#8221;make sdk&#8221;来编译时，会用到javadoc来生成文档，javadoc就必须使用JDK5的javadoc，否则编译是通不过的。因此，我们可以把JDK5 和JDK6都装上，然后只把javadoc和javadoc.1.gz指向JDK5相应的工具，其它工具还是用JDK6的。当然，我们可以只安装JDK5 或只用JDK5的工具。具体操作可以参考&lt;&lt;android源码的编译&gt;&gt;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            二、使用eclipse来开发android源码<br style="word-wrap: break-word; line-height: normal; " />
            这里主要参考官方文档<br style="word-wrap: break-word; line-height: normal; " />
            https://sites.google.com/a/android.com/opensource/using-eclipse<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            下面，从官方文档总结出具体怎样用eclipse来开发android源码<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            1、建立基本的android开发环境<br style="word-wrap: break-word; line-height: normal; " />
            请参考官方文档或&lt;&lt;android模拟器在ubuntu8.10的安装&gt;&gt;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            2、编译android源码<br style="word-wrap: break-word; line-height: normal; " />
            android源码根目录下通过make进行编译，请注意一些配置，具体可参考&lt;&lt;android源码的编译&gt;&gt;<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            3、把eclipse工程配置文件复制到android源码根目录下<br style="word-wrap: break-word; line-height: normal; " />
            cp development/ide/eclipse/.classpath ./<br style="word-wrap: break-word; line-height: normal; " />
            chmod u+w .classpath&nbsp;&nbsp;# Make the copy writable<br style="word-wrap: break-word; line-height: normal; " />
            4、修改eclipse程序的配置<br style="word-wrap: break-word; line-height: normal; " />
            1）、增大eclipse内存设置<br style="word-wrap: break-word; line-height: normal; " />
            把eclipse.ini（在eclipse软件的安装目录下）的3个值改为下面的值：<br style="word-wrap: break-word; line-height: normal; " />
            -Xms128m<br style="word-wrap: break-word; line-height: normal; " />
            -Xmx512m<br style="word-wrap: break-word; line-height: normal; " />
            -XX:MaxPermSize=256m<br style="word-wrap: break-word; line-height: normal; " />
            2）、把android-formatting.xml和android.importorder导入eclipse（可选）<br style="word-wrap: break-word; line-height: normal; " />
            android-formatting.xml、.classpath和android.importorder都放在development/ide/eclipse/下<br style="word-wrap: break-word; line-height: normal; " />
            android-formatting.xml用来配置eclipse编辑器的代码风格；android.importorder用来配置eclipse的import的顺序和结构。<br style="word-wrap: break-word; line-height: normal; " />
            在window-&gt;preferences-&gt;java-&gt;Code style-&gt;Formatter中导入android-formatting.xml<br style="word-wrap: break-word; line-height: normal; " />
            在window-&gt;preferences-&gt;java-&gt;Code style-&gt;Organize Imports中导入android.importorder<br style="word-wrap: break-word; line-height: normal; " />
            3）、安装anyedit插件（可选）<br style="word-wrap: break-word; line-height: normal; " />
            在<a href="http://andrei.gmxhome.de/anyedit/" target="_blank" style="word-wrap: break-word; text-decoration: none; color: #8bd00b; line-height: normal; ">http://andrei.gmxhome.de/anyedit/</a>下载并导入eclipse中<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            5、把android源码作为一个工程导入eclipse<br style="word-wrap: break-word; line-height: normal; " />
            导入前先检查.classpath里的文件在android源码中是否有相应的文件（文件夹），否则也会破坏android源码（一般是多添加文件/文件夹），.classpath里多余的路径可删除<br style="word-wrap: break-word; line-height: normal; " />
            新建Java Project（不是android project，否则会破坏android源码），选择从已存在的工程导入，工程名任意，完成。<br style="word-wrap: break-word; line-height: normal; " />
            导入时，eclipse要build工程，比较慢。导完后，一般都没有错误。<br style="word-wrap: break-word; line-height: normal; " />
            这里也就回答了第4个问题<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            6、eclipse上调试android里的程序。<br style="word-wrap: break-word; line-height: normal; " />
            为了不让其它版本的android工具和android文件系统影响下面的编译和调试，需要从环境变量中去除android工具和android文件系统的路径：<br style="word-wrap: break-word; line-height: normal; " />
            vim ~/.bashrc<br style="word-wrap: break-word; line-height: normal; " />
            看看有没有在PATH变量中加入android工具和android文件系统的路径，如果加有，则注释它。通过下面的方法，我们是不需要在.bashrc中添加android工具和android文件系统的路径的<br style="word-wrap: break-word; line-height: normal; " />
            执行：<br style="word-wrap: break-word; line-height: normal; " />
            cd android源码目录<br style="word-wrap: break-word; line-height: normal; " />
            . build/envsetup.sh #设了环境变量之后，会多出mmm等命令，可以通过输入help来查看<br style="word-wrap: break-word; line-height: normal; " />
            lunch 1&nbsp; &nbsp;# 把emulator等工具和ramdisk.img等文件的路径对应起来，就可以直接调用emulator等工具，也解决了第3个问题<br style="word-wrap: break-word; line-height: normal; " />
            emulator &amp;&nbsp;<br style="word-wrap: break-word; line-height: normal; " />
            ddms &amp;<br style="word-wrap: break-word; line-height: normal; " />
            注意，先启动ddms，再启动eclipse，这样eclipse中就不会说端口冲突<br style="word-wrap: break-word; line-height: normal; " />
            然后在eclipse中配置调试类型和端口：<br style="word-wrap: break-word; line-height: normal; " />
            在Run-&gt;Debug Configurations-&gt;Remote java application上双击，然后，&#8221;Host:&#8221;设为localhost，&#8221;Port:&#8221;设为8800，&#8221;Connection Type&#8221;为Standard(Socket Attach)<br style="word-wrap: break-word; line-height: normal; " />
            然后&#8220;Apply&#8221;<br style="word-wrap: break-word; line-height: normal; " />
            注意，上面设置的端口要与DDMS中设置的端口一致，ADT插件使用了8700端口，因此上面设置的端口是8800。如果出现连不到VM的错误时，请注意，要先在DDMS中选中某一进程（对应某一应用程序），才能在eclipse执行 Debug。<br style="word-wrap: break-word; line-height: normal; " />
            在eclipse调试时，可以设断点、单步调试。估计google团队也是这样开发、调试android应用程序的<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            7、编译android源码<br style="word-wrap: break-word; line-height: normal; " />
            执行：<br style="word-wrap: break-word; line-height: normal; " />
            cd android源码目录<br style="word-wrap: break-word; line-height: normal; " />
            . build/envsetup.sh<br style="word-wrap: break-word; line-height: normal; " />
            那 么就会多出mm/mmm等命令，mm/mmm用来编译模块（包括C、C＋＋、JAVA程序）。我们也可以直接在 android源码根目录下执行&#8220;make 模块名&#8221;来编译模块（模块名可以在.mk文件中找到）。模块编译后会在out/target/product/generic/system/app下生 成对应的.apk包。但是，用mm/mmm来编译生成的.apk并不会打包到system.img中，需要我们手动通过make snod把 system文件夹打包为system.img，不过这就得重新运行模拟器了，这也是很麻烦了。对于我们开发者来说，我们可以这样做：<br style="word-wrap: break-word; line-height: normal; " />
            1）把需要修改、调试的模块（比如AlarmClock.apk）从/system/app下移除，然后make snod，这样system.img就没有AlarmClock.apk了。<br style="word-wrap: break-word; line-height: normal; " />
            2）运行模拟器，就看不到AlarmClock了<br style="word-wrap: break-word; line-height: normal; " />
            3）修改AlarmClock源码并用mm/mmm来编译，在/system/app下生成AlarmClock.apk<br style="word-wrap: break-word; line-height: normal; " />
            4）通过adb把AlarmClock.apk安装到android文件系统中，安装方法有两个：<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; A、通过adb install xxx/AlarmClock.apk<br style="word-wrap: break-word; line-height: normal; " />
            &nbsp; &nbsp; B、通过adb push xxx/AlarmClock.apk /data/app<br style="word-wrap: break-word; line-height: normal; " />
            两 种方法都可以把 AlarmClock安装到/data/app下，android会自动把它显示在主菜单中（只要AlarmClock.apk中有一Activity包 含android.intent.category.LAUNCHER属性），不过A方法在/data/app生成 com.android.alarmclock.apk，B方法则是 AlarmClock.apk。用A方法时，如果原来已经安装了 AlarmClock，你还得先adb uninstall 它，而B方法则不用。推荐使用B方法。同样，卸载可以通过adb uninstall或adb shell rm xxx/xxx.apk来，也推荐用删除的方法来卸载<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            8、如何开发自己的工程<br style="word-wrap: break-word; line-height: normal; " />
            前面主要是讲如何在eclipse上开发android原有的工程。对于自己的工程，我们可以这样做：<br style="word-wrap: break-word; line-height: normal; " />
            1）新建一个android工程。<br style="word-wrap: break-word; line-height: normal; " />
            建android工程的好处就是可以充分使用ADT的功能。<br style="word-wrap: break-word; line-height: normal; " />
            2）导入需要的包<br style="word-wrap: break-word; line-height: normal; " />
            3）编译、运行、调试<br style="word-wrap: break-word; line-height: normal; " />
            4）加入到android源码相应的目录下，应用程序一般放在packages/apps下<br style="word-wrap: break-word; line-height: normal; " />
            我们观察packages/apps原有的工程就会发现，它们的代码是很&#8220;干净&#8221;的，没有ADT自动生成的assets、bin等文件夹和R.java，当然也没有.classpath和.project<br style="word-wrap: break-word; line-height: normal; " />
            5）编写Makefile文件xxx.mk<br style="word-wrap: break-word; line-height: normal; " />
            用android源码提供的专用Makefile文件xxx.mk，它的格式比较简单<br style="word-wrap: break-word; line-height: normal; " />
            6）把刚加入的工程添加到eclipse的android工程中<br style="word-wrap: break-word; line-height: normal; " />
            可以在eclipse中添加，也可以在.classpath中直接加入相应路径。如在.classpath中添加：<br style="word-wrap: break-word; line-height: normal; " />
            &lt;classpathentry kind="src" path="packages/apps/HelloWorld/src"/&gt;<br style="word-wrap: break-word; line-height: normal; " />
            R.java 中编译时自动生成的，其实所有工程用到&#8220;资源&#8221;的，都会用到R.java，这些R.java是放在out/target/common/R下。我们在源码 根目录下make全部代码时，才会对每个模块生成R.java；在make时，已经编译过并生成有.apk文件的模块是不会被编译的。因此，如果新加入的 工程已经(用mm/mmm)编译过的话，我们先对该工程的&#8220;资源&#8221;改动一下（必须是改动&#8220;资源&#8221;，因为R.java是由&#8220;资源&#8221;生成的），再make，就 在会out/target/common/R对应的包路径下看到你的工程的R.java。刷新在eclipse的out/target/common/R 子工程，再在你用到R类的地方加入它的包，如<br style="word-wrap: break-word; line-height: normal; " />
            import com.android.example.test.inside.helloworld.R;这样就不会出现找不到R定义的错误。<br style="word-wrap: break-word; line-height: normal; " />
            其实，这个错误对我们是没有任何影响的，因为我们是在shell中编译。<br style="word-wrap: break-word; line-height: normal; " />
            7）在android源码目录下编译刚加入的工程<br style="word-wrap: break-word; line-height: normal; " />
            可以用mm/mmm或make 模块名<br style="word-wrap: break-word; line-height: normal; " />
            8）用版本控件工具(svn或git或其它)把该工程上传到服务器<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            从官方文档和实践可以总结出几点：<br style="word-wrap: break-word; line-height: normal; " />
            1、可以使用eclipse来编辑JAVA程序、检查错误（主要是类库包含和语法方面），但是不能在eclipse上编译运行android源码，还是得在shell中make(或mm或mmm)<br style="word-wrap: break-word; line-height: normal; " />
            2、android源码文件夹里提供有一些eclipse配置文件，<br style="word-wrap: break-word; line-height: normal; " />
            .claapath：eclipse工程的配置文件，方便我们直接把android源码相应的文件和JAVA包导入工程<br style="word-wrap: break-word; line-height: normal; " />
            android-formatting.xml和android.importorder：这个很重要，主要是用来规范我们的编码风格，更容易使我们的代码风格一致<br style="word-wrap: break-word; line-height: normal; " />
            3、把android源码作为一个工程导入eclipse时，必须注意两点<br style="word-wrap: break-word; line-height: normal; " />
            1)、新建的工程必须是java project，不能是android project，否则会破坏android源码（一般是多添加文件/文件夹）<br style="word-wrap: break-word; line-height: normal; " />
            2)、导入前最好检查.classpath里的文件在android源码中是否有相应的文件（文件夹），否则也会破坏android源码（一般是多添加文件/文件夹）<br style="word-wrap: break-word; line-height: normal; " />
            <br style="word-wrap: break-word; line-height: normal; " />
            总的来说：<br style="word-wrap: break-word; line-height: normal; " />
            1、用eclipse来编辑代码、检查错误<br style="word-wrap: break-word; line-height: normal; " />
            2、不在eclipse上编译、运行android源码程序，只能在命令行通过make(或mm或mmm)编译android源码<br style="word-wrap: break-word; line-height: normal; " />
            3、可以在eclipse上调试android源码程序（原理：eclipse通过ddms服务器在emulator上进行调试），并可以单步调试、断点调试。<br style="word-wrap: break-word; line-height: normal; " />
            4、需要调试的程序把它从/system/app/移除，安装到data/app下，这样更方便<br style="word-wrap: break-word; line-height: normal; " />
            5、安装、卸载程序通过adb push 和adb shell rm更方便</font></td>
        </tr>
    </tbody>
</table>
</div>
</span></div>
</span>
<img src ="http://www.blogjava.net/MEYE/aggbug/335850.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:44 <a href="http://www.blogjava.net/MEYE/articles/335850.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>OPhone 3D开发之解析渲染MS3D模型</title><link>http://www.blogjava.net/MEYE/articles/335847.html</link><dc:creator>MEYE</dc:creator><author>MEYE</author><pubDate>Fri, 22 Oct 2010 01:35:00 GMT</pubDate><guid>http://www.blogjava.net/MEYE/articles/335847.html</guid><wfw:comment>http://www.blogjava.net/MEYE/comments/335847.html</wfw:comment><comments>http://www.blogjava.net/MEYE/articles/335847.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/MEYE/comments/commentRss/335847.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MEYE/services/trackbacks/335847.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: OPhone 3D开发之解析渲染MS3D模型http://www.arm9.org.ru/viewthread.php?tid=286&amp;extra=page%3D1OPhone 3D开发之解析渲染MS3D模型                        OPhone平台中，3D模块已经成为一项标准配置，而且随着硬件成本的降低，搭配硬件加速图形芯片的...&nbsp;&nbsp;<a href='http://www.blogjava.net/MEYE/articles/335847.html'>阅读全文</a><img src ="http://www.blogjava.net/MEYE/aggbug/335847.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MEYE/" target="_blank">MEYE</a> 2010-10-22 09:35 <a href="http://www.blogjava.net/MEYE/articles/335847.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>