blob: 9f6e236306e0410254c19a43591110457f362bee [file] [log] [blame]
Dianne Hackborn231cc602009-04-27 17:10:36 -07001/*
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
Dianne Hackborn7a135592009-05-06 00:28:37 -070019import android.accounts.Account;
Matthew Williams56dbf8f2013-07-26 12:56:39 -070020import android.content.ComponentName;
Fred Quintanad5e4fdc2010-03-30 15:16:21 -070021import android.content.SyncInfo;
Dianne Hackborn231cc602009-04-27 17:10:36 -070022import android.content.ISyncStatusObserver;
Fred Quintanaac9385e2009-06-22 18:00:59 -070023import android.content.SyncAdapterType;
Matthew Williamsfa774182013-06-18 15:44:11 -070024import android.content.SyncRequest;
Dianne Hackborn231cc602009-04-27 17:10:36 -070025import android.content.SyncStatusInfo;
Fred Quintanac5d1c6d2010-01-27 12:17:49 -080026import android.content.PeriodicSync;
Dianne Hackborn231cc602009-04-27 17:10:36 -070027import android.net.Uri;
28import android.os.Bundle;
29import android.database.IContentObserver;
30
31/**
32 * @hide
33 */
34interface IContentService {
Dianne Hackborn231cc602009-04-27 17:10:36 -070035 void unregisterContentObserver(IContentObserver observer);
36
Christopher Tate16aa9732012-09-17 16:23:44 -070037 /**
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,
Jeff Sharkey912e80d2017-02-24 11:00:55 -070045 IContentObserver observer, int userHandle, int targetSdkVersion);
Christopher Tate16aa9732012-09-17 16:23:44 -070046
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 Hackborn231cc602009-04-27 17:10:36 -070054 void notifyChange(in Uri uri, IContentObserver observer,
Dianne Hackborn141f11c2016-04-05 15:46:12 -070055 boolean observerWantsSelfNotifications, int flags,
Makoto Onukie183a402018-08-29 11:46:41 -070056 int userHandle, int targetSdkVersion, String callingPackage);
Dianne Hackborn231cc602009-04-27 17:10:36 -070057
Makoto Onukie183a402018-08-29 11:46:41 -070058 void requestSync(in Account account, String authority, in Bundle extras, String callingPackage);
Matthew Williams56dbf8f2013-07-26 12:56:39 -070059 /**
60 * Start a sync given a request.
61 */
Makoto Onukie183a402018-08-29 11:46:41 -070062 void sync(in SyncRequest request, String callingPackage);
63 void syncAsUser(in SyncRequest request, int userId, String callingPackage);
Matthew Williams56dbf8f2013-07-26 12:56:39 -070064 void cancelSync(in Account account, String authority, in ComponentName cname);
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +010065 void cancelSyncAsUser(in Account account, String authority, in ComponentName cname, int userId);
Matthew Williams56dbf8f2013-07-26 12:56:39 -070066
67 /** Cancel a sync, providing information about the sync to be cancelled. */
68 void cancelRequest(in SyncRequest request);
Fred Quintanac5d1c6d2010-01-27 12:17:49 -080069
Dianne Hackborn231cc602009-04-27 17:10:36 -070070 /**
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 Quintanac5d1c6d2010-01-27 12:17:49 -080073 * @return true if the provider should be synced when a network tickle is received
Dianne Hackborn231cc602009-04-27 17:10:36 -070074 */
Fred Quintanaac9385e2009-06-22 18:00:59 -070075 boolean getSyncAutomatically(in Account account, String providerName);
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +010076 boolean getSyncAutomaticallyAsUser(in Account account, String providerName, int userId);
Dianne Hackborn231cc602009-04-27 17:10:36 -070077
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 Quintanaac9385e2009-06-22 18:00:59 -070084 void setSyncAutomatically(in Account account, String providerName, boolean sync);
Alexandra Gherghinacb228072014-07-01 15:14:11 +010085 void setSyncAutomaticallyAsUser(in Account account, String providerName, boolean sync,
86 int userId);
Dianne Hackborn231cc602009-04-27 17:10:36 -070087
Fred Quintana5e787c42009-08-16 23:13:53 -070088 /**
Matthew Williams56dbf8f2013-07-26 12:56:39 -070089 * Get a list of periodic operations for a specified authority, or service.
90 * @param account account for authority, must be null if cname is non-null.
91 * @param providerName name of provider, must be null if cname is non-null.
92 * @param cname component to identify sync service, must be null if account/providerName are
93 * non-null.
Fred Quintanac5d1c6d2010-01-27 12:17:49 -080094 */
Matthew Williams56dbf8f2013-07-26 12:56:39 -070095 List<PeriodicSync> getPeriodicSyncs(in Account account, String providerName,
96 in ComponentName cname);
Fred Quintanac5d1c6d2010-01-27 12:17:49 -080097
98 /**
99 * Set whether or not the provider is to be synced on a periodic basis.
100 *
101 * @param providerName the provider whose behavior is being controlled
102 * @param pollFrequency the period that a sync should be performed, in seconds. If this is
103 * zero or less then no periodic syncs will be performed.
104 */
105 void addPeriodicSync(in Account account, String providerName, in Bundle extras,
106 long pollFrequency);
107
108 /**
109 * Set whether or not the provider is to be synced on a periodic basis.
110 *
111 * @param providerName the provider whose behavior is being controlled
112 * @param pollFrequency the period that a sync should be performed, in seconds. If this is
113 * zero or less then no periodic syncs will be performed.
114 */
115 void removePeriodicSync(in Account account, String providerName, in Bundle extras);
116
117 /**
Fred Quintana5e787c42009-08-16 23:13:53 -0700118 * Check if this account/provider is syncable.
119 * @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet.
120 */
121 int getIsSyncable(in Account account, String providerName);
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +0100122 int getIsSyncableAsUser(in Account account, String providerName, int userId);
Fred Quintana5e787c42009-08-16 23:13:53 -0700123
124 /**
125 * Set whether this account/provider is syncable.
126 * @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown
127 */
128 void setIsSyncable(in Account account, String providerName, int syncable);
Ruslan Tkhakokhov19513032019-02-05 11:06:21 +0000129 void setIsSyncableAsUser(in Account account, String providerName, int syncable, int userId);
Fred Quintana5e787c42009-08-16 23:13:53 -0700130
Fred Quintanaac9385e2009-06-22 18:00:59 -0700131 void setMasterSyncAutomatically(boolean flag);
Alexandra Gherghina4d4d4dc2014-07-15 23:11:48 +0100132 void setMasterSyncAutomaticallyAsUser(boolean flag, int userId);
Dianne Hackborn231cc602009-04-27 17:10:36 -0700133
Fred Quintanaac9385e2009-06-22 18:00:59 -0700134 boolean getMasterSyncAutomatically();
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +0100135 boolean getMasterSyncAutomaticallyAsUser(int userId);
Fred Quintanac5d1c6d2010-01-27 12:17:49 -0800136
Fred Quintanac6a69552010-09-27 17:05:04 -0700137 List<SyncInfo> getCurrentSyncs();
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +0100138 List<SyncInfo> getCurrentSyncsAsUser(int userId);
Fred Quintanac5d1c6d2010-01-27 12:17:49 -0800139
Dianne Hackborn231cc602009-04-27 17:10:36 -0700140 /**
Fred Quintanaac9385e2009-06-22 18:00:59 -0700141 * Returns the types of the SyncAdapters that are registered with the system.
142 * @return Returns the types of the SyncAdapters that are registered with the system.
143 */
144 SyncAdapterType[] getSyncAdapterTypes();
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +0100145 SyncAdapterType[] getSyncAdapterTypesAsUser(int userId);
Fred Quintanaac9385e2009-06-22 18:00:59 -0700146
Amith Yamasani37a40c22015-06-17 13:25:42 -0700147 String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId);
148
Fred Quintanaac9385e2009-06-22 18:00:59 -0700149 /**
Matthew Williams56dbf8f2013-07-26 12:56:39 -0700150 * Returns true if there is currently a operation for the given account/authority or service
151 * actively being processed.
152 * @param account account for authority, must be null if cname is non-null.
153 * @param providerName name of provider, must be null if cname is non-null.
154 * @param cname component to identify sync service, must be null if account/providerName are
155 * non-null.
156 */
157 boolean isSyncActive(in Account account, String authority, in ComponentName cname);
158
159 /**
Dianne Hackborn231cc602009-04-27 17:10:36 -0700160 * Returns the status that matches the authority. If there are multiples accounts for
161 * the authority, the one with the latest "lastSuccessTime" status is returned.
Matthew Williams56dbf8f2013-07-26 12:56:39 -0700162 * @param account account for authority, must be null if cname is non-null.
163 * @param providerName name of provider, must be null if cname is non-null.
164 * @param cname component to identify sync service, must be null if account/providerName are
165 * non-null.
Dianne Hackborn231cc602009-04-27 17:10:36 -0700166 */
Matthew Williams56dbf8f2013-07-26 12:56:39 -0700167 SyncStatusInfo getSyncStatus(in Account account, String authority, in ComponentName cname);
Alexandra Gherghina0363c3e2014-06-23 13:34:59 +0100168 SyncStatusInfo getSyncStatusAsUser(in Account account, String authority, in ComponentName cname,
169 int userId);
Dianne Hackborn231cc602009-04-27 17:10:36 -0700170
171 /**
172 * Return true if the pending status is true of any matching authorities.
Matthew Williams56dbf8f2013-07-26 12:56:39 -0700173 * @param account account for authority, must be null if cname is non-null.
174 * @param providerName name of provider, must be null if cname is non-null.
175 * @param cname component to identify sync service, must be null if account/providerName are
176 * non-null.
Dianne Hackborn231cc602009-04-27 17:10:36 -0700177 */
Matthew Williams56dbf8f2013-07-26 12:56:39 -0700178 boolean isSyncPending(in Account account, String authority, in ComponentName cname);
Alexandra Gherghinacb228072014-07-01 15:14:11 +0100179 boolean isSyncPendingAsUser(in Account account, String authority, in ComponentName cname,
180 int userId);
Fred Quintanac5d1c6d2010-01-27 12:17:49 -0800181
Dianne Hackborn231cc602009-04-27 17:10:36 -0700182 void addStatusChangeListener(int mask, ISyncStatusObserver callback);
Dianne Hackborn231cc602009-04-27 17:10:36 -0700183 void removeStatusChangeListener(ISyncStatusObserver callback);
Jeff Sharkey87314082016-03-11 17:25:11 -0700184
185 void putCache(in String packageName, in Uri key, in Bundle value, int userId);
186 Bundle getCache(in String packageName, in Uri key, int userId);
Makoto Onuki94986212018-04-11 16:24:46 -0700187
188 void resetTodayStats();
Makoto Onukiee93ad22018-10-18 16:24:13 -0700189
190 void onDbCorruption(String tag, String message, String stacktrace);
Dianne Hackborn231cc602009-04-27 17:10:36 -0700191}