Merge cherrypicks of ['googleplex-android-review.googlesource.com/31424959', 'googleplex-android-review.googlesource.com/31766493', 'googleplex-android-review.googlesource.com/31816463', 'googleplex-android-review.googlesource.com/31816479', 'googleplex-android-review.googlesource.com/32486993'] into 25Q1-release.
Change-Id: I760eb461a0bac6256b50a8a9f8d3e88f15dec224
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index ef200c3..2e09994 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -2358,8 +2358,13 @@
* @param locales The locale list. If null, an empty LocaleList will be assigned.
*/
public void setLocales(@Nullable LocaleList locales) {
+ LocaleList oldList = mLocaleList;
mLocaleList = locales == null ? LocaleList.getEmptyLocaleList() : locales;
locale = mLocaleList.get(0);
+ if (!mLocaleList.equals(oldList)) {
+ Slog.v(TAG, "Updating configuration, locales updated from " + oldList
+ + " to " + mLocaleList);
+ }
setLayoutDirection(locale);
}
diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java
index bcaceb2..0fb267e 100644
--- a/core/java/android/content/res/ResourcesImpl.java
+++ b/core/java/android/content/res/ResourcesImpl.java
@@ -491,6 +491,9 @@
}
defaultLocale =
adjustLanguageTag(lc.getDefaultLocale().toLanguageTag());
+ Slog.v(TAG, "Updating configuration, with default locale "
+ + defaultLocale + " and selected locales "
+ + Arrays.toString(selectedLocales));
} else {
String[] availableLocales;
// The LocaleList has changed. We must query the AssetManager's
@@ -526,6 +529,7 @@
for (int i = 0; i < locales.size(); i++) {
selectedLocales[i] = adjustLanguageTag(locales.get(i).toLanguageTag());
}
+ defaultLocale = adjustLanguageTag(lc.getDefaultLocale().toLanguageTag());
} else {
selectedLocales = new String[]{
adjustLanguageTag(locales.get(0).toLanguageTag())};
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
index 57bfc70..c90ebd9 100644
--- a/core/jni/android_util_AssetManager.cpp
+++ b/core/jni/android_util_AssetManager.cpp
@@ -409,19 +409,17 @@
configs.push_back(configuration);
}
- uint32_t default_locale_int = 0;
+ std::optional<ResTable_config> default_locale_opt;
if (default_locale != nullptr) {
- ResTable_config config;
- static_assert(std::is_same_v<decltype(config.locale), decltype(default_locale_int)>);
- ScopedUtfChars locale_utf8(env, default_locale);
- CHECK(locale_utf8.c_str() != nullptr);
- config.setBcp47Locale(locale_utf8.c_str());
- default_locale_int = config.locale;
+ ScopedUtfChars locale_utf8(env, default_locale);
+ CHECK(locale_utf8.c_str() != nullptr);
+ default_locale_opt.emplace();
+ default_locale_opt->setBcp47Locale(locale_utf8.c_str());
}
auto assetmanager = LockAndStartAssetManager(ptr);
assetmanager->SetConfigurations(std::move(configs), force_refresh != JNI_FALSE);
- assetmanager->SetDefaultLocale(default_locale_int);
+ assetmanager->SetDefaultLocale(default_locale_opt);
}
static jobject NativeGetAssignedPackageIdentifiers(JNIEnv* env, jclass /*clazz*/, jlong ptr,
diff --git a/core/res/res/values/config_telephony.xml b/core/res/res/values/config_telephony.xml
index 666f1cf..bddcd03 100644
--- a/core/res/res/values/config_telephony.xml
+++ b/core/res/res/values/config_telephony.xml
@@ -64,6 +64,13 @@
<integer name="auto_data_switch_performance_stability_time_threshold_millis">120000</integer>
<java-symbol type="integer" name="auto_data_switch_performance_stability_time_threshold_millis" />
+ <!-- Define the bar for switching data back to the default SIM when both SIMs are out of service
+ in milliseconds. A value of 0 means an immediate switch, otherwise for a negative value,
+ the threshold defined by auto_data_switch_availability_stability_time_threshold_millis
+ will be used instead. -->
+ <integer name="auto_data_switch_availability_switchback_stability_time_threshold_millis">150000</integer>
+ <java-symbol type="integer" name="auto_data_switch_availability_switchback_stability_time_threshold_millis" />
+
<!-- Define the maximum retry times when a validation for switching failed.-->
<integer name="auto_data_switch_validation_max_retry">7</integer>
<java-symbol type="integer" name="auto_data_switch_validation_max_retry" />
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java
index 4c7e477..4ded26f 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/embedding/SplitController.java
@@ -18,6 +18,7 @@
import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityOptions.KEY_LAUNCH_TASK_FRAGMENT_TOKEN;
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -3148,15 +3149,22 @@
final WindowContainerTransaction wct = transactionRecord.getTransaction();
final TaskFragmentContainer launchedInTaskFragment;
if (launchingActivity != null) {
- final int taskId = getTaskId(launchingActivity);
final String overlayTag = options.getString(KEY_OVERLAY_TAG);
if (Flags.activityEmbeddingOverlayPresentationFlag()
&& overlayTag != null) {
launchedInTaskFragment = createOrUpdateOverlayTaskFragmentIfNeeded(wct,
options, intent, launchingActivity);
} else {
- launchedInTaskFragment = resolveStartActivityIntent(wct, taskId, intent,
- launchingActivity);
+ final int taskId = getTaskId(launchingActivity);
+ if (taskId != INVALID_TASK_ID) {
+ launchedInTaskFragment = resolveStartActivityIntent(wct, taskId, intent,
+ launchingActivity);
+ } else {
+ // We cannot get a valid task id of launchingActivity so we fall back to
+ // treat it as a non-Activity context.
+ launchedInTaskFragment =
+ resolveStartActivityIntentFromNonActivityContext(wct, intent);
+ }
}
} else {
launchedInTaskFragment = resolveStartActivityIntentFromNonActivityContext(wct,
diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp
index 0fa31c7..4d83c9d 100644
--- a/libs/androidfw/AssetManager2.cpp
+++ b/libs/androidfw/AssetManager2.cpp
@@ -23,6 +23,7 @@
#include <map>
#include <set>
#include <span>
+#include <sstream>
#include <utility>
#include "android-base/logging.h"
@@ -438,6 +439,24 @@
return false;
}
+static std::string ConfigVecToString(std::span<const ResTable_config> configurations) {
+ std::stringstream ss;
+ ss << "[";
+ bool first = true;
+ for (const auto& config : configurations) {
+ if (!first) {
+ ss << ",";
+ }
+ char out[RESTABLE_MAX_LOCALE_LEN] = {};
+ config.getBcp47Locale(out);
+ ss << out;
+ first = false;
+ }
+ ss << "]";
+ return ss.str();
+}
+
+
void AssetManager2::SetConfigurations(std::span<const ResTable_config> configurations,
bool force_refresh) {
int diff = 0;
@@ -452,6 +471,17 @@
}
}
}
+
+ // Log the locale list change to investigate b/392255526
+ if (diff & ConfigDescription::CONFIG_LOCALE) {
+ auto oldstr = ConfigVecToString(configurations_);
+ auto newstr = ConfigVecToString(configurations);
+ if (oldstr != newstr) {
+ LOG(INFO) << "AssetManager2(" << this << ") locale list changing from "
+ << oldstr << " to " << newstr;
+ }
+ }
+
configurations_.clear();
for (auto&& config : configurations) {
configurations_.emplace_back(config);
@@ -462,6 +492,28 @@
}
}
+void AssetManager2::SetDefaultLocale(std::optional<ResTable_config> default_locale) {
+ int diff = 0;
+ if (default_locale_ && default_locale) {
+ diff = default_locale_->diff(default_locale.value());
+ } else if (default_locale_ || default_locale) {
+ diff = -1;
+ }
+ if (diff & ConfigDescription::CONFIG_LOCALE) {
+ char old_loc[RESTABLE_MAX_LOCALE_LEN] = {};
+ char new_loc[RESTABLE_MAX_LOCALE_LEN] = {};
+ if (default_locale_) {
+ default_locale_->getBcp47Locale(old_loc);
+ }
+ if (default_locale) {
+ default_locale->getBcp47Locale(new_loc);
+ }
+ LOG(INFO) << "AssetManager2(" << this << ") default locale changing from '"
+ << old_loc << "' to '" << new_loc << "'";
+ }
+ default_locale_ = default_locale;
+}
+
std::set<AssetManager2::ApkAssetsPtr> AssetManager2::GetNonSystemOverlays() const {
std::set<ApkAssetsPtr> non_system_overlays;
for (const PackageGroup& package_group : package_groups_) {
@@ -708,7 +760,7 @@
ConfigDescription best_frro_config;
Res_value best_frro_value;
bool frro_found = false;
- for( const auto& [config, value] : overlay_entry.GetInlineValue()) {
+ for (const auto& [config, value] : overlay_entry.GetInlineValue()) {
if ((!frro_found || config.isBetterThan(best_frro_config, desired_config))
&& config.match(*desired_config)) {
frro_found = true;
@@ -787,11 +839,11 @@
bool has_locale = false;
if (result->config.locale == 0) {
- if (default_locale_ != 0) {
- ResTable_config conf = {.locale = default_locale_};
- // Since we know conf has a locale and only a locale, match will tell us if that locale
- // matches
- has_locale = conf.match(config);
+ // The default_locale_ is the locale used for any resources with no locale in the config
+ if (default_locale_) {
+ // Since we know default_locale_ has a locale and only a locale, match will tell us if that
+ // locale matches
+ has_locale = default_locale_->match(config);
}
} else {
has_locale = true;
diff --git a/libs/androidfw/include/androidfw/AssetManager2.h b/libs/androidfw/include/androidfw/AssetManager2.h
index 0fdeefa..803399a 100644
--- a/libs/androidfw/include/androidfw/AssetManager2.h
+++ b/libs/androidfw/include/androidfw/AssetManager2.h
@@ -21,6 +21,7 @@
#include <array>
#include <limits>
+#include <optional>
#include <set>
#include <span>
#include <unordered_map>
@@ -167,9 +168,7 @@
return configurations_;
}
- inline void SetDefaultLocale(uint32_t default_locale) {
- default_locale_ = default_locale;
- }
+ void SetDefaultLocale(const std::optional<ResTable_config> default_locale);
// Returns all configurations for which there are resources defined, or an I/O error if reading
// resource data failed.
@@ -474,7 +473,7 @@
// without taking too much memory.
std::array<uint8_t, std::numeric_limits<uint8_t>::max() + 1> package_ids_ = {};
- uint32_t default_locale_ = 0;
+ std::optional<ResTable_config> default_locale_;
// The current configurations set for this AssetManager. When this changes, cached resources
// may need to be purged.