18c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate/*
28c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * Copyright (C) 2009 The Android Open Source Project
38c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate *
48c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License");
58c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * you may not use this file except in compliance with the License.
68c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * You may obtain a copy of the License at
78c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate *
88c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate *      http://www.apache.org/licenses/LICENSE-2.0
98c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate *
108c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * Unless required by applicable law or agreed to in writing, software
118c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS,
128c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * See the License for the specific language governing permissions and
148c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * limitations under the License.
158c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate */
168c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
174528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tatepackage android.app.backup;
188c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
194528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.RestoreSet;
204528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.IRestoreObserver;
218c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
228c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate/**
238c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * Binder interface used by clients who wish to manage a restore operation.  Every
248c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * method in this interface requires the android.permission.BACKUP permission.
258c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate *
268c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate * {@hide}
278c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate */
288c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tateinterface IRestoreSession {
298c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate    /**
308c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * Ask the current transport what the available restore sets are.
318c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     *
322d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate     * @param observer This binder points to an object whose onRestoreSetsAvailable()
332d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate     *   method will be called to supply the results of the transport's lookup.
342d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate     * @return Zero on success; nonzero on error.  The observer will only receive a
352d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate     *   result callback if this method returned zero.
368c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     */
372d449afe3d075020bdd1115bcc15c9383cbce122Christopher Tate    int getAvailableRestoreSets(IRestoreObserver observer);
388c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
398c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate    /**
408c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * Restore the given set onto the device, replacing the current data of any app
418c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * contained in the restore set with the data previously backed up.
428c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     *
438472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
448472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     *
450e0b4ae5bc5c652c8339d71ed9667e1e37baaa03Christopher Tate     * @return Zero on success; nonzero on error.  The observer will only receive
460e0b4ae5bc5c652c8339d71ed9667e1e37baaa03Christopher Tate     *   progress callbacks if this method returned zero.
478c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
488c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     *   the restore set that should be used.
497d562ec393d54dd9ef387c49d1283243bfdbd2b1Christopher Tate     * @param observer If non-null, this binder points to an object that will receive
507d562ec393d54dd9ef387c49d1283243bfdbd2b1Christopher Tate     *   progress callbacks during the restore operation.
518c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     */
528472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate    int restoreAll(long token, IRestoreObserver observer);
538472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate
548472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate    /**
55284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * Restore select packages from the given set onto the device, replacing the
56284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * current data of any app contained in the set with the data previously
57284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * backed up.
58284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *
59284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
60284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *
61284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * @return Zero on success, nonzero on error. The observer will only receive
62284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *   progress callbacks if this method returned zero.
63284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
64284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *   the restore set that should be used.
65284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * @param observer If non-null, this binder points to an object that will receive
66284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *   progress callbacks during the restore operation.
67284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     * @param packages The set of packages for which to attempt a restore.  Regardless of
68284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *   the contents of the actual back-end dataset named by {@code token}, only
69284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     *   applications mentioned in this list will have their data restored.
70284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate     */
71284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate    int restoreSome(long token, IRestoreObserver observer, in String[] packages);
72284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate
73284f1bb4daf77f7e6b688c0936dd4a31ec2e7c74Christopher Tate    /**
748472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * Restore a single application from backup.  The data will be restored from the
758472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * current backup dataset if the given package has stored data there, or from
768472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * the dataset used during the last full device setup operation if the current
778472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * backup dataset has no matching data.  If no backup data exists for this package
788472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * in either source, a nonzero value will be returned.
798472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     *
808472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * @return Zero on success; nonzero on error.  The observer will only receive
818472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     *   progress callbacks if this method returned zero.
828472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * @param packageName The name of the package whose data to restore.  If this is
838472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     *   not the name of the caller's own package, then the android.permission.BACKUP
848472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     *   permission must be held.
858472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     * @param observer If non-null, this binder points to an object that will receive
868472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     *   progress callbacks during the restore operation.
878472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate     */
888472581aa32eee1368de379c2c079ea0a66baa3cChristopher Tate    int restorePackage(in String packageName, IRestoreObserver observer);
898c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
908c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate    /**
918c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * End this restore session.  After this method is called, the IRestoreSession binder
928c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * is no longer valid.
930e0b4ae5bc5c652c8339d71ed9667e1e37baaa03Christopher Tate     *
940e0b4ae5bc5c652c8339d71ed9667e1e37baaa03Christopher Tate     * <p><b>Note:</b> The caller <i>must</i> invoke this method to end the restore session,
950e0b4ae5bc5c652c8339d71ed9667e1e37baaa03Christopher Tate     *   even if {@link getAvailableRestoreSets} or {@link performRestore} failed.
968c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     */
978c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate    void endRestoreSession();
988c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate}
99