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 17package android.content; 18 19import android.accounts.Account; 20import android.content.SyncInfo; 21import android.content.ISyncStatusObserver; 22import android.content.SyncAdapterType; 23import android.content.SyncStatusInfo; 24import android.content.PeriodicSync; 25import android.net.Uri; 26import android.os.Bundle; 27import android.database.IContentObserver; 28 29/** 30 * @hide 31 */ 32interface IContentService { 33 void registerContentObserver(in Uri uri, boolean notifyForDescendentsn, 34 IContentObserver observer); 35 void unregisterContentObserver(IContentObserver observer); 36 37 void notifyChange(in Uri uri, IContentObserver observer, 38 boolean observerWantsSelfNotifications, boolean syncToNetwork); 39 40 void requestSync(in Account account, String authority, in Bundle extras); 41 void cancelSync(in Account account, String authority); 42 43 /** 44 * Check if the provider should be synced when a network tickle is received 45 * @param providerName the provider whose setting we are querying 46 * @return true if the provider should be synced when a network tickle is received 47 */ 48 boolean getSyncAutomatically(in Account account, String providerName); 49 50 /** 51 * Set whether or not the provider is synced when it receives a network tickle. 52 * 53 * @param providerName the provider whose behavior is being controlled 54 * @param sync true if the provider should be synced when tickles are received for it 55 */ 56 void setSyncAutomatically(in Account account, String providerName, boolean sync); 57 58 /** 59 * Get the frequency of the periodic poll, if any. 60 * @param providerName the provider whose setting we are querying 61 * @return the frequency of the periodic sync in seconds. If 0 then no periodic syncs 62 * will take place. 63 */ 64 List<PeriodicSync> getPeriodicSyncs(in Account account, String providerName); 65 66 /** 67 * Set whether or not the provider is to be synced on a periodic basis. 68 * 69 * @param providerName the provider whose behavior is being controlled 70 * @param pollFrequency the period that a sync should be performed, in seconds. If this is 71 * zero or less then no periodic syncs will be performed. 72 */ 73 void addPeriodicSync(in Account account, String providerName, in Bundle extras, 74 long pollFrequency); 75 76 /** 77 * Set whether or not the provider is to be synced on a periodic basis. 78 * 79 * @param providerName the provider whose behavior is being controlled 80 * @param pollFrequency the period that a sync should be performed, in seconds. If this is 81 * zero or less then no periodic syncs will be performed. 82 */ 83 void removePeriodicSync(in Account account, String providerName, in Bundle extras); 84 85 /** 86 * Check if this account/provider is syncable. 87 * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. 88 */ 89 int getIsSyncable(in Account account, String providerName); 90 91 /** 92 * Set whether this account/provider is syncable. 93 * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown 94 */ 95 void setIsSyncable(in Account account, String providerName, int syncable); 96 97 void setMasterSyncAutomatically(boolean flag); 98 99 boolean getMasterSyncAutomatically(); 100 101 /** 102 * Returns true if there is currently a sync operation for the given 103 * account or authority in the pending list, or actively being processed. 104 */ 105 boolean isSyncActive(in Account account, String authority); 106 107 SyncInfo getCurrentSync(); 108 109 /** 110 * Returns the types of the SyncAdapters that are registered with the system. 111 * @return Returns the types of the SyncAdapters that are registered with the system. 112 */ 113 SyncAdapterType[] getSyncAdapterTypes(); 114 115 /** 116 * Returns the status that matches the authority. If there are multiples accounts for 117 * the authority, the one with the latest "lastSuccessTime" status is returned. 118 * @param authority the authority whose row should be selected 119 * @return the SyncStatusInfo for the authority, or null if none exists 120 */ 121 SyncStatusInfo getSyncStatus(in Account account, String authority); 122 123 /** 124 * Return true if the pending status is true of any matching authorities. 125 */ 126 boolean isSyncPending(in Account account, String authority); 127 128 void addStatusChangeListener(int mask, ISyncStatusObserver callback); 129 130 void removeStatusChangeListener(ISyncStatusObserver callback); 131} 132