Home | History | Annotate | Download | only in backup
      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 long mSize;
     15 
     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 
     26     /** @hide - used only in measure operation */
     27     public FullBackupDataOutput(long quota) {
     28         mData = null;
     29         mQuota = quota;
     30         mSize = 0;
     31     }
     32 
     33     /** @hide */
     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 */
     40     public FullBackupDataOutput(ParcelFileDescriptor fd) {
     41         this(fd, -1);
     42     }
     43 
     44     /** @hide */
     45     public BackupDataOutput getData() { return mData; }
     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; }
     56 }
     57