Merge "Clear data from failed commits and recommits properly." into rvc-dev am: fc424b9a32 am: 5efe0a6c21
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11859962 Change-Id: I32d2d82e844b5a36dbf45fcd9bf161f354f88048
This commit is contained in:
@@ -227,7 +227,8 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
long sessionId;
|
long sessionId;
|
||||||
do {
|
do {
|
||||||
sessionId = Math.abs(mRandom.nextLong());
|
final long randomLong = mRandom.nextLong();
|
||||||
|
sessionId = (randomLong == Long.MIN_VALUE) ? INVALID_BLOB_ID : Math.abs(randomLong);
|
||||||
if (mKnownBlobIds.indexOf(sessionId) < 0 && sessionId != INVALID_BLOB_ID) {
|
if (mKnownBlobIds.indexOf(sessionId) < 0 && sessionId != INVALID_BLOB_ID) {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
@@ -647,6 +648,17 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
session.getOwnerUid(), blob.getBlobId(), blob.getSize(),
|
session.getOwnerUid(), blob.getBlobId(), blob.getSize(),
|
||||||
FrameworkStatsLog.BLOB_COMMITTED__RESULT__ERROR_DURING_COMMIT);
|
FrameworkStatsLog.BLOB_COMMITTED__RESULT__ERROR_DURING_COMMIT);
|
||||||
session.sendCommitCallbackResult(COMMIT_RESULT_ERROR);
|
session.sendCommitCallbackResult(COMMIT_RESULT_ERROR);
|
||||||
|
// If the commit fails and this blob data didn't exist before, delete it.
|
||||||
|
// But if it is a recommit, just leave it as is.
|
||||||
|
if (session.getSessionId() == blob.getBlobId()) {
|
||||||
|
deleteBlobLocked(blob);
|
||||||
|
userBlobs.remove(blob.getBlobHandle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Delete redundant data from recommits.
|
||||||
|
if (session.getSessionId() != blob.getBlobId()) {
|
||||||
|
session.getSessionFile().delete();
|
||||||
|
mActiveBlobIds.remove(session.getSessionId());
|
||||||
}
|
}
|
||||||
getUserSessionsLocked(UserHandle.getUserId(session.getOwnerUid()))
|
getUserSessionsLocked(UserHandle.getUserId(session.getOwnerUid()))
|
||||||
.remove(session.getSessionId());
|
.remove(session.getSessionId());
|
||||||
@@ -1543,7 +1555,7 @@ public class BlobStoreManagerService extends SystemService {
|
|||||||
public int handleShellCommand(@NonNull ParcelFileDescriptor in,
|
public int handleShellCommand(@NonNull ParcelFileDescriptor in,
|
||||||
@NonNull ParcelFileDescriptor out, @NonNull ParcelFileDescriptor err,
|
@NonNull ParcelFileDescriptor out, @NonNull ParcelFileDescriptor err,
|
||||||
@NonNull String[] args) {
|
@NonNull String[] args) {
|
||||||
return (new BlobStoreManagerShellCommand(BlobStoreManagerService.this)).exec(this,
|
return new BlobStoreManagerShellCommand(BlobStoreManagerService.this).exec(this,
|
||||||
in.getFileDescriptor(), out.getFileDescriptor(), err.getFileDescriptor(), args);
|
in.getFileDescriptor(), out.getFileDescriptor(), err.getFileDescriptor(), args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ class BlobStoreSession extends IBlobStoreSession.Stub {
|
|||||||
private File mSessionFile;
|
private File mSessionFile;
|
||||||
|
|
||||||
@GuardedBy("mRevocableFds")
|
@GuardedBy("mRevocableFds")
|
||||||
private ArrayList<RevocableFileDescriptor> mRevocableFds = new ArrayList<>();
|
private final ArrayList<RevocableFileDescriptor> mRevocableFds = new ArrayList<>();
|
||||||
|
|
||||||
// This will be accessed from only one thread at any point of time, so no need to grab
|
// This will be accessed from only one thread at any point of time, so no need to grab
|
||||||
// a lock for this.
|
// a lock for this.
|
||||||
|
|||||||
Reference in New Issue
Block a user