IRestoreSession.aidl revision 4528186e0d65fc68ef0dd1941aa2ac8aefcd55a3
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.RestoreSet;
20import android.app.backup.IRestoreObserver;
21
22/**
23 * Binder interface used by clients who wish to manage a restore operation.  Every
24 * method in this interface requires the android.permission.BACKUP permission.
25 *
26 * {@hide}
27 */
28interface IRestoreSession {
29    /**
30     * Ask the current transport what the available restore sets are.
31     *
32     * @return A bundle containing two elements:  an int array under the key
33     *   "tokens" whose entries are a transport-private identifier for each backup set;
34     *   and a String array under the key "names" whose entries are the user-meaningful
35     *   text corresponding to the backup sets at each index in the tokens array.
36     */
37    RestoreSet[] getAvailableRestoreSets();
38
39    /**
40     * Restore the given set onto the device, replacing the current data of any app
41     * contained in the restore set with the data previously backed up.
42     *
43     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
44     *
45     * @return Zero on success; nonzero on error.  The observer will only receive
46     *   progress callbacks if this method returned zero.
47     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
48     *   the restore set that should be used.
49     * @param observer If non-null, this binder points to an object that will receive
50     *   progress callbacks during the restore operation.
51     */
52    int restoreAll(long token, IRestoreObserver observer);
53
54    /**
55     * Restore a single application from backup.  The data will be restored from the
56     * current backup dataset if the given package has stored data there, or from
57     * the dataset used during the last full device setup operation if the current
58     * backup dataset has no matching data.  If no backup data exists for this package
59     * in either source, a nonzero value will be returned.
60     *
61     * @return Zero on success; nonzero on error.  The observer will only receive
62     *   progress callbacks if this method returned zero.
63     * @param packageName The name of the package whose data to restore.  If this is
64     *   not the name of the caller's own package, then the android.permission.BACKUP
65     *   permission must be held.
66     * @param observer If non-null, this binder points to an object that will receive
67     *   progress callbacks during the restore operation.
68     */
69    int restorePackage(in String packageName, IRestoreObserver observer);
70
71    /**
72     * End this restore session.  After this method is called, the IRestoreSession binder
73     * is no longer valid.
74     *
75     * <p><b>Note:</b> The caller <i>must</i> invoke this method to end the restore session,
76     *   even if {@link getAvailableRestoreSets} or {@link performRestore} failed.
77     */
78    void endRestoreSession();
79}
80