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

Commit 47ef1e92 authored by JW Wang's avatar JW Wang
Browse files

Send the intent after verification completed (6/n)

This will remove the need for listening to ACTION_SESSION_UPDATED events.

Note this will break CTS which always assumes a successful intent to be
recevied after calling Session#commit() for a staged session. We will fix
that in the next CL.

PackageManagerShellCommand is also modified to make --staged-ready-timeout
continue to work as before.

Bug: 210359798
Test: atest GtsStagedInstallHostTestCases \
            CtsStagedInstallHostTestCases \
	    StagedInstallInternalTest

Change-Id: I4d6d3bcf45f0215d2b5e5bd079f8919a0fccbca4
parent 03a3c96b
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -2261,10 +2261,6 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        }

        if (params.isStaged) {
            // TODO(b/136257624): CTS test fails if we don't send session finished broadcast, even
            //  though ideally, we just need to send session committed broadcast.
            sendUpdateToRemoteStatusReceiver(INSTALL_SUCCEEDED, "Session staged", null);

            mStagedSession.verifySession();
        } else {
            verify();
@@ -2511,6 +2507,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                mStagedSession.notifyEndPreRebootVerification();
                if (error == SessionInfo.SESSION_NO_ERROR) {
                    mStagingManager.commitSession(mStagedSession);
                    sendUpdateToRemoteStatusReceiver(INSTALL_SUCCEEDED, "Session staged", null);
                } else {
                    dispatchSessionFinished(INSTALL_FAILED_VERIFICATION_FAILURE, msg, null);
                    maybeFinishChildSessions(INSTALL_FAILED_VERIFICATION_FAILURE, msg);
+17 −8
Original line number Diff line number Diff line
@@ -3563,6 +3563,7 @@ class PackageManagerShellCommand extends ShellCommand {
            }
            final LocalIntentReceiver receiver = new LocalIntentReceiver();
            session.commit(receiver.getIntentSender());
            if (!session.isStaged()) {
                final Intent result = receiver.getResult();
                final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
                        PackageInstaller.STATUS_FAILURE);
@@ -3575,6 +3576,14 @@ class PackageManagerShellCommand extends ShellCommand {
                            + result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]");
                }
                return status;
            } else {
                // Return immediately without retrieving the result. The caller will decide
                // whether to wait for the session to become ready.
                if (logSuccess) {
                    pw.println("Success");
                }
                return PackageInstaller.STATUS_SUCCESS;
            }
        } finally {
            IoUtils.closeQuietly(session);
        }