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

Commit 5815664d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add AbstractThreadedSyncAdapter#onUnsyncableAccount API"

parents 4b66fc6b 486b2417
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -113,6 +113,7 @@ java_library {
        "core/java/android/content/IOnPrimaryClipChangedListener.aidl",
        "core/java/android/content/IRestrictionsManager.aidl",
        "core/java/android/content/ISyncAdapter.aidl",
        "core/java/android/content/ISyncAdapterUnsyncableAccountCallback.aidl",
        "core/java/android/content/ISyncContext.aidl",
        "core/java/android/content/ISyncServiceAdapter.aidl",
        "core/java/android/content/ISyncStatusObserver.aidl",
+1 −0
Original line number Diff line number Diff line
@@ -8767,6 +8767,7 @@ package android.content {
    method public void onSecurityException(android.accounts.Account, android.os.Bundle, java.lang.String, android.content.SyncResult);
    method public void onSyncCanceled();
    method public void onSyncCanceled(java.lang.Thread);
    method public boolean onUnsyncableAccount();
    field public static final deprecated int LOG_SYNC_DETAILS = 2743; // 0xab7
  }
+27 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.Trace;
import android.util.Log;

@@ -165,6 +166,12 @@ public abstract class AbstractThreadedSyncAdapter {
    }

    private class ISyncAdapterImpl extends ISyncAdapter.Stub {
        @Override
        public void onUnsyncableAccount(ISyncAdapterUnsyncableAccountCallback cb)
                throws RemoteException {
            cb.onUnsyncableAccountDone(AbstractThreadedSyncAdapter.this.onUnsyncableAccount());
        }

        @Override
        public void startSync(ISyncContext syncContext, String authority, Account account,
                Bundle extras) {
@@ -373,6 +380,26 @@ public abstract class AbstractThreadedSyncAdapter {
        return mISyncAdapterImpl.asBinder();
    }

    /**
     * Allows to defer syncing until all accounts are properly set up.
     *
     * <p>Called when a account / authority pair
     * <ul>
     * <li>that can be handled by this adapter</li>
     * <li>{@link ContentResolver#requestSync(SyncRequest) is synced}</li>
     * <li>and the account/provider {@link ContentResolver#getIsSyncable(Account, String) has
     * unknown state (<0)}.</li>
     * </ul>
     *
     * <p>This might be called on a different service connection as {@link #onPerformSync}.
     *
     * @return If {@code false} syncing is deferred. Returns {@code true} by default, i.e. by
     *         default syncing starts immediately.
     */
    public boolean onUnsyncableAccount() {
        return true;
    }

    /**
     * Perform a sync for this account. SyncAdapter-specific parameters may
     * be specified in extras, which is guaranteed to not be null. Invocations
+9 −0
Original line number Diff line number Diff line
@@ -19,12 +19,21 @@ package android.content;
import android.accounts.Account;
import android.os.Bundle;
import android.content.ISyncContext;
import android.content.ISyncAdapterUnsyncableAccountCallback;

/**
 * Interface used to control the sync activity on a SyncAdapter
 * @hide
 */
oneway interface ISyncAdapter {
    /**
     * Called before {@link #startSync}. This allows the adapter to defer syncs until the
     * adapter is ready for the account
     *
     * @param cb If called back with {@code false} accounts are not synced.
     */
    void onUnsyncableAccount(ISyncAdapterUnsyncableAccountCallback cb);

    /**
     * Initiate a sync for this account. SyncAdapter-specific parameters may
     * be specified in extras, which is guaranteed to not be null.
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.content;

/**
 * Callback for {@link ISyncAdapter#onUnsyncableAccount}
 * @hide
 */
oneway interface ISyncAdapterUnsyncableAccountCallback {
    /**
     * Deliver the result for {@link ISyncAdapter#onUnsyncableAccount}
     *
     * @param isReady Iff {@code false} account is not synced.
     */
    void onUnsyncableAccountDone(boolean isReady);
}
Loading