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

Commit fbd3a2aa authored by TYM Tsai's avatar TYM Tsai Committed by Android (Google) Code Review
Browse files

Merge "Fix system server crash caused by package installer"

parents 847e366d ce23b4a5
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -705,12 +705,33 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        @Override
        public void verifySession() {
            assertCallerIsOwnerOrRootOrSystem();
            Preconditions.checkArgument(isCommitted());
            Preconditions.checkArgument(!isInTerminalState());
            if (isCommittedAndNotInTerminalState()) {
                verify();
            }
        }

        private boolean isCommittedAndNotInTerminalState() {
            String errorMsg = null;
            if (!isCommitted()) {
                errorMsg = TextUtils.formatSimple("The session %d should be committed", sessionId);
            } else if (isSessionApplied()) {
                errorMsg = TextUtils.formatSimple("The session %d has applied", sessionId);
            } else if (isSessionFailed()) {
                synchronized (PackageInstallerSession.this.mLock) {
                    errorMsg = TextUtils.formatSimple("The session %d has failed with error: %s",
                            sessionId, PackageInstallerSession.this.mSessionErrorMessage);
                }
            }
            if (errorMsg != null) {
                Slog.e(TAG, "verifySession error: " + errorMsg);
                setSessionFailed(INSTALL_FAILED_INTERNAL_ERROR, errorMsg);
                onSessionVerificationFailure(INSTALL_FAILED_INTERNAL_ERROR, errorMsg);
                return false;
            }
            return true;
        }
    }

    /**
     * Path to the validated base APK for this session, which may point at an
     * APK inside the session (when the session defines the base), or it may