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

Commit 80a6e3ea authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Sends the correct error code" into rvc-dev am: 50ec69fa am:...

Merge "Sends the correct error code" into rvc-dev am: 50ec69fa am: 72c7d056 am: 6018bfd1 am: d5002072

Change-Id: Ic73e635af7256bda0ff71640c5ab2d9f66f882e4
parents 4b543d30 d5002072
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -1170,9 +1170,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                // as appropriate once all children have been processed
                try {
                    PackageInstallerSession session = mSessionProvider.getSession(childSessionId);
                    if (!session.streamValidateAndCommit()) {
                        allSessionsReady = false;
                    }
                    allSessionsReady &= session.streamValidateAndCommit();
                    nonFailingSessions.add(session);
                } catch (PackageManagerException e) {
                    allSessionsReady = false;
@@ -1181,10 +1179,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                    }
                }
            }
            // If we encountered any unrecoverable failures, destroy all
            // other impacted sessions besides the parent; that will be cleaned up by the
            // ChildStatusIntentReceiver.
            // If we encountered any unrecoverable failures, destroy all other sessions including
            // the parent
            if (unrecoverableFailure != null) {
                // {@link #streamValidateAndCommit()} calls
                // {@link #onSessionVerificationFailure(PackageManagerException)}, but we don't
                // expect it to ever do so for parent sessions. Call that on this parent to clean
                // it up and notify listeners of the error.
                onSessionVerificationFailure(unrecoverableFailure);
                // fail other child sessions that did not already fail
                for (int i = nonFailingSessions.size() - 1; i >= 0; --i) {
                    PackageInstallerSession session = nonFailingSessions.get(i);
@@ -1251,6 +1253,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        public void statusUpdate(Intent intent) {
            mHandler.post(() -> {
                if (mChildSessionsRemaining.size() == 0) {
                    // no children to deal with, ignore.
                    return;
                }
                final boolean destroyed;
                synchronized (mLock) {
                    destroyed = mDestroyed;
                }
                if (destroyed) {
                    // the parent has already been terminated, ignore.
                    return;
                }
                final int sessionId = intent.getIntExtra(
@@ -1277,8 +1288,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                    intent.putExtra(PackageInstaller.EXTRA_SESSION_ID,
                            PackageInstallerSession.this.sessionId);
                    mChildSessionsRemaining.clear(); // we're done. Don't send any more.
                    onSessionVerificationFailure(status,
                            intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE));
                    try {
                        mStatusReceiver.sendIntent(mContext, 0, intent, null, null);
                    } catch (IntentSender.SendIntentException ignore) {
                    }
                }
            });
        }
@@ -1391,6 +1404,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
     * @throws PackageManagerException on an unrecoverable error.
     */
    private boolean streamValidateAndCommit() throws PackageManagerException {
        // TODO(patb): since the work done here for a parent session in a multi-package install is
        //             mostly superficial, consider splitting this method for the parent and
        //             single / child sessions.
        synchronized (mLock) {
            if (mCommitted) {
                return true;