“OTA在线升级时打开USB存储设备时提示下载失败”分析

时间:2022-06-04 15:51:30

问题描述:

测试环境:1 插入SD卡;2 已经开启数据流量或是连接可用的WIFI网络
测试步骤:进入OTA升级客户端(第三方)1-进入OTA客户端选择在线升级;2 升级过程中使用数据线连接手机到PC端,并打开USB存储设备

测试结果:在线升级下载界面出现"下载失败"讯息


首先,OTA升级客户端下载的更新包存储机制是内置存储优先原则;系统主存储机制为SD卡优先原则,那么基于以上两个原则现在对问题进行分析,读者可以参考下面关键log:



第一部分:下载过程中,打开USB存储设备

第一步:确定复现时间点的log标志信息

02-09 15:39:08.333: E/HwOUC(4739): [main-1]report download failure! stauts is 492(hwouc/FirmwareAndAppReceiver.java:87)

上面log信息可以看到当前下载更新失败,status is 492则表示文件存储异常


第二步:排查打开USB存储设备时,存储设备挂载的log

02-09 15:39:01.284: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_EJECT dat=file:///storage/sdcard0 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//将卸载SD卡,但SD卡上部分内容尚未处于打开状态
02-09 15:39:01.301: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_EJECT dat=file:///storage/sdcard1 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//将卸载SD卡,但SD卡上部分内容尚未处于打开状态
02-09 15:39:09.005: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_SCANNER_STARTED dat=file:///storage/sdcard1 flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{431144a8 1546:android.process.media/u0a5}////MediaScanner开始扫描内部存储
02-09 15:39:09.351: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_SCANNER_FINISHED dat=file:///storage/sdcard1 flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{431144a8 1546:android.process.media/u0a5}//扫描结束

02-09 15:39:15.456: D/ActivityThread(7090): BDC-Calling onReceive: intent=Intent { act=android.intent.action.MEDIA_SHARED dat=file:///storage/sdcard1 flg=0x10 cmp=com.mediatek.mtklogger/.framework.LogReceiver (has extras) }, ordered=true, receiver=com.mediatek.mtklogger.framework.LogReceiver@42870ee0//进入USB连接模式,SD卡被卸载,终端将无法访问SD卡


第三步:那么考虑到前面提到的两种机制,在参考第二步所提供的log,此时我们对存储路径的相关log进行分析如下:

02-09 15:38:57.510: I/StorageManagerEx(1546): getInternalStoragePath from Property path=/storage/sdcard1

02-09 15:38:57.510: D/StorageManagerEx(1546): getInternalStoragePath path=/storage/sdcard1

........

02-09 15:39:01.365: I/StorageManagerEx(7090): getInternalStoragePath from Property path=/storage/sdcard1

02-09 15:39:01.365: D/StorageManagerEx(7090): getInternalStoragePath path=/storage/sdcard1

02-09 15:39:09.535: I/StorageManagerEx(7090): getInternalStoragePath from Property path=/storage/sdcard0

02-09 15:39:09.536: D/StorageManagerEx(7090): getInternalStoragePath path=/storage/sdcard0

........

02-09 15:39:26.452: I/StorageManagerEx(1546): getInternalStoragePath from Property path=/storage/sdcard0

02-09 15:39:26.464: D/StorageManagerEx(1546): getInternalStoragePath path=/storage/sdcard0

从上面log我们可以看到,在打开USB存储设备之前,主存储为SDCard,SDCard路径为/storage/sdcard0;而内部存储为/storage/sdcard1;在打开USB存储设备之后,主存储为内部存储,内部内存储的路径为/storage/sdcard0。


第二部分:连接打开USB存储设备重新下载,下载过程中关闭USB存储设备的分析

第一步:确定复现时间点的log标志信息如下:

02-09 15:40:21.419: E/HwOUC(4739): [main-1]report download failure! stauts is 492(hwouc/FirmwareAndAppReceiver.java:87)

上面log信息可以看到当前下载更新失败,status is 492则表示文件存储异常


第二步:排查打开USB存储设备时,存储设备挂载的log

02-09 15:40:11.630: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_UNSHARED dat=file:///storage/sdcard1 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//退出USB存储模式

02-09 15:40:11.631: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_EJECT dat=file:///storage/sdcard0 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//

02-09 15:40:11.637: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_UNMOUNTED dat=file:///storage/sdcard1 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//SD卡被卸载,但并未移除SD卡

02-09 15:40:11.637: V/MediaProvider(1546): unmountReceiver: intent=Intent { act=android.intent.action.MEDIA_EJECT dat=file:///storage/sdcard0 flg=0x10 (has extras) }//将卸载SD卡,但SD卡上部分内容尚未处于打开状态

02-09 15:40:16.174: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_CHECKING dat=file:///storage/sdcard0 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//正在检测SD卡

02-09 15:40:17.412: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_MOUNTED dat=file:///storage/sdcard0 flg=0x10 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{42bd4580 683:system/1000}//SD卡已挂载

02-09 15:40:17.656: V/MediaProvider(1546): unmountReceiver: intent=Intent { act=android.intent.action.MEDIA_MOUNTED dat=file:///storage/sdcard0 flg=0x10 (has extras) }//SD卡已挂载

02-09 15:40:18.621: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_SCANNER_STARTED dat=file:///storage/sdcard0 flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{431144a8 1546:android.process.media/u0a5}//SD卡挂载后MediaScanner开始进行扫描

02-09 15:40:28.474: V/ActivityManager(683): Broadcast: Intent { act=android.intent.action.MEDIA_SCANNER_FINISHED dat=file:///storage/sdcard0 flg=0x10 } ordered=false userid=0 callerApp=ProcessRecord{431144a8 1546:android.process.media/u0a5}//扫描结束


第三步:那么考虑到前面提到的两种机制,在参考第二步所提供的log,此时我们对存储路径的相关log进行分析如下:

02-09 15:40:09.631: I/StorageManagerEx(7090): getInternalStoragePath from Property path=/storage/sdcard0

02-09 15:40:09.631: D/StorageManagerEx(7090): getInternalStoragePath path=/storage/sdcard0

........

02-09 15:40:11.669: I/StorageManagerEx(7090): getInternalStoragePath from Property path=/storage/sdcard0

02-09 15:40:11.669: D/StorageManagerEx(7090): getInternalStoragePath path=/storage/sdcard0

02-09 15:40:15.616: I/StorageManagerEx(7090): getInternalStoragePath from Property path=/storage/sdcard1

02-09 15:40:15.616: D/StorageManagerEx(7090): getInternalStoragePath path=/storage/sdcard1

........

02-09 15:40:16.043: I/StorageManagerEx(7090): getInternalStoragePath from Property path=/storage/sdcard1

02-09 15:40:16.043: D/StorageManagerEx(7090): getInternalStoragePath path=/storage/sdcard1

从上面log我们可以看到,在关闭USB存储设备之前,主存储为内部存储,而内部存储为/storage/sdcard0;在关闭USB存储设备之后,主存储为SD卡,内部内存储的路径为/storage/sdcard1。


因此,总的来说当前问题是由于打开USB存储导致内部存储路径发生变化导致。