File: FullBackupDataOutput.java

package info (click to toggle)
android-platform-frameworks-base 1%3A10.0.0%2Br36-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 321,788 kB
  • sloc: java: 962,234; cpp: 274,314; xml: 242,770; python: 5,060; sh: 1,432; ansic: 494; makefile: 47; sed: 19
file content (89 lines) | stat: -rw-r--r-- 2,633 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package android.app.backup;

import android.annotation.UnsupportedAppUsage;
import android.os.ParcelFileDescriptor;

/**
 * Provides the interface through which a {@link BackupAgent} writes entire files
 * to a full backup data set, via its {@link BackupAgent#onFullBackup(FullBackupDataOutput)}
 * method.
 */
public class FullBackupDataOutput {
    // Currently a name-scoping shim around BackupDataOutput
    @UnsupportedAppUsage
    private final BackupDataOutput mData;
    private final long mQuota;
    private final int mTransportFlags;
    private long mSize;

    /**
     * Returns the quota in bytes for the application's current backup operation.  The
     * value can vary for each operation.
     *
     * @see BackupDataOutput#getQuota()
     */
    public long getQuota() {
        return mQuota;
    }

    /**
     * Returns flags with additional information about the backup transport. For supported flags see
     * {@link android.app.backup.BackupAgent}
     *
     * @see BackupDataOutput#getTransportFlags()
     */
    public int getTransportFlags() {
        return mTransportFlags;
    }

    /** @hide - used only in measure operation */
    public FullBackupDataOutput(long quota) {
        mData = null;
        mQuota = quota;
        mSize = 0;
        mTransportFlags = 0;
    }

    /** @hide - used only in measure operation */
    public FullBackupDataOutput(long quota, int transportFlags) {
        mData = null;
        mQuota = quota;
        mSize = 0;
        mTransportFlags = transportFlags;
    }

    /** @hide */
    public FullBackupDataOutput(ParcelFileDescriptor fd, long quota) {
        mData = new BackupDataOutput(fd.getFileDescriptor(), quota, 0);
        mQuota = quota;
        mTransportFlags = 0;
    }

    /** @hide */
    public FullBackupDataOutput(ParcelFileDescriptor fd, long quota, int transportFlags) {
        mData = new BackupDataOutput(fd.getFileDescriptor(), quota, transportFlags);
        mQuota = quota;
        mTransportFlags = transportFlags;
    }

    /** @hide - used only internally to the backup manager service's stream construction */
    @UnsupportedAppUsage
    public FullBackupDataOutput(ParcelFileDescriptor fd) {
        this(fd, /*quota=*/ -1, /*transportFlags=*/ 0);
    }

    /** @hide */
    @UnsupportedAppUsage
    public BackupDataOutput getData() { return mData; }

    /** @hide - used for measurement pass */
    @UnsupportedAppUsage
    public void addSize(long size) {
        if (size > 0) {
            mSize += size;
        }
    }

    /** @hide - used for measurement pass */
    public long getSize() { return mSize; }
}