Fix crash in getOverrideLocaleConfig when package is not found
When getOverrideLocaleConfig is called for a package that is not installed
for the target user, it previously threw an IllegalArgumentException because
isPackageOwnedByCaller checked the package UID and threw if it was < 0.
This caused crashes in Settings (which calls getOverrideLocaleConfig via
LocaleConfig constructor to check if apps support locales) when it queried
packages that were not installed in the current user profile (e.g. test packages
only installed in user 0 but queried in user 10).
This change adds a package existence check at the beginning of
getOverrideLocaleConfig, returning null immediately if the package is not found,
restoring the previous behavior and preventing crashes.
Bug: 495409704
Bug: 529474515
Test: atest FrameworksServicesTests:LocaleManagerServiceTest
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:0b14d40e2f7cb84add09163976f7cbb45e1d3b7a
Merged-In: I12dea12f5dc790edb45091bc3eaca59748f3b273
Change-Id: I12dea12f5dc790edb45091bc3eaca59748f3b273
2 files changed