Android R: updateConfiguration()的relaunch App流程

本文详细解析了Android系统中updateConfiguration()函数用于切换系统语言更新配置的过程,涉及ActivityManager、ActivityTaskManagerService及ActivityRecord等多个组件的交互。当配置变更时,系统不仅更新全局配置,还可能重新启动活动以匹配新的配置。更新过程包括获取配置、设置用户选择的语言、更新持久化配置,并确保活动与最新配置一致。

updateConfiguration()的relaunch App流程

在这里插入代码片
切换系统语言更新Configuration
frameworks/base/core/java/com/android/internal/app/LocalePicker.java
public static void updateLocales(LocaleList locales) {
   
   
    try {
   
   
        IActivityManager am = ActivityManager.getService();
        Configuration config = am.getConfiguration();
        config.setLocales(locales);
        config.userSetLocale = true;
        am.updatePersistentConfiguration(config);
        BackupManager.dataChanged("com.android.providers.settings");
    } catch (RemoteException var3) {
   
   
    }

} 
->
IActivityTaskManager.aidl
389      /**
390       * Updates global configuration and applies changes to the entire system.
391       * @param values Update values for global configuration. If null is passed it will request the
392       *               Window Manager to compute new config for the default display.
393       * @throws RemoteException
394       * @return Returns true if the configuration was updated.
395       */
396      boolean updateConfiguration(in Configuration values);
->
ActivityTaskManagerService.java
4833      @Override
4834      public boolean updateConfiguration(Configuration values) {
   
   
4835          mAmInternal.enforceCallingPermission(CHANGE_CONFIGURATION, "updateConfiguration()");
4836  
4837          synchronized (mGlobalLock) {
   
   
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值