Allow system services to get/set app-locales.

As of now, the LocaleManagerService uses enforceCallingPermission to
check for the required permissions before accessing / modifying the
app-locales.

Because of this, other system services are unable to pass
the permission check since they are running with the same pid as LMS.
We want to allow the backup service and settings to get / set app
locales.

enforceCallingOrSelfPermission allows apps / services with the same
pid as the system server to fetch / write app-locales. This is a
common practice among the system services.

Bug: 203649239
Test: Manually tested with the backup service
Change-Id: Iff96b2c8d97066c2521e923195eb02cf21200714
This commit is contained in:
Nishant Kumar Singh
2021-10-20 13:33:45 +00:00
parent 9527c42843
commit 71c59893f6

View File

@@ -175,7 +175,7 @@ public class LocaleManagerService extends SystemService {
}
private void enforceChangeConfigurationPermission() {
mContext.enforceCallingPermission(
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.CHANGE_CONFIGURATION, "setApplicationLocales");
}
@@ -231,7 +231,7 @@ public class LocaleManagerService extends SystemService {
}
private void enforceReadAppSpecificLocalesPermission() {
mContext.enforceCallingPermission(
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.READ_APP_SPECIFIC_LOCALES,
"getApplicationLocales");
}