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

Commit 4a6679b9 authored by Fred Quintana's avatar Fred Quintana
Browse files

make syncadapter set whether the account is syncable

parent 084cd826
Loading
Loading
Loading
Loading
+41 −3
Original line number Diff line number Diff line
@@ -8391,6 +8391,17 @@
 visibility="public"
>
</field>
<field name="userVisible"
 type="int"
 transient="false"
 volatile="false"
 value="16843408"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="value"
 type="int"
 transient="false"
@@ -8758,7 +8769,7 @@
 type="int"
 transient="false"
 volatile="false"
 value="16843408"
 value="16843409"
 static="true"
 final="true"
 deprecated="not deprecated"
@@ -27586,6 +27597,17 @@
 visibility="public"
>
</field>
<field name="SYNC_EXTRAS_INITIALIZE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;initialize&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="SYNC_EXTRAS_MANUAL"
 type="java.lang.String"
 transient="false"
@@ -35766,6 +35788,8 @@
</parameter>
<parameter name="accountType" type="java.lang.String">
</parameter>
<parameter name="userVisible" type="boolean">
</parameter>
</constructor>
<constructor name="SyncAdapterType"
 type="android.content.SyncAdapterType"
@@ -35788,6 +35812,21 @@
 visibility="public"
>
</method>
<method name="newKey"
 return="android.content.SyncAdapterType"
 abstract="false"
 native="false"
 synchronized="false"
 static="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="authority" type="java.lang.String">
</parameter>
<parameter name="accountType" type="java.lang.String">
</parameter>
</method>
<method name="writeToParcel"
 return="void"
 abstract="false"
@@ -35833,11 +35872,10 @@
 visibility="public"
>
</field>
<field name="isUserFacing"
<field name="userVisible"
 type="boolean"
 transient="false"
 volatile="false"
 value="true"
 static="false"
 final="true"
 deprecated="not deprecated"
+18 −2
Original line number Diff line number Diff line
@@ -44,16 +44,23 @@ public abstract class AbstractThreadedSyncAdapter {

    /** Kernel event log tag.  Also listed in data/etc/event-log-tags. */
    public static final int LOG_SYNC_DETAILS = 2743;
    private final boolean mAutoInitialize;

    /**
     * Creates an {@link AbstractThreadedSyncAdapter}.
     * @param context the {@link Context} that this is running within.
     * @param context the {@link android.content.Context} that this is running within.
     * @param autoInitialize if true then sync requests that have
     * {@link ContentResolver#SYNC_EXTRAS_INITIALIZE} set will be internally handled by
     * {@link AbstractThreadedSyncAdapter} by calling
     * {@link ContentResolver#setIsSyncable(android.accounts.Account, String, int)} with 1 if it
     * is currently set to <0.
     */
    public AbstractThreadedSyncAdapter(Context context) {
    public AbstractThreadedSyncAdapter(Context context, boolean autoInitialize) {
        mContext = context;
        mISyncAdapterImpl = new ISyncAdapterImpl();
        mNumSyncStarts = new AtomicInteger(0);
        mSyncThread = null;
        mAutoInitialize = autoInitialize;
    }

    class ISyncAdapterImpl extends ISyncAdapter.Stub {
@@ -66,6 +73,15 @@ public abstract class AbstractThreadedSyncAdapter {
            // check it and when we use it
            synchronized (this) {
                if (mSyncThread == null) {
                    if (mAutoInitialize
                            && extras != null
                            && extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE, false)) {
                        if (ContentResolver.getIsSyncable(account, authority) < 0) {
                            ContentResolver.setIsSyncable(account, authority, 1);
                        }
                        syncContextClient.onFinished(new SyncResult());
                        return;
                    }
                    mSyncThread = new SyncThread(
                            "SyncAdapterThread-" + mNumSyncStarts.incrementAndGet(),
                            syncContextClient, authority, account, extras);
+12 −2
Original line number Diff line number Diff line
@@ -52,18 +52,29 @@ public abstract class ContentResolver {
     * @deprecated instead use
     * {@link #requestSync(android.accounts.Account, String, android.os.Bundle)}
     */
    @Deprecated
    public static final String SYNC_EXTRAS_ACCOUNT = "account";
    public static final String SYNC_EXTRAS_EXPEDITED = "expedited";
    /**
     * @deprecated instead use
     * {@link #SYNC_EXTRAS_MANUAL}
     */
    @Deprecated
    public static final String SYNC_EXTRAS_FORCE = "force";
    public static final String SYNC_EXTRAS_MANUAL = "force";
    public static final String SYNC_EXTRAS_UPLOAD = "upload";
    public static final String SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS = "deletions_override";
    public static final String SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS = "discard_deletions";

    /**
     * Set by the SyncManager to request that the SyncAdapter initialize itself for
     * the given account/authority pair. One required initialization step is to
     * ensure that {@link #setIsSyncable(android.accounts.Account, String, int)} has been
     * called with a >= 0 value. When this flag is set the SyncAdapter does not need to
     * do a full sync, though it is allowed to do so.
     */
    public static final String SYNC_EXTRAS_INITIALIZE = "initialize";

    public static final String SCHEME_CONTENT = "content";
    public static final String SCHEME_ANDROID_RESOURCE = "android.resource";
    public static final String SCHEME_FILE = "file";
@@ -1094,8 +1105,7 @@ public abstract class ContentResolver {
    }

    /**
     * Returns the status that matches the authority. If there are multiples accounts for
     * the authority, the one with the latest "lastSuccessTime" status is returned.
     * Returns the status that matches the authority.
     * @param account the account whose setting we are querying
     * @param authority the provider whose behavior is being queried
     * @return the SyncStatusInfo for the authority, or null if none exists
+2 −1
Original line number Diff line number Diff line
@@ -197,7 +197,8 @@ public final class ContentService extends IContentService.Stub {
        try {
            SyncManager syncManager = getSyncManager();
            if (syncManager != null) {
                syncManager.scheduleSync(account, authority, extras, 0 /* no delay */);
                syncManager.scheduleSync(account, authority, extras, 0 /* no delay */,
                        false /* onlyThoseWithUnkownSyncableState */);
            }
        } finally {
            restoreCallingIdentity(identityToken);
+4 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ public abstract class SyncAdapter {
    class Transport extends ISyncAdapter.Stub {
        public void startSync(ISyncContext syncContext, String authority, Account account,
                Bundle extras) throws RemoteException {
            SyncAdapter.this.startSync(new SyncContext(syncContext), account, extras);
            SyncAdapter.this.startSync(new SyncContext(syncContext), account, authority, extras);
        }

        public void cancelSync(ISyncContext syncContext) throws RemoteException {
@@ -58,9 +58,11 @@ public abstract class SyncAdapter {
     * @param syncContext the ISyncContext used to indicate the progress of the sync. When
     *   the sync is finished (successfully or not) ISyncContext.onFinished() must be called.
     * @param account the account that should be synced
     * @param authority the authority if the sync request
     * @param extras SyncAdapter-specific parameters
     */
    public abstract void startSync(SyncContext syncContext, Account account, Bundle extras);
    public abstract void startSync(SyncContext syncContext, Account account, String authority, 
            Bundle extras);

    /**
     * Cancel the most recently initiated sync. Due to race conditions, this may arrive
Loading