Ensure there is at least one locale in the Configuration object
When there is no intersection between the system locales and the
app-supported locales defined in the LocaleConfig, the locales in the
Configuration object are set to an empty LocaleList, which can trigger a
crash (NullPointerException) in the app and possibly in system_server or
systemui in some cases.
This fixes that issue by falling back in that case to the previous
behavior (before the improved resource multi-locale support) of
selecting the best matching locale available in the app (if any), or the
first system locale.
Additionally:
- Renamed `calcConfigChanges` to `applyConfigChanges` because it applies the new configuration in addition to calculating the changes.
- Added more comments to explain the locale selection logic.
Bug: 400163083
Test: Manually on Pixel 6 Pro with repro steps in b/400163083#comment18
Flag: EXEMPT bugfix
Change-Id: I3f525b44f89589d521b3d3408a976b11b1cfe064
3 files changed