summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/ContentResolver.java10
-rw-r--r--core/java/android/content/IContentService.aidl1
-rw-r--r--services/core/java/com/android/server/content/ContentService.java8
3 files changed, 17 insertions, 2 deletions
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java
index de3b881..87d14b9 100644
--- a/core/java/android/content/ContentResolver.java
+++ b/core/java/android/content/ContentResolver.java
@@ -2153,8 +2153,16 @@ public abstract class ContentResolver {
* @param sync the master auto-sync setting that applies to all the providers and accounts
*/
public static void setMasterSyncAutomatically(boolean sync) {
+ setMasterSyncAutomaticallyAsUser(sync, UserHandle.getCallingUserId());
+ }
+
+ /**
+ * @see #setMasterSyncAutomatically(boolean)
+ * @hide
+ */
+ public static void setMasterSyncAutomaticallyAsUser(boolean sync, int userId) {
try {
- getContentService().setMasterSyncAutomatically(sync);
+ getContentService().setMasterSyncAutomaticallyAsUser(sync, userId);
} catch (RemoteException e) {
// exception ignored; if this is thrown then it means the runtime is in the midst of
// being restarted
diff --git a/core/java/android/content/IContentService.aidl b/core/java/android/content/IContentService.aidl
index d363ad1..9998f08 100644
--- a/core/java/android/content/IContentService.aidl
+++ b/core/java/android/content/IContentService.aidl
@@ -128,6 +128,7 @@ interface IContentService {
void setIsSyncable(in Account account, String providerName, int syncable);
void setMasterSyncAutomatically(boolean flag);
+ void setMasterSyncAutomaticallyAsUser(boolean flag, int userId);
boolean getMasterSyncAutomatically();
boolean getMasterSyncAutomaticallyAsUser(int userId);
diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java
index 1279c6e..64d3dc5 100644
--- a/services/core/java/com/android/server/content/ContentService.java
+++ b/services/core/java/com/android/server/content/ContentService.java
@@ -719,10 +719,16 @@ public final class ContentService extends IContentService.Stub {
@Override
public void setMasterSyncAutomatically(boolean flag) {
+ setMasterSyncAutomaticallyAsUser(flag, UserHandle.getCallingUserId());
+ }
+
+ @Override
+ public void setMasterSyncAutomaticallyAsUser(boolean flag, int userId) {
+ enforceCrossUserPermission(userId,
+ "no permission to set the sync status for user " + userId);
mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
"no permission to write the sync settings");
- int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
try {
SyncManager syncManager = getSyncManager();