summaryrefslogtreecommitdiff
path: root/core/java/android/content/AbstractThreadedSyncAdapter.java
diff options
context:
space:
mode:
authorPhilip P. Moltmann <moltmann@google.com>2018-01-03 11:29:01 -0800
committerPhilip P. Moltmann <moltmann@google.com>2018-01-25 00:37:48 +0000
commit486b24179f25439be8e647ec22851bbe5b002bb3 (patch)
tree1102c50c2479041fd77aef5e5395bc8ddd22856e /core/java/android/content/AbstractThreadedSyncAdapter.java
parentbdd460bf491da026c5e6270061f6af2a514890b3 (diff)
Add AbstractThreadedSyncAdapter#onUnsyncableAccount API
This allows for an SyncAdapter to defer all onPerformSync calls (and the admission check for those) until the adapter is ready to accept those calls. Test: atest android.content.cts.AccountAccessSameCertTest atest android.content.cts.ContentResolverSyncTestCase atest android.content.cts.DeferSyncTest atest com.android.cts.content.CtsSyncAccountAccessOtherCertTestCases Set up a user and work account and waited until their gmail synced. Bug: 72459220 Change-Id: I8f9ab735d64189578ccdd1c3e1d7b7c5383b8ee9
Diffstat (limited to 'core/java/android/content/AbstractThreadedSyncAdapter.java')
-rw-r--r--core/java/android/content/AbstractThreadedSyncAdapter.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/content/AbstractThreadedSyncAdapter.java b/core/java/android/content/AbstractThreadedSyncAdapter.java
index 2629929e91ce..5a1216b79b82 100644
--- a/core/java/android/content/AbstractThreadedSyncAdapter.java
+++ b/core/java/android/content/AbstractThreadedSyncAdapter.java
@@ -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;
@@ -166,6 +167,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) {
if (ENABLE_LOG) {
@@ -374,6 +381,26 @@ public abstract class AbstractThreadedSyncAdapter {
}
/**
+ * 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
* of this method are guaranteed to be serialized.