Fixed NPE in package installer session.

We updated staged sessions to activation failed state when they
aren't in terminal state, and device received ota and reboot. This
happend before the StagingManager resumes the sessions when
the whole set of parent+child sessions have been restored.
A parent session probably cannot find the child session, and a null
exception could happen.

In this change, we do not destroy child sessions before we destroy
the parent session. We only destroy a child session directly if we
are sure that its parent session doesn't exist.

Bug: 147651771
Test: StagedInstallTest
Change-Id: Iac6489a04df35f851aa18a91e1dde2d73928b8ec
Merged-in: Iac6489a04df35f851aa18a91e1dde2d73928b8ec
(cherry picked from commit 1fc8b36cf38e2632db68e5d15acd3ff83d1f54aa)
2 files changed