科普向】Nexus 4 必读与常见问题解答【Android入门读

22 篇文章 0 订阅
17 篇文章 0 订阅
本帖最后由 諫山黄泉 于 2013-3-16 14:22 编辑

/**
*
[渣翻] xda: http://forum.xda-developers.com/showthread.php?t=2010338
*
*
转载请注明出处: http://bbs.gfan.com/android-5576468-1-1.html
*
*
略长, 懒得翻请自行Crtl+F
* 不定时更新...
*
*
科普向教程第二部分: http://bbs.gfan.com/android-5795118-1-1.html
*/

FAQ:

1, 什么是android?

Android(读音:['ændrɔid],中文俗称安卓)是一个以Linux为基础的半开源操作系统,主要用于移动设备,由Google成立的Open Handset Alliance(OHA,开放手持设备联盟)持续领导与开发中。
wiki: http://zh.wikipedia.org/wiki/Android

2, 什么是SDK, 我必须安装吗?
SDK = "software development kit" , 除非你是开发者, 不然这东西完全是浪费空间, 你所需要的只是SDK中提供的有关FASTBOOT与ADB的几个文件和驱动而已.

3, 什么是驱动, 我为什么要安装呢...?
知道什么是驱动就知道为什么了, wiki: http://zh.wikipedia.org/wiki/%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F

4, 我从哪儿能搞到驱动?
这个: http://forum.xda-developers.com/showthread.php?t=1992345
或者这个: http://forum.xda-developers.com/showthread.php?t=1996051
作者推荐第二个

5, 为什么要安装两次驱动?
android和PC有两种主要的通信方式: FASTBOOT和ADB, 两种接入方式的驱动是不同的, 所以需要安装两次. 以FASTBOOT方式( bootloader) 启动手机, 链接电脑后安装一次驱动; 而ADB模式需要android内核的支持, 所以正常启动手机( 或者某些自制recovery, 例如CWM) , 打开USB调试( USB debugging) , 然后连接电脑, 安装ADB驱动.

6, 怎么进入bootloader (FASTBOOT模式) ?
关掉手机, 摁住音量-键, 然后再摁住电源键, 直到开机.

7, 什么是命令行?
Windows下的命令行( Linux/MacOS下的终端), 是在图形用户界面得到普及之前使用最为广泛的用户界面,它通常不支持鼠标,用户通过键盘输入指令,计算机接收到指令后,予以执行。
wiki: http://zh.wikipedia.org/wiki/%E5%91%BD%E4%BB%A4%E8%A1%8C
TIPS: 在文件夹里, 摁住SHIFT键, 然后右键, 会看到: 在此处打开命令行窗口的选项

8, 什么是bootloader?
Bootloader(引导加载程序)是系统加电后运行的第一段代码, 一般运行的时间非常短, 但是对于嵌入式系统来说, 这段代码非常重要. 在我们的台式电脑当中, 引导加载程序由BIOS(固件程序)和位于硬盘MBR中的操作系统引导加载程序(比如NTLOADER,GRUB和LILO)一起组成.
在一般的典型系统中,整个系统的加载启动任务全由bootloader来完成. 在ARM中,系统上电或复位时通常从地址0x00000000处开始执行,而在这个位置,通常安排的就是系统的bootloader。通过这小段程序可以初始化硬件设备、建立内存空间映射图,从而将系统的软硬件环境设置到一个合适的状态!以为最终调用操作系统内核准备好正确的环境.


9, bootloader 有锁/解锁( locked/unlocked)?
你从厂家得到的设备大多是处于有锁状态. 出于安全考虑, 锁定的bootloader只能刷写拥有官方签名的镜像, 这意味着你很难改变或者修改操作系统. 解锁bootloader并不会增加设备的功能, 但是解锁后你可以随心所欲的刷写自制镜像与程序, 方便折腾...

10, 什么是root?
root本质上来说就是你获得了对系统文件与分区的root权限, 类似于Windows的管理员权限. root跟bootloader没半毛钱关系, root的是系统本身.

11, 怎么root?
root的实现过程是: 向系统目录下写入 一个叫做 su的可执行文件(功能为获得root权限), 并安装一个控制该权限开启与关闭的APP.

( PS: 每个命令都有对应的二进制可执行文件, 执行命令, 就是执行相应的二进制文件的过程, 而%PATH%保存的就是这些执行文件所在的目录...比方说常见的: cd, ls, cp, ifconfig 这几个命令的执行文件保存在 /system/bin下; su, 和busybox的命令, 习惯上, 安装在 /system/xbin 下...)

N4可用的是Chainfire的SuperSU: http://forum.xda-developers.com/showthread.php?t=1538053

非常详细的, 刷工厂镜像, root, 解锁教程: http://bbs.gfan.com/android-5795118-1-1.html

12, 解锁bootloader和root是一个意思吗?
不是, 解锁bootloader的作用是方便刷写; root的作用是获得最高权限, 可以随意操作系统文件.

13, 解锁bootloader之后必须root吗?
No.

14, 解锁bootloader后必须刷自制ROM吗?
No.

15, root之后才能刷ROM吗?
No.

16, 什么是ROM?
这里指android刷机包.

17, 不同版本android的区别是什么? 4.2 和 JOP40C有什么区别?
看这个: http://source.android.com/source/build-numbers.html

18, 原生镜像和自制镜像的区别是什么?
由Google开发编译的镜像为原生镜像( stock ROM), 其他的都是自制镜像.

19, 总听到AOSP这个词, 啥意思?
AOSP = Android Open Source Project, 他们负责android的源码编写与修改, 详情点击这里: http://source.android.com/

20, 什么是FASTBOOT?
三个意思 : 1, 用来设备和PC间通信的一个命令行工具 2, fastboot.exe 3, 设备的一种启动模式.
FASTBOOT是一个特殊的工程模式, 通过fastboot界面, 连接电脑后, 我们可以在电脑端通过特殊的指令来操作手机.
使用FASTBOOT命令, 需要PC上要安装有FASTBOOT驱动, 当前目录下必须存在fastboot.exe, 手机需要以FASTBOOT模式启动, 然后连接电脑.

22, FASTBOOT命令
在fastboot.exe所在的文件夹下打开命令行, 输入fastboot, 可以看到fastboot的命令格式.

  1. fastboot
  2. usage: fastboot [ <option> ] <command>

  3. commands:
  4.   update <filename>                        reflash device from update.zip
  5.   flashall                                 flash boot + recovery + system
  6.   flash <partition> [ <filename> ]         write a file to a flash partition
  7.   erase <partition>                        erase a flash partition
  8.   format <partition>                       format a flash partition
  9.   getvar <variable>                        display a bootloader variable
  10.   boot <kernel> [ <ramdisk> ]              download and boot kernel
  11.   flash:raw boot <kernel> [ <ramdisk> ]    create bootimage and flash it
  12.   devices                                  list all connected devices
  13.   continue                                 continue with autoboot
  14.   reboot                                   reboot device normally
  15.   reboot-bootloader                        reboot device into bootloader
  16.   help                                     show this help message

  17. options:
  18.   -w                                       erase userdata and cache
  19.   -s <serial number>                       specify device serial number
  20.   -p <product>                             specify product name
  21.   -c <cmdline>                             override kernel commandline
  22.   -i <vendor id>                           specify a custom USB vendor id
  23.   -b <base_addr>                           specify a custom kernel base address
  24.   -n <page size>                           specify the nand page size. default: 2048
复制代码
除去上面那些, 还有一个oem命令.

这些命令, 在FASTBOOT模式下, 不管有没有解锁bootloader都可以使用:

oem: 用来解锁或者锁定bootloader, 例如: fastboot oem unlock 是解锁bootloader的命令, fastboot oem lock, 是重新锁定bootloader的命令.
devices: 这命令用来检查设备是否已经正确的以FASTBOOT模式连接电脑, 例如: fastboot devices
reboot: 重启命令, 例如: fastboot reboot
reboot-bootloader: 这命令将会让你的设备重启到bootloader模式, 例如: fastboot reboot-bootloader

下面这些命令只有在解锁bootloader后才有效:

flash: 用来刷写镜像, 不能用来刷写来路不明的文件或者zip, 例如, 刷写系统区块的命令: fastboot flash system system.img
boot: 用来让核心从设备储存外的某镜像启动, 比方说你文件夹里的CMW RECOVERY镜像叫做: recovery.img, 输入: fastboot boot recovery.img, 便可让设备由recovery.img启动, 而不用将CWM刷写到设备flash之后启动.
erase: 用来擦除某些指定的区块, 例如: fastboot erase cache

以上就是会常常用到的fastboot命令啦.

23, 什么是ADB?
ADB = Android Debug Bridge, 用来设备和PC间通信的另一个工具. 使用ADB命令, 需要手机要启动到recovery模式, 或者正常启动. 一般来说, 正常启动的话, 需要打开USB调试. 当前目录下必须存在ADB相关的几个文件, PC上也必须安装有ADB驱动.

24, ADB命令.

在adb.exe所在的目录下打开命令行, 输入adb可以查看adb的命令格式.

  1. Android Debug Bridge version 1.0.29

  2. -d                            - directs command to the only connected USB device
  3.                                  returns an error if more than one USB device is present.
  4. -e                            - directs command to the only running emulator.
  5.                                  returns an error if more than one emulator is running.
  6. -s <serial number>            - directs command to the USB device or emulator with
  7.                                  the given serial number. Overrides ANDROID_SERIAL
  8.                                  environment variable.
  9. -p <product name or path>     - simple product name like 'sooner', or
  10.                                  a relative/absolute path to a product
  11.                                  out directory like 'out/target/product/sooner'.
  12.                                  If -p is not specified, the ANDROID_PRODUCT_OUT
  13.                                  environment variable is used, which must
  14.                                  be an absolute path.
  15. devices                       - list all connected devices
  16. connect <host>[:<port>]       - connect to a device via TCP/IP
  17.                                  Port 5555 is used by default if no port number is specified.
  18. disconnect [<host>[:<port>]]  - disconnect from a TCP/IP device.
  19.                                  Port 5555 is used by default if no port number is specified.
  20.                                  Using this command with no additional arguments
  21.                                  will disconnect from all connected TCP/IP devices.

  22. device commands:
  23.   adb push <local> <remote>    - copy file/dir to device
  24.   adb pull <remote> [<local>]  - copy file/dir from device
  25.   adb sync [ <directory> ]     - copy host->device only if changed
  26.                                  (-l means list but don't copy)
  27.                                  (see 'adb help all')
  28.   adb shell                    - run remote shell interactively
  29.   adb shell <command>          - run remote shell command
  30.   adb emu <command>            - run emulator console command
  31.   adb logcat [ <filter-spec> ] - View device log
  32.   adb forward <local> <remote> - forward socket connections
  33.                                  forward specs are one of:
  34.                                    tcp:<port>
  35.                                    localabstract:<unix domain socket name>
  36.                                    localreserved:<unix domain socket name>
  37.                                    localfilesystem:<unix domain socket name>
  38.                                    dev:<character device name>
  39.                                    jdwp:<process pid> (remote only)
  40.   adb jdwp                     - list PIDs of processes hosting a JDWP transport
  41.   adb install [-l] [-r] [-s] <file> - push this package file to the device and install it
  42.                                  ('-l' means forward-lock the app)
  43.                                  ('-r' means reinstall the app, keeping its data)
  44.                                  ('-s' means install on SD card instead of internal storage)
  45.   adb uninstall [-k] <package> - remove this app package from the device
  46.                                  ('-k' means keep the data and cache directories)
  47.   adb bugreport                - return all information from the device
  48.                                  that should be included in a bug report.

  49.   adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]
  50.                                - write an archive of the device's data to <file>.
  51.                                  If no -f option is supplied then the data is written
  52.                                  to "backup.ab" in the current directory.
  53.                                  (-apk|-noapk enable/disable backup of the .apks themselves
  54.                                     in the archive; the default is noapk.)
  55.                                  (-shared|-noshared enable/disable backup of the device's
  56.                                     shared storage / SD card contents; the default is noshared.)
  57.                                  (-all means to back up all installed applications)
  58.                                  (-system|-nosystem toggles whether -all automatically includes
  59.                                     system applications; the default is to include system apps)
  60.                                  (<packages...> is the list of applications to be backed up.  If
  61.                                     the -all or -shared flags are passed, then the package
  62.                                     list is optional.  Applications explicitly given on the
  63.                                     command line will be included even if -nosystem would
  64.                                     ordinarily cause them to be omitted.)

  65.   adb restore <file>           - restore device contents from the <file> backup archive

  66.   adb help                     - show this help message
  67.   adb version                  - show version num

  68. scripting:
  69.   adb wait-for-device          - block until device is online
  70.   adb start-server             - ensure that there is a server running
  71.   adb kill-server              - kill the server if it is running
  72.   adb get-state                - prints: offline | bootloader | device
  73.   adb get-serialno             - prints: <serial-number>
  74.   adb status-window            - continuously print device status for a specified device
  75.   adb remount                  - remounts the /system partition on the device read-write
  76.   adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program
  77.   adb reboot-bootloader        - reboots the device into the bootloader
  78.   adb root                     - restarts the adbd daemon with root permissions
  79.   adb usb                      - restarts the adbd daemon listening on USB
  80.   adb tcpip <port>             - restarts the adbd daemon listening on TCP on the specified port
  81. networking:
  82.   adb ppp <tty> [parameters]   - Run PPP over USB.
  83. Note: you should not automatically start a PPP connection.
  84. <tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
  85. [parameters] - Eg. defaultroute debug dump local notty usepeerdns

  86. adb sync notes: adb sync [ <directory> ]
  87.   <localdir> can be interpreted in several ways:

  88.   - If <directory> is not specified, both /system and /data partitions will be updated.

  89.   - If it is "system" or "data", only the corresponding partition
  90.     is updated.

复制代码
有关 backup 和 restore 命令请看这篇非常给力的帖子: http://forum.xda-developers.com/showthread.php?t=1420351

devices: 这命令用来检查设备是否已经正确的以adb模式连接, 例如: adb devices
reboot: 用来重启设备, 例如:  adb reboot
reboot-bootloader: 重启设备到bootloader模式, 例如: adb reboot bootloader
push: 用来向设备复制文件, 比如将c:\junk.jpg 拷贝到手机 /sdcard文件夹: adb push c:\junk.jpg /sdcard/ ( 执行前, 确保/sdcard已经挂载)
shell: 打开一个一个可以直接向android系统发送命令的终端, 命令: adb shell, 你会发现提示符变成了 $ ( 基本都是常见的Linux shell 命令)

25, N4的区块.

  1. /dev/block/platform/msm_sdcc.1/by-name:
  2. lrwxrwxrwx root root 2012-11-13 19:02 DDR -> /dev/block/mmcblk0p24
  3. lrwxrwxrwx root root 2012-11-13 19:02 aboot -> /dev/block/mmcblk0p12
  4. lrwxrwxrwx root root 2012-11-13 19:02 abootb -> /dev/block/mmcblk0p15
  5. lrwxrwxrwx root root 2012-11-13 19:02 boot -> /dev/block/mmcblk0p6
  6. lrwxrwxrwx root root 2012-11-13 19:02 cache -> /dev/block/mmcblk0p22
  7. lrwxrwxrwx root root 2012-11-13 19:02 grow -> /dev/block/mmcblk0p25
  8. lrwxrwxrwx root root 2012-11-13 19:02 m9kefs1 -> /dev/block/mmcblk0p8
  9. lrwxrwxrwx root root 2012-11-13 19:02 m9kefs2 -> /dev/block/mmcblk0p9
  10. lrwxrwxrwx root root 2012-11-13 19:02 m9kefs3 -> /dev/block/mmcblk0p10
  11. lrwxrwxrwx root root 2012-11-13 19:02 metadata -> /dev/block/mmcblk0p18
  12. lrwxrwxrwx root root 2012-11-13 19:02 misc -> /dev/block/mmcblk0p19
  13. lrwxrwxrwx root root 2012-11-13 19:02 modem -> /dev/block/mmcblk0p1
  14. lrwxrwxrwx root root 2012-11-13 19:02 persist -> /dev/block/mmcblk0p20
  15. lrwxrwxrwx root root 2012-11-13 19:02 recovery -> /dev/block/mmcblk0p7
  16. lrwxrwxrwx root root 2012-11-13 19:02 rpm -> /dev/block/mmcblk0p11
  17. lrwxrwxrwx root root 2012-11-13 19:02 rpmb -> /dev/block/mmcblk0p16
  18. lrwxrwxrwx root root 2012-11-13 19:02 sbl1 -> /dev/block/mmcblk0p2
  19. lrwxrwxrwx root root 2012-11-13 19:02 sbl2 -> /dev/block/mmcblk0p3
  20. lrwxrwxrwx root root 2012-11-13 19:02 sbl2b -> /dev/block/mmcblk0p13
  21. lrwxrwxrwx root root 2012-11-13 19:02 sbl3 -> /dev/block/mmcblk0p4
  22. lrwxrwxrwx root root 2012-11-13 19:02 sbl3b -> /dev/block/mmcblk0p14
  23. lrwxrwxrwx root root 2012-11-13 19:02 system -> /dev/block/mmcblk0p21
  24. lrwxrwxrwx root root 2012-11-13 19:02 tz -> /dev/block/mmcblk0p5
  25. lrwxrwxrwx root root 2012-11-13 19:02 tzb -> /dev/block/mmcblk0p17
  26. lrwxrwxrwx root root 2012-11-13 19:02 userdata -> /dev/block/mmcblk0p23
复制代码
来自这里: http://forum.xda-developers.com/showthread.php?t=1993036

嵌入式系统, 区块的大小与配置基本都是固定的...
比方说: lrwxrwxrwx root root 2012-11-13 19:02 system -> /dev/block/mmcblk0p21, 你会发现: /system 下挂载的是 mmcblc0p21这个区块...
recovery -> /dev/block/mmcblk0p7
userdata -> /dev/block/mmcblk0p23
cache -> /dev/block/mmcblk0p22
boot -> /dev/block/mmcblk0p6

26, 挂载.
这东西自己理解吧, Linux的目录结构和Windows不同, Windows是先有分区, 然后在分区上再产生目录, Linux下是先有目录结构, 将某分区挂载到某目录下, 那么该目录就指向这个分区, 目录可以理解成指针嘛...

27, 什么是recovery?
recovery是一个特殊的启动模式, 它提供向设备刷写文件, 升级, 或者备份等等功能. 原装recovery功能稀少坑爹, 但我们有两个非常给力的自制recovery: CMW和TWRP.

28, 我为什么在recovery模式下会看到一个仰面朝天的小绿人?
这是原版recovery, 按下电源键, 再按音量+ 来打开recovery菜单.

29, 我刚刷了CMW, 但是每次我想要启动CMW都会发现原版recovery阴魂不散, 怎么回事?
有两个文件会在你每次载入recovery时重新刷写recovery:

/system/etc/install-recovery.sh
/system/recovery-from-boot.p

PS: 这两个文件只有在OTA升级之后才会出现
删除或者将它们重命名, 然后重新刷写CMW, 就能固定CMW了.
这帖子提供了一个 recovery disabler : http://forum.xda-developers.com/showthread.php?t=1995440

传送门: http://bbs.gfan.com/android-5795118-1-1.html

>>> 长帖的坏处就是: 看到最后, 就没有力气回帖了...
>>> 觉着有用, 记得 回帖, 加分, 收藏...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值