Loading services/java/com/android/server/content/ContentService.java +6 −5 Original line number Diff line number Diff line Loading @@ -630,16 +630,16 @@ public final class ContentService extends IContentService.Stub { public void setServiceActive(ComponentName cname, boolean active) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "setIsEnabled"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "setServiceActive"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { int syncable = active ? 1 : 0; syncManager.getSyncStorageEngine().setIsEnabled( cname, userId, syncable); syncManager.getSyncStorageEngine().setIsTargetServiceActive( cname, userId, active); } } finally { restoreCallingIdentity(identityToken); Loading @@ -656,7 +656,8 @@ public final class ContentService extends IContentService.Stub { try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { return (syncManager.getIsTargetServiceActive(cname, userId) == 1); return syncManager.getSyncStorageEngine() .getIsTargetServiceActive(cname, userId); } } finally { restoreCallingIdentity(identityToken); Loading services/java/com/android/server/content/SyncManager.java +6 −13 Original line number Diff line number Diff line Loading @@ -523,14 +523,6 @@ public class SyncManager { } } /** * TODO: Decide if restricted users have different sync options for the sync service (as is * the case with sync adapters). */ public int getIsTargetServiceActive(ComponentName cname, int userId) { return mSyncStorageEngine.getIsTargetServiceActive(cname, userId); } private void ensureAlarmService() { if (mAlarmService == null) { mAlarmService = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); Loading Loading @@ -564,7 +556,7 @@ public class SyncManager { final boolean ignoreSettings = extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, false); int source = SyncStorageEngine.SOURCE_SERVICE; int isEnabled = getIsTargetServiceActive(cname, userId); boolean isEnabled = mSyncStorageEngine.getIsTargetServiceActive(cname, userId); // Only schedule this sync if // - we've explicitly been told to ignore settings. // - global sync is enabled for this user. Loading @@ -577,7 +569,7 @@ public class SyncManager { } return; } if (isEnabled == 0) { if (isEnabled) { if (isLoggable) { Log.d(TAG, "scheduleSync: " + cname + " is not enabled, dropping request"); } Loading @@ -587,7 +579,7 @@ public class SyncManager { Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(info); long delayUntil = mSyncStorageEngine.getDelayUntilTime(info); final long backoffTime = backoff != null ? backoff.first : 0; if (isEnabled < 0) { if (isEnabled) { // Initialisation sync. Bundle newExtras = new Bundle(); newExtras.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true); Loading Loading @@ -2144,7 +2136,7 @@ public class SyncManager { return false; } } else if (target.target_service) { if (getIsTargetServiceActive(target.service, target.userId) == 0) { if (mSyncStorageEngine.getIsTargetServiceActive(target.service, target.userId)) { if (isLoggable) { Log.v(TAG, " Not scheduling periodic operation: isEnabled == 0."); } Loading Loading @@ -2548,7 +2540,8 @@ public class SyncManager { return false; } } else if (target.target_service) { state = getIsTargetServiceActive(target.service, target.userId); state = mSyncStorageEngine.getIsTargetServiceActive(target.service, target.userId) ? 1 : 0; if (state == 0) { // TODO: Change this to not drop disabled syncs - keep them in the pending queue. if (isLoggable) { Loading services/java/com/android/server/content/SyncStorageEngine.java +28 −37 Original line number Diff line number Diff line Loading @@ -696,47 +696,38 @@ public class SyncStorageEngine extends Handler { } public void setIsSyncable(Account account, int userId, String providerName, int syncable) { synchronized (mAuthorities) { AuthorityInfo authority = getOrCreateAuthorityLocked( new EndPoint(account, providerName, userId), -1 /* ident */, false); setSyncableLocked(authority, syncable); } setSyncableStateForTarget(new EndPoint(account, providerName, userId), syncable); } public int getIsTargetServiceActive(ComponentName cname, int userId) { public boolean getIsTargetServiceActive(ComponentName cname, int userId) { synchronized (mAuthorities) { if (cname != null) { AuthorityInfo authority = getAuthorityLocked( new EndPoint(cname, userId), "get service enabled"); if (authority == null) { return -1; return false; } return authority.syncable; return (authority.syncable == 1); } return -1; return false; } } public void setIsEnabled(ComponentName cname, int userId, int syncable) { synchronized (mAuthorities) { AuthorityInfo authority = getOrCreateAuthorityLocked( new EndPoint(cname, userId), -1, false); setSyncableLocked(authority, syncable); } public void setIsTargetServiceActive(ComponentName cname, int userId, boolean active) { setSyncableStateForTarget(new EndPoint(cname, userId), active ? 1 : 0); } /** * An enabled sync service and a syncable provider's adapter both get resolved to the same * persisted variable - namely the "syncable" attribute for an AuthorityInfo in accounts.xml. * @param aInfo * @param syncable * @param target target to set value for. * @param syncable 0 indicates unsyncable, <0 unknown, >0 is active/syncable. */ private void setSyncableLocked(AuthorityInfo aInfo, int syncable) { private void setSyncableStateForTarget(EndPoint target, int syncable) { AuthorityInfo aInfo; synchronized (mAuthorities) { aInfo = getOrCreateAuthorityLocked(target, -1, false); if (syncable > 1) { syncable = 1; } else if (syncable < -1) { Loading @@ -745,7 +736,6 @@ public class SyncStorageEngine extends Handler { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "setIsSyncable: " + aInfo.toString() + " -> " + syncable); } if (aInfo.syncable == syncable) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "setIsSyncable: already set to " + syncable + ", doing nothing"); Loading @@ -754,7 +744,7 @@ public class SyncStorageEngine extends Handler { } aInfo.syncable = syncable; writeAccountInfoLocked(); } if (syncable > 0) { requestSync(aInfo, SyncOperation.REASON_IS_SYNCABLE, new Bundle()); } Loading Loading @@ -816,6 +806,7 @@ public class SyncStorageEngine extends Handler { * @param account account for which to set backoff. Null to specify all accounts. * @param userId id of the user making this request. * @param providerName provider for which to set backoff. Null to specify all providers. * @return true if a change occured. */ private boolean setBackoffLocked(Account account, int userId, String providerName, long nextSyncTime, long nextDelay) { Loading Loading
services/java/com/android/server/content/ContentService.java +6 −5 Original line number Diff line number Diff line Loading @@ -630,16 +630,16 @@ public final class ContentService extends IContentService.Stub { public void setServiceActive(ComponentName cname, boolean active) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "setIsEnabled"); verifySignatureForPackage(Binder.getCallingUid(), cname.getPackageName(), "setServiceActive"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { int syncable = active ? 1 : 0; syncManager.getSyncStorageEngine().setIsEnabled( cname, userId, syncable); syncManager.getSyncStorageEngine().setIsTargetServiceActive( cname, userId, active); } } finally { restoreCallingIdentity(identityToken); Loading @@ -656,7 +656,8 @@ public final class ContentService extends IContentService.Stub { try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { return (syncManager.getIsTargetServiceActive(cname, userId) == 1); return syncManager.getSyncStorageEngine() .getIsTargetServiceActive(cname, userId); } } finally { restoreCallingIdentity(identityToken); Loading
services/java/com/android/server/content/SyncManager.java +6 −13 Original line number Diff line number Diff line Loading @@ -523,14 +523,6 @@ public class SyncManager { } } /** * TODO: Decide if restricted users have different sync options for the sync service (as is * the case with sync adapters). */ public int getIsTargetServiceActive(ComponentName cname, int userId) { return mSyncStorageEngine.getIsTargetServiceActive(cname, userId); } private void ensureAlarmService() { if (mAlarmService == null) { mAlarmService = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); Loading Loading @@ -564,7 +556,7 @@ public class SyncManager { final boolean ignoreSettings = extras.getBoolean(ContentResolver.SYNC_EXTRAS_IGNORE_SETTINGS, false); int source = SyncStorageEngine.SOURCE_SERVICE; int isEnabled = getIsTargetServiceActive(cname, userId); boolean isEnabled = mSyncStorageEngine.getIsTargetServiceActive(cname, userId); // Only schedule this sync if // - we've explicitly been told to ignore settings. // - global sync is enabled for this user. Loading @@ -577,7 +569,7 @@ public class SyncManager { } return; } if (isEnabled == 0) { if (isEnabled) { if (isLoggable) { Log.d(TAG, "scheduleSync: " + cname + " is not enabled, dropping request"); } Loading @@ -587,7 +579,7 @@ public class SyncManager { Pair<Long, Long> backoff = mSyncStorageEngine.getBackoff(info); long delayUntil = mSyncStorageEngine.getDelayUntilTime(info); final long backoffTime = backoff != null ? backoff.first : 0; if (isEnabled < 0) { if (isEnabled) { // Initialisation sync. Bundle newExtras = new Bundle(); newExtras.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true); Loading Loading @@ -2144,7 +2136,7 @@ public class SyncManager { return false; } } else if (target.target_service) { if (getIsTargetServiceActive(target.service, target.userId) == 0) { if (mSyncStorageEngine.getIsTargetServiceActive(target.service, target.userId)) { if (isLoggable) { Log.v(TAG, " Not scheduling periodic operation: isEnabled == 0."); } Loading Loading @@ -2548,7 +2540,8 @@ public class SyncManager { return false; } } else if (target.target_service) { state = getIsTargetServiceActive(target.service, target.userId); state = mSyncStorageEngine.getIsTargetServiceActive(target.service, target.userId) ? 1 : 0; if (state == 0) { // TODO: Change this to not drop disabled syncs - keep them in the pending queue. if (isLoggable) { Loading
services/java/com/android/server/content/SyncStorageEngine.java +28 −37 Original line number Diff line number Diff line Loading @@ -696,47 +696,38 @@ public class SyncStorageEngine extends Handler { } public void setIsSyncable(Account account, int userId, String providerName, int syncable) { synchronized (mAuthorities) { AuthorityInfo authority = getOrCreateAuthorityLocked( new EndPoint(account, providerName, userId), -1 /* ident */, false); setSyncableLocked(authority, syncable); } setSyncableStateForTarget(new EndPoint(account, providerName, userId), syncable); } public int getIsTargetServiceActive(ComponentName cname, int userId) { public boolean getIsTargetServiceActive(ComponentName cname, int userId) { synchronized (mAuthorities) { if (cname != null) { AuthorityInfo authority = getAuthorityLocked( new EndPoint(cname, userId), "get service enabled"); if (authority == null) { return -1; return false; } return authority.syncable; return (authority.syncable == 1); } return -1; return false; } } public void setIsEnabled(ComponentName cname, int userId, int syncable) { synchronized (mAuthorities) { AuthorityInfo authority = getOrCreateAuthorityLocked( new EndPoint(cname, userId), -1, false); setSyncableLocked(authority, syncable); } public void setIsTargetServiceActive(ComponentName cname, int userId, boolean active) { setSyncableStateForTarget(new EndPoint(cname, userId), active ? 1 : 0); } /** * An enabled sync service and a syncable provider's adapter both get resolved to the same * persisted variable - namely the "syncable" attribute for an AuthorityInfo in accounts.xml. * @param aInfo * @param syncable * @param target target to set value for. * @param syncable 0 indicates unsyncable, <0 unknown, >0 is active/syncable. */ private void setSyncableLocked(AuthorityInfo aInfo, int syncable) { private void setSyncableStateForTarget(EndPoint target, int syncable) { AuthorityInfo aInfo; synchronized (mAuthorities) { aInfo = getOrCreateAuthorityLocked(target, -1, false); if (syncable > 1) { syncable = 1; } else if (syncable < -1) { Loading @@ -745,7 +736,6 @@ public class SyncStorageEngine extends Handler { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "setIsSyncable: " + aInfo.toString() + " -> " + syncable); } if (aInfo.syncable == syncable) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.d(TAG, "setIsSyncable: already set to " + syncable + ", doing nothing"); Loading @@ -754,7 +744,7 @@ public class SyncStorageEngine extends Handler { } aInfo.syncable = syncable; writeAccountInfoLocked(); } if (syncable > 0) { requestSync(aInfo, SyncOperation.REASON_IS_SYNCABLE, new Bundle()); } Loading Loading @@ -816,6 +806,7 @@ public class SyncStorageEngine extends Handler { * @param account account for which to set backoff. Null to specify all accounts. * @param userId id of the user making this request. * @param providerName provider for which to set backoff. Null to specify all providers. * @return true if a change occured. */ private boolean setBackoffLocked(Account account, int userId, String providerName, long nextSyncTime, long nextDelay) { Loading