Loading api/current.xml +32 −0 Original line number Diff line number Diff line Loading @@ -27032,6 +27032,21 @@ <parameter name="selectionArgs" type="java.lang.String[]"> </parameter> </method> <method name="getIsSyncable" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="account" type="android.accounts.Account"> </parameter> <parameter name="authority" type="java.lang.String"> </parameter> </method> <method name="getMasterSyncAutomatically" return="boolean" abstract="false" Loading Loading @@ -27329,6 +27344,23 @@ <parameter name="extras" type="android.os.Bundle"> </parameter> </method> <method name="setIsSyncable" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="account" type="android.accounts.Account"> </parameter> <parameter name="authority" type="java.lang.String"> </parameter> <parameter name="syncable" type="int"> </parameter> </method> <method name="setMasterSyncAutomatically" return="void" abstract="false" core/java/android/content/ContentResolver.java +25 −0 Original line number Diff line number Diff line Loading @@ -1011,6 +1011,31 @@ public abstract class ContentResolver { } } /** * Check if this account/provider is syncable. * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. */ public int getIsSyncable(Account account, String authority) { try { return getContentService().getIsSyncable(account, authority); } catch (RemoteException e) { throw new RuntimeException("the ContentService should always be reachable", e); } } /** * Set whether this account/provider is syncable. * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown */ public void setIsSyncable(Account account, String authority, int syncable) { try { getContentService().setIsSyncable(account, authority, syncable); } catch (RemoteException e) { // exception ignored; if this is thrown then it means the runtime is in the midst of // being restarted } } /** * Gets the master auto-sync setting that applies to all the providers and accounts. * If this is false then the per-provider auto-sync setting is ignored. Loading core/java/android/content/ContentService.java +31 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,37 @@ public final class ContentService extends IContentService.Stub { } } public int getIsSyncable(Account account, String providerName) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { return syncManager.getSyncStorageEngine().getIsSyncable( account, providerName); } } finally { restoreCallingIdentity(identityToken); } return -1; } public void setIsSyncable(Account account, String providerName, int syncable) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { syncManager.getSyncStorageEngine().setIsSyncable( account, providerName, syncable); } } finally { restoreCallingIdentity(identityToken); } } public boolean getMasterSyncAutomatically() { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); Loading core/java/android/content/IContentService.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,18 @@ interface IContentService { */ void setSyncAutomatically(in Account account, String providerName, boolean sync); /** * Check if this account/provider is syncable. * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. */ int getIsSyncable(in Account account, String providerName); /** * Set whether this account/provider is syncable. * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown */ void setIsSyncable(in Account account, String providerName, int syncable); void setMasterSyncAutomatically(boolean flag); boolean getMasterSyncAutomatically(); Loading core/java/android/content/SyncManager.java +9 −8 Original line number Diff line number Diff line Loading @@ -589,22 +589,21 @@ class SyncManager implements OnAccountsUpdatedListener { // if the url was specified then replace the list of authorities with just this authority // or clear it if this authority isn't syncable if (requestedAuthority != null) { final boolean isSyncable = syncableAuthorities.contains(requestedAuthority); final boolean hasSyncAdapter = syncableAuthorities.contains(requestedAuthority); syncableAuthorities.clear(); if (isSyncable) syncableAuthorities.add(requestedAuthority); if (hasSyncAdapter) syncableAuthorities.add(requestedAuthority); } for (String authority : syncableAuthorities) { for (Account account : accounts) { boolean isSyncable = mSyncStorageEngine.getIsSyncable(account, authority) > 0; if (!isSyncable) { continue; } if (mSyncAdapters.getServiceInfo(new SyncAdapterType(authority, account.type)) != null) { scheduleSyncOperation( new SyncOperation(account, source, authority, extras, delay)); // TODO: remove this when Calendar supports multiple accounts. Until then // pretend that only the first account exists when syncing calendar. if ("calendar".equals(authority)) { break; } } } } Loading Loading @@ -1589,9 +1588,11 @@ class SyncManager implements OnAccountsUpdatedListener { final boolean syncAutomatically = mSyncStorageEngine.getSyncAutomatically(op.account, op.authority) && mSyncStorageEngine.getMasterSyncAutomatically(); boolean isSyncable = mSyncStorageEngine.getIsSyncable(op.account, op.authority) > 0; boolean syncAllowed = manualSync || (backgroundDataUsageAllowed && syncAutomatically); if (!syncAllowed) { if (!syncAllowed || !isSyncable) { if (isLoggable) { Log.v(TAG, "runStateIdle: sync off, dropping " + op); } Loading Loading
api/current.xml +32 −0 Original line number Diff line number Diff line Loading @@ -27032,6 +27032,21 @@ <parameter name="selectionArgs" type="java.lang.String[]"> </parameter> </method> <method name="getIsSyncable" return="int" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="account" type="android.accounts.Account"> </parameter> <parameter name="authority" type="java.lang.String"> </parameter> </method> <method name="getMasterSyncAutomatically" return="boolean" abstract="false" Loading Loading @@ -27329,6 +27344,23 @@ <parameter name="extras" type="android.os.Bundle"> </parameter> </method> <method name="setIsSyncable" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="account" type="android.accounts.Account"> </parameter> <parameter name="authority" type="java.lang.String"> </parameter> <parameter name="syncable" type="int"> </parameter> </method> <method name="setMasterSyncAutomatically" return="void" abstract="false"
core/java/android/content/ContentResolver.java +25 −0 Original line number Diff line number Diff line Loading @@ -1011,6 +1011,31 @@ public abstract class ContentResolver { } } /** * Check if this account/provider is syncable. * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. */ public int getIsSyncable(Account account, String authority) { try { return getContentService().getIsSyncable(account, authority); } catch (RemoteException e) { throw new RuntimeException("the ContentService should always be reachable", e); } } /** * Set whether this account/provider is syncable. * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown */ public void setIsSyncable(Account account, String authority, int syncable) { try { getContentService().setIsSyncable(account, authority, syncable); } catch (RemoteException e) { // exception ignored; if this is thrown then it means the runtime is in the midst of // being restarted } } /** * Gets the master auto-sync setting that applies to all the providers and accounts. * If this is false then the per-provider auto-sync setting is ignored. Loading
core/java/android/content/ContentService.java +31 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,37 @@ public final class ContentService extends IContentService.Stub { } } public int getIsSyncable(Account account, String providerName) { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { return syncManager.getSyncStorageEngine().getIsSyncable( account, providerName); } } finally { restoreCallingIdentity(identityToken); } return -1; } public void setIsSyncable(Account account, String providerName, int syncable) { mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_SYNC_SETTINGS, "no permission to write the sync settings"); long identityToken = clearCallingIdentity(); try { SyncManager syncManager = getSyncManager(); if (syncManager != null) { syncManager.getSyncStorageEngine().setIsSyncable( account, providerName, syncable); } } finally { restoreCallingIdentity(identityToken); } } public boolean getMasterSyncAutomatically() { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); Loading
core/java/android/content/IContentService.aidl +12 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,18 @@ interface IContentService { */ void setSyncAutomatically(in Account account, String providerName, boolean sync); /** * Check if this account/provider is syncable. * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. */ int getIsSyncable(in Account account, String providerName); /** * Set whether this account/provider is syncable. * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown */ void setIsSyncable(in Account account, String providerName, int syncable); void setMasterSyncAutomatically(boolean flag); boolean getMasterSyncAutomatically(); Loading
core/java/android/content/SyncManager.java +9 −8 Original line number Diff line number Diff line Loading @@ -589,22 +589,21 @@ class SyncManager implements OnAccountsUpdatedListener { // if the url was specified then replace the list of authorities with just this authority // or clear it if this authority isn't syncable if (requestedAuthority != null) { final boolean isSyncable = syncableAuthorities.contains(requestedAuthority); final boolean hasSyncAdapter = syncableAuthorities.contains(requestedAuthority); syncableAuthorities.clear(); if (isSyncable) syncableAuthorities.add(requestedAuthority); if (hasSyncAdapter) syncableAuthorities.add(requestedAuthority); } for (String authority : syncableAuthorities) { for (Account account : accounts) { boolean isSyncable = mSyncStorageEngine.getIsSyncable(account, authority) > 0; if (!isSyncable) { continue; } if (mSyncAdapters.getServiceInfo(new SyncAdapterType(authority, account.type)) != null) { scheduleSyncOperation( new SyncOperation(account, source, authority, extras, delay)); // TODO: remove this when Calendar supports multiple accounts. Until then // pretend that only the first account exists when syncing calendar. if ("calendar".equals(authority)) { break; } } } } Loading Loading @@ -1589,9 +1588,11 @@ class SyncManager implements OnAccountsUpdatedListener { final boolean syncAutomatically = mSyncStorageEngine.getSyncAutomatically(op.account, op.authority) && mSyncStorageEngine.getMasterSyncAutomatically(); boolean isSyncable = mSyncStorageEngine.getIsSyncable(op.account, op.authority) > 0; boolean syncAllowed = manualSync || (backgroundDataUsageAllowed && syncAutomatically); if (!syncAllowed) { if (!syncAllowed || !isSyncable) { if (isLoggable) { Log.v(TAG, "runStateIdle: sync off, dropping " + op); } Loading