diff options
| author | Christopher Tate <ctate@google.com> | 2012-10-05 14:46:01 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-05 14:46:01 -0700 |
| commit | d0f199308e5d040bf0a968114578d620fb6a9f61 (patch) | |
| tree | f7ed974bc9b75bdf622241a43af02fb4a8ddd344 /packages/SettingsProvider/src | |
| parent | 7ef38ea9e5ee1d2fd58e818f37191a589793e236 (diff) | |
| parent | 61695ffcbccc6cca210e869eb3bc6e97127c2357 (diff) | |
| download | frameworks_base-d0f199308e5d040bf0a968114578d620fb6a9f61.zip frameworks_base-d0f199308e5d040bf0a968114578d620fb6a9f61.tar.gz frameworks_base-d0f199308e5d040bf0a968114578d620fb6a9f61.tar.bz2 | |
Merge "Make sure settings writes are permission checked correctly" into jb-mr1-dev
Diffstat (limited to 'packages/SettingsProvider/src')
| -rw-r--r-- | packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java index 76a5022..8086bbc 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java @@ -556,59 +556,52 @@ public class SettingsProvider extends ContentProvider { } } - // Okay, permission checks have cleared. Reset to our own identity so we can - // manipulate all users' data with impunity. - long oldId = Binder.clearCallingIdentity(); - try { - // Note: we assume that get/put operations for moved-to-global names have already - // been directed to the new location on the caller side (otherwise we'd fix them - // up here). - DatabaseHelper dbHelper; - SettingsCache cache; - - // Get methods - if (Settings.CALL_METHOD_GET_SYSTEM.equals(method)) { - if (LOCAL_LOGV) Slog.v(TAG, "call(system:" + request + ") for " + callingUser); - dbHelper = getOrEstablishDatabase(callingUser); - cache = sSystemCaches.get(callingUser); - return lookupValue(dbHelper, TABLE_SYSTEM, cache, request); - } - if (Settings.CALL_METHOD_GET_SECURE.equals(method)) { - if (LOCAL_LOGV) Slog.v(TAG, "call(secure:" + request + ") for " + callingUser); - dbHelper = getOrEstablishDatabase(callingUser); - cache = sSecureCaches.get(callingUser); - return lookupValue(dbHelper, TABLE_SECURE, cache, request); - } - if (Settings.CALL_METHOD_GET_GLOBAL.equals(method)) { - if (LOCAL_LOGV) Slog.v(TAG, "call(global:" + request + ") for " + callingUser); - // fast path: owner db & cache are immutable after onCreate() so we need not - // guard on the attempt to look them up - return lookupValue(getOrEstablishDatabase(UserHandle.USER_OWNER), TABLE_GLOBAL, - sGlobalCache, request); - } + // Note: we assume that get/put operations for moved-to-global names have already + // been directed to the new location on the caller side (otherwise we'd fix them + // up here). + DatabaseHelper dbHelper; + SettingsCache cache; + + // Get methods + if (Settings.CALL_METHOD_GET_SYSTEM.equals(method)) { + if (LOCAL_LOGV) Slog.v(TAG, "call(system:" + request + ") for " + callingUser); + dbHelper = getOrEstablishDatabase(callingUser); + cache = sSystemCaches.get(callingUser); + return lookupValue(dbHelper, TABLE_SYSTEM, cache, request); + } + if (Settings.CALL_METHOD_GET_SECURE.equals(method)) { + if (LOCAL_LOGV) Slog.v(TAG, "call(secure:" + request + ") for " + callingUser); + dbHelper = getOrEstablishDatabase(callingUser); + cache = sSecureCaches.get(callingUser); + return lookupValue(dbHelper, TABLE_SECURE, cache, request); + } + if (Settings.CALL_METHOD_GET_GLOBAL.equals(method)) { + if (LOCAL_LOGV) Slog.v(TAG, "call(global:" + request + ") for " + callingUser); + // fast path: owner db & cache are immutable after onCreate() so we need not + // guard on the attempt to look them up + return lookupValue(getOrEstablishDatabase(UserHandle.USER_OWNER), TABLE_GLOBAL, + sGlobalCache, request); + } - // Put methods - new value is in the args bundle under the key named by - // the Settings.NameValueTable.VALUE static. - final String newValue = (args == null) - ? null : args.getString(Settings.NameValueTable.VALUE); - - final ContentValues values = new ContentValues(); - values.put(Settings.NameValueTable.NAME, request); - values.put(Settings.NameValueTable.VALUE, newValue); - if (Settings.CALL_METHOD_PUT_SYSTEM.equals(method)) { - if (LOCAL_LOGV) Slog.v(TAG, "call_put(system:" + request + "=" + newValue + ") for " + callingUser); - insertForUser(Settings.System.CONTENT_URI, values, callingUser); - } else if (Settings.CALL_METHOD_PUT_SECURE.equals(method)) { - if (LOCAL_LOGV) Slog.v(TAG, "call_put(secure:" + request + "=" + newValue + ") for " + callingUser); - insertForUser(Settings.Secure.CONTENT_URI, values, callingUser); - } else if (Settings.CALL_METHOD_PUT_GLOBAL.equals(method)) { - if (LOCAL_LOGV) Slog.v(TAG, "call_put(global:" + request + "=" + newValue + ") for " + callingUser); - insertForUser(Settings.Global.CONTENT_URI, values, callingUser); - } else { - Slog.w(TAG, "call() with invalid method: " + method); - } - } finally { - Binder.restoreCallingIdentity(oldId); + // Put methods - new value is in the args bundle under the key named by + // the Settings.NameValueTable.VALUE static. + final String newValue = (args == null) + ? null : args.getString(Settings.NameValueTable.VALUE); + + final ContentValues values = new ContentValues(); + values.put(Settings.NameValueTable.NAME, request); + values.put(Settings.NameValueTable.VALUE, newValue); + if (Settings.CALL_METHOD_PUT_SYSTEM.equals(method)) { + if (LOCAL_LOGV) Slog.v(TAG, "call_put(system:" + request + "=" + newValue + ") for " + callingUser); + insertForUser(Settings.System.CONTENT_URI, values, callingUser); + } else if (Settings.CALL_METHOD_PUT_SECURE.equals(method)) { + if (LOCAL_LOGV) Slog.v(TAG, "call_put(secure:" + request + "=" + newValue + ") for " + callingUser); + insertForUser(Settings.Secure.CONTENT_URI, values, callingUser); + } else if (Settings.CALL_METHOD_PUT_GLOBAL.equals(method)) { + if (LOCAL_LOGV) Slog.v(TAG, "call_put(global:" + request + "=" + newValue + ") for " + callingUser); + insertForUser(Settings.Global.CONTENT_URI, values, callingUser); + } else { + Slog.w(TAG, "call() with invalid method: " + method); } return null; |
