blob: 5deedd035d0b4b53915c29a388ad76465985bd36 [file] [log] [blame]
Christopher Tate79ec80d2011-06-24 14:58:49 -07001package android.app.backup;
2
3import android.os.ParcelFileDescriptor;
4
5/**
6 * Provides the interface through which a {@link BackupAgent} writes entire files
7 * to a full backup data set, via its {@link BackupAgent#onFullBackup(FullBackupDataOutput)}
8 * method.
9 */
10public class FullBackupDataOutput {
11 // Currently a name-scoping shim around BackupDataOutput
Christopher Tate11ae7682015-03-24 18:48:10 -070012 private final BackupDataOutput mData;
Christopher Tateee87b962017-04-26 17:07:27 -070013 private final long mQuota;
Christopher Tate11ae7682015-03-24 18:48:10 -070014 private long mSize;
15
Christopher Tateee87b962017-04-26 17:07:27 -070016 /**
17 * Returns the quota in bytes for the application's current backup operation. The
18 * value can vary for each operation.
19 *
20 * @see BackupDataOutput#getQuota()
21 */
22 public long getQuota() {
23 return mQuota;
24 }
25
Christopher Tate11ae7682015-03-24 18:48:10 -070026 /** @hide - used only in measure operation */
Christopher Tateee87b962017-04-26 17:07:27 -070027 public FullBackupDataOutput(long quota) {
Christopher Tate11ae7682015-03-24 18:48:10 -070028 mData = null;
Christopher Tateee87b962017-04-26 17:07:27 -070029 mQuota = quota;
Christopher Tate11ae7682015-03-24 18:48:10 -070030 mSize = 0;
31 }
Christopher Tate79ec80d2011-06-24 14:58:49 -070032
33 /** @hide */
Christopher Tateee87b962017-04-26 17:07:27 -070034 public FullBackupDataOutput(ParcelFileDescriptor fd, long quota) {
35 mData = new BackupDataOutput(fd.getFileDescriptor(), quota);
36 mQuota = quota;
37 }
38
39 /** @hide - used only internally to the backup manager service's stream construction */
Christopher Tate79ec80d2011-06-24 14:58:49 -070040 public FullBackupDataOutput(ParcelFileDescriptor fd) {
Christopher Tateee87b962017-04-26 17:07:27 -070041 this(fd, -1);
Christopher Tate79ec80d2011-06-24 14:58:49 -070042 }
43
44 /** @hide */
45 public BackupDataOutput getData() { return mData; }
Christopher Tate11ae7682015-03-24 18:48:10 -070046
47 /** @hide - used for measurement pass */
48 public void addSize(long size) {
49 if (size > 0) {
50 mSize += size;
51 }
52 }
53
54 /** @hide - used for measurement pass */
55 public long getSize() { return mSize; }
Christopher Tate79ec80d2011-06-24 14:58:49 -070056}