IBackupManager.aidl revision 9448196076d5a5266b3ae7e4945216b30ee88aa7
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
17package android.app.backup;
18
19import android.app.backup.IBackupObserver;
20import android.app.backup.IFullBackupRestoreObserver;
21import android.app.backup.IRestoreSession;
22import android.os.ParcelFileDescriptor;
23import android.content.Intent;
24
25/**
26 * Direct interface to the Backup Manager Service that applications invoke on.  The only
27 * operation currently needed is a simple notification that the app has made changes to
28 * data it wishes to back up, so the system should run a backup pass.
29 *
30 * Apps will use the {@link android.app.backup.BackupManager} class rather than going through
31 * this Binder interface directly.
32 *
33 * {@hide}
34 */
35interface IBackupManager {
36    /**
37     * Tell the system service that the caller has made changes to its
38     * data, and therefore needs to undergo an incremental backup pass.
39     *
40     * Any application can invoke this method for its own package, but
41     * only callers who hold the android.permission.BACKUP permission
42     * may invoke it for arbitrary packages.
43     */
44    void dataChanged(String packageName);
45
46    /**
47     * Erase all backed-up data for the given package from the given storage
48     * destination.
49     *
50     * Any application can invoke this method for its own package, but
51     * only callers who hold the android.permission.BACKUP permission
52     * may invoke it for arbitrary packages.
53     */
54    void clearBackupData(String transportName, String packageName);
55
56    /**
57     * Notifies the Backup Manager Service that an agent has become available.  This
58     * method is only invoked by the Activity Manager.
59     */
60    void agentConnected(String packageName, IBinder agent);
61
62    /**
63     * Notify the Backup Manager Service that an agent has unexpectedly gone away.
64     * This method is only invoked by the Activity Manager.
65     */
66    void agentDisconnected(String packageName);
67
68    /**
69     * Notify the Backup Manager Service that an application being installed will
70     * need a data-restore pass.  This method is only invoked by the Package Manager.
71     */
72    void restoreAtInstall(String packageName, int token);
73
74    /**
75     * Enable/disable the backup service entirely.  When disabled, no backup
76     * or restore operations will take place.  Data-changed notifications will
77     * still be observed and collected, however, so that changes made while the
78     * mechanism was disabled will still be backed up properly if it is enabled
79     * at some point in the future.
80     *
81     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
82     */
83    void setBackupEnabled(boolean isEnabled);
84
85    /**
86     * Enable/disable automatic restore of application data at install time.  When
87     * enabled, installation of any package will involve the Backup Manager.  If data
88     * exists for the newly-installed package, either from the device's current [enabled]
89     * backup dataset or from the restore set used in the last wholesale restore operation,
90     * that data will be supplied to the new package's restore agent before the package
91     * is made generally available for launch.
92     *
93     * <p>Callers must hold  the android.permission.BACKUP permission to use this method.
94     *
95     * @param doAutoRestore When true, enables the automatic app-data restore facility.  When
96     *   false, this facility will be disabled.
97     */
98    void setAutoRestore(boolean doAutoRestore);
99
100    /**
101     * Indicate that any necessary one-time provisioning has occurred.
102     *
103     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
104     */
105    void setBackupProvisioned(boolean isProvisioned);
106
107    /**
108     * Report whether the backup mechanism is currently enabled.
109     *
110     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
111     */
112    boolean isBackupEnabled();
113
114    /**
115     * Set the device's backup password.  Returns {@code true} if the password was set
116     * successfully, {@code false} otherwise.  Typically a failure means that an incorrect
117     * current password was supplied.
118     *
119     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
120     */
121    boolean setBackupPassword(in String currentPw, in String newPw);
122
123    /**
124     * Reports whether a backup password is currently set.  If not, then a null or empty
125     * "current password" argument should be passed to setBackupPassword().
126     *
127     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
128     */
129    boolean hasBackupPassword();
130
131    /**
132     * Schedule an immediate backup attempt for all pending updates.  This is
133     * primarily intended for transports to use when they detect a suitable
134     * opportunity for doing a backup pass.  If there are no pending updates to
135     * be sent, no action will be taken.  Even if some updates are pending, the
136     * transport will still be asked to confirm via the usual requestBackupTime()
137     * method.
138     *
139     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
140     */
141    void backupNow();
142
143    /**
144     * Write a full backup of the given package to the supplied file descriptor.
145     * The fd may be a socket or other non-seekable destination.  If no package names
146     * are supplied, then every application on the device will be backed up to the output.
147     *
148     * <p>This method is <i>synchronous</i> -- it does not return until the backup has
149     * completed.
150     *
151     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
152     *
153     * @param fd The file descriptor to which a 'tar' file stream is to be written
154     * @param includeApks If <code>true</code>, the resulting tar stream will include the
155     *     application .apk files themselves as well as their data.
156     * @param includeObbs If <code>true</code>, the resulting tar stream will include any
157     *     application expansion (OBB) files themselves belonging to each application.
158     * @param includeShared If <code>true</code>, the resulting tar stream will include
159     *     the contents of the device's shared storage (SD card or equivalent).
160     * @param allApps If <code>true</code>, the resulting tar stream will include all
161     *     installed applications' data, not just those named in the <code>packageNames</code>
162     *     parameter.
163     * @param allIncludesSystem If {@code true}, then {@code allApps} will be interpreted
164     *     as including packages pre-installed as part of the system. If {@code false},
165     *     then setting {@code allApps} to {@code true} will mean only that all 3rd-party
166     *     applications will be included in the dataset.
167     * @param packageNames The package names of the apps whose data (and optionally .apk files)
168     *     are to be backed up.  The <code>allApps</code> parameter supersedes this.
169     */
170    void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeObbs,
171            boolean includeShared, boolean doWidgets, boolean allApps, boolean allIncludesSystem,
172            boolean doCompress, in String[] packageNames);
173
174    /**
175     * Perform a full-dataset backup of the given applications via the currently active
176     * transport.
177     *
178     * @param packageNames The package names of the apps whose data are to be backed up.
179     */
180    void fullTransportBackup(in String[] packageNames);
181
182    /**
183     * Restore device content from the data stream passed through the given socket.  The
184     * data stream must be in the format emitted by fullBackup().
185     *
186     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
187     */
188    void fullRestore(in ParcelFileDescriptor fd);
189
190    /**
191     * Confirm that the requested full backup/restore operation can proceed.  The system will
192     * not actually perform the operation described to fullBackup() / fullRestore() unless the
193     * UI calls back into the Backup Manager to confirm, passing the correct token.  At
194     * the same time, the UI supplies a callback Binder for progress notifications during
195     * the operation.
196     *
197     * <p>The password passed by the confirming entity must match the saved backup or
198     * full-device encryption password in order to perform a backup.  If a password is
199     * supplied for restore, it must match the password used when creating the full
200     * backup dataset being used for restore.
201     *
202     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
203     */
204    void acknowledgeFullBackupOrRestore(int token, boolean allow,
205            in String curPassword, in String encryptionPassword,
206            IFullBackupRestoreObserver observer);
207
208    /**
209     * Identify the currently selected transport.  Callers must hold the
210     * android.permission.BACKUP permission to use this method.
211     */
212    String getCurrentTransport();
213
214    /**
215     * Request a list of all available backup transports' names.  Callers must
216     * hold the android.permission.BACKUP permission to use this method.
217     */
218    String[] listAllTransports();
219
220    /**
221     * Specify the current backup transport.  Callers must hold the
222     * android.permission.BACKUP permission to use this method.
223     *
224     * @param transport The name of the transport to select.  This should be one
225     * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
226     * @return The name of the previously selected transport.  If the given transport
227     *   name is not one of the currently available transports, no change is made to
228     *   the current transport setting and the method returns null.
229     */
230    String selectBackupTransport(String transport);
231
232    /**
233     * Get the configuration Intent, if any, from the given transport.  Callers must
234     * hold the android.permission.BACKUP permission in order to use this method.
235     *
236     * @param transport The name of the transport to query.
237     * @return An Intent to use with Activity#startActivity() to bring up the configuration
238     *   UI supplied by the transport.  If the transport has no configuration UI, it should
239     *   return {@code null} here.
240     */
241    Intent getConfigurationIntent(String transport);
242
243    /**
244     * Get the destination string supplied by the given transport.  Callers must
245     * hold the android.permission.BACKUP permission in order to use this method.
246     *
247     * @param transport The name of the transport to query.
248     * @return A string describing the current backup destination.  This string is used
249     *   verbatim by the Settings UI as the summary text of the "configure..." item.
250     */
251    String getDestinationString(String transport);
252
253    /**
254     * Get the manage-data UI intent, if any, from the given transport.  Callers must
255     * hold the android.permission.BACKUP permission in order to use this method.
256     */
257    Intent getDataManagementIntent(String transport);
258
259    /**
260     * Get the manage-data menu label, if any, from the given transport.  Callers must
261     * hold the android.permission.BACKUP permission in order to use this method.
262     */
263    String getDataManagementLabel(String transport);
264
265    /**
266     * Begin a restore session.  Either or both of packageName and transportID
267     * may be null.  If packageName is non-null, then only the given package will be
268     * considered for restore.  If transportID is null, then the restore will use
269     * the current active transport.
270     * <p>
271     * This method requires the android.permission.BACKUP permission <i>except</i>
272     * when transportID is null and packageName is the name of the caller's own
273     * package.  In that case, the restore session returned is suitable for supporting
274     * the BackupManager.requestRestore() functionality via RestoreSession.restorePackage()
275     * without requiring the app to hold any special permission.
276     *
277     * @param packageName The name of the single package for which a restore will
278     *        be requested.  May be null, in which case all packages in the restore
279     *        set can be restored.
280     * @param transportID The name of the transport to use for the restore operation.
281     *        May be null, in which case the current active transport is used.
282     * @return An interface to the restore session, or null on error.
283     */
284    IRestoreSession beginRestoreSession(String packageName, String transportID);
285
286    /**
287     * Notify the backup manager that a BackupAgent has completed the operation
288     * corresponding to the given token.
289     *
290     * @param token The transaction token passed to the BackupAgent method being
291     *        invoked.
292     * @param result In the case of a full backup measure operation, the estimated
293     *        total file size that would result from the operation. Unused in all other
294     *        cases.
295     * {@hide}
296     */
297    void opComplete(int token, long result);
298
299    /**
300     * Make the device's backup and restore machinery (in)active.  When it is inactive,
301     * the device will not perform any backup operations, nor will it deliver data for
302     * restore, although clients can still safely call BackupManager methods.
303     *
304     * @param whichUser User handle of the defined user whose backup active state
305     *     is to be adjusted.
306     * @param makeActive {@code true} when backup services are to be made active;
307     *     {@code false} otherwise.
308     */
309    void setBackupServiceActive(int whichUser, boolean makeActive);
310
311    /**
312     * Queries the activity status of backup service as set by {@link #setBackupServiceActive}.
313     * @param whichUser User handle of the defined user whose backup active state
314     *     is being queried.
315     */
316    boolean isBackupServiceActive(int whichUser);
317
318    /**
319     * Ask the framework which dataset, if any, the given package's data would be
320     * restored from if we were to install it right now.
321     *
322     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
323     *
324     * @param packageName The name of the package whose most-suitable dataset we
325     *     wish to look up
326     * @return The dataset token from which a restore should be attempted, or zero if
327     *     no suitable data is available.
328     */
329    long getAvailableRestoreToken(String packageName);
330
331    /**
332     * Ask the framework whether this app is eligible for backup.
333     *
334     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
335     *
336     * @param packageName The name of the package.
337     * @return Whether this app is eligible for backup.
338     */
339    boolean isAppEligibleForBackup(String packageName);
340
341    /**
342     * Request an immediate backup, providing an observer to which results of the backup operation
343     * will be published. The Android backup system will decide for each package whether it will
344     * be full app data backup or key/value-pair-based backup.
345     *
346     * <p>If this method returns zero (meaning success), the OS will attempt to backup all provided
347     * packages using the remote transport.
348     *
349     * @param observer The {@link BackupObserver} to receive callbacks during the backup
350     * operation.
351     *
352     * @return Zero on success; nonzero on error.
353     */
354    int requestBackup(in String[] packages, IBackupObserver observer);
355}
356