Add getCurrentSyncs() to the SDK, which replaces the deprecated
getCurrentSync(). Change-Id: I1112df41e48ed93ff4c0c5af4825dbdce0c4cccc
This commit is contained in:
@@ -44007,6 +44007,17 @@
|
||||
synchronized="false"
|
||||
static="true"
|
||||
final="false"
|
||||
deprecated="deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="getCurrentSyncs"
|
||||
return="java.util.List<android.content.SyncInfo>"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="true"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
@@ -54150,6 +54161,34 @@
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<implements name="android.os.Parcelable">
|
||||
</implements>
|
||||
<method name="describeContents"
|
||||
return="int"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="writeToParcel"
|
||||
return="void"
|
||||
abstract="false"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="parcel" type="android.os.Parcel">
|
||||
</parameter>
|
||||
<parameter name="flags" type="int">
|
||||
</parameter>
|
||||
</method>
|
||||
<field name="account"
|
||||
type="android.accounts.Account"
|
||||
transient="false"
|
||||
@@ -242757,7 +242796,7 @@
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
<parameter name="t" type="T">
|
||||
<parameter name="arg0" type="T">
|
||||
</parameter>
|
||||
</method>
|
||||
</interface>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1087,23 +1087,6 @@ public class SyncStorageEngine extends Handler {
|
||||
reportChange(ContentResolver.SYNC_OBSERVER_TYPE_STATUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user