Merge changes from topic "fail-validation-q" into qt-qpr1-dev

* changes:
  Delete orphaned staging directories for staged session on reboot
  Clean up staged session data on validation failure
This commit is contained in:
TreeHugger Robot
2020-12-07 13:40:52 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 0 deletions

View File

@@ -287,6 +287,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
final ArraySet<File> unclaimedStages = newArraySet(
stagingDir.listFiles(sStageFilter));
// We also need to clean up orphaned staging directory for staged sessions
final File stagedSessionStagingDir = Environment.getDataStagingDirectory(volumeUuid);
unclaimedStages.addAll(newArraySet(stagedSessionStagingDir.listFiles()));
// Ignore stages claimed by active sessions
for (int i = 0; i < mSessions.size(); i++) {
final PackageInstallerSession session = mSessions.valueAt(i);

View File

@@ -881,6 +881,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
+ mParentSessionId + " and may not be committed directly.");
}
if (!markAsCommitted(statusReceiver, forTransfer)) {
if (isStaged()) {
// cleanStageDir calls mSessionProvider to get hold of child sessions, which in turn
// needs PackageInstallerService#mSessions lock. So we should not call cleanStageDir
// while holding mLock to avoid lock inversion.
cleanStageDir();
}
return;
}
if (isMultiPackage()) {