最近客戶(hù)報(bào)了個(gè)問(wèn)題妓雾,使用手機(jī)時(shí)莫名關(guān)機(jī)重啟進(jìn)入了recovery模式婿禽,提示如下內(nèi)容:
"Can't load Android system. Your data may be corrupt.? If you continue to get this message, you may need to perform a factory data reset and erase all user data stored on this device."
然后下面出現(xiàn)兩行菜單:
"Try again"
"Factory data reset"
點(diǎn)擊 Try again 可以正常進(jìn)入系統(tǒng)裸燎。
奇怪的是這整個(gè)過(guò)程很自然,有關(guān)機(jī)動(dòng)畫(huà)播放疙描,然后再重啟進(jìn)入 recovery 模式馆揉,這個(gè)模式讓客戶(hù)很懵逼。
分析發(fā)現(xiàn)隐解,這是 Android 系統(tǒng)的一個(gè)自救措施鞍帝,當(dāng)內(nèi)置的persistent類(lèi)型的應(yīng)用頻繁crash時(shí),就啟動(dòng)了這個(gè)自救功能煞茫。
最終從 /data/system/dropbox取到的內(nèi)容也可以看到帕涌,其中一款persistent類(lèi)型應(yīng)用有很多crash log。
Android 自救程序可以參考: com.android.server.RescueParty
這個(gè)類(lèi)官方說(shuō)明是
/**
* Utilities to help rescue the system from crash loops. Callers are expected to
* report boot events and persistent app crashes, and if they happen frequently
* enough this class will slowly escalate through several rescue operations
* before finally rebooting and prompting the user if they want to wipe data as
* a last resort.
*
*/
執(zhí)行流程是:
notePersistentAppCrash -> executeRescueLevel -> RecoverySystem.rebootPromptAndWipeUserData(context, TAG)
把最后重啟的過(guò)程代碼屏蔽即可避免進(jìn)入recovery模式续徽。