From 18d20709e0a238d3a571dc3d852e682e64706f56 Mon Sep 17 00:00:00 2001 From: Felka Chang Date: Mon, 24 Aug 2020 15:03:43 +0800 Subject: Fix the orphan child session after abandoning the parent session In the multipackage staged session set condition, whenever a committed parent session called abandon(), only calling dispatchSessionFinished() on the parent session would leave its children session as the orphan child sessions. The child sessions aren't handled very well and they would be never handled if the installer applications forget to handle them. The solution is to notify the each child session in this multipackage session after the parent session is abandoned. And, to add the com.android.tests.atomicinstall.SessionAbandonBehaviorTest to verify the behavior. Test: atest StagedInstallInternalTest Test: atest -p \ frameworks/base/services/core/java/com/android/server/pm/TEST_MAPPING Test: atest CtsAtomicInstallTestCases Test: # monitor the log after atest stagedInstallInternalTest and reboot. Bug: 164964410 Change-Id: I23dabf7da099baebed63e9f9fc73383984015070 --- core/java/android/content/pm/PackageInstaller.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/java') diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index e2f85282948a..f59852dbff0b 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -1356,7 +1356,9 @@ public class PackageInstaller { * Completely abandon this session, destroying all staged data and * rendering it invalid. Abandoned sessions will be reported to * {@link SessionCallback} listeners as failures. This is equivalent to - * opening the session and calling {@link Session#abandon()}. + * {@link #abandonSession(int)}. + *

If the parent is abandoned, all children will also be abandoned. Any written data + * would be destroyed and the created {@link Session} information will be discarded.

*/ public void abandon() { try { @@ -1419,7 +1421,8 @@ public class PackageInstaller { * when this session is committed. * *

If the parent is staged or has rollback enabled, all children must have - * the same properties. + * the same properties.

+ *

If the parent is abandoned, all children will also be abandoned.

* * @param sessionId the session ID to add to this multi-package session. */ -- cgit v1.2.3