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

Commit 16aece03 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Automerger Merge Worker
Browse files

Merge "Restore existing committer info correctly when a new commit fails."...

Merge "Restore existing committer info correctly when a new commit fails." into rvc-dev am: 60606304

Change-Id: If651d718af54b57e34c30926bc152cbd5e1a7e04
parents 659a027e 60606304
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ class BlobMetadata {
        return mUserId;
    }

    void addCommitter(@NonNull Committer committer) {
    void addOrReplaceCommitter(@NonNull Committer committer) {
        synchronized (mMetadataLock) {
            // We need to override the committer data, so first remove any existing
            // committer before adding the new one.
@@ -139,6 +139,12 @@ class BlobMetadata {
        }
    }

    void removeCommitter(@NonNull Committer committer) {
        synchronized (mMetadataLock) {
            mCommitters.remove(committer);
        }
    }

    void removeInvalidCommitters(SparseArray<String> packages) {
        synchronized (mMetadataLock) {
            mCommitters.removeIf(committer ->
@@ -154,7 +160,7 @@ class BlobMetadata {
        }
    }

    void addLeasee(String callingPackage, int callingUid, int descriptionResId,
    void addOrReplaceLeasee(String callingPackage, int callingUid, int descriptionResId,
            CharSequence description, long leaseExpiryTimeMillis) {
        synchronized (mMetadataLock) {
            // We need to override the leasee data, so first remove any existing
+7 −3
Original line number Diff line number Diff line
@@ -401,7 +401,7 @@ public class BlobStoreManagerService extends SystemService {
                throw new LimitExceededException("Total amount of data with an active lease"
                        + " is exceeding the max limit");
            }
            blobMetadata.addLeasee(callingPackage, callingUid,
            blobMetadata.addOrReplaceLeasee(callingPackage, callingUid,
                    descriptionResId, description, leaseExpiryTimeMillis);
            if (LOGV) {
                Slog.v(TAG, "Acquired lease on " + blobHandle
@@ -573,12 +573,16 @@ public class BlobStoreManagerService extends SystemService {
                    final Committer newCommitter = new Committer(session.getOwnerPackageName(),
                            session.getOwnerUid(), session.getBlobAccessMode());
                    final Committer existingCommitter = blob.getExistingCommitter(newCommitter);
                    blob.addCommitter(newCommitter);
                    blob.addOrReplaceCommitter(newCommitter);
                    try {
                        writeBlobsInfoLocked();
                        session.sendCommitCallbackResult(COMMIT_RESULT_SUCCESS);
                    } catch (Exception e) {
                        blob.addCommitter(existingCommitter);
                        if (existingCommitter == null) {
                            blob.removeCommitter(newCommitter);
                        } else {
                            blob.addOrReplaceCommitter(existingCommitter);
                        }
                        session.sendCommitCallbackResult(COMMIT_RESULT_ERROR);
                    }
                    getUserSessionsLocked(UserHandle.getUserId(session.getOwnerUid()))