Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 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 | |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 17 | package android.app.backup; |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 18 | |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 19 | import android.app.backup.IBackupObserver; |
Stefanot | b1f573d | 2017-01-27 12:03:53 +0000 | [diff] [blame] | 20 | import android.app.backup.IBackupManagerMonitor; |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 21 | import android.app.backup.IFullBackupRestoreObserver; |
Christopher Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 22 | import android.app.backup.IRestoreSession; |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 23 | import android.app.backup.ISelectBackupTransportCallback; |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 24 | import android.os.ParcelFileDescriptor; |
Stefano Tommasini | 471a35d | 2019-01-21 13:21:48 +0000 | [diff] [blame] | 25 | import android.os.UserHandle; |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 26 | import android.content.Intent; |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 27 | import android.content.ComponentName; |
Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 28 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 29 | /** |
| 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 Tate | 4528186 | 2010-03-05 15:46:30 -0800 | [diff] [blame] | 34 | * Apps will use the {@link android.app.backup.BackupManager} class rather than going through |
Christopher Tate | a8bf815 | 2009-04-30 11:36:21 -0700 | [diff] [blame] | 35 | * this Binder interface directly. |
| 36 | * |
| 37 | * {@hide} |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 38 | */ |
| 39 | interface IBackupManager { |
| 40 | /** |
| 41 | * Tell the system service that the caller has made changes to its |
Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 42 | * data, and therefore needs to undergo an incremental backup pass. |
Christopher Tate | ee0e78a | 2009-07-02 11:17:03 -0700 | [diff] [blame] | 43 | * |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 47 | * 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 Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 56 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 57 | void dataChanged(String packageName); |
Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
Christopher Tate | b0183f0 | 2013-11-18 14:20:36 -0800 | [diff] [blame] | 60 | * Erase all backed-up data for the given package from the given storage |
Christopher Tate | ee0e78a | 2009-07-02 11:17:03 -0700 | [diff] [blame] | 61 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 66 | * 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 Tate | ee0e78a | 2009-07-02 11:17:03 -0700 | [diff] [blame] | 75 | */ |
Christopher Tate | b0183f0 | 2013-11-18 14:20:36 -0800 | [diff] [blame] | 76 | void clearBackupData(String transportName, String packageName); |
Christopher Tate | ee0e78a | 2009-07-02 11:17:03 -0700 | [diff] [blame] | 77 | |
| 78 | /** |
Christopher Tate | 924afe2 | 2017-06-16 13:14:48 -0700 | [diff] [blame] | 79 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 84 | * 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 Tate | 924afe2 | 2017-06-16 13:14:48 -0700 | [diff] [blame] | 88 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 89 | void initializeTransportsForUser(int userId, in String[] transportNames, |
| 90 | IBackupObserver observer); |
Christopher Tate | 924afe2 | 2017-06-16 13:14:48 -0700 | [diff] [blame] | 91 | |
| 92 | /** |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 93 | * Notifies the Backup Manager Service that an agent has become available. This |
| 94 | * method is only invoked by the Activity Manager. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 95 | * |
| 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 Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 105 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 106 | void agentConnected(String packageName, IBinder agent); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 107 | |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 111 | * |
| 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 Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 121 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 122 | void agentDisconnected(String packageName); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
Christopher Tate | 1bb6906 | 2010-02-19 17:02:12 -0800 | [diff] [blame] | 125 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 127 | * |
| 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 Tate | 1bb6906 | 2010-02-19 17:02:12 -0800 | [diff] [blame] | 137 | */ |
| 138 | void restoreAtInstall(String packageName, int token); |
| 139 | |
| 140 | /** |
Christopher Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 141 | * 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 Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 148 | * 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 Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 157 | */ |
| 158 | void setBackupEnabled(boolean isEnabled); |
| 159 | |
| 160 | /** |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 161 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 169 | * 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 Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 171 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 172 | * @param userId User id for which automatic restore should be enabled/disabled. |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 173 | * @param doAutoRestore When true, enables the automatic app-data restore facility. When |
| 174 | * false, this facility will be disabled. |
| 175 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 176 | void setAutoRestoreForUser(int userId, boolean doAutoRestore); |
| 177 | |
| 178 | /** |
| 179 | * {@link android.app.backup.IBackupManager.setAutoRestoreForUser} for the calling user id. |
| 180 | */ |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 181 | void setAutoRestore(boolean doAutoRestore); |
| 182 | |
| 183 | /** |
Christopher Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 184 | * Report whether the backup mechanism is currently enabled. |
| 185 | * |
| 186 | * <p>Callers must hold the android.permission.BACKUP permission to use this method. |
Chandan Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 187 | * 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 Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 196 | */ |
| 197 | boolean isBackupEnabled(); |
| 198 | |
| 199 | /** |
Christopher Tate | 2efd2db | 2011-07-19 16:32:49 -0700 | [diff] [blame] | 200 | * 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 Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 217 | * 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 Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 225 | * 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 Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 234 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 235 | void backupNow(); |
Christopher Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 236 | |
| 237 | /** |
Johan Toras Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 238 | * Write a backup of the given package to the supplied file descriptor. |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 239 | * 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 Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 241 | * Currently only used by the 'adb backup' command. |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 242 | * |
| 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 Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 247 | * 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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 249 | * |
Ruslan Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 250 | * @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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 252 | * @param includeApks If <code>true</code>, the resulting tar stream will include the |
| 253 | * application .apk files themselves as well as their data. |
Christopher Tate | 46cc43c | 2013-02-19 14:08:59 -0800 | [diff] [blame] | 254 | * @param includeObbs If <code>true</code>, the resulting tar stream will include any |
| 255 | * application expansion (OBB) files themselves belonging to each application. |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 256 | * @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 Tate | 240c7d2 | 2011-10-03 18:13:44 -0700 | [diff] [blame] | 261 | * @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 Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 265 | * @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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 267 | * @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 Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 270 | void adbBackup(int userId, in ParcelFileDescriptor fd, boolean includeApks, boolean includeObbs, |
Christopher Tate | adfe8b8 | 2014-02-04 16:23:32 -0800 | [diff] [blame] | 271 | boolean includeShared, boolean doWidgets, boolean allApps, boolean allIncludesSystem, |
Johan Toras Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 272 | boolean doCompress, boolean doKeyValue, in String[] packageNames); |
Christopher Tate | 9ff53a7 | 2014-06-03 17:20:07 -0700 | [diff] [blame] | 273 | |
| 274 | /** |
| 275 | * Perform a full-dataset backup of the given applications via the currently active |
| 276 | * transport. |
| 277 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 278 | * 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 Tate | 9ff53a7 | 2014-06-03 17:20:07 -0700 | [diff] [blame] | 282 | * @param packageNames The package names of the apps whose data are to be backed up. |
| 283 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 284 | void fullTransportBackupForUser(int userId, in String[] packageNames); |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 285 | |
| 286 | /** |
Christopher Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 287 | * Restore device content from the data stream passed through the given socket. The |
Johan Toras Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 288 | * data stream must be in the format emitted by adbBackup(). |
| 289 | * Currently only used by the 'adb restore' command. |
Christopher Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 290 | * |
| 291 | * <p>Callers must hold the android.permission.BACKUP permission to use this method. |
Ruslan Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 292 | * 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 Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 296 | */ |
Ruslan Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 297 | void adbRestore(int userId, in ParcelFileDescriptor fd); |
Christopher Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 298 | |
| 299 | /** |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 300 | * 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 Tate | 2efd2db | 2011-07-19 16:32:49 -0700 | [diff] [blame] | 306 | * <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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 311 | * <p>Callers must hold the android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 312 | * 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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 324 | */ |
Christopher Tate | 728a1c4 | 2011-07-28 18:03:03 -0700 | [diff] [blame] | 325 | void acknowledgeFullBackupOrRestore(int token, boolean allow, |
| 326 | in String curPassword, in String encryptionPassword, |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 327 | IFullBackupRestoreObserver observer); |
| 328 | |
| 329 | /** |
Bernardo Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 330 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 334 | * 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 Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 336 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 337 | * @param userId User id for which the attributes of the transport should be updated. |
Bernardo Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 338 | * @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 Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 355 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 356 | void updateTransportAttributesForUser(int userId, in ComponentName transportComponent, |
| 357 | in String name, |
Bernardo Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 358 | in Intent configurationIntent, in String currentDestinationString, |
| 359 | in Intent dataManagementIntent, in String dataManagementLabel); |
| 360 | |
| 361 | /** |
Christopher Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 362 | * Identify the currently selected transport. Callers must hold the |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 363 | * android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 364 | * 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 Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 373 | */ |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 374 | String getCurrentTransport(); |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 375 | |
Bernardo Rufino | 98b17a6 | 2018-05-09 09:25:35 +0100 | [diff] [blame] | 376 | /** |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 380 | * 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 Rufino | 98b17a6 | 2018-05-09 09:25:35 +0100 | [diff] [blame] | 384 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 385 | ComponentName getCurrentTransportComponentForUser(int userId); |
Bernardo Rufino | 98b17a6 | 2018-05-09 09:25:35 +0100 | [diff] [blame] | 386 | |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 387 | /** |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 388 | * Request a list of all available backup transports' names. Callers must |
| 389 | * hold the android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 390 | * 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 Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 399 | */ |
| 400 | String[] listAllTransports(); |
| 401 | |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 402 | /** |
| 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 Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 409 | |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 410 | /** |
Christopher Tate | e227ec6 | 2016-06-15 17:38:00 -0700 | [diff] [blame] | 411 | * 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 Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 419 | * Specify the current backup transport. Callers must hold the |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 420 | * android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 421 | * 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 Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 423 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 424 | * @param userId User id for which the transport should be selected. |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 425 | * @param transport The name of the transport to select. This should be one |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 426 | * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}. |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 427 | * @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 Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 430 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 431 | String selectBackupTransportForUser(int userId, String transport); |
| 432 | |
| 433 | /** |
| 434 | * {@link android.app.backup.IBackupManager.selectBackupTransportForUser} for the calling user |
| 435 | * id. |
| 436 | */ |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 437 | String selectBackupTransport(String transport); |
Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 438 | |
| 439 | /** |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 440 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 445 | * 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 Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 447 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 448 | * @param userId User id for which the transport should be selected. |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 449 | * @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 Trochtova | 3b6e087 | 2018-08-09 14:16:45 +0200 | [diff] [blame] | 451 | * @param listener A listener object to get a callback on the transport being selected. |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 452 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 453 | void selectBackupTransportAsyncForUser(int userId, in ComponentName transport, |
| 454 | ISelectBackupTransportCallback listener); |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 455 | |
| 456 | /** |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 457 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 459 | * 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 Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 461 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 462 | * @param userId User id for which the configuration Intent should be reported. |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 463 | * @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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 468 | Intent getConfigurationIntentForUser(int userId, String transport); |
| 469 | |
| 470 | /** |
| 471 | * {@link android.app.backup.IBackupManager.getConfigurationIntentForUser} for the calling user |
| 472 | * id. |
| 473 | */ |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 474 | 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 479 | * 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 Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 481 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 482 | * @param userId User id for which the transport destination string should be reported. |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 483 | * @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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 487 | String getDestinationStringForUser(int userId, String transport); |
| 488 | |
| 489 | /** |
| 490 | * {@link android.app.backup.IBackupManager.getDestinationStringForUser} for the calling user |
| 491 | * id. |
| 492 | */ |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 493 | String getDestinationString(String transport); |
| 494 | |
| 495 | /** |
Christopher Tate | c17739d | 2014-07-28 15:02:04 -0700 | [diff] [blame] | 496 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 498 | * 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 Tate | c17739d | 2014-07-28 15:02:04 -0700 | [diff] [blame] | 508 | */ |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 514 | * 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 Tate | c17739d | 2014-07-28 15:02:04 -0700 | [diff] [blame] | 524 | */ |
| 525 | String getDataManagementLabel(String transport); |
| 526 | |
| 527 | /** |
Chris Tate | 44ab845 | 2010-11-16 15:10:49 -0800 | [diff] [blame] | 528 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 538 | * 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 Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 540 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 541 | * @param userId User id for which a restore session should be begun. |
Chris Tate | 44ab845 | 2010-11-16 15:10:49 -0800 | [diff] [blame] | 542 | * @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 Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 547 | * @return An interface to the restore session, or null on error. |
| 548 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 549 | IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID); |
Christopher Tate | 44a2790 | 2010-01-27 17:15:49 -0800 | [diff] [blame] | 550 | |
| 551 | /** |
| 552 | * Notify the backup manager that a BackupAgent has completed the operation |
Ruslan Tkhakokhov | 6712b72 | 2019-01-19 21:35:32 +0000 | [diff] [blame] | 553 | * 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 Tate | 44a2790 | 2010-01-27 17:15:49 -0800 | [diff] [blame] | 566 | * corresponding to the given token. |
| 567 | * |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 568 | * @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 Tate | 44a2790 | 2010-01-27 17:15:49 -0800 | [diff] [blame] | 573 | */ |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 574 | void opComplete(int token, long result); |
Christopher Tate | bbe23b3 | 2014-10-30 13:44:27 -0700 | [diff] [blame] | 575 | |
| 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-Ban | 201caf5 | 2014-11-12 18:03:08 +0000 | [diff] [blame] | 587 | |
| 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 Tate | 511d02f | 2015-04-08 20:05:30 -0700 | [diff] [blame] | 594 | |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 600 | * 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 Tate | 511d02f | 2015-04-08 20:05:30 -0700 | [diff] [blame] | 602 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 603 | * @param userId User id for which this operation should be performed. |
Christopher Tate | 511d02f | 2015-04-08 20:05:30 -0700 | [diff] [blame] | 604 | * @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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 609 | long getAvailableRestoreTokenForUser(int userId, String packageName); |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 610 | |
| 611 | /** |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 612 | * Ask the framework whether this app is eligible for backup. |
| 613 | * |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 614 | * <p>If you are calling this method multiple times, you should instead use |
| 615 | * {@link #filterAppsEligibleForBackup(String[])} to save resources. |
| 616 | * |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 617 | * <p>Callers must hold the android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 618 | * 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 Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 620 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 621 | * @param userId User id for which this operation should be performed. |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 622 | * @param packageName The name of the package. |
| 623 | * @return Whether this app is eligible for backup. |
| 624 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 625 | boolean isAppEligibleForBackupForUser(int userId, String packageName); |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 626 | |
| 627 | /** |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 628 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 631 | * 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 Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 633 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 634 | * @param userId User id for which the filter should be performed. |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 635 | * @param packages The list of packages to filter. |
| 636 | * @return The packages eligible for backup. |
| 637 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 638 | String[] filterAppsEligibleForBackupForUser(int userId, in String[] packages); |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 639 | |
| 640 | /** |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 641 | * 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 Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 648 | * <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 Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 654 | * @param observer The {@link BackupObserver} to receive callbacks during the backup |
| 655 | * operation. |
| 656 | * |
Stefanot | b1f573d | 2017-01-27 12:03:53 +0000 | [diff] [blame] | 657 | * @param monitor the {@link BackupManagerMonitor} to receive callbacks about important events |
| 658 | * during the backup operation. |
| 659 | * |
Shreyas Basarge | 38e7486 | 2017-01-11 17:15:58 +0000 | [diff] [blame] | 660 | * @param flags {@link BackupManager#FLAG_NON_INCREMENTAL_BACKUP}. |
| 661 | * |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 662 | * @return Zero on success; nonzero on error. |
| 663 | */ |
Chandan Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 664 | 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 | */ |
Stefanot | b1f573d | 2017-01-27 12:03:53 +0000 | [diff] [blame] | 670 | int requestBackup(in String[] packages, IBackupObserver observer, IBackupManagerMonitor monitor, |
| 671 | int flags); |
Shreyas Basarge | c370442 | 2017-01-28 16:50:09 +0000 | [diff] [blame] | 672 | |
| 673 | /** |
| 674 | * Cancel all running backups. After this call returns, no currently running backups will |
| 675 | * interact with the selected transport. |
Chandan Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 676 | * |
| 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 Basarge | c370442 | 2017-01-28 16:50:09 +0000 | [diff] [blame] | 687 | */ |
| 688 | void cancelBackups(); |
Stefano Tommasini | 471a35d | 2019-01-21 13:21:48 +0000 | [diff] [blame] | 689 | |
| 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 Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 709 | } |