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

Commit 07e31dfb authored by JW Wang's avatar JW Wang Committed by Chun-Wei Wang
Browse files

Fix NPE

NPE happens when there is an orphaned session which we've
tried to prevent in all cases.

Log an error message if this situation happens.

Bug: 227342978
Test: atest CtsRootPackageInstallerHostTestCases
Change-Id: Ia21323926bd9db1a6f05461904deb45b4c3dd0bc
parent 5c902afe
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -410,7 +410,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
                    // Their staging dirs will be removed too
                    PackageInstallerSession root = !session.hasParentSessionId()
                            ? session : mSessions.get(session.getParentSessionId());
                    if (!root.isDestroyed()) {
                    if (root == null) {
                        Slog.e(TAG, "freeStageDirs: found an orphaned session: "
                                + session.sessionId + " parent=" + session.getParentSessionId());
                    } else if (!root.isDestroyed()) {
                        root.abandon();
                    }
                } else {