blob: 4a85efd9e4c2a8678df0cb7a6785f0a16ce8ef59 [file] [log] [blame]
Christopher Tate487529a2009-04-29 14:03:25 -07001/*
2 * Copyright 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
Christopher Tate181fafa2009-05-14 11:12:14 -070017package android.app;
Christopher Tate487529a2009-04-29 14:03:25 -070018
Christopher Tate45281862010-03-05 15:46:30 -080019import android.app.backup.IBackupManager;
Christopher Tate22b87872009-05-04 16:41:53 -070020import android.os.ParcelFileDescriptor;
21
Christopher Tate487529a2009-04-29 14:03:25 -070022/**
23 * Interface presented by applications being asked to participate in the
Christopher Tate45281862010-03-05 15:46:30 -080024 * backup & restore mechanism. End user code will not typically implement
25 * this interface directly; they subclass BackupAgent instead.
Christopher Tate487529a2009-04-29 14:03:25 -070026 *
27 * {@hide}
Christopher Tate22b87872009-05-04 16:41:53 -070028 */
Christopher Tate44a27902010-01-27 17:15:49 -080029oneway interface IBackupAgent {
Christopher Tate487529a2009-04-29 14:03:25 -070030 /**
31 * Request that the app perform an incremental backup.
32 *
Christopher Tate22b87872009-05-04 16:41:53 -070033 * @param oldState Read-only file containing the description blob of the
Christopher Tate487529a2009-04-29 14:03:25 -070034 * app's data state as of the last backup operation's completion.
Christopher Tate22b87872009-05-04 16:41:53 -070035 * This file is empty or invalid when a full backup is being
36 * requested.
Christopher Tate487529a2009-04-29 14:03:25 -070037 *
Christopher Tate22b87872009-05-04 16:41:53 -070038 * @param data Read-write file, empty when onBackup() is called, that
Christopher Tate487529a2009-04-29 14:03:25 -070039 * is the data destination for this backup pass's incrementals.
40 *
Christopher Tate22b87872009-05-04 16:41:53 -070041 * @param newState Read-write file, empty when onBackup() is called,
Christopher Tate487529a2009-04-29 14:03:25 -070042 * where the new state blob is to be recorded.
Christopher Tate44a27902010-01-27 17:15:49 -080043 *
Shreyas Basargeb6e73c92017-01-31 20:13:43 +000044 * @param quota Quota reported by the transport for this backup operation (in bytes).
45 *
Christopher Tate44a27902010-01-27 17:15:49 -080046 * @param token Opaque token identifying this transaction. This must
47 * be echoed back to the backup service binder once the new
48 * data has been written to the data and newState files.
49 *
50 * @param callbackBinder Binder on which to indicate operation completion,
51 * passed here as a convenience to the agent.
Christopher Tate487529a2009-04-29 14:03:25 -070052 */
Christopher Tate22b87872009-05-04 16:41:53 -070053 void doBackup(in ParcelFileDescriptor oldState,
54 in ParcelFileDescriptor data,
Christopher Tate44a27902010-01-27 17:15:49 -080055 in ParcelFileDescriptor newState,
Shreyas Basargeb6e73c92017-01-31 20:13:43 +000056 long quotaBytes, int token, IBackupManager callbackBinder);
Christopher Tate487529a2009-04-29 14:03:25 -070057
58 /**
59 * Restore an entire data snapshot to the application.
60 *
Christopher Tate22b87872009-05-04 16:41:53 -070061 * @param data Read-only file containing the full data snapshot of the
Christopher Tate487529a2009-04-29 14:03:25 -070062 * app's backup. This is to be a <i>replacement</i> of the app's
63 * current data, not to be merged into it.
64 *
Christopher Tate5cbbf562009-06-22 16:44:51 -070065 * @param appVersionCode The android:versionCode attribute of the application
66 * that created this data set. This can help the agent distinguish among
67 * various historical backup content possibilities.
68 *
Christopher Tate22b87872009-05-04 16:41:53 -070069 * @param newState Read-write file, empty when onRestore() is called,
Christopher Tate487529a2009-04-29 14:03:25 -070070 * that is to be written with the state description that holds after
71 * the restore has been completed.
Christopher Tate44a27902010-01-27 17:15:49 -080072 *
73 * @param token Opaque token identifying this transaction. This must
74 * be echoed back to the backup service binder once the agent is
75 * finished restoring the application based on the restore data
76 * contents.
77 *
78 * @param callbackBinder Binder on which to indicate operation completion,
79 * passed here as a convenience to the agent.
Christopher Tate487529a2009-04-29 14:03:25 -070080 */
Christopher Tateadfe8b82014-02-04 16:23:32 -080081 void doRestore(in ParcelFileDescriptor data,
Dianne Hackborn3accca02013-09-20 09:32:11 -070082 long appVersionCode, in ParcelFileDescriptor newState,
Christopher Tateadfe8b82014-02-04 16:23:32 -080083 int token, IBackupManager callbackBinder);
Christopher Tate75a99702011-05-18 16:28:19 -070084
85 /**
Christopher Tate79ec80d2011-06-24 14:58:49 -070086 * Perform a "full" backup to the given file descriptor. The output file is presumed
87 * to be a socket or other non-seekable, write-only data sink. When this method is
88 * called, the app should write all of its files to the output.
89 *
90 * @param data Write-only file to receive the backed-up file content stream.
91 * The data must be formatted correctly for the resulting archive to be
92 * legitimate, so that will be tightly controlled by the available API.
93 *
Shreyas Basargeb6e73c92017-01-31 20:13:43 +000094 * @param quota Quota reported by the transport for this backup operation (in bytes).
95 *
Christopher Tate79ec80d2011-06-24 14:58:49 -070096 * @param token Opaque token identifying this transaction. This must
97 * be echoed back to the backup service binder once the agent is
98 * finished restoring the application based on the restore data
99 * contents.
100 *
101 * @param callbackBinder Binder on which to indicate operation completion,
102 * passed here as a convenience to the agent.
103 */
Shreyas Basargeb6e73c92017-01-31 20:13:43 +0000104 void doFullBackup(in ParcelFileDescriptor data, long quotaBytes, int token, IBackupManager callbackBinder);
Christopher Tate79ec80d2011-06-24 14:58:49 -0700105
106 /**
Christopher Tate11ae7682015-03-24 18:48:10 -0700107 * Estimate how much data a full backup will deliver
108 */
Shreyas Basargeb6e73c92017-01-31 20:13:43 +0000109 void doMeasureFullBackup(long quotaBytes, int token, IBackupManager callbackBinder);
Christopher Tate11ae7682015-03-24 18:48:10 -0700110
111 /**
Sergey Poromov872d3b62016-01-12 15:48:08 +0100112 * Tells the application agent that the backup data size exceeded current transport quota.
113 * Later calls to {@link #onBackup(ParcelFileDescriptor, BackupDataOutput, ParcelFileDescriptor)}
114 * and {@link #onFullBackup(FullBackupDataOutput)} could use this information
115 * to reduce backup size under the limit.
116 * However, the quota can change, so do not assume that the value passed in here is absolute,
117 * similarly all subsequent backups should not be restricted to this size.
118 * This callback will be invoked before data has been put onto the wire in a preflight check,
119 * so it is relatively inexpensive to hit your quota.
120 * Apps that hit quota repeatedly without dealing with it can be subject to having their backup
121 * schedule reduced.
122 * The {@code quotaBytes} is a loose guideline b/c of metadata added by the backupmanager
123 * so apps should be more aggressive in trimming their backup set.
124 *
125 * @param backupDataBytes Expected or already processed amount of data.
126 * Could be less than total backup size if backup process was interrupted
127 * before finish of processing all backup data.
128 * @param quotaBytes Current amount of backup data that is allowed for the app.
129 */
130 void doQuotaExceeded(long backupDataBytes, long quotaBytes);
131
132 /**
Christopher Tate75a99702011-05-18 16:28:19 -0700133 * Restore a single "file" to the application. The file was typically obtained from
134 * a full-backup dataset. The agent reads 'size' bytes of file content
135 * from the provided file descriptor.
136 *
137 * @param data Read-only pipe delivering the file content itself.
138 *
139 * @param size Size of the file being restored.
140 * @param type Type of file system entity, e.g. FullBackup.TYPE_DIRECTORY.
141 * @param domain Name of the file's semantic domain to which the 'path' argument is a
142 * relative path. e.g. FullBackup.DATABASE_TREE_TOKEN.
143 * @param path Relative path of the file within its semantic domain.
144 * @param mode Access mode of the file system entity, e.g. 0660.
145 * @param mtime Last modification time of the file system entity.
Christopher Tateadfe8b82014-02-04 16:23:32 -0800146 * @param token Opaque token identifying this transaction. This must
147 * be echoed back to the backup service binder once the agent is
148 * finished restoring the application based on the restore data
149 * contents.
150 * @param callbackBinder Binder on which to indicate operation completion,
151 * passed here as a convenience to the agent.
Christopher Tate75a99702011-05-18 16:28:19 -0700152 */
153 void doRestoreFile(in ParcelFileDescriptor data, long size,
154 int type, String domain, String path, long mode, long mtime,
155 int token, IBackupManager callbackBinder);
Christopher Tateadfe8b82014-02-04 16:23:32 -0800156
Christopher Tatecba59412014-04-01 10:38:29 -0700157 /**
Christopher Tate2e40d112014-07-15 12:37:38 -0700158 * Provide the app with a canonical "all data has been delivered" end-of-restore
159 * callback so that it can do any postprocessing of the restored data that might
160 * be appropriate. This is issued after both key/value and full data restore
161 * operations have completed.
162 *
163 * @param token Opaque token identifying this transaction. This must
164 * be echoed back to the backup service binder once the agent is
165 * finished restoring the application based on the restore data
166 * contents.
167 * @param callbackBinder Binder on which to indicate operation completion,
168 * passed here as a convenience to the agent.
169 */
170 void doRestoreFinished(int token, IBackupManager callbackBinder);
171
172 /**
Christopher Tatecba59412014-04-01 10:38:29 -0700173 * Out of band: instruct the agent to crash within the client process. This is used
174 * when the backup infrastructure detects a semantic error post-hoc and needs to
175 * pass the problem back to the app.
176 *
177 * @param message The message to be passed to the agent's application in an exception.
178 */
179 void fail(String message);
Christopher Tate487529a2009-04-29 14:03:25 -0700180}