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 
17 package android.app.backup;
18 
19 import android.app.backup.RestoreSet;
20 import 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  */
28 interface IRestoreSession {
29     /**
30      * Ask the current transport what the available restore sets are.
31      *
32      * @param observer This binder points to an object whose onRestoreSetsAvailable()
33      *   method will be called to supply the results of the transport's lookup.
34      * @return Zero on success; nonzero on error.  The observer will only receive a
35      *   result callback if this method returned zero.
36      */
getAvailableRestoreSets(IRestoreObserver observer)37     int getAvailableRestoreSets(IRestoreObserver observer);
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      */
restoreAll(long token, IRestoreObserver observer)52     int restoreAll(long token, IRestoreObserver observer);
53 
54     /**
55      * Restore select packages from the given set onto the device, replacing the
56      * current data of any app contained in the set with the data previously
57      * backed up.
58      *
59      * <p>Callers must hold the android.permission.BACKUP permission to use this method.
60      *
61      * @return Zero on success, nonzero on error. The observer will only receive
62      *   progress callbacks if this method returned zero.
63      * @param token The token from {@link getAvailableRestoreSets()} corresponding to
64      *   the restore set that should be used.
65      * @param observer If non-null, this binder points to an object that will receive
66      *   progress callbacks during the restore operation.
67      * @param packages The set of packages for which to attempt a restore.  Regardless of
68      *   the contents of the actual back-end dataset named by {@code token}, only
69      *   applications mentioned in this list will have their data restored.
70      */
restoreSome(long token, IRestoreObserver observer, in String[] packages)71     int restoreSome(long token, IRestoreObserver observer, in String[] packages);
72 
73     /**
74      * Restore a single application from backup.  The data will be restored from the
75      * current backup dataset if the given package has stored data there, or from
76      * the dataset used during the last full device setup operation if the current
77      * backup dataset has no matching data.  If no backup data exists for this package
78      * in either source, a nonzero value will be returned.
79      *
80      * @return Zero on success; nonzero on error.  The observer will only receive
81      *   progress callbacks if this method returned zero.
82      * @param packageName The name of the package whose data to restore.  If this is
83      *   not the name of the caller's own package, then the android.permission.BACKUP
84      *   permission must be held.
85      * @param observer If non-null, this binder points to an object that will receive
86      *   progress callbacks during the restore operation.
87      */
restorePackage(in String packageName, IRestoreObserver observer)88     int restorePackage(in String packageName, IRestoreObserver observer);
89 
90     /**
91      * End this restore session.  After this method is called, the IRestoreSession binder
92      * is no longer valid.
93      *
94      * <p><b>Note:</b> The caller <i>must</i> invoke this method to end the restore session,
95      *   even if {@link getAvailableRestoreSets} or {@link performRestore} failed.
96      */
endRestoreSession()97     void endRestoreSession();
98 }
99