blob: 8386c72e340644a41e49c89eb32fe48657530a8b [file] [log] [blame]
Christopher Tate487529a2009-04-29 14:03:25 -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
Christopher Tate45281862010-03-05 15:46:30 -080017package android.app.backup;
Christopher Tate487529a2009-04-29 14:03:25 -070018
Sergey Poromovfe06bf62015-12-15 16:26:23 +010019import android.app.backup.IBackupObserver;
Stefanotb1f573d2017-01-27 12:03:53 +000020import android.app.backup.IBackupManagerMonitor;
Christopher Tate4a627c72011-04-01 14:43:32 -070021import android.app.backup.IFullBackupRestoreObserver;
Christopher Tate45281862010-03-05 15:46:30 -080022import android.app.backup.IRestoreSession;
Shreyas Basarge865303f2017-01-13 14:48:56 +000023import android.app.backup.ISelectBackupTransportCallback;
Christopher Tate4a627c72011-04-01 14:43:32 -070024import android.os.ParcelFileDescriptor;
Stefano Tommasini471a35d2019-01-21 13:21:48 +000025import android.os.UserHandle;
Christopher Tatef5e1c292010-12-08 18:40:26 -080026import android.content.Intent;
Shreyas Basarge865303f2017-01-13 14:48:56 +000027import android.content.ComponentName;
Christopher Tate8c850b72009-06-07 19:33:20 -070028
Christopher Tate487529a2009-04-29 14:03:25 -070029/**
30 * Direct interface to the Backup Manager Service that applications invoke on. The only
31 * operation currently needed is a simple notification that the app has made changes to
32 * data it wishes to back up, so the system should run a backup pass.
33 *
Christopher Tate45281862010-03-05 15:46:30 -080034 * Apps will use the {@link android.app.backup.BackupManager} class rather than going through
Christopher Tatea8bf8152009-04-30 11:36:21 -070035 * this Binder interface directly.
36 *
37 * {@hide}
Christopher Tate487529a2009-04-29 14:03:25 -070038 */
39interface IBackupManager {
40 /**
41 * Tell the system service that the caller has made changes to its
Christopher Tate46758122009-05-06 11:22:00 -070042 * data, and therefore needs to undergo an incremental backup pass.
Christopher Tateee0e78a2009-07-02 11:17:03 -070043 *
44 * Any application can invoke this method for its own package, but
45 * only callers who hold the android.permission.BACKUP permission
46 * may invoke it for arbitrary packages.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000047 * If {@code userId} is different from the calling user id, then the caller must hold the
48 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
49 *
50 * @param userId User id for which the caller has made changes to its data.
51 */
52 void dataChangedForUser(int userId, String packageName);
53
54 /**
55 * {@link android.app.backup.IBackupManager.dataChangedForUser} for the calling user id.
Christopher Tate487529a2009-04-29 14:03:25 -070056 */
Christopher Tate5cbbf562009-06-22 16:44:51 -070057 void dataChanged(String packageName);
Christopher Tate46758122009-05-06 11:22:00 -070058
59 /**
Christopher Tateb0183f02013-11-18 14:20:36 -080060 * Erase all backed-up data for the given package from the given storage
Christopher Tateee0e78a2009-07-02 11:17:03 -070061 * destination.
62 *
63 * Any application can invoke this method for its own package, but
64 * only callers who hold the android.permission.BACKUP permission
65 * may invoke it for arbitrary packages.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000066 * If {@code userId} is different from the calling user id, then the caller must hold the
67 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
68 *
69 * @param userId User id for which backup data should be erased.
70 */
71 void clearBackupDataForUser(int userId, String transportName, String packageName);
72
73 /**
74 * {@link android.app.backup.IBackupManager.clearBackupDataForUser} for the calling user id.
Christopher Tateee0e78a2009-07-02 11:17:03 -070075 */
Christopher Tateb0183f02013-11-18 14:20:36 -080076 void clearBackupData(String transportName, String packageName);
Christopher Tateee0e78a2009-07-02 11:17:03 -070077
78 /**
Christopher Tate924afe22017-06-16 13:14:48 -070079 * Run an initialize operation on the given transports. This will wipe all data from
80 * the backing data store and establish a clean starting point for all backup
81 * operations.
82 *
83 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000084 * If {@code userId} is different from the calling user id, then the caller must hold the
85 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
86 *
87 * @param userId User id for which the given transports should be initialized.
Christopher Tate924afe22017-06-16 13:14:48 -070088 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +000089 void initializeTransportsForUser(int userId, in String[] transportNames,
90 IBackupObserver observer);
Christopher Tate924afe22017-06-16 13:14:48 -070091
92 /**
Christopher Tate181fafa2009-05-14 11:12:14 -070093 * Notifies the Backup Manager Service that an agent has become available. This
94 * method is only invoked by the Activity Manager.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000095 *
96 * If {@code userId} is different from the calling user id, then the caller must hold the
97 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
98 *
99 * @param userId User id for which an agent has become available.
100 */
101 void agentConnectedForUser(int userId, String packageName, IBinder agent);
102
103 /**
104 * {@link android.app.backup.IBackupManager.agentConnected} for the calling user id.
Christopher Tate181fafa2009-05-14 11:12:14 -0700105 */
Christopher Tate5cbbf562009-06-22 16:44:51 -0700106 void agentConnected(String packageName, IBinder agent);
Christopher Tate181fafa2009-05-14 11:12:14 -0700107
108 /**
109 * Notify the Backup Manager Service that an agent has unexpectedly gone away.
110 * This method is only invoked by the Activity Manager.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000111 *
112 * If {@code userId} is different from the calling user id, then the caller must hold the
113 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
114 *
115 * @param userId User id for which an agent has unexpectedly gone away.
116 */
117 void agentDisconnectedForUser(int userId, String packageName);
118
119 /**
120 * {@link android.app.backup.IBackupManager.agentDisconnected} for the calling user id.
Christopher Tate181fafa2009-05-14 11:12:14 -0700121 */
Christopher Tate5cbbf562009-06-22 16:44:51 -0700122 void agentDisconnected(String packageName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700123
124 /**
Christopher Tate1bb69062010-02-19 17:02:12 -0800125 * Notify the Backup Manager Service that an application being installed will
126 * need a data-restore pass. This method is only invoked by the Package Manager.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000127 *
128 * If {@code userId} is different from the calling user id, then the caller must hold the
129 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
130 *
131 * @param userId User id for which the application will need a data-restore pass.
132 */
133 void restoreAtInstallForUser(int userId, String packageName, int token);
134
135 /**
136 * {@link android.app.backup.IBackupManager.restoreAtInstallForUser} for the calling user id.
Christopher Tate1bb69062010-02-19 17:02:12 -0800137 */
138 void restoreAtInstall(String packageName, int token);
139
140 /**
Christopher Tate6ef58a12009-06-29 14:56:28 -0700141 * Enable/disable the backup service entirely. When disabled, no backup
142 * or restore operations will take place. Data-changed notifications will
143 * still be observed and collected, however, so that changes made while the
144 * mechanism was disabled will still be backed up properly if it is enabled
145 * at some point in the future.
146 *
147 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathcd44f752018-12-07 16:49:37 +0000148 * If {@code userId} is different from the calling user id, then the caller must hold the
149 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
150 *
151 * @param userId User id for which backup service should be enabled/disabled.
152 */
153 void setBackupEnabledForUser(int userId, boolean isEnabled);
154
155 /**
156 * {@link android.app.backup.IBackupManager.setBackupEnabledForUser} for the calling user id.
Christopher Tate6ef58a12009-06-29 14:56:28 -0700157 */
158 void setBackupEnabled(boolean isEnabled);
159
160 /**
Christopher Tatecce9da52010-02-03 15:11:15 -0800161 * Enable/disable automatic restore of application data at install time. When
162 * enabled, installation of any package will involve the Backup Manager. If data
163 * exists for the newly-installed package, either from the device's current [enabled]
164 * backup dataset or from the restore set used in the last wholesale restore operation,
165 * that data will be supplied to the new package's restore agent before the package
166 * is made generally available for launch.
167 *
168 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000169 * If {@code userId} is different from the calling user id, then the caller must hold the
170 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tatecce9da52010-02-03 15:11:15 -0800171 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000172 * @param userId User id for which automatic restore should be enabled/disabled.
Christopher Tatecce9da52010-02-03 15:11:15 -0800173 * @param doAutoRestore When true, enables the automatic app-data restore facility. When
174 * false, this facility will be disabled.
175 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000176 void setAutoRestoreForUser(int userId, boolean doAutoRestore);
177
178 /**
179 * {@link android.app.backup.IBackupManager.setAutoRestoreForUser} for the calling user id.
180 */
Christopher Tatecce9da52010-02-03 15:11:15 -0800181 void setAutoRestore(boolean doAutoRestore);
182
183 /**
Christopher Tate6ef58a12009-06-29 14:56:28 -0700184 * Report whether the backup mechanism is currently enabled.
185 *
186 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathcd44f752018-12-07 16:49:37 +0000187 * If {@code userId} is different from the calling user id, then the caller must hold the
188 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
189 *
190 * @param userId User id for which the backup service status should be reported.
191 */
192 boolean isBackupEnabledForUser(int userId);
193
194 /**
195 * {@link android.app.backup.IBackupManager.isBackupEnabledForUser} for the calling user id.
Christopher Tate6ef58a12009-06-29 14:56:28 -0700196 */
197 boolean isBackupEnabled();
198
199 /**
Christopher Tate2efd2db2011-07-19 16:32:49 -0700200 * Set the device's backup password. Returns {@code true} if the password was set
201 * successfully, {@code false} otherwise. Typically a failure means that an incorrect
202 * current password was supplied.
203 *
204 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
205 */
206 boolean setBackupPassword(in String currentPw, in String newPw);
207
208 /**
209 * Reports whether a backup password is currently set. If not, then a null or empty
210 * "current password" argument should be passed to setBackupPassword().
211 *
212 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
213 */
214 boolean hasBackupPassword();
215
216 /**
Christopher Tateace7f092009-06-15 18:07:25 -0700217 * Schedule an immediate backup attempt for all pending updates. This is
218 * primarily intended for transports to use when they detect a suitable
219 * opportunity for doing a backup pass. If there are no pending updates to
220 * be sent, no action will be taken. Even if some updates are pending, the
221 * transport will still be asked to confirm via the usual requestBackupTime()
222 * method.
223 *
224 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathcd44f752018-12-07 16:49:37 +0000225 * If {@code userId} is different from the calling user id, then the caller must hold the
226 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
227 *
228 * @param userId User id for which an immediate backup should be scheduled.
229 */
230 void backupNowForUser(int userId);
231
232 /**
233 * {@link android.app.backup.IBackupManager.backupNowForUser} for the calling user id.
Christopher Tateace7f092009-06-15 18:07:25 -0700234 */
Christopher Tate5cbbf562009-06-22 16:44:51 -0700235 void backupNow();
Christopher Tateace7f092009-06-15 18:07:25 -0700236
237 /**
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000238 * Write a backup of the given package to the supplied file descriptor.
Christopher Tate4a627c72011-04-01 14:43:32 -0700239 * The fd may be a socket or other non-seekable destination. If no package names
240 * are supplied, then every application on the device will be backed up to the output.
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000241 * Currently only used by the 'adb backup' command.
Christopher Tate4a627c72011-04-01 14:43:32 -0700242 *
243 * <p>This method is <i>synchronous</i> -- it does not return until the backup has
244 * completed.
245 *
246 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000247 * If the {@code userId} is different from the calling user id, then the caller must hold the
248 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate4a627c72011-04-01 14:43:32 -0700249 *
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000250 * @param userId User id for which backup should be performed.
251 * @param fd The file descriptor to which a 'tar' file stream is to be written.
Christopher Tate4a627c72011-04-01 14:43:32 -0700252 * @param includeApks If <code>true</code>, the resulting tar stream will include the
253 * application .apk files themselves as well as their data.
Christopher Tate46cc43c2013-02-19 14:08:59 -0800254 * @param includeObbs If <code>true</code>, the resulting tar stream will include any
255 * application expansion (OBB) files themselves belonging to each application.
Christopher Tate4a627c72011-04-01 14:43:32 -0700256 * @param includeShared If <code>true</code>, the resulting tar stream will include
257 * the contents of the device's shared storage (SD card or equivalent).
258 * @param allApps If <code>true</code>, the resulting tar stream will include all
259 * installed applications' data, not just those named in the <code>packageNames</code>
260 * parameter.
Christopher Tate240c7d22011-10-03 18:13:44 -0700261 * @param allIncludesSystem If {@code true}, then {@code allApps} will be interpreted
262 * as including packages pre-installed as part of the system. If {@code false},
263 * then setting {@code allApps} to {@code true} will mean only that all 3rd-party
264 * applications will be included in the dataset.
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000265 * @param doKeyValue If {@code true}, also packages supporting key-value backup will be backed
266 * up. If {@code false}, key-value packages will be skipped.
Christopher Tate4a627c72011-04-01 14:43:32 -0700267 * @param packageNames The package names of the apps whose data (and optionally .apk files)
268 * are to be backed up. The <code>allApps</code> parameter supersedes this.
269 */
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000270 void adbBackup(int userId, in ParcelFileDescriptor fd, boolean includeApks, boolean includeObbs,
Christopher Tateadfe8b82014-02-04 16:23:32 -0800271 boolean includeShared, boolean doWidgets, boolean allApps, boolean allIncludesSystem,
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000272 boolean doCompress, boolean doKeyValue, in String[] packageNames);
Christopher Tate9ff53a72014-06-03 17:20:07 -0700273
274 /**
275 * Perform a full-dataset backup of the given applications via the currently active
276 * transport.
277 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000278 * If {@code userId} is different from the calling user id, then the caller must hold the
279 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
280 *
281 * @param userId User id for which the full-dataset backup should be performed.
Christopher Tate9ff53a72014-06-03 17:20:07 -0700282 * @param packageNames The package names of the apps whose data are to be backed up.
283 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000284 void fullTransportBackupForUser(int userId, in String[] packageNames);
Christopher Tate4a627c72011-04-01 14:43:32 -0700285
286 /**
Christopher Tate75a99702011-05-18 16:28:19 -0700287 * Restore device content from the data stream passed through the given socket. The
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000288 * data stream must be in the format emitted by adbBackup().
289 * Currently only used by the 'adb restore' command.
Christopher Tate75a99702011-05-18 16:28:19 -0700290 *
291 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000292 * If the {@code userId} is different from the calling user id, then the caller must hold the
293 * android.permission.INTERACT_ACROSS_USERS_FULL.
294 *
295 * @param userId User id for which restore should be performed.
Christopher Tate75a99702011-05-18 16:28:19 -0700296 */
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000297 void adbRestore(int userId, in ParcelFileDescriptor fd);
Christopher Tate75a99702011-05-18 16:28:19 -0700298
299 /**
Christopher Tate4a627c72011-04-01 14:43:32 -0700300 * Confirm that the requested full backup/restore operation can proceed. The system will
301 * not actually perform the operation described to fullBackup() / fullRestore() unless the
302 * UI calls back into the Backup Manager to confirm, passing the correct token. At
303 * the same time, the UI supplies a callback Binder for progress notifications during
304 * the operation.
305 *
Christopher Tate2efd2db2011-07-19 16:32:49 -0700306 * <p>The password passed by the confirming entity must match the saved backup or
307 * full-device encryption password in order to perform a backup. If a password is
308 * supplied for restore, it must match the password used when creating the full
309 * backup dataset being used for restore.
310 *
Christopher Tate4a627c72011-04-01 14:43:32 -0700311 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000312 * If {@code userId} is different from the calling user id, then the caller must hold the
313 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
314 *
315 * @param userId User id for which the requested backup/restore operation can proceed.
316 */
317 void acknowledgeFullBackupOrRestoreForUser(int userId, int token, boolean allow,
318 in String curPassword, in String encryptionPassword,
319 IFullBackupRestoreObserver observer);
320
321 /**
322 * {@link android.app.backup.IBackupManager.acknowledgeFullBackupOrRestoreForUser} for the
323 * calling user id.
Christopher Tate4a627c72011-04-01 14:43:32 -0700324 */
Christopher Tate728a1c42011-07-28 18:03:03 -0700325 void acknowledgeFullBackupOrRestore(int token, boolean allow,
326 in String curPassword, in String encryptionPassword,
Christopher Tate4a627c72011-04-01 14:43:32 -0700327 IFullBackupRestoreObserver observer);
328
329 /**
Bernardo Rufinoab953332017-11-22 22:10:32 +0000330 * Update the attributes of the transport identified by {@code transportComponent}. If the
331 * specified transport has not been bound at least once (for registration), this call will be
332 * ignored. Only the host process of the transport can change its description, otherwise a
333 * {@link SecurityException} will be thrown.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000334 * If {@code userId} is different from the calling user id, then the caller must hold the
335 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Bernardo Rufinoab953332017-11-22 22:10:32 +0000336 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000337 * @param userId User id for which the attributes of the transport should be updated.
Bernardo Rufinoab953332017-11-22 22:10:32 +0000338 * @param transportComponent The identity of the transport being described.
339 * @param name A {@link String} with the new name for the transport. This is NOT for
340 * identification. MUST NOT be {@code null}.
341 * @param configurationIntent An {@link Intent} that can be passed to
342 * {@link Context#startActivity} in order to launch the transport's configuration UI. It may
343 * be {@code null} if the transport does not offer any user-facing configuration UI.
344 * @param currentDestinationString A {@link String} describing the destination to which the
345 * transport is currently sending data. MUST NOT be {@code null}.
346 * @param dataManagementIntent An {@link Intent} that can be passed to
347 * {@link Context#startActivity} in order to launch the transport's data-management UI. It
348 * may be {@code null} if the transport does not offer any user-facing data
349 * management UI.
350 * @param dataManagementLabel A {@link String} to be used as the label for the transport's data
351 * management affordance. This MUST be {@code null} when dataManagementIntent is
352 * {@code null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
353 * @throws SecurityException If the UID of the calling process differs from the package UID of
354 * {@code transportComponent} or if the caller does NOT have BACKUP permission.
Bernardo Rufinoab953332017-11-22 22:10:32 +0000355 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000356 void updateTransportAttributesForUser(int userId, in ComponentName transportComponent,
357 in String name,
Bernardo Rufinoab953332017-11-22 22:10:32 +0000358 in Intent configurationIntent, in String currentDestinationString,
359 in Intent dataManagementIntent, in String dataManagementLabel);
360
361 /**
Christopher Tateace7f092009-06-15 18:07:25 -0700362 * Identify the currently selected transport. Callers must hold the
Christopher Tate043dadc2009-06-02 16:11:00 -0700363 * android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000364 * If {@code userId} is different from the calling user id, then the caller must hold the
365 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
366 *
367 * @param userId User id for which the currently selected transport should be identified.
368 */
369 String getCurrentTransportForUser(int userId);
370
371 /**
372 * {@link android.app.backup.IBackupManager.getCurrentTransportForUser} for the calling user id.
Christopher Tate46758122009-05-06 11:22:00 -0700373 */
Christopher Tate91717492009-06-26 21:07:13 -0700374 String getCurrentTransport();
Christopher Tate043dadc2009-06-02 16:11:00 -0700375
Bernardo Rufino98b17a62018-05-09 09:25:35 +0100376 /**
377 * Returns the {@link ComponentName} of the host service of the selected transport or {@code
378 * null} if no transport selected or if the transport selected is not registered. Callers must
379 * hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000380 * If {@code userId} is different from the calling user id, then the caller must hold the
381 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
382 *
383 * @param userId User id for which the currently selected transport should be identified.
Bernardo Rufino98b17a62018-05-09 09:25:35 +0100384 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000385 ComponentName getCurrentTransportComponentForUser(int userId);
Bernardo Rufino98b17a62018-05-09 09:25:35 +0100386
Christopher Tate043dadc2009-06-02 16:11:00 -0700387 /**
Christopher Tate91717492009-06-26 21:07:13 -0700388 * Request a list of all available backup transports' names. Callers must
389 * hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000390 * If {@code userId} is different from the calling user id, then the caller must hold the
391 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
392 *
393 * @param userId User id for which all available backup transports' names should be listed.
394 */
395 String[] listAllTransportsForUser(int userId);
396
397 /**
398 * {@link android.app.backup.IBackupManager.listAllTransportsForUser} for the calling user id.
Christopher Tate91717492009-06-26 21:07:13 -0700399 */
400 String[] listAllTransports();
401
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000402 /**
403 * If {@code userId} is different from the calling user id, then the caller must hold the
404 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
405 *
406 * @param userId User id for which all available backup transports should be listed.
407 */
408 ComponentName[] listAllTransportComponentsForUser(int userId);
Shreyas Basarge865303f2017-01-13 14:48:56 +0000409
Christopher Tate91717492009-06-26 21:07:13 -0700410 /**
Christopher Tatee227ec62016-06-15 17:38:00 -0700411 * Retrieve the list of whitelisted transport components. Callers do </i>not</i> need
412 * any special permission.
413 *
414 * @return The names of all whitelisted transport components defined by the system.
415 */
416 String[] getTransportWhitelist();
417
418 /**
Christopher Tate91717492009-06-26 21:07:13 -0700419 * Specify the current backup transport. Callers must hold the
Christopher Tate043dadc2009-06-02 16:11:00 -0700420 * android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000421 * If {@code userId} is different from the calling user id, then the caller must hold the
422 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate043dadc2009-06-02 16:11:00 -0700423 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000424 * @param userId User id for which the transport should be selected.
Christopher Tate91717492009-06-26 21:07:13 -0700425 * @param transport The name of the transport to select. This should be one
Christopher Tate043dadc2009-06-02 16:11:00 -0700426 * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
Christopher Tate91717492009-06-26 21:07:13 -0700427 * @return The name of the previously selected transport. If the given transport
428 * name is not one of the currently available transports, no change is made to
429 * the current transport setting and the method returns null.
Christopher Tate043dadc2009-06-02 16:11:00 -0700430 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000431 String selectBackupTransportForUser(int userId, String transport);
432
433 /**
434 * {@link android.app.backup.IBackupManager.selectBackupTransportForUser} for the calling user
435 * id.
436 */
Christopher Tate91717492009-06-26 21:07:13 -0700437 String selectBackupTransport(String transport);
Christopher Tate8c850b72009-06-07 19:33:20 -0700438
439 /**
Shreyas Basarge865303f2017-01-13 14:48:56 +0000440 * Specify the current backup transport and get notified when the transport is ready to be used.
441 * This method is async because BackupManager might need to bind to the specified transport
442 * which is in a separate process.
443 *
444 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000445 * If {@code userId} is different from the calling user id, then the caller must hold the
446 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Shreyas Basarge865303f2017-01-13 14:48:56 +0000447 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000448 * @param userId User id for which the transport should be selected.
Shreyas Basarge865303f2017-01-13 14:48:56 +0000449 * @param transport ComponentName of the service hosting the transport. This is different from
450 * the transport's name that is returned by {@link BackupTransport#name()}.
Lenka Trochtova3b6e0872018-08-09 14:16:45 +0200451 * @param listener A listener object to get a callback on the transport being selected.
Shreyas Basarge865303f2017-01-13 14:48:56 +0000452 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000453 void selectBackupTransportAsyncForUser(int userId, in ComponentName transport,
454 ISelectBackupTransportCallback listener);
Shreyas Basarge865303f2017-01-13 14:48:56 +0000455
456 /**
Christopher Tatef5e1c292010-12-08 18:40:26 -0800457 * Get the configuration Intent, if any, from the given transport. Callers must
458 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000459 * If {@code userId} is different from the calling user id, then the caller must hold the
460 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800461 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000462 * @param userId User id for which the configuration Intent should be reported.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800463 * @param transport The name of the transport to query.
464 * @return An Intent to use with Activity#startActivity() to bring up the configuration
465 * UI supplied by the transport. If the transport has no configuration UI, it should
466 * return {@code null} here.
467 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000468 Intent getConfigurationIntentForUser(int userId, String transport);
469
470 /**
471 * {@link android.app.backup.IBackupManager.getConfigurationIntentForUser} for the calling user
472 * id.
473 */
Christopher Tatef5e1c292010-12-08 18:40:26 -0800474 Intent getConfigurationIntent(String transport);
475
476 /**
477 * Get the destination string supplied by the given transport. Callers must
478 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000479 * If {@code userId} is different from the calling user id, then the caller must hold the
480 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800481 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000482 * @param userId User id for which the transport destination string should be reported.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800483 * @param transport The name of the transport to query.
484 * @return A string describing the current backup destination. This string is used
485 * verbatim by the Settings UI as the summary text of the "configure..." item.
486 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000487 String getDestinationStringForUser(int userId, String transport);
488
489 /**
490 * {@link android.app.backup.IBackupManager.getDestinationStringForUser} for the calling user
491 * id.
492 */
Christopher Tatef5e1c292010-12-08 18:40:26 -0800493 String getDestinationString(String transport);
494
495 /**
Christopher Tatec17739d2014-07-28 15:02:04 -0700496 * Get the manage-data UI intent, if any, from the given transport. Callers must
497 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000498 * If {@code userId} is different from the calling user id, then the caller must hold the
499 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
500 *
501 * @param userId User id for which the manage-data UI intent should be reported.
502 */
503 Intent getDataManagementIntentForUser(int userId, String transport);
504
505 /**
506 * {@link android.app.backup.IBackupManager.getDataManagementIntentForUser} for the calling user
507 * id.
Christopher Tatec17739d2014-07-28 15:02:04 -0700508 */
509 Intent getDataManagementIntent(String transport);
510
511 /**
512 * Get the manage-data menu label, if any, from the given transport. Callers must
513 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000514 * If {@code userId} is different from the calling user id, then the caller must hold the
515 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
516 *
517 * @param userId User id for which the manage-data menu label should be reported.
518 */
519 String getDataManagementLabelForUser(int userId, String transport);
520
521 /**
522 * {@link android.app.backup.IBackupManager.getDataManagementLabelForUser} for the calling user
523 * id.
Christopher Tatec17739d2014-07-28 15:02:04 -0700524 */
525 String getDataManagementLabel(String transport);
526
527 /**
Chris Tate44ab8452010-11-16 15:10:49 -0800528 * Begin a restore session. Either or both of packageName and transportID
529 * may be null. If packageName is non-null, then only the given package will be
530 * considered for restore. If transportID is null, then the restore will use
531 * the current active transport.
532 * <p>
533 * This method requires the android.permission.BACKUP permission <i>except</i>
534 * when transportID is null and packageName is the name of the caller's own
535 * package. In that case, the restore session returned is suitable for supporting
536 * the BackupManager.requestRestore() functionality via RestoreSession.restorePackage()
537 * without requiring the app to hold any special permission.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000538 * If {@code userId} is different from the calling user id, then the caller must hold the
539 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate8c850b72009-06-07 19:33:20 -0700540 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000541 * @param userId User id for which a restore session should be begun.
Chris Tate44ab8452010-11-16 15:10:49 -0800542 * @param packageName The name of the single package for which a restore will
543 * be requested. May be null, in which case all packages in the restore
544 * set can be restored.
545 * @param transportID The name of the transport to use for the restore operation.
546 * May be null, in which case the current active transport is used.
Christopher Tate8c850b72009-06-07 19:33:20 -0700547 * @return An interface to the restore session, or null on error.
548 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000549 IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID);
Christopher Tate44a27902010-01-27 17:15:49 -0800550
551 /**
552 * Notify the backup manager that a BackupAgent has completed the operation
Ruslan Tkhakokhov6712b722019-01-19 21:35:32 +0000553 * corresponding to the given token and user id.
554 *
555 * @param userId User id for which the operation has been completed.
556 * @param token The transaction token passed to the BackupAgent method being
557 * invoked.
558 * @param result In the case of a full backup measure operation, the estimated
559 * total file size that would result from the operation. Unused in all other
560 * cases.
561 */
562 void opCompleteForUser(int userId, int token, long result);
563
564 /**
565 * Notify the backup manager that a BackupAgent has completed the operation
Christopher Tate44a27902010-01-27 17:15:49 -0800566 * corresponding to the given token.
567 *
Christopher Tate11ae7682015-03-24 18:48:10 -0700568 * @param token The transaction token passed to the BackupAgent method being
569 * invoked.
570 * @param result In the case of a full backup measure operation, the estimated
571 * total file size that would result from the operation. Unused in all other
572 * cases.
Christopher Tate44a27902010-01-27 17:15:49 -0800573 */
Christopher Tate11ae7682015-03-24 18:48:10 -0700574 void opComplete(int token, long result);
Christopher Tatebbe23b32014-10-30 13:44:27 -0700575
576 /**
577 * Make the device's backup and restore machinery (in)active. When it is inactive,
578 * the device will not perform any backup operations, nor will it deliver data for
579 * restore, although clients can still safely call BackupManager methods.
580 *
581 * @param whichUser User handle of the defined user whose backup active state
582 * is to be adjusted.
583 * @param makeActive {@code true} when backup services are to be made active;
584 * {@code false} otherwise.
585 */
586 void setBackupServiceActive(int whichUser, boolean makeActive);
Zoltan Szatmary-Ban201caf52014-11-12 18:03:08 +0000587
588 /**
589 * Queries the activity status of backup service as set by {@link #setBackupServiceActive}.
590 * @param whichUser User handle of the defined user whose backup active state
591 * is being queried.
592 */
593 boolean isBackupServiceActive(int whichUser);
Christopher Tate511d02f2015-04-08 20:05:30 -0700594
595 /**
596 * Ask the framework which dataset, if any, the given package's data would be
597 * restored from if we were to install it right now.
598 *
599 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000600 * If {@code userId} is different from the calling user id, then the caller must hold the
601 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate511d02f2015-04-08 20:05:30 -0700602 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000603 * @param userId User id for which this operation should be performed.
Christopher Tate511d02f2015-04-08 20:05:30 -0700604 * @param packageName The name of the package whose most-suitable dataset we
605 * wish to look up
606 * @return The dataset token from which a restore should be attempted, or zero if
607 * no suitable data is available.
608 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000609 long getAvailableRestoreTokenForUser(int userId, String packageName);
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100610
611 /**
Sergey Poromov94481962016-01-07 18:25:35 +0100612 * Ask the framework whether this app is eligible for backup.
613 *
Bernardo Rufinofa518532018-01-02 16:01:53 +0000614 * <p>If you are calling this method multiple times, you should instead use
615 * {@link #filterAppsEligibleForBackup(String[])} to save resources.
616 *
Sergey Poromov94481962016-01-07 18:25:35 +0100617 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000618 * If {@code userId} is different from the calling user id, then the caller must hold the
619 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Sergey Poromov94481962016-01-07 18:25:35 +0100620 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000621 * @param userId User id for which this operation should be performed.
Sergey Poromov94481962016-01-07 18:25:35 +0100622 * @param packageName The name of the package.
623 * @return Whether this app is eligible for backup.
624 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000625 boolean isAppEligibleForBackupForUser(int userId, String packageName);
Sergey Poromov94481962016-01-07 18:25:35 +0100626
627 /**
Bernardo Rufinofa518532018-01-02 16:01:53 +0000628 * Filter the packages that are eligible for backup and return the result.
629 *
630 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000631 * If {@code userId} is different from the calling user id, then the caller must hold the
632 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Bernardo Rufinofa518532018-01-02 16:01:53 +0000633 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000634 * @param userId User id for which the filter should be performed.
Bernardo Rufinofa518532018-01-02 16:01:53 +0000635 * @param packages The list of packages to filter.
636 * @return The packages eligible for backup.
637 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000638 String[] filterAppsEligibleForBackupForUser(int userId, in String[] packages);
Bernardo Rufinofa518532018-01-02 16:01:53 +0000639
640 /**
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100641 * Request an immediate backup, providing an observer to which results of the backup operation
642 * will be published. The Android backup system will decide for each package whether it will
643 * be full app data backup or key/value-pair-based backup.
644 *
645 * <p>If this method returns zero (meaning success), the OS will attempt to backup all provided
646 * packages using the remote transport.
647 *
Chandan Nathcd44f752018-12-07 16:49:37 +0000648 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
649 * If {@code userId} is different from the calling user id, then the caller must hold the
650 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
651 *
652 * @param userId User id for which an immediate backup should be requested.
653
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100654 * @param observer The {@link BackupObserver} to receive callbacks during the backup
655 * operation.
656 *
Stefanotb1f573d2017-01-27 12:03:53 +0000657 * @param monitor the {@link BackupManagerMonitor} to receive callbacks about important events
658 * during the backup operation.
659 *
Shreyas Basarge38e74862017-01-11 17:15:58 +0000660 * @param flags {@link BackupManager#FLAG_NON_INCREMENTAL_BACKUP}.
661 *
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100662 * @return Zero on success; nonzero on error.
663 */
Chandan Nathcd44f752018-12-07 16:49:37 +0000664 int requestBackupForUser(int userId, in String[] packages, IBackupObserver observer,
665 IBackupManagerMonitor monitor, int flags);
666
667 /**
668 * {@link android.app.backup.IBackupManager.requestBackupForUser} for the calling user id.
669 */
Stefanotb1f573d2017-01-27 12:03:53 +0000670 int requestBackup(in String[] packages, IBackupObserver observer, IBackupManagerMonitor monitor,
671 int flags);
Shreyas Basargec3704422017-01-28 16:50:09 +0000672
673 /**
674 * Cancel all running backups. After this call returns, no currently running backups will
675 * interact with the selected transport.
Chandan Nathcd44f752018-12-07 16:49:37 +0000676 *
677 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
678 * If {@code userId} is different from the calling user id, then the caller must hold the
679 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
680 *
681 * @param userId User id for which backups should be cancelled.
682 */
683 void cancelBackupsForUser(int userId);
684
685 /**
686 * {@link android.app.backup.IBackupManager.cancelBackups} for the calling user id.
Shreyas Basargec3704422017-01-28 16:50:09 +0000687 */
688 void cancelBackups();
Stefano Tommasini471a35d2019-01-21 13:21:48 +0000689
690 /**
691 * Returns a {@link UserHandle} for the user that has {@code ancestralSerialNumber} as the serial
692 * number of the it's ancestral work profile.
693 *
694 * <p> The ancestral work profile is set by {@link #setAncestralSerialNumber(long)}
695 * and it corresponds to the profile that was used to restore to the callers profile.
696 */
697 UserHandle getUserForAncestralSerialNumber(in long ancestralSerialNumber);
698
699 /**
700 * Sets the ancestral work profile for the calling user.
701 *
702 * <p> The ancestral work profile corresponds to the profile that was used to restore to the
703 * callers profile.
704 *
705 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
706 */
707 void setAncestralSerialNumber(in long ancestralSerialNumber);
708
Christopher Tate487529a2009-04-29 14:03:25 -0700709}