Christopher Tate | 79ec80d | 2011-06-24 14:58:49 -0700 | [diff] [blame] | 1 | package android.app.backup; |
| 2 | |
| 3 | import 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 | */ |
| 10 | public class FullBackupDataOutput { |
| 11 | // Currently a name-scoping shim around BackupDataOutput |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 12 | private final BackupDataOutput mData; |
Christopher Tate | ee87b96 | 2017-04-26 17:07:27 -0700 | [diff] [blame] | 13 | private final long mQuota; |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 14 | private long mSize; |
| 15 | |
Christopher Tate | ee87b96 | 2017-04-26 17:07:27 -0700 | [diff] [blame] | 16 | /** |
| 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 Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 26 | /** @hide - used only in measure operation */ |
Christopher Tate | ee87b96 | 2017-04-26 17:07:27 -0700 | [diff] [blame] | 27 | public FullBackupDataOutput(long quota) { |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 28 | mData = null; |
Christopher Tate | ee87b96 | 2017-04-26 17:07:27 -0700 | [diff] [blame] | 29 | mQuota = quota; |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 30 | mSize = 0; |
| 31 | } |
Christopher Tate | 79ec80d | 2011-06-24 14:58:49 -0700 | [diff] [blame] | 32 | |
| 33 | /** @hide */ |
Christopher Tate | ee87b96 | 2017-04-26 17:07:27 -0700 | [diff] [blame] | 34 | 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 Tate | 79ec80d | 2011-06-24 14:58:49 -0700 | [diff] [blame] | 40 | public FullBackupDataOutput(ParcelFileDescriptor fd) { |
Christopher Tate | ee87b96 | 2017-04-26 17:07:27 -0700 | [diff] [blame] | 41 | this(fd, -1); |
Christopher Tate | 79ec80d | 2011-06-24 14:58:49 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | /** @hide */ |
| 45 | public BackupDataOutput getData() { return mData; } |
Christopher Tate | 11ae768 | 2015-03-24 18:48:10 -0700 | [diff] [blame] | 46 | |
| 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 Tate | 79ec80d | 2011-06-24 14:58:49 -0700 | [diff] [blame] | 56 | } |