summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/content
diff options
context:
space:
mode:
authorAlexandra Gherghina <alexgherghina@google.com>2014-07-01 15:14:11 +0100
committerAlexandra Gherghina <alexgherghina@google.com>2014-07-02 13:34:14 +0100
commitcb22807ffcf79db1b62162842d0a90251a463ea7 (patch)
tree6316e0bf5616af22f59485e3cc52ede6408864b2 /services/core/java/com/android/server/content
parentf29131f7013dc0d6994556b95e74db608c89beb8 (diff)
downloadframeworks_base-cb22807ffcf79db1b62162842d0a90251a463ea7.zip
frameworks_base-cb22807ffcf79db1b62162842d0a90251a463ea7.tar.gz
frameworks_base-cb22807ffcf79db1b62162842d0a90251a463ea7.tar.bz2
Adds per-user APIs required by the Settings app
Bug: 15466880 Change-Id: Ic99fbf074564901b04d32b08f3a7a38555f330b3
Diffstat (limited to 'services/core/java/com/android/server/content')
-rw-r--r--services/core/java/com/android/server/content/ContentService.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java
index a6485e9..1279c6e 100644
--- a/services/core/java/com/android/server/content/ContentService.java
+++ b/services/core/java/com/android/server/content/ContentService.java
@@ -537,19 +537,26 @@ public final class ContentService extends IContentService.Stub {
@Override
public void setSyncAutomatically(Account account, String providerName, boolean sync) {
+ setSyncAutomaticallyAsUser(account, providerName, sync, UserHandle.getCallingUserId());
+ }
+
+ @Override
+ public void setSyncAutomaticallyAsUser(Account account, String providerName, boolean sync,
+ int userId) {
if (TextUtils.isEmpty(providerName)) {
throw new IllegalArgumentException("Authority must be non-empty");
}
mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
"no permission to write the sync settings");
+ enforceCrossUserPermission(userId,
+ "no permission to modify the sync settings for user " + userId);
- int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
try {
SyncManager syncManager = getSyncManager();
if (syncManager != null) {
- syncManager.getSyncStorageEngine()
- .setSyncAutomatically(account, userId, providerName, sync);
+ syncManager.getSyncStorageEngine().setSyncAutomatically(account, userId,
+ providerName, sync);
}
} finally {
restoreCallingIdentity(identityToken);
@@ -806,11 +813,17 @@ public final class ContentService extends IContentService.Stub {
}
public boolean isSyncPending(Account account, String authority, ComponentName cname) {
+ return isSyncPendingAsUser(account, authority, cname, UserHandle.getCallingUserId());
+ }
+
+ @Override
+ public boolean isSyncPendingAsUser(Account account, String authority, ComponentName cname,
+ int userId) {
mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
"no permission to read the sync stats");
-
+ enforceCrossUserPermission(userId,
+ "no permission to retrieve the sync settings for user " + userId);
int callerUid = Binder.getCallingUid();
- int userId = UserHandle.getCallingUserId();
long identityToken = clearCallingIdentity();
SyncManager syncManager = getSyncManager();
if (syncManager == null) return false;