1231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn/* 2231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Copyright (C) 2009 The Android Open Source Project 3231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 4231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 5231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * you may not use this file except in compliance with the License. 6231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * You may obtain a copy of the License at 7231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 8231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 9231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 10231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Unless required by applicable law or agreed to in writing, software 11231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 12231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * See the License for the specific language governing permissions and 14231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * limitations under the License. 15231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 16231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 17231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornpackage android.content; 18231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 197a1355950172b7a549820e9a2cd4a9b2099ec32fDianne Hackbornimport android.accounts.Account; 2056dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williamsimport android.content.ComponentName; 21d5e4fdc8a4743abc0d9fe3cb952a78f9ad078c6bFred Quintanaimport android.content.SyncInfo; 22231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.content.ISyncStatusObserver; 23ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintanaimport android.content.SyncAdapterType; 24fa77418134c6f1f80af225a78819f069e9c974fbMatthew Williamsimport android.content.SyncRequest; 25231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.content.SyncStatusInfo; 26c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintanaimport android.content.PeriodicSync; 27231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.net.Uri; 28231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.os.Bundle; 29231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackbornimport android.database.IContentObserver; 30231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 31231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn/** 32231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * @hide 33231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 34231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborninterface IContentService { 35231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn void unregisterContentObserver(IContentObserver observer); 36231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 3716aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate /** 3816aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * Register a content observer tied to a specific user's view of the provider. 3916aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * @param userHandle the user whose view of the provider is to be observed. May be 4016aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * the calling user without requiring any permission, otherwise the caller needs to 4116aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * hold the INTERACT_ACROSS_USERS_FULL permission. Pseudousers USER_ALL and 4216aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * USER_CURRENT are properly handled. 4316aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate */ 4416aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate void registerContentObserver(in Uri uri, boolean notifyForDescendants, 45912e80d3450943ac2bbca03f33c31c042799a0a1Jeff Sharkey IContentObserver observer, int userHandle, int targetSdkVersion); 4616aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate 4716aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate /** 4816aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * Notify observers of a particular user's view of the provider. 4916aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * @param userHandle the user whose view of the provider is to be notified. May be 5016aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * the calling user without requiring any permission, otherwise the caller needs to 5116aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * hold the INTERACT_ACROSS_USERS_FULL permission. Pseudousers USER_ALL 5216aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate * USER_CURRENT are properly interpreted. 5316aa9736175f5bbe924a6e5587a2ca47c2dd702bChristopher Tate */ 54231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn void notifyChange(in Uri uri, IContentObserver observer, 55141f11c82a2dbf042833f75aeae6f028e8ae2084Dianne Hackborn boolean observerWantsSelfNotifications, int flags, 56912e80d3450943ac2bbca03f33c31c042799a0a1Jeff Sharkey int userHandle, int targetSdkVersion); 57231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 58ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana void requestSync(in Account account, String authority, in Bundle extras); 5956dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams /** 6056dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * Start a sync given a request. 6156dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams */ 62fa77418134c6f1f80af225a78819f069e9c974fbMatthew Williams void sync(in SyncRequest request); 630363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina void syncAsUser(in SyncRequest request, int userId); 6456dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams void cancelSync(in Account account, String authority, in ComponentName cname); 650363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina void cancelSyncAsUser(in Account account, String authority, in ComponentName cname, int userId); 6656dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams 6756dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams /** Cancel a sync, providing information about the sync to be cancelled. */ 6856dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams void cancelRequest(in SyncRequest request); 69c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana 70231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn /** 71231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Check if the provider should be synced when a network tickle is received 72231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * @param providerName the provider whose setting we are querying 73c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * @return true if the provider should be synced when a network tickle is received 74231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 75ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana boolean getSyncAutomatically(in Account account, String providerName); 760363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina boolean getSyncAutomaticallyAsUser(in Account account, String providerName, int userId); 77231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 78231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn /** 79231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Set whether or not the provider is synced when it receives a network tickle. 80231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * 81231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * @param providerName the provider whose behavior is being controlled 82231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * @param sync true if the provider should be synced when tickles are received for it 83231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 84ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana void setSyncAutomatically(in Account account, String providerName, boolean sync); 85cb22807ffcf79db1b62162842d0a90251a463ea7Alexandra Gherghina void setSyncAutomaticallyAsUser(in Account account, String providerName, boolean sync, 86cb22807ffcf79db1b62162842d0a90251a463ea7Alexandra Gherghina int userId); 87231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 885e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana /** 8956dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * Get a list of periodic operations for a specified authority, or service. 9056dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param account account for authority, must be null if cname is non-null. 9156dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param providerName name of provider, must be null if cname is non-null. 9256dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param cname component to identify sync service, must be null if account/providerName are 9356dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * non-null. 94c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana */ 9556dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams List<PeriodicSync> getPeriodicSyncs(in Account account, String providerName, 9656dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams in ComponentName cname); 97c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana 98c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana /** 99c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * Set whether or not the provider is to be synced on a periodic basis. 100c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * 101c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * @param providerName the provider whose behavior is being controlled 102c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * @param pollFrequency the period that a sync should be performed, in seconds. If this is 103c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * zero or less then no periodic syncs will be performed. 104c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana */ 105c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana void addPeriodicSync(in Account account, String providerName, in Bundle extras, 106c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana long pollFrequency); 107c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana 108c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana /** 109c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * Set whether or not the provider is to be synced on a periodic basis. 110c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * 111c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * @param providerName the provider whose behavior is being controlled 112c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * @param pollFrequency the period that a sync should be performed, in seconds. If this is 113c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana * zero or less then no periodic syncs will be performed. 114c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana */ 115c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana void removePeriodicSync(in Account account, String providerName, in Bundle extras); 116c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana 117c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana /** 1185e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana * Check if this account/provider is syncable. 1195e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. 1205e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana */ 1215e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana int getIsSyncable(in Account account, String providerName); 1220363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina int getIsSyncableAsUser(in Account account, String providerName, int userId); 1235e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana 1245e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana /** 1255e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana * Set whether this account/provider is syncable. 1265e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown 1275e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana */ 1285e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana void setIsSyncable(in Account account, String providerName, int syncable); 1295e787c42f2a6b3afc8ec8320a08d51b2d44b8614Fred Quintana 13056dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams void setMasterSyncAutomatically(boolean flag); 1314d4d4dc4e0bdbe9cceac04b4b1d92c1c71b7bac0Alexandra Gherghina void setMasterSyncAutomaticallyAsUser(boolean flag, int userId); 13256dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams 13356dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams boolean getMasterSyncAutomatically(); 1340363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina boolean getMasterSyncAutomaticallyAsUser(int userId); 1354890b085fb4a3f79dd29627a824a77a4fbda3924Torne (Richard Coles) 136c6a69559cb62bd20166c0c9684e64c60d779da38Fred Quintana List<SyncInfo> getCurrentSyncs(); 1370363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina List<SyncInfo> getCurrentSyncsAsUser(int userId); 138c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana 139231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn /** 140ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana * Returns the types of the SyncAdapters that are registered with the system. 141ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana * @return Returns the types of the SyncAdapters that are registered with the system. 142ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana */ 143ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana SyncAdapterType[] getSyncAdapterTypes(); 1440363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina SyncAdapterType[] getSyncAdapterTypesAsUser(int userId); 145ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana 14637a40c24deb02bca3868a8085069afae112f22e4Amith Yamasani String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId); 14737a40c24deb02bca3868a8085069afae112f22e4Amith Yamasani 148ac9385ef3105fb7464e1f46049c62755a8b7f0e9Fred Quintana /** 14956dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * Returns true if there is currently a operation for the given account/authority or service 15056dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * actively being processed. 15156dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param account account for authority, must be null if cname is non-null. 15256dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param providerName name of provider, must be null if cname is non-null. 15356dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param cname component to identify sync service, must be null if account/providerName are 15456dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * non-null. 15556dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams */ 15656dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams boolean isSyncActive(in Account account, String authority, in ComponentName cname); 15756dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams 15856dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams /** 159231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Returns the status that matches the authority. If there are multiples accounts for 160231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * the authority, the one with the latest "lastSuccessTime" status is returned. 16156dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param account account for authority, must be null if cname is non-null. 16256dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param providerName name of provider, must be null if cname is non-null. 16356dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param cname component to identify sync service, must be null if account/providerName are 16456dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * non-null. 165231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 16656dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams SyncStatusInfo getSyncStatus(in Account account, String authority, in ComponentName cname); 1670363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina SyncStatusInfo getSyncStatusAsUser(in Account account, String authority, in ComponentName cname, 1680363c3eb089afd4474bfd6ae6ee8a500d6e97614Alexandra Gherghina int userId); 169231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn 170231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn /** 171231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn * Return true if the pending status is true of any matching authorities. 17256dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param account account for authority, must be null if cname is non-null. 17356dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param providerName name of provider, must be null if cname is non-null. 17456dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * @param cname component to identify sync service, must be null if account/providerName are 17556dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams * non-null. 176231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn */ 17756dbf8f23677d28615e61ef2fbb0e738cca02528Matthew Williams boolean isSyncPending(in Account account, String authority, in ComponentName cname); 178cb22807ffcf79db1b62162842d0a90251a463ea7Alexandra Gherghina boolean isSyncPendingAsUser(in Account account, String authority, in ComponentName cname, 179cb22807ffcf79db1b62162842d0a90251a463ea7Alexandra Gherghina int userId); 180c5d1c6db61f208b206b260f897bb5bbc64be4d97Fred Quintana 181231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn void addStatusChangeListener(int mask, ISyncStatusObserver callback); 182231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn void removeStatusChangeListener(ISyncStatusObserver callback); 1838731408b11a24e3a92188653548f2c90bf866a32Jeff Sharkey 1848731408b11a24e3a92188653548f2c90bf866a32Jeff Sharkey void putCache(in String packageName, in Uri key, in Bundle value, int userId); 1858731408b11a24e3a92188653548f2c90bf866a32Jeff Sharkey Bundle getCache(in String packageName, in Uri key, int userId); 186231cc608d06ffc31c24bf8aa8c8275bdd2636581Dianne Hackborn} 187