Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6feb5cdf authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Automerger Merge Worker
Browse files

Merge "Don't attribute a blob to a user if there are leasees from other...

Merge "Don't attribute a blob to a user if there are leasees from other users." into sc-dev am: 08ad40f2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14796666

Change-Id: Ibd678c29934ff7de8d6cb11d8ba9996b0a845d6d
parents 587acbbc 08ad40f2
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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)) {
+3 −2
Original line number Diff line number Diff line
@@ -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 -> {
                if (blobMetadata.shouldAttributeToUser(userHandle.getIdentifier())) {
                    blobsDataSize.getAndAdd(blobMetadata.getSize());
                }
            });

            stats.dataSize += blobsDataSize.get();