CMSettings: Enforce correct permission for writing settings
If an application is writing to SECURE or GLOBAL they should only be required to hold the WRITE_SECURE_SETTINGS permission and not both. Change-Id: Ife14b5e19340f04e2e3b7ebba121104253d1dc88
This commit is contained in:
parent
cdf4d0d699
commit
e67ae8f648
@ -316,12 +316,10 @@ public class CMSettingsProvider extends ContentProvider {
|
||||
|
||||
// Framework can't do automatic permission checking for calls, so we need
|
||||
// to do it here.
|
||||
if (getContext().checkCallingOrSelfPermission(
|
||||
cyanogenmod.platform.Manifest.permission.WRITE_SETTINGS) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException(
|
||||
String.format("Permission denial: writing to settings requires %1$s",
|
||||
cyanogenmod.platform.Manifest.permission.WRITE_SETTINGS));
|
||||
if (CMSettings.CALL_METHOD_PUT_SYSTEM.equals(method)) {
|
||||
enforceWritePermission(cyanogenmod.platform.Manifest.permission.WRITE_SETTINGS);
|
||||
} else {
|
||||
enforceWritePermission(cyanogenmod.platform.Manifest.permission.WRITE_SECURE_SETTINGS);
|
||||
}
|
||||
|
||||
// Put methods
|
||||
@ -342,6 +340,15 @@ public class CMSettingsProvider extends ContentProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void enforceWritePermission(String permission) {
|
||||
if (getContext().checkCallingOrSelfPermission(permission)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException(
|
||||
String.format("Permission denial: writing to settings requires %s",
|
||||
permission));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a single value for a specific user, uri, and key.
|
||||
* @param userId The id of the user to perform the lookup for.
|
||||
|
Loading…
Reference in New Issue
Block a user