IBackupManager.aidl revision 2efd2dbbac9eac89620683696c6076463c3a1cd6
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.IFullBackupRestoreObserver;
20import android.app.backup.IRestoreSession;
21import android.os.ParcelFileDescriptor;
22import android.content.Intent;
23
24/**
25 * Direct interface to the Backup Manager Service that applications invoke on.  The only
26 * operation currently needed is a simple notification that the app has made changes to
27 * data it wishes to back up, so the system should run a backup pass.
28 *
29 * Apps will use the {@link android.app.backup.BackupManager} class rather than going through
30 * this Binder interface directly.
31 *
32 * {@hide}
33 */
34interface IBackupManager {
35    /**
36     * Tell the system service that the caller has made changes to its
37     * data, and therefore needs to undergo an incremental backup pass.
38     *
39     * Any application can invoke this method for its own package, but
40     * only callers who hold the android.permission.BACKUP permission
41     * may invoke it for arbitrary packages.
42     */
43    void dataChanged(String packageName);
44
45    /**
46     * Erase all backed-up data for the given package from the storage
47     * destination.
48     *
49     * Any application can invoke this method for its own package, but
50     * only callers who hold the android.permission.BACKUP permission
51     * may invoke it for arbitrary packages.
52     */
53    void clearBackupData(String packageName);
54
55    /**
56     * Notifies the Backup Manager Service that an agent has become available.  This
57     * method is only invoked by the Activity Manager.
58     */
59    void agentConnected(String packageName, IBinder agent);
60
61    /**
62     * Notify the Backup Manager Service that an agent has unexpectedly gone away.
63     * This method is only invoked by the Activity Manager.
64     */
65    void agentDisconnected(String packageName);
66
67    /**
68     * Notify the Backup Manager Service that an application being installed will
69     * need a data-restore pass.  This method is only invoked by the Package Manager.
70     */
71    void restoreAtInstall(String packageName, int token);
72
73    /**
74     * Enable/disable the backup service entirely.  When disabled, no backup
75     * or restore operations will take place.  Data-changed notifications will
76     * still be observed and collected, however, so that changes made while the
77     * mechanism was disabled will still be backed up properly if it is enabled
78     * at some point in the future.
79     *
80     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
81     */
82    void setBackupEnabled(boolean isEnabled);
83
84    /**
85     * Enable/disable automatic restore of application data at install time.  When
86     * enabled, installation of any package will involve the Backup Manager.  If data
87     * exists for the newly-installed package, either from the device's current [enabled]
88     * backup dataset or from the restore set used in the last wholesale restore operation,
89     * that data will be supplied to the new package's restore agent before the package
90     * is made generally available for launch.
91     *
92     * <p>Callers must hold  the android.permission.BACKUP permission to use this method.
93     *
94     * @param doAutoRestore When true, enables the automatic app-data restore facility.  When
95     *   false, this facility will be disabled.
96     */
97    void setAutoRestore(boolean doAutoRestore);
98
99    /**
100     * Indicate that any necessary one-time provisioning has occurred.
101     *
102     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
103     */
104    void setBackupProvisioned(boolean isProvisioned);
105
106    /**
107     * Report whether the backup mechanism is currently enabled.
108     *
109     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
110     */
111    boolean isBackupEnabled();
112
113    /**
114     * Set the device's backup password.  Returns {@code true} if the password was set
115     * successfully, {@code false} otherwise.  Typically a failure means that an incorrect
116     * current password was supplied.
117     *
118     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
119     */
120    boolean setBackupPassword(in String currentPw, in String newPw);
121
122    /**
123     * Reports whether a backup password is currently set.  If not, then a null or empty
124     * "current password" argument should be passed to setBackupPassword().
125     *
126     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
127     */
128    boolean hasBackupPassword();
129
130    /**
131     * Schedule an immediate backup attempt for all pending updates.  This is
132     * primarily intended for transports to use when they detect a suitable
133     * opportunity for doing a backup pass.  If there are no pending updates to
134     * be sent, no action will be taken.  Even if some updates are pending, the
135     * transport will still be asked to confirm via the usual requestBackupTime()
136     * method.
137     *
138     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
139     */
140    void backupNow();
141
142    /**
143     * Write a full backup of the given package to the supplied file descriptor.
144     * The fd may be a socket or other non-seekable destination.  If no package names
145     * are supplied, then every application on the device will be backed up to the output.
146     *
147     * <p>This method is <i>synchronous</i> -- it does not return until the backup has
148     * completed.
149     *
150     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
151     *
152     * @param fd The file descriptor to which a 'tar' file stream is to be written
153     * @param includeApks If <code>true</code>, the resulting tar stream will include the
154     *     application .apk files themselves as well as their data.
155     * @param includeShared If <code>true</code>, the resulting tar stream will include
156     *     the contents of the device's shared storage (SD card or equivalent).
157     * @param allApps If <code>true</code>, the resulting tar stream will include all
158     *     installed applications' data, not just those named in the <code>packageNames</code>
159     *     parameter.
160     * @param packageNames The package names of the apps whose data (and optionally .apk files)
161     *     are to be backed up.  The <code>allApps</code> parameter supersedes this.
162     */
163    void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeShared,
164            boolean allApps, in String[] packageNames);
165
166    /**
167     * Restore device content from the data stream passed through the given socket.  The
168     * data stream must be in the format emitted by fullBackup().
169     *
170     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
171     */
172    void fullRestore(in ParcelFileDescriptor fd);
173
174    /**
175     * Confirm that the requested full backup/restore operation can proceed.  The system will
176     * not actually perform the operation described to fullBackup() / fullRestore() unless the
177     * UI calls back into the Backup Manager to confirm, passing the correct token.  At
178     * the same time, the UI supplies a callback Binder for progress notifications during
179     * the operation.
180     *
181     * <p>The password passed by the confirming entity must match the saved backup or
182     * full-device encryption password in order to perform a backup.  If a password is
183     * supplied for restore, it must match the password used when creating the full
184     * backup dataset being used for restore.
185     *
186     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
187     */
188    void acknowledgeFullBackupOrRestore(int token, boolean allow, in String password,
189            IFullBackupRestoreObserver observer);
190
191    /**
192     * Identify the currently selected transport.  Callers must hold the
193     * android.permission.BACKUP permission to use this method.
194     */
195    String getCurrentTransport();
196
197    /**
198     * Request a list of all available backup transports' names.  Callers must
199     * hold the android.permission.BACKUP permission to use this method.
200     */
201    String[] listAllTransports();
202
203    /**
204     * Specify the current backup transport.  Callers must hold the
205     * android.permission.BACKUP permission to use this method.
206     *
207     * @param transport The name of the transport to select.  This should be one
208     * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
209     * @return The name of the previously selected transport.  If the given transport
210     *   name is not one of the currently available transports, no change is made to
211     *   the current transport setting and the method returns null.
212     */
213    String selectBackupTransport(String transport);
214
215    /**
216     * Get the configuration Intent, if any, from the given transport.  Callers must
217     * hold the android.permission.BACKUP permission in order to use this method.
218     *
219     * @param transport The name of the transport to query.
220     * @return An Intent to use with Activity#startActivity() to bring up the configuration
221     *   UI supplied by the transport.  If the transport has no configuration UI, it should
222     *   return {@code null} here.
223     */
224    Intent getConfigurationIntent(String transport);
225
226    /**
227     * Get the destination string supplied by the given transport.  Callers must
228     * hold the android.permission.BACKUP permission in order to use this method.
229     *
230     * @param transport The name of the transport to query.
231     * @return A string describing the current backup destination.  This string is used
232     *   verbatim by the Settings UI as the summary text of the "configure..." item.
233     */
234    String getDestinationString(String transport);
235
236    /**
237     * Begin a restore session.  Either or both of packageName and transportID
238     * may be null.  If packageName is non-null, then only the given package will be
239     * considered for restore.  If transportID is null, then the restore will use
240     * the current active transport.
241     * <p>
242     * This method requires the android.permission.BACKUP permission <i>except</i>
243     * when transportID is null and packageName is the name of the caller's own
244     * package.  In that case, the restore session returned is suitable for supporting
245     * the BackupManager.requestRestore() functionality via RestoreSession.restorePackage()
246     * without requiring the app to hold any special permission.
247     *
248     * @param packageName The name of the single package for which a restore will
249     *        be requested.  May be null, in which case all packages in the restore
250     *        set can be restored.
251     * @param transportID The name of the transport to use for the restore operation.
252     *        May be null, in which case the current active transport is used.
253     * @return An interface to the restore session, or null on error.
254     */
255    IRestoreSession beginRestoreSession(String packageName, String transportID);
256
257    /**
258     * Notify the backup manager that a BackupAgent has completed the operation
259     * corresponding to the given token.
260     *
261     * @param token The transaction token passed to a BackupAgent's doBackup() or
262     *        doRestore() method.
263     * {@hide}
264     */
265    void opComplete(int token);
266}
267