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 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 57 | @UnsupportedAppUsage |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 58 | void dataChanged(String packageName); |
Christopher Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
Christopher Tate | b0183f0 | 2013-11-18 14:20:36 -0800 | [diff] [blame] | 61 | * 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] | 62 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 67 | * 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 Tate | ee0e78a | 2009-07-02 11:17:03 -0700 | [diff] [blame] | 76 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 77 | @UnsupportedAppUsage |
Christopher Tate | b0183f0 | 2013-11-18 14:20:36 -0800 | [diff] [blame] | 78 | void clearBackupData(String transportName, String packageName); |
Christopher Tate | ee0e78a | 2009-07-02 11:17:03 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
Christopher Tate | 924afe2 | 2017-06-16 13:14:48 -0700 | [diff] [blame] | 81 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 86 | * 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 Tate | 924afe2 | 2017-06-16 13:14:48 -0700 | [diff] [blame] | 90 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 91 | void initializeTransportsForUser(int userId, in String[] transportNames, |
| 92 | IBackupObserver observer); |
Christopher Tate | 924afe2 | 2017-06-16 13:14:48 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 95 | * Notifies the Backup Manager Service that an agent has become available. This |
| 96 | * method is only invoked by the Activity Manager. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 97 | * |
| 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 Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 107 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 108 | void agentConnected(String packageName, IBinder agent); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 109 | |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 113 | * |
| 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 Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 123 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 124 | void agentDisconnected(String packageName); |
Christopher Tate | 181fafa | 2009-05-14 11:12:14 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
Christopher Tate | 1bb6906 | 2010-02-19 17:02:12 -0800 | [diff] [blame] | 127 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 129 | * |
| 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 Tate | 1bb6906 | 2010-02-19 17:02:12 -0800 | [diff] [blame] | 139 | */ |
| 140 | void restoreAtInstall(String packageName, int token); |
| 141 | |
| 142 | /** |
Christopher Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 143 | * 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 Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 150 | * 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 Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 159 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 160 | @UnsupportedAppUsage |
Christopher Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 161 | void setBackupEnabled(boolean isEnabled); |
| 162 | |
| 163 | /** |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 164 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 172 | * 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 Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 174 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 175 | * @param userId User id for which automatic restore should be enabled/disabled. |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 176 | * @param doAutoRestore When true, enables the automatic app-data restore facility. When |
| 177 | * false, this facility will be disabled. |
| 178 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 179 | void setAutoRestoreForUser(int userId, boolean doAutoRestore); |
| 180 | |
| 181 | /** |
| 182 | * {@link android.app.backup.IBackupManager.setAutoRestoreForUser} for the calling user id. |
| 183 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 184 | @UnsupportedAppUsage |
Christopher Tate | cce9da5 | 2010-02-03 15:11:15 -0800 | [diff] [blame] | 185 | void setAutoRestore(boolean doAutoRestore); |
| 186 | |
| 187 | /** |
Christopher Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 188 | * Report whether the backup mechanism is currently enabled. |
| 189 | * |
| 190 | * <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] | 191 | * 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 Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 200 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 201 | @UnsupportedAppUsage |
Christopher Tate | 6ef58a1 | 2009-06-29 14:56:28 -0700 | [diff] [blame] | 202 | boolean isBackupEnabled(); |
| 203 | |
| 204 | /** |
Christopher Tate | 2efd2db | 2011-07-19 16:32:49 -0700 | [diff] [blame] | 205 | * 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 Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 222 | * 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 Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 230 | * 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 Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 239 | */ |
Christopher Tate | 5cbbf56 | 2009-06-22 16:44:51 -0700 | [diff] [blame] | 240 | void backupNow(); |
Christopher Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 241 | |
| 242 | /** |
Johan Toras Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 243 | * Write a backup of the given package to the supplied file descriptor. |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 244 | * 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 Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 246 | * Currently only used by the 'adb backup' command. |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 247 | * |
| 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 Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 252 | * 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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 254 | * |
Ruslan Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 255 | * @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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 257 | * @param includeApks If <code>true</code>, the resulting tar stream will include the |
| 258 | * application .apk files themselves as well as their data. |
Christopher Tate | 46cc43c | 2013-02-19 14:08:59 -0800 | [diff] [blame] | 259 | * @param includeObbs If <code>true</code>, the resulting tar stream will include any |
| 260 | * application expansion (OBB) files themselves belonging to each application. |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 261 | * @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 Tate | 240c7d2 | 2011-10-03 18:13:44 -0700 | [diff] [blame] | 266 | * @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 Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 270 | * @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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 272 | * @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 Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 275 | void adbBackup(int userId, in ParcelFileDescriptor fd, boolean includeApks, boolean includeObbs, |
Christopher Tate | adfe8b8 | 2014-02-04 16:23:32 -0800 | [diff] [blame] | 276 | boolean includeShared, boolean doWidgets, boolean allApps, boolean allIncludesSystem, |
Johan Toras Halseth | b59a4b8 | 2017-03-03 15:37:43 +0000 | [diff] [blame] | 277 | boolean doCompress, boolean doKeyValue, in String[] packageNames); |
Christopher Tate | 9ff53a7 | 2014-06-03 17:20:07 -0700 | [diff] [blame] | 278 | |
| 279 | /** |
| 280 | * Perform a full-dataset backup of the given applications via the currently active |
| 281 | * transport. |
| 282 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 283 | * 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 Tate | 9ff53a7 | 2014-06-03 17:20:07 -0700 | [diff] [blame] | 287 | * @param packageNames The package names of the apps whose data are to be backed up. |
| 288 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 289 | void fullTransportBackupForUser(int userId, in String[] packageNames); |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 290 | |
| 291 | /** |
Christopher Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 292 | * 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] | 293 | * data stream must be in the format emitted by adbBackup(). |
| 294 | * Currently only used by the 'adb restore' command. |
Christopher Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 295 | * |
| 296 | * <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] | 297 | * 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 Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 301 | */ |
Ruslan Tkhakokhov | a2fe6c5 | 2018-12-03 17:28:39 +0000 | [diff] [blame] | 302 | void adbRestore(int userId, in ParcelFileDescriptor fd); |
Christopher Tate | 75a9970 | 2011-05-18 16:28:19 -0700 | [diff] [blame] | 303 | |
| 304 | /** |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 305 | * 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 Tate | 2efd2db | 2011-07-19 16:32:49 -0700 | [diff] [blame] | 311 | * <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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 316 | * <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] | 317 | * 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 Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 329 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 330 | @UnsupportedAppUsage |
Christopher Tate | 728a1c4 | 2011-07-28 18:03:03 -0700 | [diff] [blame] | 331 | void acknowledgeFullBackupOrRestore(int token, boolean allow, |
| 332 | in String curPassword, in String encryptionPassword, |
Christopher Tate | 4a627c7 | 2011-04-01 14:43:32 -0700 | [diff] [blame] | 333 | IFullBackupRestoreObserver observer); |
| 334 | |
| 335 | /** |
Bernardo Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 336 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 340 | * 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 Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 342 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 343 | * @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] | 344 | * @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 Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 361 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 362 | void updateTransportAttributesForUser(int userId, in ComponentName transportComponent, |
| 363 | in String name, |
Bernardo Rufino | ab95333 | 2017-11-22 22:10:32 +0000 | [diff] [blame] | 364 | in Intent configurationIntent, in String currentDestinationString, |
| 365 | in Intent dataManagementIntent, in String dataManagementLabel); |
| 366 | |
| 367 | /** |
Christopher Tate | ace7f09 | 2009-06-15 18:07:25 -0700 | [diff] [blame] | 368 | * Identify the currently selected transport. Callers must hold the |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 369 | * android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 370 | * 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 Tate | 4675812 | 2009-05-06 11:22:00 -0700 | [diff] [blame] | 379 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 380 | @UnsupportedAppUsage |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 381 | String getCurrentTransport(); |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 382 | |
Bernardo Rufino | 98b17a6 | 2018-05-09 09:25:35 +0100 | [diff] [blame] | 383 | /** |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 387 | * 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 Rufino | 98b17a6 | 2018-05-09 09:25:35 +0100 | [diff] [blame] | 391 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 392 | ComponentName getCurrentTransportComponentForUser(int userId); |
Bernardo Rufino | 98b17a6 | 2018-05-09 09:25:35 +0100 | [diff] [blame] | 393 | |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 394 | /** |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 395 | * Request a list of all available backup transports' names. Callers must |
| 396 | * hold the android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 397 | * 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 Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 406 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 407 | @UnsupportedAppUsage |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 408 | String[] listAllTransports(); |
| 409 | |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 410 | /** |
| 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 Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 417 | |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 418 | /** |
Christopher Tate | e227ec6 | 2016-06-15 17:38:00 -0700 | [diff] [blame] | 419 | * 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 Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 427 | * Specify the current backup transport. Callers must hold the |
Christopher Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 428 | * android.permission.BACKUP permission to use this method. |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 429 | * 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 Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 431 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 432 | * @param userId User id for which the transport should be selected. |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 433 | * @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] | 434 | * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}. |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 435 | * @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 Tate | 043dadc | 2009-06-02 16:11:00 -0700 | [diff] [blame] | 438 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 439 | String selectBackupTransportForUser(int userId, String transport); |
| 440 | |
| 441 | /** |
| 442 | * {@link android.app.backup.IBackupManager.selectBackupTransportForUser} for the calling user |
| 443 | * id. |
| 444 | */ |
Andrei Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 445 | @UnsupportedAppUsage |
Christopher Tate | 9171749 | 2009-06-26 21:07:13 -0700 | [diff] [blame] | 446 | String selectBackupTransport(String transport); |
Christopher Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 447 | |
| 448 | /** |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 449 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 454 | * 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 Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 456 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 457 | * @param userId User id for which the transport should be selected. |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 458 | * @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 Trochtova | 3b6e087 | 2018-08-09 14:16:45 +0200 | [diff] [blame] | 460 | * @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] | 461 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 462 | void selectBackupTransportAsyncForUser(int userId, in ComponentName transport, |
| 463 | ISelectBackupTransportCallback listener); |
Shreyas Basarge | 865303f | 2017-01-13 14:48:56 +0000 | [diff] [blame] | 464 | |
| 465 | /** |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 466 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 468 | * 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 Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 470 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 471 | * @param userId User id for which the configuration Intent should be reported. |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 472 | * @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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 477 | Intent getConfigurationIntentForUser(int userId, String transport); |
| 478 | |
| 479 | /** |
| 480 | * {@link android.app.backup.IBackupManager.getConfigurationIntentForUser} for the calling user |
| 481 | * id. |
| 482 | */ |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 483 | 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 488 | * 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 Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 490 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 491 | * @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] | 492 | * @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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 496 | String getDestinationStringForUser(int userId, String transport); |
| 497 | |
| 498 | /** |
| 499 | * {@link android.app.backup.IBackupManager.getDestinationStringForUser} for the calling user |
| 500 | * id. |
| 501 | */ |
Christopher Tate | f5e1c29 | 2010-12-08 18:40:26 -0800 | [diff] [blame] | 502 | String getDestinationString(String transport); |
| 503 | |
| 504 | /** |
Christopher Tate | c17739d | 2014-07-28 15:02:04 -0700 | [diff] [blame] | 505 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 507 | * 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 Tate | c17739d | 2014-07-28 15:02:04 -0700 | [diff] [blame] | 517 | */ |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 523 | * 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 Tate | c17739d | 2014-07-28 15:02:04 -0700 | [diff] [blame] | 533 | */ |
| 534 | String getDataManagementLabel(String transport); |
| 535 | |
| 536 | /** |
Chris Tate | 44ab845 | 2010-11-16 15:10:49 -0800 | [diff] [blame] | 537 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 547 | * 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 Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 549 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 550 | * @param userId User id for which a restore session should be begun. |
Chris Tate | 44ab845 | 2010-11-16 15:10:49 -0800 | [diff] [blame] | 551 | * @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 Tate | 8c850b7 | 2009-06-07 19:33:20 -0700 | [diff] [blame] | 556 | * @return An interface to the restore session, or null on error. |
| 557 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 558 | IRestoreSession beginRestoreSessionForUser(int userId, String packageName, String transportID); |
Christopher Tate | 44a2790 | 2010-01-27 17:15:49 -0800 | [diff] [blame] | 559 | |
| 560 | /** |
| 561 | * Notify the backup manager that a BackupAgent has completed the operation |
Ruslan Tkhakokhov | 6712b72 | 2019-01-19 21:35:32 +0000 | [diff] [blame] | 562 | * 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 Tate | 44a2790 | 2010-01-27 17:15:49 -0800 | [diff] [blame] | 575 | * corresponding to the given token. |
| 576 | * |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 577 | * @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 Tate | 44a2790 | 2010-01-27 17:15:49 -0800 | [diff] [blame] | 582 | */ |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 583 | void opComplete(int token, long result); |
Christopher Tate | bbe23b3 | 2014-10-30 13:44:27 -0700 | [diff] [blame] | 584 | |
| 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-Ban | 201caf5 | 2014-11-12 18:03:08 +0000 | [diff] [blame] | 596 | |
| 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 Onea | f650e3c | 2019-02-25 13:15:54 +0000 | [diff] [blame] | 602 | @UnsupportedAppUsage |
Zoltan Szatmary-Ban | 201caf5 | 2014-11-12 18:03:08 +0000 | [diff] [blame] | 603 | boolean isBackupServiceActive(int whichUser); |
Christopher Tate | 511d02f | 2015-04-08 20:05:30 -0700 | [diff] [blame] | 604 | |
| 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 610 | * 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 Tate | 511d02f | 2015-04-08 20:05:30 -0700 | [diff] [blame] | 612 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 613 | * @param userId User id for which this operation should be performed. |
Christopher Tate | 511d02f | 2015-04-08 20:05:30 -0700 | [diff] [blame] | 614 | * @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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 619 | long getAvailableRestoreTokenForUser(int userId, String packageName); |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 620 | |
| 621 | /** |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 622 | * Ask the framework whether this app is eligible for backup. |
| 623 | * |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 624 | * <p>If you are calling this method multiple times, you should instead use |
| 625 | * {@link #filterAppsEligibleForBackup(String[])} to save resources. |
| 626 | * |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 627 | * <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] | 628 | * 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 Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 630 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 631 | * @param userId User id for which this operation should be performed. |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 632 | * @param packageName The name of the package. |
| 633 | * @return Whether this app is eligible for backup. |
| 634 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 635 | boolean isAppEligibleForBackupForUser(int userId, String packageName); |
Sergey Poromov | 9448196 | 2016-01-07 18:25:35 +0100 | [diff] [blame] | 636 | |
| 637 | /** |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 638 | * 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 Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 641 | * 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 Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 643 | * |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 644 | * @param userId User id for which the filter should be performed. |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 645 | * @param packages The list of packages to filter. |
| 646 | * @return The packages eligible for backup. |
| 647 | */ |
Chandan Nath | d1ee43e | 2018-12-16 21:41:03 +0000 | [diff] [blame] | 648 | String[] filterAppsEligibleForBackupForUser(int userId, in String[] packages); |
Bernardo Rufino | fa51853 | 2018-01-02 16:01:53 +0000 | [diff] [blame] | 649 | |
| 650 | /** |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 651 | * 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 Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 658 | * <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 Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 664 | * @param observer The {@link BackupObserver} to receive callbacks during the backup |
| 665 | * operation. |
| 666 | * |
Stefanot | b1f573d | 2017-01-27 12:03:53 +0000 | [diff] [blame] | 667 | * @param monitor the {@link BackupManagerMonitor} to receive callbacks about important events |
| 668 | * during the backup operation. |
| 669 | * |
Shreyas Basarge | 38e7486 | 2017-01-11 17:15:58 +0000 | [diff] [blame] | 670 | * @param flags {@link BackupManager#FLAG_NON_INCREMENTAL_BACKUP}. |
| 671 | * |
Sergey Poromov | fe06bf6 | 2015-12-15 16:26:23 +0100 | [diff] [blame] | 672 | * @return Zero on success; nonzero on error. |
| 673 | */ |
Chandan Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 674 | 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 | */ |
Stefanot | b1f573d | 2017-01-27 12:03:53 +0000 | [diff] [blame] | 680 | int requestBackup(in String[] packages, IBackupObserver observer, IBackupManagerMonitor monitor, |
| 681 | int flags); |
Shreyas Basarge | c370442 | 2017-01-28 16:50:09 +0000 | [diff] [blame] | 682 | |
| 683 | /** |
| 684 | * Cancel all running backups. After this call returns, no currently running backups will |
| 685 | * interact with the selected transport. |
Chandan Nath | cd44f75 | 2018-12-07 16:49:37 +0000 | [diff] [blame] | 686 | * |
| 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 Basarge | c370442 | 2017-01-28 16:50:09 +0000 | [diff] [blame] | 697 | */ |
| 698 | void cancelBackups(); |
Stefano Tommasini | 471a35d | 2019-01-21 13:21:48 +0000 | [diff] [blame] | 699 | |
| 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 Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 719 | } |