blob: d3d7c68d09924123ed683c9048d1518862cf2059 [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
Bernardo Rufino2d87f452018-06-22 11:47:49 +010019import android.app.backup.IBackupCallback;
Christopher Tate45281862010-03-05 15:46:30 -080020import android.app.backup.IBackupManager;
Christopher Tate22b87872009-05-04 16:41:53 -070021import android.os.ParcelFileDescriptor;
22
Christopher Tate487529a2009-04-29 14:03:25 -070023/**
24 * Interface presented by applications being asked to participate in the
Christopher Tate45281862010-03-05 15:46:30 -080025 * backup & restore mechanism. End user code will not typically implement
26 * this interface directly; they subclass BackupAgent instead.
Christopher Tate487529a2009-04-29 14:03:25 -070027 *
28 * {@hide}
Christopher Tate22b87872009-05-04 16:41:53 -070029 */
Christopher Tate44a27902010-01-27 17:15:49 -080030oneway interface IBackupAgent {
Christopher Tate487529a2009-04-29 14:03:25 -070031 /**
32 * Request that the app perform an incremental backup.
33 *
Christopher Tate22b87872009-05-04 16:41:53 -070034 * @param oldState Read-only file containing the description blob of the
Christopher Tate487529a2009-04-29 14:03:25 -070035 * app's data state as of the last backup operation's completion.
Christopher Tate22b87872009-05-04 16:41:53 -070036 * This file is empty or invalid when a full backup is being
37 * requested.
Christopher Tate487529a2009-04-29 14:03:25 -070038 *
Christopher Tate22b87872009-05-04 16:41:53 -070039 * @param data Read-write file, empty when onBackup() is called, that
Christopher Tate487529a2009-04-29 14:03:25 -070040 * is the data destination for this backup pass's incrementals.
41 *
Christopher Tate22b87872009-05-04 16:41:53 -070042 * @param newState Read-write file, empty when onBackup() is called,
Christopher Tate487529a2009-04-29 14:03:25 -070043 * where the new state blob is to be recorded.
Christopher Tate44a27902010-01-27 17:15:49 -080044 *
Shreyas Basargeb6e73c92017-01-31 20:13:43 +000045 * @param quota Quota reported by the transport for this backup operation (in bytes).
46 *
Christopher Tate44a27902010-01-27 17:15:49 -080047 * @param token Opaque token identifying this transaction. This must
48 * be echoed back to the backup service binder once the new
49 * data has been written to the data and newState files.
50 *
Bernardo Rufino74eee102018-08-29 16:01:49 +010051 * @param callbackBinder Binder on which to indicate operation completion.
Robert Berry39194c02018-01-11 13:50:56 +000052 *
53 * @param transportFlags Flags with additional information about the transport.
Christopher Tate487529a2009-04-29 14:03:25 -070054 */
Christopher Tate22b87872009-05-04 16:41:53 -070055 void doBackup(in ParcelFileDescriptor oldState,
56 in ParcelFileDescriptor data,
Christopher Tate44a27902010-01-27 17:15:49 -080057 in ParcelFileDescriptor newState,
Bernardo Rufino2d87f452018-06-22 11:47:49 +010058 long quotaBytes, IBackupCallback callbackBinder, int transportFlags);
Christopher Tate487529a2009-04-29 14:03:25 -070059
60 /**
61 * Restore an entire data snapshot to the application.
62 *
Christopher Tate22b87872009-05-04 16:41:53 -070063 * @param data Read-only file containing the full data snapshot of the
Christopher Tate487529a2009-04-29 14:03:25 -070064 * app's backup. This is to be a <i>replacement</i> of the app's
65 * current data, not to be merged into it.
66 *
Christopher Tate5cbbf562009-06-22 16:44:51 -070067 * @param appVersionCode The android:versionCode attribute of the application
68 * that created this data set. This can help the agent distinguish among
69 * various historical backup content possibilities.
70 *
Christopher Tate22b87872009-05-04 16:41:53 -070071 * @param newState Read-write file, empty when onRestore() is called,
Christopher Tate487529a2009-04-29 14:03:25 -070072 * that is to be written with the state description that holds after
73 * the restore has been completed.
Christopher Tate44a27902010-01-27 17:15:49 -080074 *
75 * @param token Opaque token identifying this transaction. This must
76 * be echoed back to the backup service binder once the agent is
77 * finished restoring the application based on the restore data
78 * contents.
79 *
80 * @param callbackBinder Binder on which to indicate operation completion,
81 * passed here as a convenience to the agent.
Christopher Tate487529a2009-04-29 14:03:25 -070082 */
Christopher Tateadfe8b82014-02-04 16:23:32 -080083 void doRestore(in ParcelFileDescriptor data,
Dianne Hackborn3accca02013-09-20 09:32:11 -070084 long appVersionCode, in ParcelFileDescriptor newState,
Christopher Tateadfe8b82014-02-04 16:23:32 -080085 int token, IBackupManager callbackBinder);
Christopher Tate75a99702011-05-18 16:28:19 -070086
87 /**
Christopher Tate79ec80d2011-06-24 14:58:49 -070088 * Perform a "full" backup to the given file descriptor. The output file is presumed
89 * to be a socket or other non-seekable, write-only data sink. When this method is
90 * called, the app should write all of its files to the output.
91 *
92 * @param data Write-only file to receive the backed-up file content stream.
93 * The data must be formatted correctly for the resulting archive to be
94 * legitimate, so that will be tightly controlled by the available API.
95 *
Shreyas Basargeb6e73c92017-01-31 20:13:43 +000096 * @param quota Quota reported by the transport for this backup operation (in bytes).
97 *
Christopher Tate79ec80d2011-06-24 14:58:49 -070098 * @param token Opaque token identifying this transaction. This must
99 * be echoed back to the backup service binder once the agent is
100 * finished restoring the application based on the restore data
101 * contents.
102 *
103 * @param callbackBinder Binder on which to indicate operation completion,
104 * passed here as a convenience to the agent.
Robert Berry39194c02018-01-11 13:50:56 +0000105 *
106 * @param transportFlags Flags with additional information about transport.
Christopher Tate79ec80d2011-06-24 14:58:49 -0700107 */
Robert Berry39194c02018-01-11 13:50:56 +0000108 void doFullBackup(in ParcelFileDescriptor data, long quotaBytes, int token,
109 IBackupManager callbackBinder, int transportFlags);
Christopher Tate79ec80d2011-06-24 14:58:49 -0700110
111 /**
Christopher Tate11ae7682015-03-24 18:48:10 -0700112 * Estimate how much data a full backup will deliver
113 */
Robert Berry39194c02018-01-11 13:50:56 +0000114 void doMeasureFullBackup(long quotaBytes, int token, IBackupManager callbackBinder,
115 int transportFlags);
Christopher Tate11ae7682015-03-24 18:48:10 -0700116
117 /**
Sergey Poromov872d3b62016-01-12 15:48:08 +0100118 * Tells the application agent that the backup data size exceeded current transport quota.
119 * Later calls to {@link #onBackup(ParcelFileDescriptor, BackupDataOutput, ParcelFileDescriptor)}
120 * and {@link #onFullBackup(FullBackupDataOutput)} could use this information
121 * to reduce backup size under the limit.
122 * However, the quota can change, so do not assume that the value passed in here is absolute,
123 * similarly all subsequent backups should not be restricted to this size.
124 * This callback will be invoked before data has been put onto the wire in a preflight check,
125 * so it is relatively inexpensive to hit your quota.
126 * Apps that hit quota repeatedly without dealing with it can be subject to having their backup
127 * schedule reduced.
128 * The {@code quotaBytes} is a loose guideline b/c of metadata added by the backupmanager
129 * so apps should be more aggressive in trimming their backup set.
130 *
131 * @param backupDataBytes Expected or already processed amount of data.
132 * Could be less than total backup size if backup process was interrupted
133 * before finish of processing all backup data.
134 * @param quotaBytes Current amount of backup data that is allowed for the app.
Bernardo Rufino74eee102018-08-29 16:01:49 +0100135 * @param callbackBinder Binder on which to indicate operation completion.
Sergey Poromov872d3b62016-01-12 15:48:08 +0100136 */
Bernardo Rufino74eee102018-08-29 16:01:49 +0100137 void doQuotaExceeded(long backupDataBytes, long quotaBytes, IBackupCallback callbackBinder);
Sergey Poromov872d3b62016-01-12 15:48:08 +0100138
139 /**
Christopher Tate75a99702011-05-18 16:28:19 -0700140 * Restore a single "file" to the application. The file was typically obtained from
141 * a full-backup dataset. The agent reads 'size' bytes of file content
142 * from the provided file descriptor.
143 *
144 * @param data Read-only pipe delivering the file content itself.
145 *
146 * @param size Size of the file being restored.
147 * @param type Type of file system entity, e.g. FullBackup.TYPE_DIRECTORY.
148 * @param domain Name of the file's semantic domain to which the 'path' argument is a
149 * relative path. e.g. FullBackup.DATABASE_TREE_TOKEN.
150 * @param path Relative path of the file within its semantic domain.
151 * @param mode Access mode of the file system entity, e.g. 0660.
152 * @param mtime Last modification time of the file system entity.
Christopher Tateadfe8b82014-02-04 16:23:32 -0800153 * @param token Opaque token identifying this transaction. This must
154 * be echoed back to the backup service binder once the agent is
155 * finished restoring the application based on the restore data
156 * contents.
157 * @param callbackBinder Binder on which to indicate operation completion,
158 * passed here as a convenience to the agent.
Christopher Tate75a99702011-05-18 16:28:19 -0700159 */
160 void doRestoreFile(in ParcelFileDescriptor data, long size,
161 int type, String domain, String path, long mode, long mtime,
162 int token, IBackupManager callbackBinder);
Christopher Tateadfe8b82014-02-04 16:23:32 -0800163
Christopher Tatecba59412014-04-01 10:38:29 -0700164 /**
Christopher Tate2e40d112014-07-15 12:37:38 -0700165 * Provide the app with a canonical "all data has been delivered" end-of-restore
166 * callback so that it can do any postprocessing of the restored data that might
167 * be appropriate. This is issued after both key/value and full data restore
168 * operations have completed.
169 *
170 * @param token Opaque token identifying this transaction. This must
171 * be echoed back to the backup service binder once the agent is
172 * finished restoring the application based on the restore data
173 * contents.
174 * @param callbackBinder Binder on which to indicate operation completion,
175 * passed here as a convenience to the agent.
176 */
177 void doRestoreFinished(int token, IBackupManager callbackBinder);
178
179 /**
Christopher Tatecba59412014-04-01 10:38:29 -0700180 * Out of band: instruct the agent to crash within the client process. This is used
181 * when the backup infrastructure detects a semantic error post-hoc and needs to
182 * pass the problem back to the app.
183 *
184 * @param message The message to be passed to the agent's application in an exception.
185 */
186 void fail(String message);
Christopher Tate487529a2009-04-29 14:03:25 -0700187}