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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -3563,18 +3563,27 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
}
|
||||
final LocalIntentReceiver receiver = new LocalIntentReceiver();
|
||||
session.commit(receiver.getIntentSender());
|
||||
final Intent result = receiver.getResult();
|
||||
final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
|
||||
PackageInstaller.STATUS_FAILURE);
|
||||
if (status == PackageInstaller.STATUS_SUCCESS) {
|
||||
if (!session.isStaged()) {
|
||||
final Intent result = receiver.getResult();
|
||||
final int status = result.getIntExtra(PackageInstaller.EXTRA_STATUS,
|
||||
PackageInstaller.STATUS_FAILURE);
|
||||
if (status == PackageInstaller.STATUS_SUCCESS) {
|
||||
if (logSuccess) {
|
||||
pw.println("Success");
|
||||
}
|
||||
} else {
|
||||
pw.println("Failure ["
|
||||
+ 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");
|
||||
}
|
||||
} else {
|
||||
pw.println("Failure ["
|
||||
+ result.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE) + "]");
|
||||
return PackageInstaller.STATUS_SUCCESS;
|
||||
}
|
||||
return status;
|
||||
} finally {
|
||||
IoUtils.closeQuietly(session);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user