From d9bc801301acdf24fda7ff043da35f70631948b1 Mon Sep 17 00:00:00 2001 From: Chris Antol Date: Mon, 10 Apr 2023 18:08:37 +0000 Subject: [PATCH] Only override embedded activity locale if source package lookup yields locales to match Calling Configuration#setLocales also sets the text direction for the containing Activity. If we pass an empty LocaleList to this method, then we lose the intended text direction for its locale. So this change will only override the target (embedded) Activity's locales if our package lookup for the host yields a populated LocaleList to provide. Bug: 277363604 Test: Verified on Pixel devices in Settings app Change-Id: I8bcdab0737c18f861f74a8f9bd2d15043359e27b --- .../java/com/android/server/wm/ActivityRecord.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 0b98495c8e992..2a8a4f4eaf018 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -306,7 +306,6 @@ import android.os.Bundle; import android.os.Debug; import android.os.IBinder; import android.os.IRemoteCallback; -import android.os.LocaleList; import android.os.PersistableBundle; import android.os.Process; import android.os.RemoteCallbackList; @@ -10597,17 +10596,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return; } - LocaleList locale; final ActivityTaskManagerInternal.PackageConfig appConfig = mAtmService.mPackageConfigPersister.findPackageConfiguration( task.realActivity.getPackageName(), mUserId); - // if there is no app locale for the package, clear the target activity's locale. - if (appConfig == null || appConfig.mLocales == null || appConfig.mLocales.isEmpty()) { - locale = LocaleList.getEmptyLocaleList(); - } else { - locale = appConfig.mLocales; + // If package lookup yields locales, set the target activity's locales to match, + // otherwise leave target activity as-is. + if (appConfig != null && appConfig.mLocales != null && !appConfig.mLocales.isEmpty()) { + resolvedConfig.setLocales(appConfig.mLocales); } - resolvedConfig.setLocales(locale); } /**