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();
    }


相关推荐
骐骥143 分钟前
2025-09-08升级问题记录:app提示“此应用专为旧版Android打造..”或“此应用与最新版 Android 不兼容”
android·升级·不兼容·target sdk·专为旧版 android 系统
Zender Han1 小时前
Flutter 视频播放器——flick_video_player 介绍与使用
android·flutter·ios·音视频
尚久龙2 小时前
安卓学习 之 用户登录界面的简单实现
android·运维·服务器·学习·手机·android studio·安卓
Modu_MrLiu2 小时前
Android实战进阶 - 启动页
android·实战进阶·启动页·倒计时场景
出门吃三碗饭3 小时前
编译器构造:从零手写汇编与反汇编程序(一)
android·汇编
Just_Paranoid4 小时前
【WorkManager】无法在 Direct Boot 模式下初始化
android·jetpack·usermanager·workmanager·directboot
前端小超超4 小时前
如何配置capacitor 打包的安卓app固定竖屏展示?
android·前端·gitee
顾林海4 小时前
探秘Android JVM TI:虚拟机背后的"隐形管家"
android·面试·性能优化
刘大国5 小时前
<android>反编译魔改安卓系统应用并替换
android
恋猫de小郭6 小时前
Flutter Riverpod 3.0 发布,大规模重构下的全新状态管理框架
android·前端·flutter