Fix path traversal and missing ownership check in LocaleManagerService

The getOverrideLocaleConfig method in LocaleManagerService lacked an ownership
check, allowing unauthorized cross-package and cross-user disclosure of
app-specific locale configurations. Additionally, the packageName parameter was
used to construct a file path without proper validation, enabling path traversal
attacks.

This change adds the missing ownership and permission checks, ensuring that
only the app owner, installer, or apps with the READ_APP_SPECIFIC_LOCALES
permission can access the configuration. It also validates that the constructed
file path remains within the intended directory to prevent path traversal, and logs blocked attempts to SafetyNet.

Bug: 495409704
Test: atest LocaleManagerServiceTest and manual test
Flag: EXEMPT BUGFIX

TAG=agy
CONV=1df5aed4-e067-499d-af15-55319a43c2f4
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:e4c79ddf98cb8874e2ed6dadc05712fc4be38d29
Merged-In: I9a342686e569f529bb37d9c19eebbceb60f6aa9d
Change-Id: I9a342686e569f529bb37d9c19eebbceb60f6aa9d
2 files changed