Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6a69559 authored by Fred Quintana's avatar Fred Quintana
Browse files

Add getCurrentSyncs() to the SDK, which replaces the deprecated

getCurrentSync().

Change-Id: I1112df41e48ed93ff4c0c5af4825dbdce0c4cccc
parent fdcd2660
Loading
Loading
Loading
Loading
+40 −1
Original line number Diff line number Diff line
@@ -44007,6 +44007,17 @@
 synchronized="false"
 static="true"
 final="false"
 deprecated="deprecated"
 visibility="public"
>
</method>
<method name="getCurrentSyncs"
 return="java.util.List&lt;android.content.SyncInfo&gt;"
 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>
+26 −2
Original line number Diff line number Diff line
@@ -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);
        }
+2 −6
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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.
+2 −1
Original line number Diff line number Diff line
@@ -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;

Loading