summaryrefslogtreecommitdiffstats
path: root/core/java/android/provider
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2012-10-02 13:14:11 -0700
committerVictoria Lease <violets@google.com>2012-10-08 17:19:43 -0700
commitb711d57ca4e2c6a1befbfa1a41f4b8094755a93f (patch)
treed4b9ae528636f2b4b61fa4c97ae5b6b0ee29c823 /core/java/android/provider
parentbb5f014ae805f166328d72cbf826e8f1f17c9daf (diff)
downloadframeworks_base-b711d57ca4e2c6a1befbfa1a41f4b8094755a93f.zip
frameworks_base-b711d57ca4e2c6a1befbfa1a41f4b8094755a93f.tar.gz
frameworks_base-b711d57ca4e2c6a1befbfa1a41f4b8094755a93f.tar.bz2
Multiuser love for LocationManager
LocationManagerService now keeps track of the current user ID and denies location requests made by all but the foreground user. Additionally, location settings are now user-specific, rather than global to the device. Location provider services now run as specific users, and when the device's foreground user changes, we rebind to appropriately-owned providers. Bug: 6926385 Bug: 7247203 Change-Id: I346074959e96e52bcc77eeb188dffe322b690879
Diffstat (limited to 'core/java/android/provider')
-rw-r--r--core/java/android/provider/Settings.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 3bbdf36..91c6db5 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -4052,7 +4052,20 @@ public final class Settings {
* @return true if the provider is enabled
*/
public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) {
- String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED);
+ return isLocationProviderEnabledForUser(cr, provider, UserHandle.myUserId());
+ }
+
+ /**
+ * Helper method for determining if a location provider is enabled.
+ * @param cr the content resolver to use
+ * @param provider the location provider to query
+ * @param userId the userId to query
+ * @return true if the provider is enabled
+ * @hide
+ */
+ public static final boolean isLocationProviderEnabledForUser(ContentResolver cr, String provider, int userId) {
+ String allowedProviders = Settings.Secure.getStringForUser(cr,
+ LOCATION_PROVIDERS_ALLOWED, userId);
return TextUtils.delimitedStringContains(allowedProviders, ',', provider);
}
@@ -4064,6 +4077,19 @@ public final class Settings {
*/
public static final void setLocationProviderEnabled(ContentResolver cr,
String provider, boolean enabled) {
+ setLocationProviderEnabledForUser(cr, provider, enabled, UserHandle.myUserId());
+ }
+
+ /**
+ * Thread-safe method for enabling or disabling a single location provider.
+ * @param cr the content resolver to use
+ * @param provider the location provider to enable or disable
+ * @param enabled true if the provider should be enabled
+ * @param userId the userId for which to enable/disable providers
+ * @hide
+ */
+ public static final void setLocationProviderEnabledForUser(ContentResolver cr,
+ String provider, boolean enabled, int userId) {
// to ensure thread safety, we write the provider name with a '+' or '-'
// and let the SettingsProvider handle it rather than reading and modifying
// the list of enabled providers.
@@ -4072,7 +4098,8 @@ public final class Settings {
} else {
provider = "-" + provider;
}
- putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider);
+ putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider,
+ userId);
}
}