手机Android充电通电自动开机(关机状态下)ADB教程已经验证 - 全文内容:
显示技术博客列表手机Android充电通电自动开机(关机状态下)ADB教程已经验证
超短链接
提取手机boot.img镜像
解包boot.img镜像
修改init.rc文本
打包boot.img
刷入修改后的boot.img到手机
完成,测试
工具: ADB, Fastboot, Bootimg [工具下载:把你的旧手机改造成车载导航.zip]
bootimg解封包工具与Tasker.apk与断电关机.apk 把你的旧手机改造成车载导航.rar
提取手机boot.img镜像
手机打开USB调试(开发者选项)
手机USB连接电脑
在CMD窗口cd到adb.exe的路径,输入“adb devices”来检测一下链接状况。
输入“adb shell”,回车,再输入“su”回车,这注意看,提示符应该已经从$符号变成了#号。
在“/dev/block/platform”目录下找到对应的by-name目录,一般只有一个目录很好找
127|root@ido:/dev # cd /dev/block/platform/ root@ido:/dev/block/platform # ls 7824900.sdhci root@ido:/dev/block/platform # root@ido:/dev/block/platform/7824900.sdhci # ls by-name by-num mmcblk0 mmcblk0p1 mmcblk0p10 mmcblk0p11 mmcblk0p12 mmcblk0p13
输入命令列出搜索到的文件夹”ls -al /dev/block/platform/7824900.sdhci/by-name/”,找到boot对应文件名称为” boot -> /dev/block/mmcblk0p22”
root@ido:/ # ls -al /dev/block/platform/7824900.sdhci/by-name/ lrwxrwxrwx root root 1970-01-02 04:18 DDR -> /dev/block/mmcblk0p19 lrwxrwxrwx root root 1970-01-02 04:18 aboot -> /dev/block/mmcblk0p4 lrwxrwxrwx root root 1970-01-02 04:18 abootbak -> /dev/block/mmcblk0p5 lrwxrwxrwx root root 1970-01-02 04:18 boot -> /dev/block/mmcblk0p22 lrwxrwxrwx root root 1970-01-02 04:18 cache -> /dev/block/mmcblk0p25 lrwxrwxrwx root root 1970-01-02 04:18 config -> /dev/block/mmcblk0p28 lrwxrwxrwx root root 1970-01-02 04:18 cust -> /dev/block/mmcblk0p30 lrwxrwxrwx root root 1970-01-02 04:18 fsc -> /dev/block/mmcblk0p16 lrwxrwxrwx root root 1970-01-02 04:18 fsg -> /dev/block/mmcblk0p20 lrwxrwxrwx root root 1970-01-02 04:18 hyp -> /dev/block/mmcblk0p10 lrwxrwxrwx root root 1970-01-02 04:18 hypbak -> /dev/block/mmcblk0p11 lrwxrwxrwx root root 1970-01-02 04:18 keystore -> /dev/block/mmcblk0p27 lrwxrwxrwx root root 1970-01-02 04:18 misc -> /dev/block/mmcblk0p15 lrwxrwxrwx root root 1970-01-02 04:18 modem -> /dev/block/mmcblk0p1 lrwxrwxrwx root root 1970-01-02 04:18 modemst1 -> /dev/block/mmcblk0p13 lrwxrwxrwx root root 1970-01-02 04:18 modemst2 -> /dev/block/mmcblk0p14 lrwxrwxrwx root root 1970-01-02 04:18 oem -> /dev/block/mmcblk0p29 lrwxrwxrwx root root 1970-01-02 04:18 pad -> /dev/block/mmcblk0p12 lrwxrwxrwx root root 1970-01-02 04:18 persist -> /dev/block/mmcblk0p24 lrwxrwxrwx root root 1970-01-02 04:18 recovery -> /dev/block/mmcblk0p26 lrwxrwxrwx root root 1970-01-02 04:18 rpm -> /dev/block/mmcblk0p6 lrwxrwxrwx root root 1970-01-02 04:18 rpmbak -> /dev/block/mmcblk0p7 lrwxrwxrwx root root 1970-01-02 04:18 sbl1 -> /dev/block/mmcblk0p2 lrwxrwxrwx root root 1970-01-02 04:18 sbl1bak -> /dev/block/mmcblk0p3 lrwxrwxrwx root root 1970-01-02 04:18 sec -> /dev/block/mmcblk0p21 lrwxrwxrwx root root 1970-01-02 04:18 splash -> /dev/block/mmcblk0p18 lrwxrwxrwx root root 1970-01-02 04:18 ssd -> /dev/block/mmcblk0p17 lrwxrwxrwx root root 1970-01-02 04:18 system -> /dev/block/mmcblk0p23 lrwxrwxrwx root root 1970-01-02 04:18 tz -> /dev/block/mmcblk0p8 lrwxrwxrwx root root 1970-01-02 04:18 tzbak -> /dev/block/mmcblk0p9 lrwxrwxrwx root root 1970-01-02 04:18 userdata -> /dev/block/mmcblk0p31 root@ido:/ #
开始提取,输入“dd if=/dev/block/mmcblk0p22 of=/sdcard/boot.img”,这里的”/dev/block/mmcblk0p22”就是刚才上面找到的boot对应文件
root@ido:/sdcard # dd if=/dev/block/mmcblk0p22 of=/sdcard/boot.img 65536+0 records in 65536+0 records out 33554432 bytes transferred in 8.681 secs (3865272 bytes/sec) root@ido:/sdcard #
把内存卡根目录下提取的”boot.img”文件拷贝到电脑
解包boot.img镜像
电脑上把拷贝的boot.img和bootimg.exe放在相同目录下。
CMD到bootimg.exe目录下执行“bootimg —unpack-bootimg” 解包 //路径不能有中文.否则报错
F:\1\bootimg>bootimg --unpack-bootimg arguments: [bootimg file] bootimg file: boot.img output: kernel[.gz] ramdisk[.gz] second[.gz] found nonstandard ramdisk_addr found device_tree_image base: 0x80000000 ramdisk_addr: 0x82000000 second_addr: 0x80f00000 tags_addr: 0x80000100 page_size: 2048 name: "" cmdline: "console=115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk" padding_size=2048 arguments: [ramdisk file] [directory] ramdisk file: ramdisk.gz directory: initrd output: cpiolist.txt compress: True F:\1\bootimg>
修改init.rc文本
解包boot.img后会获得”initrd”文件夹,里面有我们需要修改的”init.rc”文件
使用EmEditor修改init.rc文件,在”on charger”这一项目添加”setprop sys.powerctl reboot”
on charger class_start charger #这段自带不用删也可以,而且听说某些系统需要先进入charger流程,否则会卡第一屏 setprop sys.powerctl reboot #添加进这段
修改init.rc完毕,保存
打包boot.img
现在要把修改的文件重新打包成boot.img。还是回到刚才的cmd窗口。输入“bootimg —repack-bootimg”回车。程序会自动把文件打包回去。现在目录下就会变成3个文件,一个程序bootimg.exe,一个原始文件boot-old.img,一个新生成的文件boot-new.img。
F:\1\bootimg>bootimg --repack-bootimg arguments: [cpiolist file] cpiolist file: cpiolist.txt output: ramdisk.cpio.gz compress_level: 6 arguments: [base] [cmdline] [page_size] [padding_size] kernel: kernel ramdisk: ramdisk.cpio.gz second: dt_image: dt_image base: 0x80000000 ramdisk_addr: 0x82000000 second_addr: 0x80f00000 tags_addr: 0x80000100 name: cmdline: console=115200,n8 androidboot.console=ttyHSL0 androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk page_size: 2048 padding_size: 2048 output: boot-new.img F:\1\bootimg>
刷入修改后的boot.img到手机
必须在调式模式下打开Fastboot刷机功能
把boot-new.img拷贝到adb.exe所在的目录,并且重命名为boot.img,在此目录打开命令窗口。
把手机进入到fastboot的状态。关机,同时按住音量减和电源键。这时你的手机会进入fastboot的状态,准备开始写入boot.img。
在命令窗口输入“fastboot flash boot boot.img”回车,开始刷写boot.img。因为文件很小,几秒钟就提示完成了。
F:\1\platform-tools>fastboot flash boot boot.img target reported max download size of 268435456 bytes sending 'boot' (9324 KB)... OKAY [ 0.434s] writing 'boot'... OKAY [ 0.241s] finished. total time: 0.683s F:\1\platform-tools>
输入“fastboot reboot”回车,会重启手机
完成,测试
操作完以上步骤,就实现了安卓关机状态通电自动开机.
测试1: 关机,保持usb线供电,数秒后自动开机.
测试2: 关机.拔掉usb线,然后插入usb线,数秒后自动开机.
完成