| 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 |
|
| 19 |
import android.accounts.Account; |
| 20 |
import android.content.ComponentName; |
| 21 |
import android.content.SyncInfo; |
| 22 |
import android.content.ISyncStatusObserver; |
| 23 |
import android.content.SyncAdapterType; |
| 24 |
import android.content.SyncRequest; |
| 25 |
import android.content.SyncStatusInfo; |
| 26 |
import android.content.PeriodicSync; |
| 27 |
import android.net.Uri; |
| 28 |
import android.os.Bundle; |
| 29 |
import android.database.IContentObserver; |
| 30 |
|
| 31 |
/** |
| 32 |
* @hide |
| 33 |
*/ |
| 34 |
interface IContentService { |
| 35 |
void unregisterContentObserver(IContentObserver observer); |
| 36 |
|
| 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, int targetSdkVersion); |
| 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 |
*/ |
| 54 |
void notifyChange(in Uri[] uris, IContentObserver observer, |
| 55 |
boolean observerWantsSelfNotifications, int flags, |
| 56 |
int userHandle, int targetSdkVersion, String callingPackage); |
| 57 |
|
| 58 |
void requestSync(in Account account, String authority, in Bundle extras, String callingPackage); |
| 59 |
/** |
| 60 |
* Start a sync given a request. |
| 61 |
*/ |
| 62 |
void sync(in SyncRequest request, String callingPackage); |
| 63 |
void syncAsUser(in SyncRequest request, int userId, String callingPackage); |
| 64 |
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) |
| 65 |
void cancelSync(in Account account, String authority, in ComponentName cname); |
| 66 |
void cancelSyncAsUser(in Account account, String authority, in ComponentName cname, int userId); |
| 67 |
|
| 68 |
/** Cancel a sync, providing information about the sync to be cancelled. */ |
| 69 |
void cancelRequest(in SyncRequest request); |
| 70 |
|
| 71 |
/** |
| 72 |
* Check if the provider should be synced when a network tickle is received |
| 73 |
* @param providerName the provider whose setting we are querying |
| 74 |
* @return true if the provider should be synced when a network tickle is received |
| 75 |
*/ |
| 76 |
boolean getSyncAutomatically(in Account account, String providerName); |
| 77 |
boolean getSyncAutomaticallyAsUser(in Account account, String providerName, int userId); |
| 78 |
|
| 79 |
/** |
| 80 |
* Set whether or not the provider is synced when it receives a network tickle. |
| 81 |
* |
| 82 |
* @param providerName the provider whose behavior is being controlled |
| 83 |
* @param sync true if the provider should be synced when tickles are received for it |
| 84 |
*/ |
| 85 |
void setSyncAutomatically(in Account account, String providerName, boolean sync); |
| 86 |
void setSyncAutomaticallyAsUser(in Account account, String providerName, boolean sync, |
| 87 |
int userId); |
| 88 |
|
| 89 |
/** |
| 90 |
* Get a list of periodic operations for a specified authority, or service. |
| 91 |
* @param account account for authority, must be null if cname is non-null. |
| 92 |
* @param providerName name of provider, must be null if cname is non-null. |
| 93 |
* @param cname component to identify sync service, must be null if account/providerName are |
| 94 |
* non-null. |
| 95 |
*/ |
| 96 |
List<PeriodicSync> getPeriodicSyncs(in Account account, String providerName, |
| 97 |
in ComponentName cname); |
| 98 |
|
| 99 |
/** |
| 100 |
* Set whether or not the provider is to be synced on a periodic basis. |
| 101 |
* |
| 102 |
* @param providerName the provider whose behavior is being controlled |
| 103 |
* @param pollFrequency the period that a sync should be performed, in seconds. If this is |
| 104 |
* zero or less then no periodic syncs will be performed. |
| 105 |
*/ |
| 106 |
void addPeriodicSync(in Account account, String providerName, in Bundle extras, |
| 107 |
long pollFrequency); |
| 108 |
|
| 109 |
/** |
| 110 |
* Set whether or not the provider is to be synced on a periodic basis. |
| 111 |
* |
| 112 |
* @param providerName the provider whose behavior is being controlled |
| 113 |
* @param pollFrequency the period that a sync should be performed, in seconds. If this is |
| 114 |
* zero or less then no periodic syncs will be performed. |
| 115 |
*/ |
| 116 |
void removePeriodicSync(in Account account, String providerName, in Bundle extras); |
| 117 |
|
| 118 |
/** |
| 119 |
* Check if this account/provider is syncable. |
| 120 |
* @return >0 if it is syncable, 0 if not, and <0 if the state isn't known yet. |
| 121 |
*/ |
| 122 |
@UnsupportedAppUsage |
| 123 |
int getIsSyncable(in Account account, String providerName); |
| 124 |
int getIsSyncableAsUser(in Account account, String providerName, int userId); |
| 125 |
|
| 126 |
/** |
| 127 |
* Set whether this account/provider is syncable. |
| 128 |
* @param syncable, >0 denotes syncable, 0 means not syncable, <0 means unknown |
| 129 |
*/ |
| 130 |
void setIsSyncable(in Account account, String providerName, int syncable); |
| 131 |
void setIsSyncableAsUser(in Account account, String providerName, int syncable, int userId); |
| 132 |
|
| 133 |
@UnsupportedAppUsage |
| 134 |
void setMasterSyncAutomatically(boolean flag); |
| 135 |
void setMasterSyncAutomaticallyAsUser(boolean flag, int userId); |
| 136 |
|
| 137 |
@UnsupportedAppUsage |
| 138 |
boolean getMasterSyncAutomatically(); |
| 139 |
boolean getMasterSyncAutomaticallyAsUser(int userId); |
| 140 |
|
| 141 |
List<SyncInfo> getCurrentSyncs(); |
| 142 |
List<SyncInfo> getCurrentSyncsAsUser(int userId); |
| 143 |
|
| 144 |
/** |
| 145 |
* Returns the types of the SyncAdapters that are registered with the system. |
| 146 |
* @return Returns the types of the SyncAdapters that are registered with the system. |
| 147 |
*/ |
| 148 |
@UnsupportedAppUsage |
| 149 |
SyncAdapterType[] getSyncAdapterTypes(); |
| 150 |
SyncAdapterType[] getSyncAdapterTypesAsUser(int userId); |
| 151 |
|
| 152 |
String[] getSyncAdapterPackagesForAuthorityAsUser(String authority, int userId); |
| 153 |
String getSyncAdapterPackageAsUser(String accountType, String authority, int userId); |
| 154 |
|
| 155 |
/** |
| 156 |
* Returns true if there is currently a operation for the given account/authority or service |
| 157 |
* actively being processed. |
| 158 |
* @param account account for authority, must be null if cname is non-null. |
| 159 |
* @param providerName name of provider, must be null if cname is non-null. |
| 160 |
* @param cname component to identify sync service, must be null if account/providerName are |
| 161 |
* non-null. |
| 162 |
*/ |
| 163 |
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) |
| 164 |
boolean isSyncActive(in Account account, String authority, in ComponentName cname); |
| 165 |
|
| 166 |
/** |
| 167 |
* Returns the status that matches the authority. If there are multiples accounts for |
| 168 |
* the authority, the one with the latest "lastSuccessTime" status is returned. |
| 169 |
* @param account account for authority, must be null if cname is non-null. |
| 170 |
* @param providerName name of provider, must be null if cname is non-null. |
| 171 |
* @param cname component to identify sync service, must be null if account/providerName are |
| 172 |
* non-null. |
| 173 |
*/ |
| 174 |
SyncStatusInfo getSyncStatus(in Account account, String authority, in ComponentName cname); |
| 175 |
SyncStatusInfo getSyncStatusAsUser(in Account account, String authority, in ComponentName cname, |
| 176 |
int userId); |
| 177 |
|
| 178 |
/** |
| 179 |
* Return true if the pending status is true of any matching authorities. |
| 180 |
* @param account account for authority, must be null if cname is non-null. |
| 181 |
* @param providerName name of provider, must be null if cname is non-null. |
| 182 |
* @param cname component to identify sync service, must be null if account/providerName are |
| 183 |
* non-null. |
| 184 |
*/ |
| 185 |
boolean isSyncPending(in Account account, String authority, in ComponentName cname); |
| 186 |
boolean isSyncPendingAsUser(in Account account, String authority, in ComponentName cname, |
| 187 |
int userId); |
| 188 |
|
| 189 |
void addStatusChangeListener(int mask, ISyncStatusObserver callback); |
| 190 |
void removeStatusChangeListener(ISyncStatusObserver callback); |
| 191 |
|
| 192 |
void putCache(in String packageName, in Uri key, in Bundle value, int userId); |
| 193 |
Bundle getCache(in String packageName, in Uri key, int userId); |
| 194 |
|
| 195 |
void resetTodayStats(); |
| 196 |
|
| 197 |
void onDbCorruption(String tag, String message, String stacktrace); |
| 198 |
} |