1487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate/*
2487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * Copyright (C) 2009 The Android Open Source Project
3487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate *
4487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License");
5487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * you may not use this file except in compliance with the License.
6487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * You may obtain a copy of the License at
7487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate *
8487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate *      http://www.apache.org/licenses/LICENSE-2.0
9487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate *
10487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * Unless required by applicable law or agreed to in writing, software
11487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS,
12487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * See the License for the specific language governing permissions and
14487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * limitations under the License.
15487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate */
16487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate
174528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tatepackage android.app.backup;
18487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate
194a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.app.backup.IFullBackupRestoreObserver;
204528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tateimport android.app.backup.IRestoreSession;
214a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tateimport android.os.ParcelFileDescriptor;
22f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tateimport android.content.Intent;
238c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
24487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate/**
25487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * Direct interface to the Backup Manager Service that applications invoke on.  The only
26487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * operation currently needed is a simple notification that the app has made changes to
27487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate * data it wishes to back up, so the system should run a backup pass.
28487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate *
294528186e0d65fc68ef0dd1941aa2ac8aefcd55a3Christopher Tate * Apps will use the {@link android.app.backup.BackupManager} class rather than going through
30a8bf815c6153290b173f34b071dddb0a0034a115Christopher Tate * this Binder interface directly.
31a8bf815c6153290b173f34b071dddb0a0034a115Christopher Tate *
32a8bf815c6153290b173f34b071dddb0a0034a115Christopher Tate * {@hide}
33487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate */
34487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tateinterface IBackupManager {
35487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate    /**
36487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate     * Tell the system service that the caller has made changes to its
3746758123868d91e7b186aebb27c4c4988dede43eChristopher Tate     * data, and therefore needs to undergo an incremental backup pass.
38ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     *
39ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * Any application can invoke this method for its own package, but
40ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * only callers who hold the android.permission.BACKUP permission
41ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * may invoke it for arbitrary packages.
42487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate     */
435cbbf5652a78902ac3382dc4a3583bc5b0351027Christopher Tate    void dataChanged(String packageName);
44ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate
45ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate    /**
46ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * Erase all backed-up data for the given package from the storage
47ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * destination.
48ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     *
49ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * Any application can invoke this method for its own package, but
50ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * only callers who hold the android.permission.BACKUP permission
51ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     * may invoke it for arbitrary packages.
52ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate     */
53ee0e78af5af3bf23dd928fe5e0ebeb39157eaf66Christopher Tate    void clearBackupData(String packageName);
5446758123868d91e7b186aebb27c4c4988dede43eChristopher Tate
5546758123868d91e7b186aebb27c4c4988dede43eChristopher Tate    /**
56181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate     * Notifies the Backup Manager Service that an agent has become available.  This
57181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate     * method is only invoked by the Activity Manager.
58181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate     */
595cbbf5652a78902ac3382dc4a3583bc5b0351027Christopher Tate    void agentConnected(String packageName, IBinder agent);
60181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate
61181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate    /**
62181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate     * Notify the Backup Manager Service that an agent has unexpectedly gone away.
63181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate     * This method is only invoked by the Activity Manager.
64181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate     */
655cbbf5652a78902ac3382dc4a3583bc5b0351027Christopher Tate    void agentDisconnected(String packageName);
66181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate
67181fafaf48208978b8ba2022683ffa78aaeddde1Christopher Tate    /**
681bb6906c7a903ee6427c8ff37bdc5896c386ff73Christopher Tate     * Notify the Backup Manager Service that an application being installed will
691bb6906c7a903ee6427c8ff37bdc5896c386ff73Christopher Tate     * need a data-restore pass.  This method is only invoked by the Package Manager.
701bb6906c7a903ee6427c8ff37bdc5896c386ff73Christopher Tate     */
711bb6906c7a903ee6427c8ff37bdc5896c386ff73Christopher Tate    void restoreAtInstall(String packageName, int token);
721bb6906c7a903ee6427c8ff37bdc5896c386ff73Christopher Tate
731bb6906c7a903ee6427c8ff37bdc5896c386ff73Christopher Tate    /**
746ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * Enable/disable the backup service entirely.  When disabled, no backup
756ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * or restore operations will take place.  Data-changed notifications will
766ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * still be observed and collected, however, so that changes made while the
776ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * mechanism was disabled will still be backed up properly if it is enabled
786ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * at some point in the future.
796ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     *
806ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
816ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     */
826ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate    void setBackupEnabled(boolean isEnabled);
836ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate
846ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate    /**
85cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * Enable/disable automatic restore of application data at install time.  When
86cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * enabled, installation of any package will involve the Backup Manager.  If data
87cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * exists for the newly-installed package, either from the device's current [enabled]
88cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * backup dataset or from the restore set used in the last wholesale restore operation,
89cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * that data will be supplied to the new package's restore agent before the package
90cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * is made generally available for launch.
91cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     *
92cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * <p>Callers must hold  the android.permission.BACKUP permission to use this method.
93cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     *
94cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     * @param doAutoRestore When true, enables the automatic app-data restore facility.  When
95cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     *   false, this facility will be disabled.
96cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate     */
97cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate    void setAutoRestore(boolean doAutoRestore);
98cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate
99cce9da5dc3d515f98c260af41a03e61e57b4e7a6Christopher Tate    /**
1008031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate     * Indicate that any necessary one-time provisioning has occurred.
1018031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate     *
1028031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
1038031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate     */
1048031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate    void setBackupProvisioned(boolean isProvisioned);
1058031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate
1068031a3df2fd0c38d85eeae39c1ea2c83e813f4ffChristopher Tate    /**
1076ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * Report whether the backup mechanism is currently enabled.
1086ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     *
1096ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
1106ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate     */
1116ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate    boolean isBackupEnabled();
1126ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate
1136ef58a1509b9d3348a33ca5686917796c2759aa5Christopher Tate    /**
1142efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * Set the device's backup password.  Returns {@code true} if the password was set
1152efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * successfully, {@code false} otherwise.  Typically a failure means that an incorrect
1162efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * current password was supplied.
1172efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     *
1182efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
1192efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     */
1202efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate    boolean setBackupPassword(in String currentPw, in String newPw);
1212efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate
1222efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate    /**
1232efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * Reports whether a backup password is currently set.  If not, then a null or empty
1242efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * "current password" argument should be passed to setBackupPassword().
1252efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     *
1262efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
1272efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     */
1282efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate    boolean hasBackupPassword();
1292efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate
1302efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate    /**
131ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * Schedule an immediate backup attempt for all pending updates.  This is
132ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * primarily intended for transports to use when they detect a suitable
133ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * opportunity for doing a backup pass.  If there are no pending updates to
134ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * be sent, no action will be taken.  Even if some updates are pending, the
135ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * transport will still be asked to confirm via the usual requestBackupTime()
136ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * method.
137ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     *
138ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
139ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     */
1405cbbf5652a78902ac3382dc4a3583bc5b0351027Christopher Tate    void backupNow();
141ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate
142ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate    /**
1434a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * Write a full backup of the given package to the supplied file descriptor.
1444a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * The fd may be a socket or other non-seekable destination.  If no package names
1454a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * are supplied, then every application on the device will be backed up to the output.
1464a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *
1474a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * <p>This method is <i>synchronous</i> -- it does not return until the backup has
1484a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * completed.
1494a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *
1504a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
1514a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *
1524a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * @param fd The file descriptor to which a 'tar' file stream is to be written
1534a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * @param includeApks If <code>true</code>, the resulting tar stream will include the
1544a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *     application .apk files themselves as well as their data.
1554a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * @param includeShared If <code>true</code>, the resulting tar stream will include
1564a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *     the contents of the device's shared storage (SD card or equivalent).
1574a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * @param allApps If <code>true</code>, the resulting tar stream will include all
1584a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *     installed applications' data, not just those named in the <code>packageNames</code>
1594a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *     parameter.
160240c7d2d1fb2944ee6a6f1dee41c7bbd766f8f0dChristopher Tate     * @param allIncludesSystem If {@code true}, then {@code allApps} will be interpreted
161240c7d2d1fb2944ee6a6f1dee41c7bbd766f8f0dChristopher Tate     *     as including packages pre-installed as part of the system. If {@code false},
162240c7d2d1fb2944ee6a6f1dee41c7bbd766f8f0dChristopher Tate     *     then setting {@code allApps} to {@code true} will mean only that all 3rd-party
163240c7d2d1fb2944ee6a6f1dee41c7bbd766f8f0dChristopher Tate     *     applications will be included in the dataset.
1644a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * @param packageNames The package names of the apps whose data (and optionally .apk files)
1654a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *     are to be backed up.  The <code>allApps</code> parameter supersedes this.
1664a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     */
1674a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate    void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeShared,
168240c7d2d1fb2944ee6a6f1dee41c7bbd766f8f0dChristopher Tate            boolean allApps, boolean allIncludesSystem, in String[] packageNames);
1694a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate
1704a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate    /**
17175a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate     * Restore device content from the data stream passed through the given socket.  The
17275a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate     * data stream must be in the format emitted by fullBackup().
17375a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate     *
17475a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
17575a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate     */
17675a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate    void fullRestore(in ParcelFileDescriptor fd);
17775a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate
17875a99709accef8cf221fd436d646727e7c8dd1f1Christopher Tate    /**
1794a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * Confirm that the requested full backup/restore operation can proceed.  The system will
1804a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * not actually perform the operation described to fullBackup() / fullRestore() unless the
1814a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * UI calls back into the Backup Manager to confirm, passing the correct token.  At
1824a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * the same time, the UI supplies a callback Binder for progress notifications during
1834a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * the operation.
1844a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     *
1852efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * <p>The password passed by the confirming entity must match the saved backup or
1862efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * full-device encryption password in order to perform a backup.  If a password is
1872efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * supplied for restore, it must match the password used when creating the full
1882efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     * backup dataset being used for restore.
1892efd2dbbac9eac89620683696c6076463c3a1cd6Christopher Tate     *
1904a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
1914a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate     */
192728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate    void acknowledgeFullBackupOrRestore(int token, boolean allow,
193728a1c4d5ed3b808172013a7f5bb5065d1e964f6Christopher Tate            in String curPassword, in String encryptionPassword,
1944a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate            IFullBackupRestoreObserver observer);
1954a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate
1964a627c71ff53a4fca1f961f4b1dcc0461df18a06Christopher Tate    /**
197ace7f094bf07bbd90cb998b9462e4f2d101a498cChristopher Tate     * Identify the currently selected transport.  Callers must hold the
198043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate     * android.permission.BACKUP permission to use this method.
19946758123868d91e7b186aebb27c4c4988dede43eChristopher Tate     */
2009171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate    String getCurrentTransport();
201043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate
202043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate    /**
2039171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     * Request a list of all available backup transports' names.  Callers must
2049171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     * hold the android.permission.BACKUP permission to use this method.
2059171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     */
2069171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate    String[] listAllTransports();
2079171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate
2089171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate    /**
2099171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     * Specify the current backup transport.  Callers must hold the
210043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate     * android.permission.BACKUP permission to use this method.
211043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate     *
2129171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     * @param transport The name of the transport to select.  This should be one
213043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate     * of {@link BackupManager.TRANSPORT_GOOGLE} or {@link BackupManager.TRANSPORT_ADB}.
2149171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     * @return The name of the previously selected transport.  If the given transport
2159171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     *   name is not one of the currently available transports, no change is made to
2169171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate     *   the current transport setting and the method returns null.
217043dadc7516d20c3b3ccbcb20c53aaeef076a237Christopher Tate     */
2189171749700853305f3e6abbcdbd9e02f3a71d459Christopher Tate    String selectBackupTransport(String transport);
2198c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate
2208c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate    /**
221f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * Get the configuration Intent, if any, from the given transport.  Callers must
222f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * hold the android.permission.BACKUP permission in order to use this method.
223f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     *
224f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * @param transport The name of the transport to query.
225f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * @return An Intent to use with Activity#startActivity() to bring up the configuration
226f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     *   UI supplied by the transport.  If the transport has no configuration UI, it should
227f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     *   return {@code null} here.
228f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     */
229f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate    Intent getConfigurationIntent(String transport);
230f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate
231f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate    /**
232f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * Get the destination string supplied by the given transport.  Callers must
233f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * hold the android.permission.BACKUP permission in order to use this method.
234f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     *
235f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * @param transport The name of the transport to query.
236f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     * @return A string describing the current backup destination.  This string is used
237f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     *   verbatim by the Settings UI as the summary text of the "configure..." item.
238f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate     */
239f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate    String getDestinationString(String transport);
240f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate
241f5e1c296370b45503a6c48bdb7da8b829bc0b906Christopher Tate    /**
24244ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * Begin a restore session.  Either or both of packageName and transportID
24344ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * may be null.  If packageName is non-null, then only the given package will be
24444ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * considered for restore.  If transportID is null, then the restore will use
24544ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * the current active transport.
24644ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * <p>
24744ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * This method requires the android.permission.BACKUP permission <i>except</i>
24844ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * when transportID is null and packageName is the name of the caller's own
24944ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * package.  In that case, the restore session returned is suitable for supporting
25044ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * the BackupManager.requestRestore() functionality via RestoreSession.restorePackage()
25144ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * without requiring the app to hold any special permission.
2528c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     *
25344ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * @param packageName The name of the single package for which a restore will
25444ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     *        be requested.  May be null, in which case all packages in the restore
25544ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     *        set can be restored.
25644ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     * @param transportID The name of the transport to use for the restore operation.
25744ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate     *        May be null, in which case the current active transport is used.
2588c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     * @return An interface to the restore session, or null on error.
2598c850b792f2d371fd8a4aff146d9d757ee982539Christopher Tate     */
26044ab8453e1c4c46790f792a46d026fa1017d8cfeChris Tate    IRestoreSession beginRestoreSession(String packageName, String transportID);
26144a2790374bf27116cbd91060d4f096ca5999709Christopher Tate
26244a2790374bf27116cbd91060d4f096ca5999709Christopher Tate    /**
26344a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     * Notify the backup manager that a BackupAgent has completed the operation
26444a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     * corresponding to the given token.
26544a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     *
26644a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     * @param token The transaction token passed to a BackupAgent's doBackup() or
26744a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     *        doRestore() method.
26844a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     * {@hide}
26944a2790374bf27116cbd91060d4f096ca5999709Christopher Tate     */
27044a2790374bf27116cbd91060d4f096ca5999709Christopher Tate    void opComplete(int token);
271487529a70cd1479ae8d6bbfb356be7e72542c185Christopher Tate}
272