diff options
| author | 2020-10-21 08:43:37 +0000 | |
|---|---|---|
| committer | 2020-10-21 08:43:37 +0000 | |
| commit | dbb2d21bbb747da9e9bd9d5a1d1c65f6b19f8b0c (patch) | |
| tree | 94ca1ba1235208dd9786ed943170ec8972205012 | |
| parent | bafa575166c5089b51744f251b50ec10833896a8 (diff) | |
| parent | d7203652f7d86118c0d3cf6bfd11d56148dd2298 (diff) | |
Merge "Use public API of Settings.Secure to get/put secure settings" am: d7203652f7
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1463904
Change-Id: Ic681954e4daf5242ef5cc5f02fb48f080e57d533
| -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 d3abe871b80e..35f9e2fae688 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() { |