blob: 70ecdae92652d747c87818f1dc33c3e5f5ea1a95 [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 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +000057 @UnsupportedAppUsage
Christopher Tate5cbbf562009-06-22 16:44:51 -070058 void dataChanged(String packageName);
Christopher Tate46758122009-05-06 11:22:00 -070059
60 /**
Christopher Tateb0183f02013-11-18 14:20:36 -080061 * Erase all backed-up data for the given package from the given storage
Christopher Tateee0e78a2009-07-02 11:17:03 -070062 * destination.
63 *
64 * Any application can invoke this method for its own package, but
65 * only callers who hold the android.permission.BACKUP permission
66 * may invoke it for arbitrary packages.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000067 * If {@code userId} is different from the calling user id, then the caller must hold the
68 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
69 *
70 * @param userId User id for which backup data should be erased.
71 */
72 void clearBackupDataForUser(int userId, String transportName, String packageName);
73
74 /**
75 * {@link android.app.backup.IBackupManager.clearBackupDataForUser} for the calling user id.
Christopher Tateee0e78a2009-07-02 11:17:03 -070076 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +000077 @UnsupportedAppUsage
Christopher Tateb0183f02013-11-18 14:20:36 -080078 void clearBackupData(String transportName, String packageName);
Christopher Tateee0e78a2009-07-02 11:17:03 -070079
80 /**
Christopher Tate924afe22017-06-16 13:14:48 -070081 * Run an initialize operation on the given transports. This will wipe all data from
82 * the backing data store and establish a clean starting point for all backup
83 * operations.
84 *
85 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000086 * If {@code userId} is different from the calling user id, then the caller must hold the
87 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
88 *
89 * @param userId User id for which the given transports should be initialized.
Christopher Tate924afe22017-06-16 13:14:48 -070090 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +000091 void initializeTransportsForUser(int userId, in String[] transportNames,
92 IBackupObserver observer);
Christopher Tate924afe22017-06-16 13:14:48 -070093
94 /**
Christopher Tate181fafa2009-05-14 11:12:14 -070095 * Notifies the Backup Manager Service that an agent has become available. This
96 * method is only invoked by the Activity Manager.
Chandan Nathd1ee43e2018-12-16 21:41:03 +000097 *
98 * If {@code userId} is different from the calling user id, then the caller must hold the
99 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
100 *
101 * @param userId User id for which an agent has become available.
102 */
103 void agentConnectedForUser(int userId, String packageName, IBinder agent);
104
105 /**
106 * {@link android.app.backup.IBackupManager.agentConnected} for the calling user id.
Christopher Tate181fafa2009-05-14 11:12:14 -0700107 */
Christopher Tate5cbbf562009-06-22 16:44:51 -0700108 void agentConnected(String packageName, IBinder agent);
Christopher Tate181fafa2009-05-14 11:12:14 -0700109
110 /**
111 * Notify the Backup Manager Service that an agent has unexpectedly gone away.
112 * This method is only invoked by the Activity Manager.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000113 *
114 * If {@code userId} is different from the calling user id, then the caller must hold the
115 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
116 *
117 * @param userId User id for which an agent has unexpectedly gone away.
118 */
119 void agentDisconnectedForUser(int userId, String packageName);
120
121 /**
122 * {@link android.app.backup.IBackupManager.agentDisconnected} for the calling user id.
Christopher Tate181fafa2009-05-14 11:12:14 -0700123 */
Christopher Tate5cbbf562009-06-22 16:44:51 -0700124 void agentDisconnected(String packageName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700125
126 /**
Christopher Tate1bb69062010-02-19 17:02:12 -0800127 * Notify the Backup Manager Service that an application being installed will
128 * need a data-restore pass. This method is only invoked by the Package Manager.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000129 *
130 * If {@code userId} is different from the calling user id, then the caller must hold the
131 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
132 *
133 * @param userId User id for which the application will need a data-restore pass.
134 */
135 void restoreAtInstallForUser(int userId, String packageName, int token);
136
137 /**
138 * {@link android.app.backup.IBackupManager.restoreAtInstallForUser} for the calling user id.
Christopher Tate1bb69062010-02-19 17:02:12 -0800139 */
140 void restoreAtInstall(String packageName, int token);
141
142 /**
Christopher Tate6ef58a12009-06-29 14:56:28 -0700143 * Enable/disable the backup service entirely. When disabled, no backup
144 * or restore operations will take place. Data-changed notifications will
145 * still be observed and collected, however, so that changes made while the
146 * mechanism was disabled will still be backed up properly if it is enabled
147 * at some point in the future.
148 *
149 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathcd44f752018-12-07 16:49:37 +0000150 * If {@code userId} is different from the calling user id, then the caller must hold the
151 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
152 *
153 * @param userId User id for which backup service should be enabled/disabled.
154 */
155 void setBackupEnabledForUser(int userId, boolean isEnabled);
156
157 /**
158 * {@link android.app.backup.IBackupManager.setBackupEnabledForUser} for the calling user id.
Christopher Tate6ef58a12009-06-29 14:56:28 -0700159 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000160 @UnsupportedAppUsage
Christopher Tate6ef58a12009-06-29 14:56:28 -0700161 void setBackupEnabled(boolean isEnabled);
162
163 /**
Christopher Tatecce9da52010-02-03 15:11:15 -0800164 * Enable/disable automatic restore of application data at install time. When
165 * enabled, installation of any package will involve the Backup Manager. If data
166 * exists for the newly-installed package, either from the device's current [enabled]
167 * backup dataset or from the restore set used in the last wholesale restore operation,
168 * that data will be supplied to the new package's restore agent before the package
169 * is made generally available for launch.
170 *
171 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000172 * If {@code userId} is different from the calling user id, then the caller must hold the
173 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tatecce9da52010-02-03 15:11:15 -0800174 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000175 * @param userId User id for which automatic restore should be enabled/disabled.
Christopher Tatecce9da52010-02-03 15:11:15 -0800176 * @param doAutoRestore When true, enables the automatic app-data restore facility. When
177 * false, this facility will be disabled.
178 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000179 void setAutoRestoreForUser(int userId, boolean doAutoRestore);
180
181 /**
182 * {@link android.app.backup.IBackupManager.setAutoRestoreForUser} for the calling user id.
183 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000184 @UnsupportedAppUsage
Christopher Tatecce9da52010-02-03 15:11:15 -0800185 void setAutoRestore(boolean doAutoRestore);
186
187 /**
Christopher Tate6ef58a12009-06-29 14:56:28 -0700188 * Report whether the backup mechanism is currently enabled.
189 *
190 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathcd44f752018-12-07 16:49:37 +0000191 * If {@code userId} is different from the calling user id, then the caller must hold the
192 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
193 *
194 * @param userId User id for which the backup service status should be reported.
195 */
196 boolean isBackupEnabledForUser(int userId);
197
198 /**
199 * {@link android.app.backup.IBackupManager.isBackupEnabledForUser} for the calling user id.
Christopher Tate6ef58a12009-06-29 14:56:28 -0700200 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000201 @UnsupportedAppUsage
Christopher Tate6ef58a12009-06-29 14:56:28 -0700202 boolean isBackupEnabled();
203
204 /**
Christopher Tate2efd2db2011-07-19 16:32:49 -0700205 * Set the device's backup password. Returns {@code true} if the password was set
206 * successfully, {@code false} otherwise. Typically a failure means that an incorrect
207 * current password was supplied.
208 *
209 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
210 */
211 boolean setBackupPassword(in String currentPw, in String newPw);
212
213 /**
214 * Reports whether a backup password is currently set. If not, then a null or empty
215 * "current password" argument should be passed to setBackupPassword().
216 *
217 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
218 */
219 boolean hasBackupPassword();
220
221 /**
Christopher Tateace7f092009-06-15 18:07:25 -0700222 * Schedule an immediate backup attempt for all pending updates. This is
223 * primarily intended for transports to use when they detect a suitable
224 * opportunity for doing a backup pass. If there are no pending updates to
225 * be sent, no action will be taken. Even if some updates are pending, the
226 * transport will still be asked to confirm via the usual requestBackupTime()
227 * method.
228 *
229 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathcd44f752018-12-07 16:49:37 +0000230 * If {@code userId} is different from the calling user id, then the caller must hold the
231 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
232 *
233 * @param userId User id for which an immediate backup should be scheduled.
234 */
235 void backupNowForUser(int userId);
236
237 /**
238 * {@link android.app.backup.IBackupManager.backupNowForUser} for the calling user id.
Christopher Tateace7f092009-06-15 18:07:25 -0700239 */
Christopher Tate5cbbf562009-06-22 16:44:51 -0700240 void backupNow();
Christopher Tateace7f092009-06-15 18:07:25 -0700241
242 /**
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000243 * Write a backup of the given package to the supplied file descriptor.
Christopher Tate4a627c72011-04-01 14:43:32 -0700244 * The fd may be a socket or other non-seekable destination. If no package names
245 * are supplied, then every application on the device will be backed up to the output.
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000246 * Currently only used by the 'adb backup' command.
Christopher Tate4a627c72011-04-01 14:43:32 -0700247 *
248 * <p>This method is <i>synchronous</i> -- it does not return until the backup has
249 * completed.
250 *
251 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000252 * If the {@code userId} is different from the calling user id, then the caller must hold the
253 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate4a627c72011-04-01 14:43:32 -0700254 *
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000255 * @param userId User id for which backup should be performed.
256 * @param fd The file descriptor to which a 'tar' file stream is to be written.
Christopher Tate4a627c72011-04-01 14:43:32 -0700257 * @param includeApks If <code>true</code>, the resulting tar stream will include the
258 * application .apk files themselves as well as their data.
Christopher Tate46cc43c2013-02-19 14:08:59 -0800259 * @param includeObbs If <code>true</code>, the resulting tar stream will include any
260 * application expansion (OBB) files themselves belonging to each application.
Christopher Tate4a627c72011-04-01 14:43:32 -0700261 * @param includeShared If <code>true</code>, the resulting tar stream will include
262 * the contents of the device's shared storage (SD card or equivalent).
263 * @param allApps If <code>true</code>, the resulting tar stream will include all
264 * installed applications' data, not just those named in the <code>packageNames</code>
265 * parameter.
Christopher Tate240c7d22011-10-03 18:13:44 -0700266 * @param allIncludesSystem If {@code true}, then {@code allApps} will be interpreted
267 * as including packages pre-installed as part of the system. If {@code false},
268 * then setting {@code allApps} to {@code true} will mean only that all 3rd-party
269 * applications will be included in the dataset.
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000270 * @param doKeyValue If {@code true}, also packages supporting key-value backup will be backed
271 * up. If {@code false}, key-value packages will be skipped.
Christopher Tate4a627c72011-04-01 14:43:32 -0700272 * @param packageNames The package names of the apps whose data (and optionally .apk files)
273 * are to be backed up. The <code>allApps</code> parameter supersedes this.
274 */
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000275 void adbBackup(int userId, in ParcelFileDescriptor fd, boolean includeApks, boolean includeObbs,
Christopher Tateadfe8b82014-02-04 16:23:32 -0800276 boolean includeShared, boolean doWidgets, boolean allApps, boolean allIncludesSystem,
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000277 boolean doCompress, boolean doKeyValue, in String[] packageNames);
Christopher Tate9ff53a72014-06-03 17:20:07 -0700278
279 /**
280 * Perform a full-dataset backup of the given applications via the currently active
281 * transport.
282 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000283 * If {@code userId} is different from the calling user id, then the caller must hold the
284 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
285 *
286 * @param userId User id for which the full-dataset backup should be performed.
Christopher Tate9ff53a72014-06-03 17:20:07 -0700287 * @param packageNames The package names of the apps whose data are to be backed up.
288 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000289 void fullTransportBackupForUser(int userId, in String[] packageNames);
Christopher Tate4a627c72011-04-01 14:43:32 -0700290
291 /**
Christopher Tate75a99702011-05-18 16:28:19 -0700292 * Restore device content from the data stream passed through the given socket. The
Johan Toras Halsethb59a4b82017-03-03 15:37:43 +0000293 * data stream must be in the format emitted by adbBackup().
294 * Currently only used by the 'adb restore' command.
Christopher Tate75a99702011-05-18 16:28:19 -0700295 *
296 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000297 * If the {@code userId} is different from the calling user id, then the caller must hold the
298 * android.permission.INTERACT_ACROSS_USERS_FULL.
299 *
300 * @param userId User id for which restore should be performed.
Christopher Tate75a99702011-05-18 16:28:19 -0700301 */
Ruslan Tkhakokhova2fe6c52018-12-03 17:28:39 +0000302 void adbRestore(int userId, in ParcelFileDescriptor fd);
Christopher Tate75a99702011-05-18 16:28:19 -0700303
304 /**
Christopher Tate4a627c72011-04-01 14:43:32 -0700305 * Confirm that the requested full backup/restore operation can proceed. The system will
306 * not actually perform the operation described to fullBackup() / fullRestore() unless the
307 * UI calls back into the Backup Manager to confirm, passing the correct token. At
308 * the same time, the UI supplies a callback Binder for progress notifications during
309 * the operation.
310 *
Christopher Tate2efd2db2011-07-19 16:32:49 -0700311 * <p>The password passed by the confirming entity must match the saved backup or
312 * full-device encryption password in order to perform a backup. If a password is
313 * supplied for restore, it must match the password used when creating the full
314 * backup dataset being used for restore.
315 *
Christopher Tate4a627c72011-04-01 14:43:32 -0700316 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000317 * If {@code userId} is different from the calling user id, then the caller must hold the
318 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
319 *
320 * @param userId User id for which the requested backup/restore operation can proceed.
321 */
322 void acknowledgeFullBackupOrRestoreForUser(int userId, int token, boolean allow,
323 in String curPassword, in String encryptionPassword,
324 IFullBackupRestoreObserver observer);
325
326 /**
327 * {@link android.app.backup.IBackupManager.acknowledgeFullBackupOrRestoreForUser} for the
328 * calling user id.
Christopher Tate4a627c72011-04-01 14:43:32 -0700329 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000330 @UnsupportedAppUsage
Christopher Tate728a1c42011-07-28 18:03:03 -0700331 void acknowledgeFullBackupOrRestore(int token, boolean allow,
332 in String curPassword, in String encryptionPassword,
Christopher Tate4a627c72011-04-01 14:43:32 -0700333 IFullBackupRestoreObserver observer);
334
335 /**
Bernardo Rufinoab953332017-11-22 22:10:32 +0000336 * Update the attributes of the transport identified by {@code transportComponent}. If the
337 * specified transport has not been bound at least once (for registration), this call will be
338 * ignored. Only the host process of the transport can change its description, otherwise a
339 * {@link SecurityException} will be thrown.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000340 * If {@code userId} is different from the calling user id, then the caller must hold the
341 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Bernardo Rufinoab953332017-11-22 22:10:32 +0000342 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000343 * @param userId User id for which the attributes of the transport should be updated.
Bernardo Rufinoab953332017-11-22 22:10:32 +0000344 * @param transportComponent The identity of the transport being described.
345 * @param name A {@link String} with the new name for the transport. This is NOT for
346 * identification. MUST NOT be {@code null}.
347 * @param configurationIntent An {@link Intent} that can be passed to
348 * {@link Context#startActivity} in order to launch the transport's configuration UI. It may
349 * be {@code null} if the transport does not offer any user-facing configuration UI.
350 * @param currentDestinationString A {@link String} describing the destination to which the
351 * transport is currently sending data. MUST NOT be {@code null}.
352 * @param dataManagementIntent An {@link Intent} that can be passed to
353 * {@link Context#startActivity} in order to launch the transport's data-management UI. It
354 * may be {@code null} if the transport does not offer any user-facing data
355 * management UI.
356 * @param dataManagementLabel A {@link String} to be used as the label for the transport's data
357 * management affordance. This MUST be {@code null} when dataManagementIntent is
358 * {@code null} and MUST NOT be {@code null} when dataManagementIntent is not {@code null}.
359 * @throws SecurityException If the UID of the calling process differs from the package UID of
360 * {@code transportComponent} or if the caller does NOT have BACKUP permission.
Bernardo Rufinoab953332017-11-22 22:10:32 +0000361 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000362 void updateTransportAttributesForUser(int userId, in ComponentName transportComponent,
363 in String name,
Bernardo Rufinoab953332017-11-22 22:10:32 +0000364 in Intent configurationIntent, in String currentDestinationString,
365 in Intent dataManagementIntent, in String dataManagementLabel);
366
367 /**
Christopher Tateace7f092009-06-15 18:07:25 -0700368 * Identify the currently selected transport. Callers must hold the
Christopher Tate043dadc2009-06-02 16:11:00 -0700369 * android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000370 * If {@code userId} is different from the calling user id, then the caller must hold the
371 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
372 *
373 * @param userId User id for which the currently selected transport should be identified.
374 */
375 String getCurrentTransportForUser(int userId);
376
377 /**
378 * {@link android.app.backup.IBackupManager.getCurrentTransportForUser} for the calling user id.
Christopher Tate46758122009-05-06 11:22:00 -0700379 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000380 @UnsupportedAppUsage
Christopher Tate91717492009-06-26 21:07:13 -0700381 String getCurrentTransport();
Christopher Tate043dadc2009-06-02 16:11:00 -0700382
Bernardo Rufino98b17a62018-05-09 09:25:35 +0100383 /**
384 * Returns the {@link ComponentName} of the host service of the selected transport or {@code
385 * null} if no transport selected or if the transport selected is not registered. Callers must
386 * hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000387 * If {@code userId} is different from the calling user id, then the caller must hold the
388 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
389 *
390 * @param userId User id for which the currently selected transport should be identified.
Bernardo Rufino98b17a62018-05-09 09:25:35 +0100391 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000392 ComponentName getCurrentTransportComponentForUser(int userId);
Bernardo Rufino98b17a62018-05-09 09:25:35 +0100393
Christopher Tate043dadc2009-06-02 16:11:00 -0700394 /**
Christopher Tate91717492009-06-26 21:07:13 -0700395 * Request a list of all available backup transports' names. Callers must
396 * hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000397 * If {@code userId} is different from the calling user id, then the caller must hold the
398 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
399 *
400 * @param userId User id for which all available backup transports' names should be listed.
401 */
402 String[] listAllTransportsForUser(int userId);
403
404 /**
405 * {@link android.app.backup.IBackupManager.listAllTransportsForUser} for the calling user id.
Christopher Tate91717492009-06-26 21:07:13 -0700406 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000407 @UnsupportedAppUsage
Christopher Tate91717492009-06-26 21:07:13 -0700408 String[] listAllTransports();
409
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000410 /**
411 * If {@code userId} is different from the calling user id, then the caller must hold the
412 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
413 *
414 * @param userId User id for which all available backup transports should be listed.
415 */
416 ComponentName[] listAllTransportComponentsForUser(int userId);
Shreyas Basarge865303f2017-01-13 14:48:56 +0000417
Christopher Tate91717492009-06-26 21:07:13 -0700418 /**
Christopher Tatee227ec62016-06-15 17:38:00 -0700419 * Retrieve the list of whitelisted transport components. Callers do </i>not</i> need
420 * any special permission.
421 *
422 * @return The names of all whitelisted transport components defined by the system.
423 */
424 String[] getTransportWhitelist();
425
426 /**
Christopher Tate91717492009-06-26 21:07:13 -0700427 * Specify the current backup transport. Callers must hold the
Christopher Tate043dadc2009-06-02 16:11:00 -0700428 * android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000429 * If {@code userId} is different from the calling user id, then the caller must hold the
430 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate043dadc2009-06-02 16:11:00 -0700431 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000432 * @param userId User id for which the transport should be selected.
Christopher Tate91717492009-06-26 21:07:13 -0700433 * @param transport The name of the transport to select. This should be one
Christopher Tate043dadc2009-06-02 16:11:00 -0700434 * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
Christopher Tate91717492009-06-26 21:07:13 -0700435 * @return The name of the previously selected transport. If the given transport
436 * name is not one of the currently available transports, no change is made to
437 * the current transport setting and the method returns null.
Christopher Tate043dadc2009-06-02 16:11:00 -0700438 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000439 String selectBackupTransportForUser(int userId, String transport);
440
441 /**
442 * {@link android.app.backup.IBackupManager.selectBackupTransportForUser} for the calling user
443 * id.
444 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000445 @UnsupportedAppUsage
Christopher Tate91717492009-06-26 21:07:13 -0700446 String selectBackupTransport(String transport);
Christopher Tate8c850b72009-06-07 19:33:20 -0700447
448 /**
Shreyas Basarge865303f2017-01-13 14:48:56 +0000449 * Specify the current backup transport and get notified when the transport is ready to be used.
450 * This method is async because BackupManager might need to bind to the specified transport
451 * which is in a separate process.
452 *
453 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000454 * If {@code userId} is different from the calling user id, then the caller must hold the
455 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Shreyas Basarge865303f2017-01-13 14:48:56 +0000456 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000457 * @param userId User id for which the transport should be selected.
Shreyas Basarge865303f2017-01-13 14:48:56 +0000458 * @param transport ComponentName of the service hosting the transport. This is different from
459 * the transport's name that is returned by {@link BackupTransport#name()}.
Lenka Trochtova3b6e0872018-08-09 14:16:45 +0200460 * @param listener A listener object to get a callback on the transport being selected.
Shreyas Basarge865303f2017-01-13 14:48:56 +0000461 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000462 void selectBackupTransportAsyncForUser(int userId, in ComponentName transport,
463 ISelectBackupTransportCallback listener);
Shreyas Basarge865303f2017-01-13 14:48:56 +0000464
465 /**
Christopher Tatef5e1c292010-12-08 18:40:26 -0800466 * Get the configuration Intent, if any, from the given transport. Callers must
467 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000468 * If {@code userId} is different from the calling user id, then the caller must hold the
469 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800470 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000471 * @param userId User id for which the configuration Intent should be reported.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800472 * @param transport The name of the transport to query.
473 * @return An Intent to use with Activity#startActivity() to bring up the configuration
474 * UI supplied by the transport. If the transport has no configuration UI, it should
475 * return {@code null} here.
476 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000477 Intent getConfigurationIntentForUser(int userId, String transport);
478
479 /**
480 * {@link android.app.backup.IBackupManager.getConfigurationIntentForUser} for the calling user
481 * id.
482 */
Christopher Tatef5e1c292010-12-08 18:40:26 -0800483 Intent getConfigurationIntent(String transport);
484
485 /**
486 * Get the destination string supplied by the given transport. Callers must
487 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000488 * If {@code userId} is different from the calling user id, then the caller must hold the
489 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800490 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000491 * @param userId User id for which the transport destination string should be reported.
Christopher Tatef5e1c292010-12-08 18:40:26 -0800492 * @param transport The name of the transport to query.
493 * @return A string describing the current backup destination. This string is used
494 * verbatim by the Settings UI as the summary text of the "configure..." item.
495 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000496 String getDestinationStringForUser(int userId, String transport);
497
498 /**
499 * {@link android.app.backup.IBackupManager.getDestinationStringForUser} for the calling user
500 * id.
501 */
Christopher Tatef5e1c292010-12-08 18:40:26 -0800502 String getDestinationString(String transport);
503
504 /**
Christopher Tatec17739d2014-07-28 15:02:04 -0700505 * Get the manage-data UI intent, if any, from the given transport. Callers must
506 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000507 * If {@code userId} is different from the calling user id, then the caller must hold the
508 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
509 *
510 * @param userId User id for which the manage-data UI intent should be reported.
511 */
512 Intent getDataManagementIntentForUser(int userId, String transport);
513
514 /**
515 * {@link android.app.backup.IBackupManager.getDataManagementIntentForUser} for the calling user
516 * id.
Christopher Tatec17739d2014-07-28 15:02:04 -0700517 */
518 Intent getDataManagementIntent(String transport);
519
520 /**
521 * Get the manage-data menu label, if any, from the given transport. Callers must
522 * hold the android.permission.BACKUP permission in order to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000523 * If {@code userId} is different from the calling user id, then the caller must hold the
524 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
525 *
526 * @param userId User id for which the manage-data menu label should be reported.
527 */
528 String getDataManagementLabelForUser(int userId, String transport);
529
530 /**
531 * {@link android.app.backup.IBackupManager.getDataManagementLabelForUser} for the calling user
532 * id.
Christopher Tatec17739d2014-07-28 15:02:04 -0700533 */
534 String getDataManagementLabel(String transport);
535
536 /**
Chris Tate44ab8452010-11-16 15:10:49 -0800537 * Begin a restore session. Either or both of packageName and transportID
538 * may be null. If packageName is non-null, then only the given package will be
539 * considered for restore. If transportID is null, then the restore will use
540 * the current active transport.
541 * <p>
542 * This method requires the android.permission.BACKUP permission <i>except</i>
543 * when transportID is null and packageName is the name of the caller's own
544 * package. In that case, the restore session returned is suitable for supporting
545 * the BackupManager.requestRestore() functionality via RestoreSession.restorePackage()
546 * without requiring the app to hold any special permission.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000547 * If {@code userId} is different from the calling user id, then the caller must hold the
548 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate8c850b72009-06-07 19:33:20 -0700549 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000550 * @param userId User id for which a restore session should be begun.
Chris Tate44ab8452010-11-16 15:10:49 -0800551 * @param packageName The name of the single package for which a restore will
552 * be requested. May be null, in which case all packages in the restore
553 * set can be restored.
554 * @param transportID The name of the transport to use for the restore operation.
555 * May be null, in which case the current active transport is used.
Christopher Tate8c850b72009-06-07 19:33:20 -0700556 * @return An interface to the restore session, or null on error.
557 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000558 IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID);
Christopher Tate44a27902010-01-27 17:15:49 -0800559
560 /**
561 * Notify the backup manager that a BackupAgent has completed the operation
Ruslan Tkhakokhov6712b722019-01-19 21:35:32 +0000562 * corresponding to the given token and user id.
563 *
564 * @param userId User id for which the operation has been completed.
565 * @param token The transaction token passed to the BackupAgent method being
566 * invoked.
567 * @param result In the case of a full backup measure operation, the estimated
568 * total file size that would result from the operation. Unused in all other
569 * cases.
570 */
571 void opCompleteForUser(int userId, int token, long result);
572
573 /**
574 * Notify the backup manager that a BackupAgent has completed the operation
Christopher Tate44a27902010-01-27 17:15:49 -0800575 * corresponding to the given token.
576 *
Christopher Tate11ae7682015-03-24 18:48:10 -0700577 * @param token The transaction token passed to the BackupAgent method being
578 * invoked.
579 * @param result In the case of a full backup measure operation, the estimated
580 * total file size that would result from the operation. Unused in all other
581 * cases.
Christopher Tate44a27902010-01-27 17:15:49 -0800582 */
Christopher Tate11ae7682015-03-24 18:48:10 -0700583 void opComplete(int token, long result);
Christopher Tatebbe23b32014-10-30 13:44:27 -0700584
585 /**
586 * Make the device's backup and restore machinery (in)active. When it is inactive,
587 * the device will not perform any backup operations, nor will it deliver data for
588 * restore, although clients can still safely call BackupManager methods.
589 *
590 * @param whichUser User handle of the defined user whose backup active state
591 * is to be adjusted.
592 * @param makeActive {@code true} when backup services are to be made active;
593 * {@code false} otherwise.
594 */
595 void setBackupServiceActive(int whichUser, boolean makeActive);
Zoltan Szatmary-Ban201caf52014-11-12 18:03:08 +0000596
597 /**
598 * Queries the activity status of backup service as set by {@link #setBackupServiceActive}.
599 * @param whichUser User handle of the defined user whose backup active state
600 * is being queried.
601 */
Andrei Oneaf650e3c2019-02-25 13:15:54 +0000602 @UnsupportedAppUsage
Zoltan Szatmary-Ban201caf52014-11-12 18:03:08 +0000603 boolean isBackupServiceActive(int whichUser);
Christopher Tate511d02f2015-04-08 20:05:30 -0700604
605 /**
606 * Ask the framework which dataset, if any, the given package's data would be
607 * restored from if we were to install it right now.
608 *
609 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000610 * If {@code userId} is different from the calling user id, then the caller must hold the
611 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Christopher Tate511d02f2015-04-08 20:05:30 -0700612 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000613 * @param userId User id for which this operation should be performed.
Christopher Tate511d02f2015-04-08 20:05:30 -0700614 * @param packageName The name of the package whose most-suitable dataset we
615 * wish to look up
616 * @return The dataset token from which a restore should be attempted, or zero if
617 * no suitable data is available.
618 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000619 long getAvailableRestoreTokenForUser(int userId, String packageName);
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100620
621 /**
Sergey Poromov94481962016-01-07 18:25:35 +0100622 * Ask the framework whether this app is eligible for backup.
623 *
Bernardo Rufinofa518532018-01-02 16:01:53 +0000624 * <p>If you are calling this method multiple times, you should instead use
625 * {@link #filterAppsEligibleForBackup(String[])} to save resources.
626 *
Sergey Poromov94481962016-01-07 18:25:35 +0100627 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000628 * If {@code userId} is different from the calling user id, then the caller must hold the
629 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Sergey Poromov94481962016-01-07 18:25:35 +0100630 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000631 * @param userId User id for which this operation should be performed.
Sergey Poromov94481962016-01-07 18:25:35 +0100632 * @param packageName The name of the package.
633 * @return Whether this app is eligible for backup.
634 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000635 boolean isAppEligibleForBackupForUser(int userId, String packageName);
Sergey Poromov94481962016-01-07 18:25:35 +0100636
637 /**
Bernardo Rufinofa518532018-01-02 16:01:53 +0000638 * Filter the packages that are eligible for backup and return the result.
639 *
640 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000641 * If {@code userId} is different from the calling user id, then the caller must hold the
642 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
Bernardo Rufinofa518532018-01-02 16:01:53 +0000643 *
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000644 * @param userId User id for which the filter should be performed.
Bernardo Rufinofa518532018-01-02 16:01:53 +0000645 * @param packages The list of packages to filter.
646 * @return The packages eligible for backup.
647 */
Chandan Nathd1ee43e2018-12-16 21:41:03 +0000648 String[] filterAppsEligibleForBackupForUser(int userId, in String[] packages);
Bernardo Rufinofa518532018-01-02 16:01:53 +0000649
650 /**
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100651 * Request an immediate backup, providing an observer to which results of the backup operation
652 * will be published. The Android backup system will decide for each package whether it will
653 * be full app data backup or key/value-pair-based backup.
654 *
655 * <p>If this method returns zero (meaning success), the OS will attempt to backup all provided
656 * packages using the remote transport.
657 *
Chandan Nathcd44f752018-12-07 16:49:37 +0000658 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
659 * If {@code userId} is different from the calling user id, then the caller must hold the
660 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
661 *
662 * @param userId User id for which an immediate backup should be requested.
663
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100664 * @param observer The {@link BackupObserver} to receive callbacks during the backup
665 * operation.
666 *
Stefanotb1f573d2017-01-27 12:03:53 +0000667 * @param monitor the {@link BackupManagerMonitor} to receive callbacks about important events
668 * during the backup operation.
669 *
Shreyas Basarge38e74862017-01-11 17:15:58 +0000670 * @param flags {@link BackupManager#FLAG_NON_INCREMENTAL_BACKUP}.
671 *
Sergey Poromovfe06bf62015-12-15 16:26:23 +0100672 * @return Zero on success; nonzero on error.
673 */
Chandan Nathcd44f752018-12-07 16:49:37 +0000674 int requestBackupForUser(int userId, in String[] packages, IBackupObserver observer,
675 IBackupManagerMonitor monitor, int flags);
676
677 /**
678 * {@link android.app.backup.IBackupManager.requestBackupForUser} for the calling user id.
679 */
Stefanotb1f573d2017-01-27 12:03:53 +0000680 int requestBackup(in String[] packages, IBackupObserver observer, IBackupManagerMonitor monitor,
681 int flags);
Shreyas Basargec3704422017-01-28 16:50:09 +0000682
683 /**
684 * Cancel all running backups. After this call returns, no currently running backups will
685 * interact with the selected transport.
Chandan Nathcd44f752018-12-07 16:49:37 +0000686 *
687 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
688 * If {@code userId} is different from the calling user id, then the caller must hold the
689 * android.permission.INTERACT_ACROSS_USERS_FULL permission.
690 *
691 * @param userId User id for which backups should be cancelled.
692 */
693 void cancelBackupsForUser(int userId);
694
695 /**
696 * {@link android.app.backup.IBackupManager.cancelBackups} for the calling user id.
Shreyas Basargec3704422017-01-28 16:50:09 +0000697 */
698 void cancelBackups();
Stefano Tommasini471a35d2019-01-21 13:21:48 +0000699
700 /**
701 * Returns a {@link UserHandle} for the user that has {@code ancestralSerialNumber} as the serial
702 * number of the it's ancestral work profile.
703 *
704 * <p> The ancestral work profile is set by {@link #setAncestralSerialNumber(long)}
705 * and it corresponds to the profile that was used to restore to the callers profile.
706 */
707 UserHandle getUserForAncestralSerialNumber(in long ancestralSerialNumber);
708
709 /**
710 * Sets the ancestral work profile for the calling user.
711 *
712 * <p> The ancestral work profile corresponds to the profile that was used to restore to the
713 * callers profile.
714 *
715 * <p>Callers must hold the android.permission.BACKUP permission to use this method.
716 */
717 void setAncestralSerialNumber(in long ancestralSerialNumber);
718
Christopher Tate487529a2009-04-29 14:03:25 -0700719}