第一階段
- 先確定event log 中relaunch的時(shí)間點(diǎn)
08-11 15:40:11.327 1000 1709 4746 I wm_relaunch_resume_activity: [0,133396621,3,com.android.xxx/.XXX]
- 往前查找對應(yīng)event log中configuration_changed 相關(guān)log
附近時(shí)間點(diǎn)往前沒找到笋轨,請前往下面第二階段
08-11 15:40:11.051 1000 1709 4746 I configuration_changed: 4
- 根據(jù)2中config 數(shù)值轉(zhuǎn)換為16進(jìn)制逛万,在attrs_manifest.xml 中找到對應(yīng)的config名稱
上面的4轉(zhuǎn)換為16進(jìn)制是0x0004,對應(yīng)android功能清單文件中的locale
<attr name="configChanges">
<flag name="mcc" value="0x0001" />
<flag name="mnc" value="0x0002" />
<flag name="locale" value="0x0004" />
<flag name="touchscreen" value="0x0008" />
<flag name="keyboard" value="0x0010" />
<flag name="keyboardHidden" value="0x0020" />
<flag name="navigation" value="0x0040" />
<flag name="orientation" value="0x0080" />
<flag name="screenLayout" value="0x0100" />
<flag name="uiMode" value="0x0200" />
<flag name="screenSize" value="0x0400" />
<flag name="smallestScreenSize" value="0x0800" />
<flag name="density" value="0x1000" />
<flag name="layoutDirection" value="0x2000" />
<flag name="colorMode" value="0x4000" />
<flag name="fontScale" value="0x40000000" />
<flag name="fontWeightAdjustment" value="0x10000000" />
</attr>
- 在功能清單文件中配置規(guī)避Activity重啟
配置后沒生效,請前往第三階段
<activity
android:name=".XXXActivity"
android:configChanges="locale"/>
第二階段
如果relaunch的頁面在config發(fā)生改變時(shí)不在前臺,則會在該頁面再次resume時(shí)觸發(fā)Activity的relaunch
- 不看時(shí)間往前搜索最近一個(gè)configuration_changed
// config發(fā)生在2min前
08-11 15:40:11.051 1000 1709 4746 I configuration_changed: 4
// 再次resume該頁面
08-11 15:42:04.763 1000 1709 3335 I wm_set_resumed_activity: [0,com.android.settings/.XXX,resumeTopActivity]
// 同一system server線程觸發(fā)relaunch
08-11 15:42:04.770 1000 1709 3335 I wm_relaunch_resume_activity: [0,88191110,3,com.android.settings/.XXX]
- 重復(fù)第一階段的3 章蚣、4操作
第三階段
配置后沒有生效兜辞,仍然發(fā)生頁面的relaunch
- 確定配置是否生效
目標(biāo)Activity未被finish前執(zhí)行adb shell dumpsys activity a >a.txt
查看目標(biāo)Activity的configChanges 數(shù)值是否與預(yù)期一致,確定Rom中是否攜帶對應(yīng)的修改。
* Hist #4: ActivityRecord{541b086 u0 com.android.settings/.XXX t3}
packageName=com.android.settings processName=com.android.settings
launchedFromUid=1000 launchedFromPackage=com.android.provision launchedFromFeature=null userId=0
app=ProcessRecord{74745ed 16242:com.android.settings/1000}
Intent { cmp=com.android.settings/.XXX }
........
configChanges=0xfa7 // 確定跟功能清單文件是否一致
neverSandboxDisplayApis=false
alwaysSandboxDisplayApis=false
areBoundsLetterboxed=false
- 查看是否有遺漏的其他的config 改變
執(zhí)行adb shell wm logging enable-text WM_DEBUG_CONFIGURATION
命令后再次復(fù)線問題并抓取bugreoprt - 按照第一階段的1间螟、2找到對應(yīng)的時(shí)間點(diǎn)吴旋,并在main log中查找“allChanges”
08-11 15:42:04.763 1000 1709 3335 I wm_set_resumed_activity: [0,com.android.settings/.SetUpNewFingerprintInternalActivity,resumeTopActivity]
// 包括兩個(gè)config,缺一不可 {CONFIG_LOCALE, CONFIG_LAYOUT_DIRECTION}
08-11 15:42:04.770 1000 1709 3335 V WindowManager: Configuration changes for ActivityRecord{541b086 u0 com.android.settings/.SetUpNewFingerprintInternalActivity t3}, allChanges={CONFIG_LOCALE, CONFIG_LAYOUT_DIRECTION}
08-11 15:42:04.770 1000 1709 3335 I wm_relaunch_resume_activity: [0,88191110,3,com.android.settings/.SetUpNewFingerprintInternalActivity]
- 重復(fù)第一階段的3厢破、4操作添加遺漏的configChanges