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

Commit 41c25e35 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Fixed NPE in package installer session." into qt-qpr1-dev am: 53a56839

Change-Id: I0078d29119d6bb2810bd55b82cfa397f843f0353
parents 08730cb3 53a56839
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -258,12 +258,15 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
        }
        }
        // Don't hold mSessions lock when calling restoreSession, since it might trigger an APK
        // Don't hold mSessions lock when calling restoreSession, since it might trigger an APK
        // atomic install which needs to query sessions, which requires lock on mSessions.
        // atomic install which needs to query sessions, which requires lock on mSessions.
        boolean isDeviceUpgrading = mPm.isDeviceUpgrading();
        for (PackageInstallerSession session : stagedSessionsToRestore) {
        for (PackageInstallerSession session : stagedSessionsToRestore) {
            if (mPm.isDeviceUpgrading() && !session.isStagedAndInTerminalState()) {
            if (!session.isStagedAndInTerminalState() && session.hasParentSessionId()
                    && getSession(session.getParentSessionId()) == null) {
                session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
                session.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
                        "Build fingerprint has changed");
                        "An orphan staged session " + session.sessionId + " is found, "
                                + "parent " + session.getParentSessionId() + " is missing");
            }
            }
            mStagingManager.restoreSession(session);
            mStagingManager.restoreSession(session, isDeviceUpgrading);
        }
        }
        // Broadcasts are not sent while we restore sessions on boot, since no processes would be
        // Broadcasts are not sent while we restore sessions on boot, since no processes would be
        // ready to listen to them. From now on, we greedily assume that broadcasts requests are
        // ready to listen to them. From now on, we greedily assume that broadcasts requests are
+8 −1
Original line number Original line Diff line number Diff line
@@ -630,7 +630,7 @@ public class StagingManager {
        return false;
        return false;
    }
    }


    void restoreSession(@NonNull PackageInstallerSession session) {
    void restoreSession(@NonNull PackageInstallerSession session, boolean isDeviceUpgrading) {
        PackageInstallerSession sessionToResume = session;
        PackageInstallerSession sessionToResume = session;
        synchronized (mStagedSessions) {
        synchronized (mStagedSessions) {
            mStagedSessions.append(session.sessionId, session);
            mStagedSessions.append(session.sessionId, session);
@@ -647,6 +647,13 @@ public class StagingManager {
                }
                }
            }
            }
        }
        }
        // The preconditions used during pre-reboot verification might have changed when device
        // is upgrading. Updated staged sessions to activation failed before we resume the session.
        if (isDeviceUpgrading && !sessionToResume.isStagedAndInTerminalState()) {
            sessionToResume.setStagedSessionFailed(SessionInfo.STAGED_SESSION_ACTIVATION_FAILED,
                        "Build fingerprint has changed");
            return;
        }
        checkStateAndResume(sessionToResume);
        checkStateAndResume(sessionToResume);
    }
    }