最开始犯的低级错误
验证安装包的时候出现了 java.security.SignatureException: no signature in file (no footer) 这个错误
这个是由于拷贝的 update.zip 文件不对引起的 校验的时候 RecoverySystem 会读取zip文件前6个字节判断
正确的完整升级包拷贝 out 目录下 system.img 同级下 full_xxxx-ota-mp1xx.zip
错误的升级包我拷贝了 obj\PACKAGING\target_files_intermediates 目录下的 full_xxxx.zip
这个目录下的zip是用来制作差异包的,真是憨憨了。
言归正传,当校验通过后重启进入recovery界面时,就会出现 @/cache/recovery/block.map’ failed 错误,
这个错误你需要eng版本才能看见,user版本只是一个小机器人error然后自动重启。
设备重启后 adb pull /cache/recovery/ 查看 last_log
[ 0.166714] I:Got 3 arguments from /cache/recovery/command [ 0.180099] /system/bin/recovery: unrecognized option `--update_package=@/cache/recovery/block.map' [ 0.183039] Loading make_device from librecovery_ui_ext.so [ 0.192444] I:Brightness: 127 (50%) [ 0.204379] Failed to find/open a drm device: No such file or directory [ 0.204902] fb0 reports (possibly inaccurate): [ 0.204925] vi.bits_per_pixel = 32 [ 0.204942] vi.red.offset = 0 .length = 8 [ 0.204959] vi.green.offset = 8 .length = 8 [ 0.204975] vi.blue.offset = 16 .length = 8 [ 0.235279] framebuffer: 0 (800 x 1280) [ 0.277860] erasing_text: zh_CN (55 x 19 @ 2540) [ 0.282375] no_command_text: zh_CN (42 x 19 @ 2540) [ 0.286267] error_text: zh_CN (46 x 19 @ 2540) [ 0.287852] E:Failed to load bitmap cancel_wipe_data_text (error -1) [ 0.288308] E:Failed to load bitmap factory_data_reset_text (error -1) [ 0.288725] E:Failed to load bitmap try_again_text (error -1) [ 0.289150] E:Failed to load bitmap wipe_data_confirmation_text (error -1) [ 0.289577] E:Failed to load bitmap wipe_data_menu_header_text (error -1) [ 0.553152] __bionic_open_tzdata: couldn't find any tzdata when looking for America/New_York! [ 0.553469] I:Starting recovery (pid 320) on Mon Feb 1 02:07:18 2021 [ 0.553647] I: [ 0.554056] I:locale is [zh_CN] [ 0.562685] SELinux: Skipping /product_file_contexts: empty file [ 0.563427] SELinux: Skipping /odm_file_contexts: empty file [ 0.563908] SELinux: Loaded file_contexts
看着错误信息是和 SELinux 权限相关,将 SELinux 临时关闭后重新升级了一次发现可成功升级,这样确定了和 SELinux 相关
那么我们要找到 user 版本缺少的权限,设备重启前看到的关键日志
成功
D/RecoverySystem: try uncryptUpdatePacks!!! D/RecoverySystem: try uncrypt-block!!! I/uncrypt: type=1400 audit(0.0:2057): avc: denied { search } for name="gsi" dev="mmcblk0p10" ino=16 scontext=u:r:uncrypt:s0 tcontext=u:object_r:gsi_metadata_file:s0 tclass=dir permissive=1 I//system/bin/uncrypt: uncrypt called in debug mode, skip socket communication I/uncrypt: type=1400 audit(0.0:2058): avc: denied { write } for name="update.zip" dev="mmcblk0p36" ino=1368153 scontext=u:r:uncrypt:s0 tcontext=u:object_r:media_rw_data_file:s0 tclass=file permissive=1 I//system/bin/uncrypt: update package is "/data/media/update.zip" I//system/bin/uncrypt: encryptable: yes I//system/bin/uncrypt: encrypted: yes I//system/bin/uncrypt: writing block map /cache/recovery/block.map I//system/bin/uncrypt: block size: 4096 bytes I//system/bin/uncrypt: file size: 736913983 bytes, 179911 blocks I//system/bin/uncrypt: uncrypt succeeded D/RecoverySystem: try uncrypt-cmd!!!
失败
I sysUpgrade:: verifyPackage is completed and it ok I sysUpgrade:: It will install package W RecoverySystem: !!! REBOOTING TO INSTALL /data/media/update.zip !!! D RecoverySystem: try uncryptUpdatePacks!!! D RecoverySystem: try uncrypt-block!!! W uncrypt : type=1400 audit(0.0:27111): avc: denied { search } for name="/" dev="mmcblk0p10" ino=2 scontext=u:r:uncrypt:s0 tcontext=u:object_r:metadata_file:s0 tclass=dir permissive=0 I /system/bin/uncrypt: update package is "/data/media/update.zip" 01-31 21:07:45.012 5554 5554 W uncrypt : type=1400 audit(0.0:27112): avc: denied { write } for name="update.zip" dev="mmcblk0p36" ino=1368153 scontext=u:r:uncrypt:s0 tcontext=u:object_r:media_rw_data_file:s0 tclass=file permissive=0 I /system/bin/uncrypt: encryptable: yes I /system/bin/uncrypt: encrypted: yes I /system/bin/uncrypt: writing block map /cache/recovery/block.map I /system/bin/uncrypt: block size: 4096 bytes I /system/bin/uncrypt: file size: 736913983 bytes, 179911 blocks E /system/bin/uncrypt: failed to open /data/media/update.zip for reading: Permission denied I /system/bin/uncrypt: uncrypt failed
根据 avc denied 权限,查找 uncrypt.te
device/mediatek/sepolicy/basic/non_plat/uncrypt.te
allow uncrypt metadata_file:dir { search }; allow uncrypt media_rw_data_file:file { write };
至此问题解决
Android 9 § recovery升级Map of ‘@/cache/recovery/block.map‘ failed问题分析指南