From e0616ffb741b64e3bc7a1e3ad9def3d50eee53fd Mon Sep 17 00:00:00 2001 From: Fred Quintana Date: Wed, 19 Aug 2009 13:13:18 -0700 Subject: [PATCH] add a supportsUploading flag in the SyncAdapter description and honor it in the SyncManager --- api/current.xml | 37 +++++++++++- core/java/android/content/SyncAdapterType.java | 69 +++++++++++++++++++--- core/java/android/content/SyncAdaptersCache.java | 5 +- core/java/android/content/SyncManager.java | 27 +++++---- .../android/preference/CheckBoxPreference.java | 14 ++--- core/res/res/values/attrs.xml | 1 + core/res/res/values/public.xml | 1 + 7 files changed, 126 insertions(+), 28 deletions(-) diff --git a/api/current.xml b/api/current.xml index 881c71fd7aab..a330a2a2003a 100644 --- a/api/current.xml +++ b/api/current.xml @@ -7489,6 +7489,17 @@ visibility="public" > + + + + + + + + - CREATOR = new Creator() { diff --git a/core/java/android/content/SyncAdaptersCache.java b/core/java/android/content/SyncAdaptersCache.java index c27fd259ee12..7d9f1de9da92 100644 --- a/core/java/android/content/SyncAdaptersCache.java +++ b/core/java/android/content/SyncAdaptersCache.java @@ -49,7 +49,10 @@ import android.util.AttributeSet; } final boolean userVisible = sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_userVisible, true); - return new SyncAdapterType(authority, accountType, userVisible); + final boolean supportsUploading = + sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_supportsUploading, + true); + return new SyncAdapterType(authority, accountType, userVisible, supportsUploading); } finally { sa.recycle(); } diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java index 34efc51f21d5..82cf23f13b0b 100644 --- a/core/java/android/content/SyncManager.java +++ b/core/java/android/content/SyncManager.java @@ -526,13 +526,6 @@ class SyncManager implements OnAccountsUpdatedListener { public void scheduleSync(Account requestedAccount, String requestedAuthority, Bundle extras, long delay, boolean onlyThoseWithUnkownSyncableState) { boolean isLoggable = Log.isLoggable(TAG, Log.VERBOSE); - if (isLoggable) { - Log.v(TAG, "scheduleSync:" - + " delay " + delay - + ", account " + requestedAccount - + ", authority " + requestedAuthority - + ", extras " + ((extras == null) ? "(null)" : extras)); - } if (!isSyncEnabled()) { if (isLoggable) { @@ -617,13 +610,27 @@ class SyncManager implements OnAccountsUpdatedListener { if (onlyThoseWithUnkownSyncableState && isSyncable >= 0) { continue; } - if (mSyncAdapters.getServiceInfo(SyncAdapterType.newKey(authority, account.type)) - != null) { + final RegisteredServicesCache.ServiceInfo syncAdapterInfo = + mSyncAdapters.getServiceInfo( + SyncAdapterType.newKey(authority, account.type)); + if (syncAdapterInfo != null) { + if (!syncAdapterInfo.type.supportsUploading() && uploadOnly) { + continue; + } // make this an initialization sync if the isSyncable state is unknown - Bundle extrasCopy = new Bundle(extras); + Bundle extrasCopy = extras; if (isSyncable < 0) { + extrasCopy = new Bundle(extras); extrasCopy.putBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, true); } + if (isLoggable) { + Log.v(TAG, "scheduleSync:" + + " delay " + delay + + ", source " + source + + ", account " + account + + ", authority " + authority + + ", extras " + extrasCopy); + } scheduleSyncOperation( new SyncOperation(account, source, authority, extrasCopy, delay)); } diff --git a/core/java/android/preference/CheckBoxPreference.java b/core/java/android/preference/CheckBoxPreference.java index cf5664c3814e..f16a7e479cb1 100644 --- a/core/java/android/preference/CheckBoxPreference.java +++ b/core/java/android/preference/CheckBoxPreference.java @@ -149,14 +149,12 @@ public class CheckBoxPreference extends Preference { * @param checked The checked state. */ public void setChecked(boolean checked) { - - mChecked = checked; - - persistBoolean(checked); - - notifyDependencyChange(shouldDisableDependents()); - - notifyChanged(); + if (mChecked != checked) { + mChecked = checked; + persistBoolean(checked); + notifyDependencyChange(shouldDisableDependents()); + notifyChanged(); + } } /** diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index e03211d00de0..729b1db5c499 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3410,6 +3410,7 @@ + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index bbeb78da0fcc..4bc376b946fa 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1159,4 +1159,5 @@ + -- 2.11.0