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 12 private final BackupDataOutput mData; 13 private final long mQuota; 14 private final int mTransportFlags; 15 private long mSize; 16 17 /** 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 */ getQuota()23 public long getQuota() { 24 return mQuota; 25 } 26 27 /** 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 */ getTransportFlags()33 public int getTransportFlags() { 34 return mTransportFlags; 35 } 36 37 /** @hide - used only in measure operation */ FullBackupDataOutput(long quota)38 public FullBackupDataOutput(long quota) { 39 mData = null; 40 mQuota = quota; 41 mSize = 0; 42 mTransportFlags = 0; 43 } 44 45 /** @hide - used only in measure operation */ FullBackupDataOutput(long quota, int transportFlags)46 public FullBackupDataOutput(long quota, int transportFlags) { 47 mData = null; 48 mQuota = quota; 49 mSize = 0; 50 mTransportFlags = transportFlags; 51 } 52 53 /** @hide */ FullBackupDataOutput(ParcelFileDescriptor fd, long quota)54 public FullBackupDataOutput(ParcelFileDescriptor fd, long quota) { 55 mData = new BackupDataOutput(fd.getFileDescriptor(), quota, 0); 56 mQuota = quota; 57 mTransportFlags = 0; 58 } 59 60 /** @hide */ FullBackupDataOutput(ParcelFileDescriptor fd, long quota, int transportFlags)61 public FullBackupDataOutput(ParcelFileDescriptor fd, long quota, int transportFlags) { 62 mData = new BackupDataOutput(fd.getFileDescriptor(), quota, transportFlags); 63 mQuota = quota; 64 mTransportFlags = transportFlags; 65 } 66 67 /** @hide - used only internally to the backup manager service's stream construction */ FullBackupDataOutput(ParcelFileDescriptor fd)68 public FullBackupDataOutput(ParcelFileDescriptor fd) { 69 this(fd, /*quota=*/ -1, /*transportFlags=*/ 0); 70 } 71 72 /** @hide */ getData()73 public BackupDataOutput getData() { return mData; } 74 75 /** @hide - used for measurement pass */ addSize(long size)76 public void addSize(long size) { 77 if (size > 0) { 78 mSize += size; 79 } 80 } 81 82 /** @hide - used for measurement pass */ getSize()83 public long getSize() { return mSize; } 84 } 85