summaryrefslogtreecommitdiff
path: root/tests/BlobStoreTestUtils/src
diff options
context:
space:
mode:
authorSudheer Shanka <sudheersai@google.com>2020-03-15 23:31:37 -0700
committerSudheer Shanka <sudheersai@google.com>2020-03-18 20:56:29 -0700
commitc0fd5fa650ea79cb473f922328446b42d95a7c2f (patch)
tree33eaa766bb3cba513a495ae43b96df33634e293f /tests/BlobStoreTestUtils/src
parentdb74198593842290281605191685084ddf58841f (diff)
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
Diffstat (limited to 'tests/BlobStoreTestUtils/src')
-rw-r--r--tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java2
-rw-r--r--tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java6
2 files changed, 6 insertions, 2 deletions
diff --git a/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java b/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java
index b805744a8387..42908bef6178 100644
--- a/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java
+++ b/tests/BlobStoreTestUtils/src/com/android/utils/blob/DummyBlobData.java
@@ -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();
diff --git a/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java b/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java
index 654c1e21999d..482b23f129fd 100644
--- a/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java
+++ b/tests/BlobStoreTestUtils/src/com/android/utils/blob/Utils.java
@@ -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,