Don't attribute a blob to a user if there are leasees from other users.
Bug: 187460239 Test: atest --test-mapping apex/blobstore Change-Id: I5e9c0473e4c058d430ed012a3ca3ee63f3595821
This commit is contained in:
@@ -403,6 +403,19 @@ class BlobMetadata {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean shouldAttributeToUser(int userId) {
|
||||
synchronized (mMetadataLock) {
|
||||
for (int i = 0, size = mLeasees.size(); i < size; ++i) {
|
||||
final Leasee leasee = mLeasees.valueAt(i);
|
||||
// Don't attribute the blob to userId if there is a lease on it from another user.
|
||||
if (userId != UserHandle.getUserId(leasee.uid)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean shouldAttributeToLeasee(@NonNull String packageName, int userId,
|
||||
boolean callerHasStatsPermission) {
|
||||
if (!isALeaseeInUser(packageName, INVALID_UID, userId)) {
|
||||
|
||||
@@ -1333,9 +1333,10 @@ public class BlobStoreManagerService extends SystemService {
|
||||
blobsDataSize.getAndAdd(session.getSize());
|
||||
}, userHandle.getIdentifier());
|
||||
|
||||
// TODO(http://b/187460239): Update this to only include blobs available to userId.
|
||||
forEachBlob(blobMetadata -> {
|
||||
blobsDataSize.getAndAdd(blobMetadata.getSize());
|
||||
if (blobMetadata.shouldAttributeToUser(userHandle.getIdentifier())) {
|
||||
blobsDataSize.getAndAdd(blobMetadata.getSize());
|
||||
}
|
||||
});
|
||||
|
||||
stats.dataSize += blobsDataSize.get();
|
||||
|
||||
Reference in New Issue
Block a user