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

Commit fa774181 authored by Matthew Williams's avatar Matthew Williams
Browse files

AnonymousSyncService & SyncRequest.

Changes to the way bundles are parcelled broke SM,
this update writes out the bundle as xml. This circumvents
the need for parcel, and makes it easier to debug whats
happening.
Change-Id: I6cd5d3a2eb80bfa5b3ae0c7f2d2ff91a65daaa34
parent 7bfddb54
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ LOCAL_SRC_FILES += \
	core/java/android/content/IIntentReceiver.aidl \
	core/java/android/content/IIntentSender.aidl \
	core/java/android/content/IOnPrimaryClipChangedListener.aidl \
	core/java/android/content/IAnonymousSyncAdapter.aidl \
	core/java/android/content/ISyncAdapter.aidl \
	core/java/android/content/ISyncContext.aidl \
	core/java/android/content/ISyncStatusObserver.aidl \
@@ -339,6 +340,7 @@ aidl_files := \
	frameworks/base/core/java/android/content/Intent.aidl \
	frameworks/base/core/java/android/content/IntentSender.aidl \
	frameworks/base/core/java/android/content/PeriodicSync.aidl \
	frameworks/base/core/java/android/content/SyncRequest.aidl \
	frameworks/base/core/java/android/content/SyncStats.aidl \
	frameworks/base/core/java/android/content/res/Configuration.aidl \
	frameworks/base/core/java/android/database/CursorWindow.aidl \
+35 −0
Original line number Diff line number Diff line
@@ -5572,6 +5572,7 @@ package android.content {
    method public final android.os.Bundle call(android.net.Uri, java.lang.String, java.lang.String, android.os.Bundle);
    method public deprecated void cancelSync(android.net.Uri);
    method public static void cancelSync(android.accounts.Account, java.lang.String);
    method public static void cancelSync(android.content.SyncRequest);
    method public final int delete(android.net.Uri, java.lang.String, java.lang.String[]);
    method public static deprecated android.content.SyncInfo getCurrentSync();
    method public static java.util.List<android.content.SyncInfo> getCurrentSyncs();
@@ -5599,6 +5600,7 @@ package android.content {
    method public static void removePeriodicSync(android.accounts.Account, java.lang.String, android.os.Bundle);
    method public static void removeStatusChangeListener(java.lang.Object);
    method public static void requestSync(android.accounts.Account, java.lang.String, android.os.Bundle);
    method public static void requestSync(android.content.SyncRequest);
    method public static void setIsSyncable(android.accounts.Account, java.lang.String, int);
    method public static void setMasterSyncAutomatically(boolean);
    method public static void setSyncAutomatically(android.accounts.Account, java.lang.String, boolean);
@@ -6534,7 +6536,9 @@ package android.content {
    field public final android.accounts.Account account;
    field public final java.lang.String authority;
    field public final android.os.Bundle extras;
    field public final boolean isService;
    field public final long period;
    field public final android.content.ComponentName service;
  }
  public class ReceiverCallNotAllowedException extends android.util.AndroidRuntimeException {
@@ -6653,6 +6657,31 @@ package android.content {
    field public final long startTime;
  }
  public class SyncRequest implements android.os.Parcelable {
    method public int describeContents();
    method public boolean isExpedited();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
  public static class SyncRequest.Builder {
    ctor public SyncRequest.Builder();
    method public android.content.SyncRequest build();
    method public android.content.SyncRequest.Builder setAllowMetered(boolean);
    method public android.content.SyncRequest.Builder setExpedited(boolean);
    method public android.content.SyncRequest.Builder setExtras(android.os.Bundle);
    method public android.content.SyncRequest.Builder setIgnoreBackoff(boolean);
    method public android.content.SyncRequest.Builder setIgnoreSettings(boolean);
    method public android.content.SyncRequest.Builder setManual(boolean);
    method public android.content.SyncRequest.Builder setNoRetry(boolean);
    method public android.content.SyncRequest.Builder setPriority(int);
    method public android.content.SyncRequest.Builder setSyncAdapter(android.accounts.Account, java.lang.String);
    method public android.content.SyncRequest.Builder setSyncAdapter(android.content.ComponentName);
    method public android.content.SyncRequest.Builder setTransferSize(long, long);
    method public android.content.SyncRequest.Builder syncOnce(long, long);
    method public android.content.SyncRequest.Builder syncPeriodic(long, long);
  }
  public final class SyncResult implements android.os.Parcelable {
    ctor public SyncResult();
    method public void clear();
@@ -6676,6 +6705,12 @@ package android.content {
    field public boolean tooManyRetries;
  }
  public abstract class SyncService extends android.app.Service {
    ctor public SyncService();
    method public android.os.IBinder onBind(android.content.Intent);
    method public abstract void onPerformSync(android.os.Bundle, android.content.SyncResult);
  }
  public class SyncStats implements android.os.Parcelable {
    ctor public SyncStats();
    ctor public SyncStats(android.os.Parcel);
+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ public abstract class AbstractThreadedSyncAdapter {
    }

    private class ISyncAdapterImpl extends ISyncAdapter.Stub {
        @Override
        public void startSync(ISyncContext syncContext, String authority, Account account,
                Bundle extras) {
            final SyncContext syncContextClient = new SyncContext(syncContext);
@@ -184,6 +185,7 @@ public abstract class AbstractThreadedSyncAdapter {
            }
        }

        @Override
        public void cancelSync(ISyncContext syncContext) {
            // synchronize to make sure that mSyncThreads doesn't change between when we
            // check it and when we use it
+52 −4
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.os.UserHandle;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
import android.util.Pair;

import java.io.File;
import java.io.FileInputStream;
@@ -131,6 +132,19 @@ public abstract class ContentResolver {
     */
    public static final String SYNC_EXTRAS_DISCARD_LOCAL_DELETIONS = "discard_deletions";

    /* Extensions to API. TODO: Not clear if we will keep these as public flags. */
    /** {@hide} User-specified flag for expected upload size. */
    public static final String SYNC_EXTRAS_EXPECTED_UPLOAD = "expected_upload";

    /** {@hide} User-specified flag for expected download size. */
    public static final String SYNC_EXTRAS_EXPECTED_DOWNLOAD = "expected_download";

    /** {@hide} Priority of this sync with respect to other syncs scheduled for this application. */
    public static final String SYNC_EXTRAS_PRIORITY = "sync_priority";

    /** {@hide} Flag to allow sync to occur on metered network. */
    public static final String SYNC_EXTRAS_ALLOW_METERED = "allow_metered";

    /**
     * Set by the SyncManager to request that the SyncAdapter initialize itself for
     * the given account/authority pair. One required initialization step is to
@@ -1385,6 +1399,8 @@ public abstract class ContentResolver {
     * <li>Float</li>
     * <li>Double</li>
     * <li>String</li>
     * <li>Account</li>
     * <li>null</li>
     * </ul>
     *
     * @param uri the uri of the provider to sync or null to sync all providers.
@@ -1416,6 +1432,8 @@ public abstract class ContentResolver {
     * <li>Float</li>
     * <li>Double</li>
     * <li>String</li>
     * <li>Account</li>
     * <li>null</li>
     * </ul>
     *
     * @param account which account should be synced
@@ -1423,10 +1441,24 @@ public abstract class ContentResolver {
     * @param extras any extras to pass to the SyncAdapter.
     */
    public static void requestSync(Account account, String authority, Bundle extras) {
        validateSyncExtrasBundle(extras);
        SyncRequest request =
            new SyncRequest.Builder()
                .setSyncAdapter(account, authority)
                .setExtras(extras)
                .syncOnce(0, 0)     // Immediate sync.
                .build();
        requestSync(request);
    }

    /**
     * Register a sync with the SyncManager. These requests are built using the
     * {@link SyncRequest.Builder}.
     */
    public static void requestSync(SyncRequest request) {
        try {
            getContentService().requestSync(account, authority, extras);
            getContentService().sync(request);
        } catch(RemoteException e) {
            // Shouldn't happen.
        }
    }

@@ -1618,6 +1650,22 @@ public abstract class ContentResolver {
        }
    }

    /**
     * Remove the specified sync. This will remove any syncs that have been scheduled to run, but
     * will not cancel any running syncs.
     * <p>This method requires the caller to hold the permission</p>
     * If the request is for a periodic sync this will cancel future occurrences of the sync.
     *
     * It is possible to cancel a sync using a SyncRequest object that is different from the object
     * with which you requested the sync. Do so by building a SyncRequest with exactly the same
     * service/adapter, frequency, <b>and</b> extras bundle.
     *
     * @param request SyncRequest object containing information about sync to cancel.
     */
    public static void cancelSync(SyncRequest request) {
        // TODO: Finish this implementation.
    }

    /**
     * Get the list of information about the periodic syncs for the given account and authority.
     * <p>This method requires the caller to hold the permission
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 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;
import android.os.Bundle;
import android.content.ISyncContext;

/**
 * Interface to define an anonymous service that is extended by developers
 * in order to perform anonymous syncs (syncs without an Account or Content
 * Provider specified). See {@link android.content.AbstractThreadedSyncAdapter}.
 * {@hide}
 */
oneway interface IAnonymousSyncAdapter {

    /**
     * Initiate a sync. SyncAdapter-specific parameters may be specified in
     * extras, which is guaranteed to not be null.
     *
     * @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 extras SyncAdapter-specific parameters.
     *
     */
    void startSync(ISyncContext syncContext, in Bundle extras);

    /**
     * Cancel the currently ongoing sync.
     */
    void cancelSync(ISyncContext syncContext);

}
Loading