Merge "Include size of the blobs in BlobInfo." into rvc-dev am: 312ed3383d am: 2457fddcf4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11744169 Change-Id: I74bed56088f7078f58fad3a564863908695bf725
This commit is contained in:
@@ -16,9 +16,13 @@
|
|||||||
|
|
||||||
package android.app.blob;
|
package android.app.blob;
|
||||||
|
|
||||||
|
import static android.text.format.Formatter.FLAG_IEC_UNITS;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.app.AppGlobals;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.text.format.Formatter;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -32,13 +36,15 @@ public final class BlobInfo implements Parcelable {
|
|||||||
private final long mId;
|
private final long mId;
|
||||||
private final long mExpiryTimeMs;
|
private final long mExpiryTimeMs;
|
||||||
private final CharSequence mLabel;
|
private final CharSequence mLabel;
|
||||||
|
private final long mSizeBytes;
|
||||||
private final List<LeaseInfo> mLeaseInfos;
|
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) {
|
List<LeaseInfo> leaseInfos) {
|
||||||
mId = id;
|
mId = id;
|
||||||
mExpiryTimeMs = expiryTimeMs;
|
mExpiryTimeMs = expiryTimeMs;
|
||||||
mLabel = label;
|
mLabel = label;
|
||||||
|
mSizeBytes = sizeBytes;
|
||||||
mLeaseInfos = leaseInfos;
|
mLeaseInfos = leaseInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +52,7 @@ public final class BlobInfo implements Parcelable {
|
|||||||
mId = in.readLong();
|
mId = in.readLong();
|
||||||
mExpiryTimeMs = in.readLong();
|
mExpiryTimeMs = in.readLong();
|
||||||
mLabel = in.readCharSequence();
|
mLabel = in.readCharSequence();
|
||||||
|
mSizeBytes = in.readLong();
|
||||||
mLeaseInfos = in.readArrayList(null /* classloader */);
|
mLeaseInfos = in.readArrayList(null /* classloader */);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +68,10 @@ public final class BlobInfo implements Parcelable {
|
|||||||
return mLabel;
|
return mLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getSizeBytes() {
|
||||||
|
return mSizeBytes;
|
||||||
|
}
|
||||||
|
|
||||||
public List<LeaseInfo> getLeases() {
|
public List<LeaseInfo> getLeases() {
|
||||||
return Collections.unmodifiableList(mLeaseInfos);
|
return Collections.unmodifiableList(mLeaseInfos);
|
||||||
}
|
}
|
||||||
@@ -70,6 +81,7 @@ public final class BlobInfo implements Parcelable {
|
|||||||
dest.writeLong(mId);
|
dest.writeLong(mId);
|
||||||
dest.writeLong(mExpiryTimeMs);
|
dest.writeLong(mExpiryTimeMs);
|
||||||
dest.writeCharSequence(mLabel);
|
dest.writeCharSequence(mLabel);
|
||||||
|
dest.writeLong(mSizeBytes);
|
||||||
dest.writeList(mLeaseInfos);
|
dest.writeList(mLeaseInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,10 +95,16 @@ public final class BlobInfo implements Parcelable {
|
|||||||
+ "id: " + mId + ","
|
+ "id: " + mId + ","
|
||||||
+ "expiryMs: " + mExpiryTimeMs + ","
|
+ "expiryMs: " + mExpiryTimeMs + ","
|
||||||
+ "label: " + mLabel + ","
|
+ "label: " + mLabel + ","
|
||||||
|
+ "size: " + formatBlobSize(mSizeBytes) + ","
|
||||||
+ "leases: " + LeaseInfo.toShortString(mLeaseInfos) + ","
|
+ "leases: " + LeaseInfo.toShortString(mLeaseInfos) + ","
|
||||||
+ "}";
|
+ "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String formatBlobSize(long sizeBytes) {
|
||||||
|
return Formatter.formatFileSize(AppGlobals.getInitialApplication(),
|
||||||
|
sizeBytes, FLAG_IEC_UNITS);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -482,7 +482,8 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
descriptionResId, leasee.description));
|
descriptionResId, leasee.description));
|
||||||
});
|
});
|
||||||
blobInfos.add(new BlobInfo(blobMetadata.getBlobId(),
|
blobInfos.add(new BlobInfo(blobMetadata.getBlobId(),
|
||||||
blobHandle.getExpiryTimeMillis(), blobHandle.getLabel(), leaseInfos));
|
blobHandle.getExpiryTimeMillis(), blobHandle.getLabel(),
|
||||||
|
blobMetadata.getSize(), leaseInfos));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return blobInfos;
|
return blobInfos;
|
||||||
|
|||||||
Reference in New Issue
Block a user