Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 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 | |
Dianne Hackborn | 7a13559 | 2009-05-06 00:28:37 -0700 | [diff] [blame] | 19 | import android.accounts.Account; |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 20 | import android.content.ComponentName; |
Fred Quintana | d5e4fdc | 2010-03-30 15:16:21 -0700 | [diff] [blame] | 21 | import android.content.SyncInfo; |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 22 | import android.content.ISyncStatusObserver; |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 23 | import android.content.SyncAdapterType; |
Matthew Williams | fa77418 | 2013-06-18 15:44:11 -0700 | [diff] [blame] | 24 | import android.content.SyncRequest; |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 25 | import android.content.SyncStatusInfo; |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 26 | import android.content.PeriodicSync; |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 27 | import android.net.Uri; |
| 28 | import android.os.Bundle; |
| 29 | import android.database.IContentObserver; |
| 30 | |
| 31 | /** |
| 32 | * @hide |
| 33 | */ |
| 34 | interface IContentService { |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 35 | void unregisterContentObserver(IContentObserver observer); |
| 36 | |
Christopher Tate | 16aa973 | 2012-09-17 16:23:44 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Register a content observer tied to a specific user's view of the provider. |
| 39 | * @param userHandle the user whose view of the provider is to be observed. May be |
| 40 | * the calling user without requiring any permission, otherwise the caller needs to |
| 41 | * hold the INTERACT_ACROSS_USERS_FULL permission. Pseudousers USER_ALL and |
| 42 | * USER_CURRENT are properly handled. |
| 43 | */ |
| 44 | void registerContentObserver(in Uri uri, boolean notifyForDescendants, |
| 45 | IContentObserver observer, int userHandle); |
| 46 | |
| 47 | /** |
| 48 | * Notify observers of a particular user's view of the provider. |
| 49 | * @param userHandle the user whose view of the provider is to be notified. May be |
| 50 | * the calling user without requiring any permission, otherwise the caller needs to |
| 51 | * hold the INTERACT_ACROSS_USERS_FULL permission. Pseudousers USER_ALL |
| 52 | * USER_CURRENT are properly interpreted. |
| 53 | */ |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 54 | void notifyChange(in Uri uri, IContentObserver observer, |
Christopher Tate | 16aa973 | 2012-09-17 16:23:44 -0700 | [diff] [blame] | 55 | boolean observerWantsSelfNotifications, boolean syncToNetwork, |
| 56 | int userHandle); |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 57 | |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 58 | void requestSync(in Account account, String authority, in Bundle extras); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Start a sync given a request. |
| 61 | */ |
Matthew Williams | fa77418 | 2013-06-18 15:44:11 -0700 | [diff] [blame] | 62 | void sync(in SyncRequest request); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 63 | void syncAsUser(in SyncRequest request, int userId); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 64 | void cancelSync(in Account account, String authority, in ComponentName cname); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 65 | void cancelSyncAsUser(in Account account, String authority, in ComponentName cname, int userId); |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 66 | |
| 67 | /** Cancel a sync, providing information about the sync to be cancelled. */ |
| 68 | void cancelRequest(in SyncRequest request); |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 69 | |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 70 | /** |
| 71 | * Check if the provider should be synced when a network tickle is received |
| 72 | * @param providerName the provider whose setting we are querying |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 73 | * @return true if the provider should be synced when a network tickle is received |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 74 | */ |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 75 | boolean getSyncAutomatically(in Account account, String providerName); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 76 | boolean getSyncAutomaticallyAsUser(in Account account, String providerName, int userId); |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
| 79 | * Set whether or not the provider is synced when it receives a network tickle. |
| 80 | * |
| 81 | * @param providerName the provider whose behavior is being controlled |
| 82 | * @param sync true if the provider should be synced when tickles are received for it |
| 83 | */ |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 84 | void setSyncAutomatically(in Account account, String providerName, boolean sync); |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 85 | |
Fred Quintana | 5e787c4 | 2009-08-16 23:13:53 -0700 | [diff] [blame] | 86 | /** |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 87 | * Get a list of periodic operations for a specified authority, or service. |
| 88 | * @param account account for authority, must be null if cname is non-null. |
| 89 | * @param providerName name of provider, must be null if cname is non-null. |
| 90 | * @param cname component to identify sync service, must be null if account/providerName are |
| 91 | * non-null. |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 92 | */ |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 93 | List<PeriodicSync> getPeriodicSyncs(in Account account, String providerName, |
| 94 | in ComponentName cname); |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Set whether or not the provider is to be synced on a periodic basis. |
| 98 | * |
| 99 | * @param providerName the provider whose behavior is being controlled |
| 100 | * @param pollFrequency the period that a sync should be performed, in seconds. If this is |
| 101 | * zero or less then no periodic syncs will be performed. |
| 102 | */ |
| 103 | void addPeriodicSync(in Account account, String providerName, in Bundle extras, |
| 104 | long pollFrequency); |
| 105 | |
| 106 | /** |
| 107 | * Set whether or not the provider is to be synced on a periodic basis. |
| 108 | * |
| 109 | * @param providerName the provider whose behavior is being controlled |
| 110 | * @param pollFrequency the period that a sync should be performed, in seconds. If this is |
| 111 | * zero or less then no periodic syncs will be performed. |
| 112 | */ |
| 113 | void removePeriodicSync(in Account account, String providerName, in Bundle extras); |
| 114 | |
| 115 | /** |
Fred Quintana | 5e787c4 | 2009-08-16 23:13:53 -0700 | [diff] [blame] | 116 | * Check if this account/provider is syncable. |
| 117 | * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. |
| 118 | */ |
| 119 | int getIsSyncable(in Account account, String providerName); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 120 | int getIsSyncableAsUser(in Account account, String providerName, int userId); |
Fred Quintana | 5e787c4 | 2009-08-16 23:13:53 -0700 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * Set whether this account/provider is syncable. |
| 124 | * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown |
| 125 | */ |
| 126 | void setIsSyncable(in Account account, String providerName, int syncable); |
| 127 | |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 128 | void setMasterSyncAutomatically(boolean flag); |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 129 | |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 130 | boolean getMasterSyncAutomatically(); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 131 | boolean getMasterSyncAutomaticallyAsUser(int userId); |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 132 | |
Fred Quintana | c6a6955 | 2010-09-27 17:05:04 -0700 | [diff] [blame] | 133 | List<SyncInfo> getCurrentSyncs(); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 134 | List<SyncInfo> getCurrentSyncsAsUser(int userId); |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 135 | |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 136 | /** |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 137 | * Returns the types of the SyncAdapters that are registered with the system. |
| 138 | * @return Returns the types of the SyncAdapters that are registered with the system. |
| 139 | */ |
| 140 | SyncAdapterType[] getSyncAdapterTypes(); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 141 | SyncAdapterType[] getSyncAdapterTypesAsUser(int userId); |
Fred Quintana | ac9385e | 2009-06-22 18:00:59 -0700 | [diff] [blame] | 142 | |
| 143 | /** |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 144 | * Returns true if there is currently a operation for the given account/authority or service |
| 145 | * actively being processed. |
| 146 | * @param account account for authority, must be null if cname is non-null. |
| 147 | * @param providerName name of provider, must be null if cname is non-null. |
| 148 | * @param cname component to identify sync service, must be null if account/providerName are |
| 149 | * non-null. |
| 150 | */ |
| 151 | boolean isSyncActive(in Account account, String authority, in ComponentName cname); |
| 152 | |
| 153 | /** |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 154 | * Returns the status that matches the authority. If there are multiples accounts for |
| 155 | * the authority, the one with the latest "lastSuccessTime" status is returned. |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 156 | * @param account account for authority, must be null if cname is non-null. |
| 157 | * @param providerName name of provider, must be null if cname is non-null. |
| 158 | * @param cname component to identify sync service, must be null if account/providerName are |
| 159 | * non-null. |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 160 | */ |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 161 | SyncStatusInfo getSyncStatus(in Account account, String authority, in ComponentName cname); |
Alexandra Gherghina | 0363c3e | 2014-06-23 13:34:59 +0100 | [diff] [blame^] | 162 | SyncStatusInfo getSyncStatusAsUser(in Account account, String authority, in ComponentName cname, |
| 163 | int userId); |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 164 | |
| 165 | /** |
| 166 | * Return true if the pending status is true of any matching authorities. |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 167 | * @param account account for authority, must be null if cname is non-null. |
| 168 | * @param providerName name of provider, must be null if cname is non-null. |
| 169 | * @param cname component to identify sync service, must be null if account/providerName are |
| 170 | * non-null. |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 171 | */ |
Matthew Williams | 56dbf8f | 2013-07-26 12:56:39 -0700 | [diff] [blame] | 172 | boolean isSyncPending(in Account account, String authority, in ComponentName cname); |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 173 | |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 174 | void addStatusChangeListener(int mask, ISyncStatusObserver callback); |
Fred Quintana | c5d1c6d | 2010-01-27 12:17:49 -0800 | [diff] [blame] | 175 | |
Dianne Hackborn | 231cc60 | 2009-04-27 17:10:36 -0700 | [diff] [blame] | 176 | void removeStatusChangeListener(ISyncStatusObserver callback); |
| 177 | } |