diff options
author | Fred Quintana <fredq@google.com> | 2010-09-27 17:05:04 -0700 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2010-10-08 09:50:45 -0700 |
commit | c6a69559cb62bd20166c0c9684e64c60d779da38 (patch) | |
tree | acb3d14e5158255c4232733299d8a7775289280e /core/java/android/content | |
parent | fdcd2660ec4e45b957b085d0814fd4f405675504 (diff) | |
download | frameworks_base-c6a69559cb62bd20166c0c9684e64c60d779da38.zip frameworks_base-c6a69559cb62bd20166c0c9684e64c60d779da38.tar.gz frameworks_base-c6a69559cb62bd20166c0c9684e64c60d779da38.tar.bz2 |
Add getCurrentSyncs() to the SDK, which replaces the deprecated
getCurrentSync().
Change-Id: I1112df41e48ed93ff4c0c5af4825dbdce0c4cccc
Diffstat (limited to 'core/java/android/content')
-rw-r--r-- | core/java/android/content/ContentResolver.java | 28 | ||||
-rw-r--r-- | core/java/android/content/ContentService.java | 8 | ||||
-rw-r--r-- | core/java/android/content/IContentService.aidl | 2 | ||||
-rw-r--r-- | core/java/android/content/SyncInfo.java | 3 | ||||
-rw-r--r-- | core/java/android/content/SyncStorageEngine.java | 17 |
5 files changed, 31 insertions, 27 deletions
diff --git a/core/java/android/content/ContentResolver.java b/core/java/android/content/ContentResolver.java index 3289120..da1aac4 100644 --- a/core/java/android/content/ContentResolver.java +++ b/core/java/android/content/ContentResolver.java @@ -1319,12 +1319,36 @@ public abstract class ContentResolver { } /** - * If a sync is active returns the information about it, otherwise returns false. + * If a sync is active returns the information about it, otherwise returns null. + * <p> * @return the SyncInfo for the currently active sync or null if one is not active. + * @deprecated + * Since multiple concurrent syncs are now supported you should use + * {@link #getCurrentSyncs()} to get the accurate list of current syncs. + * This method returns the first item from the list of current syncs + * or null if there are none. */ + @Deprecated public static SyncInfo getCurrentSync() { try { - return getContentService().getCurrentSync(); + final List<SyncInfo> syncs = getContentService().getCurrentSyncs(); + if (syncs.isEmpty()) { + return null; + } + return syncs.get(0); + } catch (RemoteException e) { + throw new RuntimeException("the ContentService should always be reachable", e); + } + } + + /** + * Returns a list with information about all the active syncs. This list will be empty + * if there are no active syncs. + * @return a List of SyncInfo objects for the currently active syncs. + */ + public static List<SyncInfo> getCurrentSyncs() { + try { + return getContentService().getCurrentSyncs(); } catch (RemoteException e) { throw new RuntimeException("the ContentService should always be reachable", e); } diff --git a/core/java/android/content/ContentService.java b/core/java/android/content/ContentService.java index fc2dfc0..afe8483 100644 --- a/core/java/android/content/ContentService.java +++ b/core/java/android/content/ContentService.java @@ -386,19 +386,15 @@ public final class ContentService extends IContentService.Stub { return false; } - public SyncInfo getCurrentSync() { + public List<SyncInfo> getCurrentSyncs() { mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS, "no permission to read the sync stats"); long identityToken = clearCallingIdentity(); try { - SyncManager syncManager = getSyncManager(); - if (syncManager != null) { - return syncManager.getSyncStorageEngine().getCurrentSync(); - } + return getSyncManager().getSyncStorageEngine().getCurrentSyncs(); } finally { restoreCallingIdentity(identityToken); } - return null; } public SyncStatusInfo getSyncStatus(Account account, String authority) { diff --git a/core/java/android/content/IContentService.aidl b/core/java/android/content/IContentService.aidl index a6368d5..86a9392 100644 --- a/core/java/android/content/IContentService.aidl +++ b/core/java/android/content/IContentService.aidl @@ -104,7 +104,7 @@ interface IContentService { */ boolean isSyncActive(in Account account, String authority); - SyncInfo getCurrentSync(); + List<SyncInfo> getCurrentSyncs(); /** * Returns the types of the SyncAdapters that are registered with the system. diff --git a/core/java/android/content/SyncInfo.java b/core/java/android/content/SyncInfo.java index 616b05f..abfe964 100644 --- a/core/java/android/content/SyncInfo.java +++ b/core/java/android/content/SyncInfo.java @@ -18,12 +18,13 @@ package android.content; import android.accounts.Account; import android.os.Parcel; +import android.os.Parcelable; import android.os.Parcelable.Creator; /** * Information about the sync operation that is currently underway. */ -public class SyncInfo { +public class SyncInfo implements Parcelable { /** @hide */ public final int authorityId; diff --git a/core/java/android/content/SyncStorageEngine.java b/core/java/android/content/SyncStorageEngine.java index 487f6ce..17d85fa 100644 --- a/core/java/android/content/SyncStorageEngine.java +++ b/core/java/android/content/SyncStorageEngine.java @@ -1088,23 +1088,6 @@ public class SyncStorageEngine extends Handler { } /** - * Return the currently active sync information, or null if there is no - * active sync. Note that the returned object is the real, live active - * sync object, so be careful what you do with it. - * <p> - * Since multiple concurrent syncs are now supported you should use - * {@link #getCurrentSyncs()} to get the accurate list of current syncs. - * This method returns the first item from the list of current syncs - * or null if there are none. - * @deprecated use {@link #getCurrentSyncs()} - */ - public SyncInfo getCurrentSync() { - synchronized (mAuthorities) { - return !mCurrentSyncs.isEmpty() ? mCurrentSyncs.get(0) : null; - } - } - - /** * Return a list of the currently active syncs. Note that the returned items are the * real, live active sync objects, so be careful what you do with it. */ |