Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e9ac20d authored by Alexandra Gherghina's avatar Alexandra Gherghina
Browse files

Do Not Merge Per-user API for master sync

Change-Id: I6a8088eb3bfddae4c8e38904dd26baf3c7c09c9e
(cherry picked from commit 222aea8bd997807784dc99ca53f63280d384fdf0)
parent b192a176
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -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);
+7 −1
Original line number Diff line number Diff line
@@ -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();