Android Configuration相关问题如何定位分析(中英文切换、黑夜白天模式等)

Android Configuration相关问题如何定位分析(中英文切换、黑夜白天模式等).

Configuration的常见问题场景:

  • app的size position不正确
  • 中英文显示不正确
  • 白天黑夜模式不正确

Configuration信息如下:

复制代码
mFullConfiguration={1.0 ?mcc?mnc [en_GB] ldltr sw960dp w1707dp h795dp 240dpi xlrg long land car finger -keyb/v/h -nav/h 
	 	winConfig={ mBounds=Rect(0, 0 - 2560, 1440) mAppBounds=Rect(0, 0 - 2560, 1312) 
		mMaxBounds=Rect(0, 0 - 2560, 1440) mDisplayRotation=ROTATION_0 
		mWindowingMode=fullscreen mDisplayWindowingMode=fullscreen mActivityType=undefined 
		mAlwaysOnTop=undefined mRotation=ROTATION_0} s.767 fontWeightAdjustment=0}

本文重点讲解Configuration问题的分析手段,并结合真实案例进行定位分析。

1. 问题描述

前置条件:车辆电源模式为ON

操作步骤:

1.语言模式切换英文,查看界面显示

  1. 重启车机

预期结果:1.界面显示英文

实际结果:1.语言模式显示中文,界面显示英文

2.分析过程以及常用的debug手段

(1) adb shell dumpsys window w > ws.log

从dump WMS可以看出,系统侧的configuration是英文,也就是正常的,但是app侧确实中文,那么说明是app侧的问题。

(2)config debug如何开启config log:定位系统侧问题的手段

1. ActivityThread.java

public static final boolean DEBUG_CONFIGURATION = true;

2. WindowManagerDebugConfig.java

static final boolean DEBUG_CONFIGURATION = true;

(3)分析app调用的接口,然后针对性的在framewrok加log和堆栈信息debug:定位app侧问题的手段

Resources.java

java 复制代码
    /**
     * Return the current configuration that is in effect for this resource 
     * object.  The returned object should be treated as read-only.
     * 
     * @return The resource's current configuration. 
     */
    public Configuration getConfiguration() {
        Log.w("config200", "Resources, getConfiguration " + mResourcesImpl.getConfiguration());
        if (mResourcesImpl.getConfiguration() != null && mResourcesImpl.getConfiguration().toString().contains("zh_CN]")) {
            Log.w("config200", "Resources, getConfiguration ", new Throwable("xxxx"));
        }
        return mResourcesImpl.getConfiguration();
    }


相关推荐
xiaoshiquan12065 小时前
Gradle 复合构建:宿主项目直接依赖 SDK 源码模块的配置实践
android
南山电子nscn6 小时前
中科芯CETC汽车电池管理系统BMS进口芯片国产型号替代指南
单片机·汽车·bms
小师兄吃牛肉8 小时前
Android Studio 2025 专业介绍:新特性、性能与开发体验全面解析
android·ide·android studio
美摄科技8 小时前
安卓离线类美颜特效SDK
android
fengci.9 小时前
BUUCTF(困难部分)
android·开发语言·前端·学习·php
MIXrer11 小时前
亲子乐园上什么新项目?沙盘赛车体验馆比传统电玩更能带复购
汽车·娱乐
传奇开心果11 小时前
【Compose Multiplatform跨端声明式UI实用技术】第9课:跨平台 ViewModel 与状态架构
android·kotlin
用户693717500138411 小时前
当你向领导申请 AI 编程工具预算时,如果领导追问“能提效多少,有量化数据吗”,你该怎么回答?
android·后端·ios
workflower12 小时前
无人机注册量与飞行量
大数据·网络·人工智能·云计算·汽车·无人机
开开心心_Every12 小时前
免费压缩软件WinRAR无弹窗、广告干扰
java·开发语言·前端·spring·智能手机·word·winrar