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) {

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

被折叠的 条评论
为什么被折叠?



