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

Commit 87a6cc1e authored by Mohammad Samiul Islam's avatar Mohammad Samiul Islam
Browse files

Pass sessionId instead of whole object during pre-reboot verification

Also, if session is aborted before the pre-reboot verification is
complete, we now stop the verification process.

Bug: 140233823
Test: StagedInstallTest#testFailInstallAnotherSessionAlreadyInProgress_MultiPackageSinglePackage
Test: StagedInstallTest
Change-Id: I4cff8060aa1600c505531f00986ebbeb523c07c8
Merged-In: I4cff8060aa1600c505531f00986ebbeb523c07c8
parent 0c4788f7
Loading
Loading
Loading
Loading
+25 −16
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ public class StagingManager {
                // Greedily re-trigger the pre-reboot verification.
                Slog.d(TAG, "Found pending staged session " + session.sessionId + " still to be "
                        + "verified, resuming pre-reboot verification");
                mPreRebootVerificationHandler.startPreRebootVerification(session);
                mPreRebootVerificationHandler.startPreRebootVerification(session.sessionId);
                return;
            }
            if (!apexSessionInfo.isActivated && !apexSessionInfo.isSuccess) {
@@ -429,7 +429,7 @@ public class StagingManager {
                            return;
                        }
                        mPreRebootVerificationHandler.notifyPreRebootVerification_Apk_Complete(
                                originalSession);
                                originalSession.sessionId);
                    });
            apkSession.commit(receiver.getIntentSender(), false);
            return;
@@ -526,7 +526,7 @@ public class StagingManager {

    void commitSession(@NonNull PackageInstallerSession session) {
        updateStoredSession(session);
        mPreRebootVerificationHandler.startPreRebootVerification(session);
        mPreRebootVerificationHandler.startPreRebootVerification(session.sessionId);
    }

    @Nullable
@@ -653,7 +653,7 @@ public class StagingManager {
        if (!session.isStagedSessionReady()) {
            // The framework got restarted before the pre-reboot verification could complete,
            // restart the verification.
            mPreRebootVerificationHandler.startPreRebootVerification(session);
            mPreRebootVerificationHandler.startPreRebootVerification(session.sessionId);
        } else {
            // Session had already being marked ready. Start the checks to verify if there is any
            // follow-up work.
@@ -737,7 +737,16 @@ public class StagingManager {

        @Override
        public void handleMessage(Message msg) {
            PackageInstallerSession session = (PackageInstallerSession) msg.obj;
            final int sessionId = msg.arg1;
            final PackageInstallerSession session;
            synchronized (mStagedSessions) {
                session = mStagedSessions.get(sessionId);
            }
            // Maybe session was aborted before pre-reboot verification was complete
            if (session == null) {
                Slog.d(TAG, "Stopping pre-reboot verification for sessionId: " + sessionId);
                return;
            }
            switch (msg.what) {
                case MSG_PRE_REBOOT_VERIFICATION_START:
                    handlePreRebootVerification_Start(session);
@@ -755,20 +764,20 @@ public class StagingManager {
        }

        // Method for starting the pre-reboot verification
        private void startPreRebootVerification(PackageInstallerSession session) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_START, session).sendToTarget();
        private void startPreRebootVerification(int sessionId) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_START, sessionId, 0).sendToTarget();
        }

        private void notifyPreRebootVerification_Start_Complete(PackageInstallerSession session) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_APEX, session).sendToTarget();
        private void notifyPreRebootVerification_Start_Complete(int sessionId) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_APEX, sessionId, 0).sendToTarget();
        }

        private void notifyPreRebootVerification_Apex_Complete(PackageInstallerSession session) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_APK, session).sendToTarget();
        private void notifyPreRebootVerification_Apex_Complete(int sessionId) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_APK, sessionId, 0).sendToTarget();
        }

        private void notifyPreRebootVerification_Apk_Complete(PackageInstallerSession session) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_END, session).sendToTarget();
        private void notifyPreRebootVerification_Apk_Complete(int sessionId) {
            obtainMessage(MSG_PRE_REBOOT_VERIFICATION_END, sessionId, 0).sendToTarget();
        }

        /**
@@ -778,7 +787,7 @@ public class StagingManager {
         */
        private void handlePreRebootVerification_Start(@NonNull PackageInstallerSession session) {
            Slog.d(TAG, "Starting preRebootVerification for session " + session.sessionId);
            notifyPreRebootVerification_Start_Complete(session);
            notifyPreRebootVerification_Start_Complete(session.sessionId);
        }

        /**
@@ -808,7 +817,7 @@ public class StagingManager {
                }
            }

            notifyPreRebootVerification_Apex_Complete(session);
            notifyPreRebootVerification_Apex_Complete(session.sessionId);
        }

        /**
@@ -819,7 +828,7 @@ public class StagingManager {
         */
        private void handlePreRebootVerification_Apk(@NonNull PackageInstallerSession session) {
            if (!sessionContainsApk(session)) {
                notifyPreRebootVerification_Apk_Complete(session);
                notifyPreRebootVerification_Apk_Complete(session.sessionId);
                return;
            }