Loading services/core/java/com/android/server/pm/PackageInstallerSession.java +14 −7 Original line number Diff line number Diff line Loading @@ -995,6 +995,19 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { mSealed = true; if (params.isStaged) { final PackageInstallerSession activeSession = mStagingManager.getActiveSession(); final boolean anotherSessionAlreadyInProgress = activeSession != null && sessionId != activeSession.sessionId && mParentSessionId != activeSession.sessionId; if (anotherSessionAlreadyInProgress) { throw new PackageManagerException( PackageManager.INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS, "There is already in-progress committed staged session " + activeSession.sessionId, null); } } // Read transfers from the original owner stay open, but as the session's data // cannot be modified anymore, there is no leak of information. For staged sessions, // further validation is performed by the staging manager. Loading Loading @@ -1081,13 +1094,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { .write(); } if (params.isStaged) { try { mStagingManager.commitSession(this); } catch (StagingManager.AlreadyInProgressStagedSessionException e) { dispatchSessionFinished( PackageManager.INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS, e.getMessage(), null); } destroyInternal(); dispatchSessionFinished(PackageManager.INSTALL_SUCCEEDED, "Session staged", null); return; Loading services/core/java/com/android/server/pm/StagingManager.java +2 −20 Original line number Diff line number Diff line Loading @@ -477,23 +477,13 @@ public class StagingManager { return true; } void commitSession(@NonNull PackageInstallerSession session) throws AlreadyInProgressStagedSessionException { PackageInstallerSession activeSession = getActiveSession(); boolean anotherSessionAlreadyInProgress = activeSession != null && session.sessionId != activeSession.sessionId; void commitSession(@NonNull PackageInstallerSession session) { updateStoredSession(session); if (anotherSessionAlreadyInProgress) { session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, "There is already in-progress committed staged session " + activeSession.sessionId); throw new AlreadyInProgressStagedSessionException(activeSession.sessionId); } mBgHandler.post(() -> preRebootVerification(session)); } @Nullable private PackageInstallerSession getActiveSession() { PackageInstallerSession getActiveSession() { synchronized (mStagedSessions) { for (int i = 0; i < mStagedSessions.size(); i++) { final PackageInstallerSession session = mStagedSessions.valueAt(i); Loading Loading @@ -651,12 +641,4 @@ public class StagingManager { } } } static final class AlreadyInProgressStagedSessionException extends Exception { AlreadyInProgressStagedSessionException(int sessionId) { super("There is already in-progress committed staged session " + sessionId); } } } Loading
services/core/java/com/android/server/pm/PackageInstallerSession.java +14 −7 Original line number Diff line number Diff line Loading @@ -995,6 +995,19 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { mSealed = true; if (params.isStaged) { final PackageInstallerSession activeSession = mStagingManager.getActiveSession(); final boolean anotherSessionAlreadyInProgress = activeSession != null && sessionId != activeSession.sessionId && mParentSessionId != activeSession.sessionId; if (anotherSessionAlreadyInProgress) { throw new PackageManagerException( PackageManager.INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS, "There is already in-progress committed staged session " + activeSession.sessionId, null); } } // Read transfers from the original owner stay open, but as the session's data // cannot be modified anymore, there is no leak of information. For staged sessions, // further validation is performed by the staging manager. Loading Loading @@ -1081,13 +1094,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { .write(); } if (params.isStaged) { try { mStagingManager.commitSession(this); } catch (StagingManager.AlreadyInProgressStagedSessionException e) { dispatchSessionFinished( PackageManager.INSTALL_FAILED_OTHER_STAGED_SESSION_IN_PROGRESS, e.getMessage(), null); } destroyInternal(); dispatchSessionFinished(PackageManager.INSTALL_SUCCEEDED, "Session staged", null); return; Loading
services/core/java/com/android/server/pm/StagingManager.java +2 −20 Original line number Diff line number Diff line Loading @@ -477,23 +477,13 @@ public class StagingManager { return true; } void commitSession(@NonNull PackageInstallerSession session) throws AlreadyInProgressStagedSessionException { PackageInstallerSession activeSession = getActiveSession(); boolean anotherSessionAlreadyInProgress = activeSession != null && session.sessionId != activeSession.sessionId; void commitSession(@NonNull PackageInstallerSession session) { updateStoredSession(session); if (anotherSessionAlreadyInProgress) { session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_VERIFICATION_FAILED, "There is already in-progress committed staged session " + activeSession.sessionId); throw new AlreadyInProgressStagedSessionException(activeSession.sessionId); } mBgHandler.post(() -> preRebootVerification(session)); } @Nullable private PackageInstallerSession getActiveSession() { PackageInstallerSession getActiveSession() { synchronized (mStagedSessions) { for (int i = 0; i < mStagedSessions.size(); i++) { final PackageInstallerSession session = mStagedSessions.valueAt(i); Loading Loading @@ -651,12 +641,4 @@ public class StagingManager { } } } static final class AlreadyInProgressStagedSessionException extends Exception { AlreadyInProgressStagedSessionException(int sessionId) { super("There is already in-progress committed staged session " + sessionId); } } }