blob: 18f4283399415b867c2abbc9f915613d78547d74 [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;
Robert Berry39194c02018-01-11 13:50:56 +000014 private final int mTransportFlags;
Christopher Tate11ae7682015-03-24 18:48:10 -070015 private long mSize;
16
Christopher Tateee87b962017-04-26 17:07:27 -070017 /**
18 * Returns the quota in bytes for the application's current backup operation. The
19 * value can vary for each operation.
20 *
21 * @see BackupDataOutput#getQuota()
22 */
23 public long getQuota() {
24 return mQuota;
25 }
26
Robert Berry39194c02018-01-11 13:50:56 +000027 /**
28 * Returns flags with additional information about the backup transport. For supported flags see
29 * {@link android.app.backup.BackupAgent}
30 *
31 * @see BackupDataOutput#getTransportFlags()
32 */
33 public int getTransportFlags() {
34 return mTransportFlags;
35 }
36
Christopher Tate11ae7682015-03-24 18:48:10 -070037 /** @hide - used only in measure operation */
Christopher Tateee87b962017-04-26 17:07:27 -070038 public FullBackupDataOutput(long quota) {
Christopher Tate11ae7682015-03-24 18:48:10 -070039 mData = null;
Christopher Tateee87b962017-04-26 17:07:27 -070040 mQuota = quota;
Christopher Tate11ae7682015-03-24 18:48:10 -070041 mSize = 0;
Robert Berry39194c02018-01-11 13:50:56 +000042 mTransportFlags = 0;
43 }
44
45 /** @hide - used only in measure operation */
46 public FullBackupDataOutput(long quota, int transportFlags) {
47 mData = null;
48 mQuota = quota;
49 mSize = 0;
50 mTransportFlags = transportFlags;
Christopher Tate11ae7682015-03-24 18:48:10 -070051 }
Christopher Tate79ec80d2011-06-24 14:58:49 -070052
53 /** @hide */
Christopher Tateee87b962017-04-26 17:07:27 -070054 public FullBackupDataOutput(ParcelFileDescriptor fd, long quota) {
Robert Berry39194c02018-01-11 13:50:56 +000055 mData = new BackupDataOutput(fd.getFileDescriptor(), quota, 0);
Christopher Tateee87b962017-04-26 17:07:27 -070056 mQuota = quota;
Robert Berry39194c02018-01-11 13:50:56 +000057 mTransportFlags = 0;
58 }
59
60 /** @hide */
61 public FullBackupDataOutput(ParcelFileDescriptor fd, long quota, int transportFlags) {
62 mData = new BackupDataOutput(fd.getFileDescriptor(), quota, transportFlags);
63 mQuota = quota;
64 mTransportFlags = transportFlags;
Christopher Tateee87b962017-04-26 17:07:27 -070065 }
66
67 /** @hide - used only internally to the backup manager service's stream construction */
Christopher Tate79ec80d2011-06-24 14:58:49 -070068 public FullBackupDataOutput(ParcelFileDescriptor fd) {
Robert Berry39194c02018-01-11 13:50:56 +000069 this(fd, /*quota=*/ -1, /*transportFlags=*/ 0);
Christopher Tate79ec80d2011-06-24 14:58:49 -070070 }
71
72 /** @hide */
73 public BackupDataOutput getData() { return mData; }
Christopher Tate11ae7682015-03-24 18:48:10 -070074
75 /** @hide - used for measurement pass */
76 public void addSize(long size) {
77 if (size > 0) {
78 mSize += size;
79 }
80 }
81
82 /** @hide - used for measurement pass */
83 public long getSize() { return mSize; }
Christopher Tate79ec80d2011-06-24 14:58:49 -070084}