通过adb dump activity的configChanges配置
如题,本文介绍如何通过adb获取某个activity的configChanges配置信息。
参考部分资料:
https://blog.csdn.net/m0_51703524/article/details/122477760
1,dump获取configChanges整型值
adb shell dumpsys activity activities
输出如下,我们以Settings activity为例,可以看到configChanges=0x3:
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
Display #0 (activities from top to bottom):* Task{2ee653b #1100004 type=standard A=1101000:com.android.car.settings isResizeable=true minWidth=-1 minHeight=-1 U=11 visible=true visibleRequested=true mode=fullscreen translucent=false sz=1}mLastNonFullscreenBounds=Rect(995, 239 - 1510, 1154)isSleeping=falsetopResumedActivity=ActivityRecord{d79bd6c u11 com.android.car.settings/.Settings_Launcher_Homepage t1100004}* Hist #0: ActivityRecord{d79bd6c u11 com.android.car.settings/.Settings_Launcher_Homepage t1100004}packageName=com.android.car.settings processName=com.android.car.settingslaunchedFromUid=0 launchedFromPackage=com.android.shell launchedFromFeature=null userId=11app=ProcessRecord{3d98359 17474:com.android.car.settings/u11s1000}Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10004000 pkg=com.android.car.settings cmp=com.android.car.settings/.Settings_Launcher_Homepage }rootOfTask=true task=Task{2ee653b #1100004 type=standard A=1101000:com.android.car.settings isResizeable=true minWidth=-1 minHeight=-1}taskAffinity=1101000:com.android.car.settingsmActivityComponent=com.android.car.settings/.common.CarSettingActivities$HomepageActivitybaseDir=/system/priv-app/CarSettings/CarSettings.apkdataDir=/data/user/11/com.android.car.settingsstateNotNeeded=false componentSpecified=false mActivityType=standardcompat={200dpi always-compat} theme=0x7f120142mLastReportedConfigurations:mGlobalConfig={1.0 ?mcc0mnc [en_US] ldltr sw1134dp w2003dp h1134dp 200dpi xlrg long hdr land car -touch -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 2504, 1418) mAppBounds=Rect(0, 0 - 2504, 1418) mMaxBounds=Rect(0, 0 - 2504, 1418) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=undefined mAlwaysOnTop=undefined mRotation=ROTATION_0} as.5 s.59 fontWeightAdjustment=0}mOverrideConfig={1.0 ?mcc0mnc [en_US] ldltr sw1134dp w2003dp h1134dp 200dpi xlrg long hdr land car -touch -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 2504, 1418) mAppBounds=Rect(0, 0 - 2504, 1418) mMaxBounds=Rect(0, 0 - 2504, 1418) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.5 s.2 fontWeightAdjustment=0}mLastReportedActivityWindowInfo=ActivityWindowInfo{isEmbedded=false, taskBounds=Rect(0, 0 - 2504, 1418), taskFragmentBounds=Rect(0, 0 - 2504, 1418)}CurrentConfiguration={1.0 ?mcc0mnc [en_US] ldltr sw1134dp w2003dp h1134dp 200dpi xlrg long hdr land car -touch -keyb/v/h -nav/h winConfig={ mBounds=Rect(0, 0 - 2504, 1418) mAppBounds=Rect(0, 0 - 2504, 1418) mMaxBounds=Rect(0, 0 - 2504, 1418) mDisplayRotation=ROTATION_0 mWindowingMode=fullscreen mActivityType=standard mAlwaysOnTop=undefined mRotation=ROTATION_0} as.5 s.2 fontWeightAdjustment=0}RequestedOverrideConfiguration={0.0 ?mcc0mnc ?localeList ?layoutDir ?swdp ?wdp ?hdp ?density ?lsize ?long ?ldr ?wideColorGamut ?orien ?uimode ?night ?touch ?keyb/?/? ?nav/? winConfig={ mBounds=Rect(0, 0 - 0, 0) mAppBounds=null mMaxBounds=Rect(0, 0 - 0, 0) mDisplayRotation=undefined mWindowingMode=undefined mActivityType=standard mAlwaysOnTop=undefined mRotation=undefined} ?fontWeightAdjustment}taskDescription: label="null" icon=null iconResource=/0 iconFilename=null primaryColor=ff91cef5backgroundColor=ff181c1f statusBarColor=ff000000 navigationBarColor=808080backgroundColorFloating=ff181c1flaunchFailed=false launchCount=1 lastLaunchTime=-4s39msmHaveState=false mIcicle=nullstate=RESUMED delayedResume=false finishing=falsekeysPaused=false inHistory=true idle=trueoccludesParent=true noDisplay=false immersive=false launchMode=2mActivityType=standardmImeInsetsFrozenUntilStartInput=falsewindows=[Window{e951aaf u11 com.android.car.settings/com.android.car.settings.Settings_Launcher_Homepage}]windowType=2mOccludesParent=trueoverrideOrientation=SCREEN_ORIENTATION_UNSPECIFIEDrequestedOrientation=SCREEN_ORIENTATION_UNSPECIFIEDmVisibleRequested=true mVisible=true mClientVisible=true reportedDrawn=true reportedVisible=truemNumInterestingWindows=1 mNumDrawnWindows=1 allDrawn=true lastAllDrawn=true)startingData=null firstWindowDrawn=true mIsExiting=falsenowVisible=true lastVisibleTime=-3s316msconnections={ConnectionRecord{20ce848 u11 CR com.android.car/.CarService:@d162eb flags=0x1}, ConnectionRecord{b653965 u11 CR com.android.car/.CarService:@714025c flags=0x1}, ConnectionRecord{cb55873 u11 CR com.android.car/.CarService:@d501ce2 flags=0x1}}resizeMode=RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSIONmLastReportedMultiWindowMode=false mLastReportedPictureInPictureMode=falsesupportsSizeChanges=SIZE_CHANGES_UNSUPPORTED_METADATA**configChanges=0x3**neverSandboxDisplayApis=falsealwaysSandboxDisplayApis=falseisTransparentPolicyRunning=falseareBoundsLetterboxed=falseisLetterboxRunning=false
2,计算configChanges配置
configChanges=0x3是通过一些常量值进行按位逻辑或(|)运算,得到的一个组合值。
常量的定义在sourceCode/frameworks/base/core/res/res/values/attrs_manifest.xml
所以通过计算得知,Settings activity的configChanges=0x3就是mcc|mnc的组合配置。
<attr name="configChanges"><!-- The IMSI MCC has changed, that is a SIM has been detected andupdated the Mobile Country Code. By default from Android O, wedon't recreate the activity even the app doesn't specify mcc inconfigChanges. If the app wants to recreate the activity, specifymcc in recreateOnConfigChanges. --><flag name="mcc" value="0x0001" /><!-- The IMSI MNC has changed, that is a SIM has been detected andupdated the Mobile Network Code. By default from Android O, wedon't recreate the activity even the app doesn't specify mnc inconfigChanges. If the app wants to recreate the acvitity, specifymnc in recreateOnConfigChanges. --><flag name="mnc" value="0x0002" /><!-- The locale has changed, that is the user has selected a newlanguage that text should be displayed in. --><flag name="locale" value="0x0004" /><!-- The touchscreen has changed. Should never normally happen. --><flag name="touchscreen" value="0x0008" /><!-- The keyboard type has changed, for example the user has pluggedin an external keyboard. --><flag name="keyboard" value="0x0010" /><!-- The keyboard or navigation accessibility has changed, for examplethe user has slid the keyboard out to expose it. Note thatdespite its name, this applied to any accessibility: keyboardor navigation. --><flag name="keyboardHidden" value="0x0020" /><!-- The navigation type has changed. Should never normally happen. --><flag name="navigation" value="0x0040" /><!-- The screen orientation has changed, that is the user hasrotated the device. --><flag name="orientation" value="0x0080" /><!-- The screen layout has changed. This might be caused by adifferent display being activated. --><flag name="screenLayout" value="0x0100" /><!-- The global user interface mode has changed. For example,going in or out of car mode, night mode changing, etc. --><flag name="uiMode" value="0x0200" /><!-- The current available screen size has changed. If applications don'ttarget at least {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}then the activity will always handle this itself (the changewill not result in a restart). This represents a change in thecurrently available size, so will change when the user switchesbetween landscape and portrait. --><flag name="screenSize" value="0x0400" /><!-- The physical screen size has changed. If applications don'ttarget at least {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}then the activity will always handle this itself (the changewill not result in a restart). This represents a change in sizeregardless of orientation, so will only change when the actualphysical screen size has changed such as switching to an externaldisplay. --><flag name="smallestScreenSize" value="0x0800" /><!-- The display density has changed. This might be caused by the userspecifying a different display scale, or it might be caused by adifferent display being activated. --><flag name="density" value="0x1000" /><!-- The layout direction has changed. For example going from LTR to RTL. --><flag name="layoutDirection" value="0x2000" /><!-- The color mode of the screen has changed (color gamut or dynamic range). --><flag name="colorMode" value="0x4000" /><!-- The grammatical gender has changed, for example the user set the grammatical genderfrom the UI. --><flag name="grammaticalGender" value="0x8000" /><!-- The font scaling factor has changed, that is the user hasselected a new global font size. --><flag name="fontScale" value="0x40000000" /><!-- The font weight adjustment value has changed. Used to reflect the user increasing fontweight. --><flag name="fontWeightAdjustment" value="0x10000000" /><!-- The assets paths have changed. For example a runtime overlay is installed and enabled.Corresponds to {@link android.content.pm.ActivityInfo#CONFIG_ASSETS_PATHS}. --><flag name="assetsPaths" value="0x80000000" /><!-- This is probably not the flag you want, the resources compiler supports a lessdangerous version of it, 'allKnown', that only suppresses all currently existingconfiguration change restarts depending on your target SDK rather than whatever thelatest SDK supports, allowing the application to work with resources on future Platformversions.Activity doesn't use Android Resources at all and doesn't need to be restarted on anyconfiguration changes. This overrides all other flags, and this is recommended to beused individually. Corresponds to{@link android.content.pm.ActivityInfo#CONFIG_RESOURCES_UNUSED}. --><flag name="resourcesUnused" value="0x8000000" /></attr>