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