diff options
| author | 2020-10-21 09:56:45 +0000 | |
|---|---|---|
| committer | 2020-10-21 09:56:45 +0000 | |
| commit | 7fbdf711d9c1ccd413976c160858870f7808f338 (patch) | |
| tree | dd46bce967bcdfc98f2a52e3b713f7f2bbdedd30 | |
| parent | df3eb6cff27a1a17c093d9e7ea27c0de7521a9b8 (diff) | |
| parent | c34b1748feb1e679480dbbc19c43941e8c42d7da (diff) | |
Merge "Use public API of Settings.Secure to get/put secure settings" am: d7203652f7 am: dbb2d21bbb am: 93d09dde3a am: c34b1748fe
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1463904
Change-Id: I17de63457259f7791916e4a1ff5575124784ae4a
| -rw-r--r-- | services/core/java/com/android/server/connectivity/Vpn.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 1ed6b35341b8..e2187932b3e6 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -38,6 +38,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ComponentName; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -1976,28 +1977,33 @@ public class Vpn { * @see Settings.Secure#putStringForUser */ public void settingsSecurePutStringForUser(String key, String value, int userId) { - Settings.Secure.putStringForUser(mContext.getContentResolver(), key, value, userId); + Settings.Secure.putString(getContentResolverAsUser(userId), key, value); } /** * @see Settings.Secure#putIntForUser */ public void settingsSecurePutIntForUser(String key, int value, int userId) { - Settings.Secure.putIntForUser(mContext.getContentResolver(), key, value, userId); + Settings.Secure.putInt(getContentResolverAsUser(userId), key, value); } /** * @see Settings.Secure#getStringForUser */ public String settingsSecureGetStringForUser(String key, int userId) { - return Settings.Secure.getStringForUser(mContext.getContentResolver(), key, userId); + return Settings.Secure.getString(getContentResolverAsUser(userId), key); } /** * @see Settings.Secure#getIntForUser */ public int settingsSecureGetIntForUser(String key, int def, int userId) { - return Settings.Secure.getIntForUser(mContext.getContentResolver(), key, def, userId); + return Settings.Secure.getInt(getContentResolverAsUser(userId), key, def); + } + + private ContentResolver getContentResolverAsUser(int userId) { + return mContext.createContextAsUser( + UserHandle.of(userId), 0 /* flags */).getContentResolver(); } public boolean isCallerSystem() { |