Home | History | Annotate | Download | only in content
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.content;
     18 
     19 import android.accounts.Account;
     20 import android.content.SyncInfo;
     21 import android.content.ISyncStatusObserver;
     22 import android.content.SyncAdapterType;
     23 import android.content.SyncStatusInfo;
     24 import android.content.PeriodicSync;
     25 import android.net.Uri;
     26 import android.os.Bundle;
     27 import android.database.IContentObserver;
     28 
     29 /**
     30  * @hide
     31  */
     32 interface IContentService {
     33     void unregisterContentObserver(IContentObserver observer);
     34 
     35     /**
     36      * Register a content observer tied to a specific user's view of the provider.
     37      * @param userHandle the user whose view of the provider is to be observed.  May be
     38      *     the calling user without requiring any permission, otherwise the caller needs to
     39      *     hold the INTERACT_ACROSS_USERS_FULL permission.  Pseudousers USER_ALL and
     40      *     USER_CURRENT are properly handled.
     41      */
     42     void registerContentObserver(in Uri uri, boolean notifyForDescendants,
     43             IContentObserver observer, int userHandle);
     44 
     45     /**
     46      * Notify observers of a particular user's view of the provider.
     47      * @param userHandle the user whose view of the provider is to be notified.  May be
     48      *     the calling user without requiring any permission, otherwise the caller needs to
     49      *     hold the INTERACT_ACROSS_USERS_FULL permission.  Pseudousers USER_ALL
     50      *     USER_CURRENT are properly interpreted.
     51      */
     52     void notifyChange(in Uri uri, IContentObserver observer,
     53             boolean observerWantsSelfNotifications, boolean syncToNetwork,
     54             int userHandle);
     55 
     56     void requestSync(in Account account, String authority, in Bundle extras);
     57     void cancelSync(in Account account, String authority);
     58 
     59     /**
     60      * Check if the provider should be synced when a network tickle is received
     61      * @param providerName the provider whose setting we are querying
     62      * @return true if the provider should be synced when a network tickle is received
     63      */
     64     boolean getSyncAutomatically(in Account account, String providerName);
     65 
     66     /**
     67      * Set whether or not the provider is synced when it receives a network tickle.
     68      *
     69      * @param providerName the provider whose behavior is being controlled
     70      * @param sync true if the provider should be synced when tickles are received for it
     71      */
     72     void setSyncAutomatically(in Account account, String providerName, boolean sync);
     73 
     74     /**
     75      * Get the frequency of the periodic poll, if any.
     76      * @param providerName the provider whose setting we are querying
     77      * @return the frequency of the periodic sync in seconds. If 0 then no periodic syncs
     78      * will take place.
     79      */
     80     List<PeriodicSync> getPeriodicSyncs(in Account account, String providerName);
     81 
     82     /**
     83      * Set whether or not the provider is to be synced on a periodic basis.
     84      *
     85      * @param providerName the provider whose behavior is being controlled
     86      * @param pollFrequency the period that a sync should be performed, in seconds. If this is
     87      * zero or less then no periodic syncs will be performed.
     88      */
     89     void addPeriodicSync(in Account account, String providerName, in Bundle extras,
     90       long pollFrequency);
     91 
     92     /**
     93      * Set whether or not the provider is to be synced on a periodic basis.
     94      *
     95      * @param providerName the provider whose behavior is being controlled
     96      * @param pollFrequency the period that a sync should be performed, in seconds. If this is
     97      * zero or less then no periodic syncs will be performed.
     98      */
     99     void removePeriodicSync(in Account account, String providerName, in Bundle extras);
    100 
    101     /**
    102      * Check if this account/provider is syncable.
    103      * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet.
    104      */
    105     int getIsSyncable(in Account account, String providerName);
    106 
    107     /**
    108      * Set whether this account/provider is syncable.
    109      * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown
    110      */
    111     void setIsSyncable(in Account account, String providerName, int syncable);
    112 
    113     void setMasterSyncAutomatically(boolean flag);
    114 
    115     boolean getMasterSyncAutomatically();
    116 
    117     /**
    118      * Returns true if there is currently a sync operation for the given
    119      * account or authority in the pending list, or actively being processed.
    120      */
    121     boolean isSyncActive(in Account account, String authority);
    122 
    123     List<SyncInfo> getCurrentSyncs();
    124 
    125     /**
    126      * Returns the types of the SyncAdapters that are registered with the system.
    127      * @return Returns the types of the SyncAdapters that are registered with the system.
    128      */
    129     SyncAdapterType[] getSyncAdapterTypes();
    130 
    131     /**
    132      * Returns the status that matches the authority. If there are multiples accounts for
    133      * the authority, the one with the latest "lastSuccessTime" status is returned.
    134      * @param authority the authority whose row should be selected
    135      * @return the SyncStatusInfo for the authority, or null if none exists
    136      */
    137     SyncStatusInfo getSyncStatus(in Account account, String authority);
    138 
    139     /**
    140      * Return true if the pending status is true of any matching authorities.
    141      */
    142     boolean isSyncPending(in Account account, String authority);
    143 
    144     void addStatusChangeListener(int mask, ISyncStatusObserver callback);
    145 
    146     void removeStatusChangeListener(ISyncStatusObserver callback);
    147 }
    148