Delete a blob after the last lease of it is released.

Also, avoid deleting it if it was committed recently
to allow app that contributed it to acquire a lease.

Bug: 151378266
Test: atest --test-mapping apex/blobstore
Change-Id: I32f9bc0d0e9d74e7a07c279b5057f53ccb610673
This commit is contained in:
Sudheer Shanka
2020-03-15 23:31:37 -07:00
parent db74198593
commit c0fd5fa650
6 changed files with 144 additions and 59 deletions

View File

@@ -46,7 +46,7 @@ public class DummyBlobData {
byte[] mFileDigest;
long mExpiryTimeMs;
public DummyBlobData(Builder builder) {
private DummyBlobData(Builder builder) {
mRandom = new Random(builder.getRandomSeed());
mFile = new File(builder.getContext().getFilesDir(), builder.getFileName());
mFileSize = builder.getFileSize();

View File

@@ -124,7 +124,11 @@ public class Utils {
final BlobStoreManager blobStoreManager = (BlobStoreManager) context.getSystemService(
Context.BLOB_STORE_SERVICE);
blobStoreManager.releaseLease(blobHandle);
assertThat(blobStoreManager.getLeaseInfo(blobHandle)).isNull();
try {
assertThat(blobStoreManager.getLeaseInfo(blobHandle)).isNull();
} catch (SecurityException e) {
// Expected, ignore
}
}
private static void assertLeaseInfo(LeaseInfo leaseInfo, String packageName,