Android 9 (P) recovery升级Map of ‘@/cache/recovery/block.map‘ failed问题分析指南

本文分析了Android 9(P)版本中,由于SELinux权限问题导致的recovery升级失败,详细介绍了如何通过查看logcat-bevents|grepavc日志定位问题,并添加相应的SELinux权限来解决这一难题。

Adnroid 9 (P) recovery升级Map of '@/cache/recovery/block.map’failed问题分析指南


Android 9 (P)开发适配指南系列博客目录:

Adnroid 9 (P) recovery升级Map of '@/cache/recovery/block.map’failed问题分析指南
Android 9 (P)版本解决VNDK library: XXX’s ABI has EXTENDING CHANGES
Android 9 (P)非SDK API限制调用开发指南
Android 9 (P)适配以太网功能开发指南
Android 9 (P)在user模式下无法使用fastboot烧录怎么破
Android 9 (P)静默安装/卸载App适配终极指南



引言

  自从Android 4.4将SELinux加入Android以后,这个东西虽然说有了安全但是在开发中经常会遇到一些莫名其妙的问题,本篇今天要说的就是就是由于SELinux规则问题导致的Map of '@/cache/recovery/block.map’failed无法升级问题。

注意:本篇讲解的代码是在Android P 高通8953平台。




一.问题复盘

  随着android版本升级,升级包越来越大,当升级包无法存储在cache分区的时候,会把升级包下载到data分区,然后从data分区升级,最近从data分区加载升级包升级的时候,遇到了如下错误,这个错误可以在升级失败以后在/cache/recovery/last_log中查看,具体日志如下:

[    0.000179] __bionic_open_tzdata: couldn't find any tzdata when looking for Asia/Shanghai!
[    0.000238] Starting recovery (pid 387) on Thu Jan  1 05:28:26 1970
[    0.001760] recovery filesystem table
[    0.001783] =========================
[    0.001789]   0 /vendor ext4 /dev/block/platform/soc/7824900.sdhci/by-name/vendor 0
[    0.001794]   1 / ext4 /dev/block/bootdevice/by-name/system 0
[    0.001799]   2 /cache ext4 /dev/block/bootdevice/by-name/cache 0
[    0.001804]   3 /vendor ext4 /dev/block/bootdevice/by-name/vendor 0
[    0.001809]   4 /data ext4 /dev/block/bootdevice/by-name/userdata 0
[    0.001814]   5 /sdcard vfat /dev/block/mmcblk1p1 0
[    0.001819]   6 /boot emmc /dev/block/bootdevice/by-name/boot 0
[    0.001823]   7 /recovery emmc /dev/block/bootdevice/by-name/recovery 0
[    0.001828]   8 /misc emmc /dev/block/bootdevice/by-name/misc 0
[    0.001833]   9 /tmp ramdisk ramdisk 0
[    0.001837]
[    0.003088] I:Boot command: boot-recovery
[    0.003104] I:Got 3 arguments from boot message
[    0.047245] locale is [zh-CN]
[    0.047297] stage is []
[    0.047321] reason is [(null)]
[    0.047981] W:Failed to read max brightness: No such file or directory
[    0.048017] I:Screensaver disabled
[    0.049631] cannot find/open a drm device: No such file or directory
[    0.050030] fb0 reports (possibly inaccurate):
[    0.050049]   vi.bits_per_pixel = 32
[    0.050055]   vi.red.offset   =   0   .length =   8
[    0.050060]   vi.green.offset =   8   .length =   8
[    0.050065]   vi.blue.offset  =  16   .length =   8
[    0.064662] framebuffer: 0 (1920 x 1080)
[    0.515251]           erasing_text: zh (81 x 38 @ 5031)
[    0.527722]        no_command_text: zh (111 x 38 @ 5031)
[    0.538287]             error_text: zh (65 x 38 @ 5031)
[    0.993697]        installing_text: zh (222 x 38 @ 5922)
[    1.023212] SELinux: Loaded file_contexts
[    1.023333] Command: "/sbin/recovery" "--update_package=@/cache/recovery/block.map" "--locale=zh-CN"
[    1.152498] I:Update location: @/cache/recovery/block.map
[    1.152563] Opening update package...
[    1.185800] E:Failed to read /cache/recovery/block.map: No such file or directory
[    1.202350] E:Map of '@/cache/recovery/block.map' failed
[    1.235591] E:failed to map file
[    1.280567] W:Failed to read /sys/class/thermal/thermal_zone53/temp: Invalid argument
[    1.280665] W:Failed to read /sys/class/thermal/thermal_zone52/temp: Invalid argument
[    1.280730] W:Failed to read /sys/class/thermal/thermal_zone51/temp: Invalid argument
[    1.280872] W:Failed to read /sys/class/thermal/thermal_zone49/temp: No such device
[    1.280936] W:Failed to read /sys/class/thermal/thermal_zone48/temp: No such device
[    1.281001] W:Failed to read /sys/class/thermal/thermal_zone47/temp: No such device
[    1.281064] W:Failed to read /sys/class/thermal/thermal_zone46/temp: Invalid argument
[    1.281127] W:Failed to read /sys/class/thermal/thermal_zone45/temp: Invalid argument
[    1.287659] I:current maximum temperature: 90000
[    1.287840] I:@/cache/recovery/block.map
[    1.287866] I:0
[    1.287889] I:time_total: 0
[    1.287911] I:retry: 0
[    1.287933] I:error: 26
[    1.287955] I:uncrypt_time: 0
[    1.287977] I:uncrypt_error: 117
[    1.287999] I:temperature_start: 90000
[    1.288021] I:temperature_end: 90000
[    1.288043] I:temperature_max: 90000
[    1.288065] I:
[    1.288093] Installation aborted.
[    1.303354] Mounted /cache/xxx-recovery
[    1.336868] mkdir /cache/xxx-recovery error[File exists]
[    1.356593] Recovery install reason=update_package result=fail on Thu Jan  1 05:28:27 1970
[    1.356622]  !
[    6.421470] I:Saving locale "zh-CN"

其中关键点信息如下:

[    1.185800] E:Failed to read /cache/recovery/block.map: No such file or directory
[    1.202350] E:Map of '@/cache/recovery/block.map' failed
[    1.235591] E:failed to map file

根据关键点信息去终端cache分区下查找是否存在该文件, 结果如下:

130|msm8953_64:/cache/recovery # ls -l
total 448
-rw------- 1 root   root      277 2020-05-12 17:48 block.map
-rw-r--r-- 1 root   root      271 1970-01-02 15:42 last_install
-rw------- 1 system system 368240 1970-01-02 15:42 last_kmsg
-rw------- 1 root   root        5 1970-01-02 15:42 last_locale
-rw------- 1 system system     38 2020-05-12 17:47 uncrypt_file

尼玛,这个文件是存在的,那为啥提示不存在了,这个就是问题关键了。这个要怎么解决呢!




二.解决问题

  我们我们追寻重启进入recovery之前的log信息,通过logcat -b events | grep avc查看,日志如下所示:

[ 1212.869820@3] type</
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值