diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-06-09 06:36:19 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-06-09 06:36:19 +0000 |
commit | 312ed3383d6db157502d98a17b56e58c6b865307 (patch) | |
tree | d92c7a15486686d3cb8946a4ccc21011b785a964 /apex/blobstore/framework | |
parent | f2193638d7e1049559e933b73a57aec4aae77ac8 (diff) | |
parent | 6531079cfaf83ca8d4dd27622a5ffb4a3af9d45f (diff) |
Merge "Include size of the blobs in BlobInfo." into rvc-dev
Diffstat (limited to 'apex/blobstore/framework')
-rw-r--r-- | apex/blobstore/framework/java/android/app/blob/BlobInfo.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/apex/blobstore/framework/java/android/app/blob/BlobInfo.java b/apex/blobstore/framework/java/android/app/blob/BlobInfo.java index 80062d5d245f..ba92d95b483e 100644 --- a/apex/blobstore/framework/java/android/app/blob/BlobInfo.java +++ b/apex/blobstore/framework/java/android/app/blob/BlobInfo.java @@ -16,9 +16,13 @@ package android.app.blob; +import static android.text.format.Formatter.FLAG_IEC_UNITS; + import android.annotation.NonNull; +import android.app.AppGlobals; import android.os.Parcel; import android.os.Parcelable; +import android.text.format.Formatter; import java.util.Collections; import java.util.List; @@ -32,13 +36,15 @@ public final class BlobInfo implements Parcelable { private final long mId; private final long mExpiryTimeMs; private final CharSequence mLabel; + private final long mSizeBytes; private final List<LeaseInfo> mLeaseInfos; - public BlobInfo(long id, long expiryTimeMs, CharSequence label, + public BlobInfo(long id, long expiryTimeMs, CharSequence label, long sizeBytes, List<LeaseInfo> leaseInfos) { mId = id; mExpiryTimeMs = expiryTimeMs; mLabel = label; + mSizeBytes = sizeBytes; mLeaseInfos = leaseInfos; } @@ -46,6 +52,7 @@ public final class BlobInfo implements Parcelable { mId = in.readLong(); mExpiryTimeMs = in.readLong(); mLabel = in.readCharSequence(); + mSizeBytes = in.readLong(); mLeaseInfos = in.readArrayList(null /* classloader */); } @@ -61,6 +68,10 @@ public final class BlobInfo implements Parcelable { return mLabel; } + public long getSizeBytes() { + return mSizeBytes; + } + public List<LeaseInfo> getLeases() { return Collections.unmodifiableList(mLeaseInfos); } @@ -70,6 +81,7 @@ public final class BlobInfo implements Parcelable { dest.writeLong(mId); dest.writeLong(mExpiryTimeMs); dest.writeCharSequence(mLabel); + dest.writeLong(mSizeBytes); dest.writeList(mLeaseInfos); } @@ -83,10 +95,16 @@ public final class BlobInfo implements Parcelable { + "id: " + mId + "," + "expiryMs: " + mExpiryTimeMs + "," + "label: " + mLabel + "," + + "size: " + formatBlobSize(mSizeBytes) + "," + "leases: " + LeaseInfo.toShortString(mLeaseInfos) + "," + "}"; } + private static String formatBlobSize(long sizeBytes) { + return Formatter.formatFileSize(AppGlobals.getInitialApplication(), + sizeBytes, FLAG_IEC_UNITS); + } + @Override public int describeContents() { return 0; |