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

Commit 2ef05dca authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Handles pre-process failure without crashing system

This change ensures that if we encounter any issues copying the APK to
be installed, we also fail the other sessions to prevent them being
cleaned up incorrectly on post-install.

Test: manual; use debugger to force InstallArgs.copyApk() to fail
Bug: 133380744
Change-Id: I19e84a4683a36ac152d435fab3d0b191db6cc2df
parent 23d7a55d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -15032,24 +15032,26 @@ public class PackageManagerService extends IPackageManager.Stub
        void tryProcessInstallRequest(InstallArgs args, int currentStatus) {
            mCurrentState.put(args, currentStatus);
            boolean success = true;
            if (mCurrentState.size() != mChildParams.size()) {
                return;
            }
            int completeStatus = PackageManager.INSTALL_SUCCEEDED;
            for (Integer status : mCurrentState.values()) {
                if (status == PackageManager.INSTALL_UNKNOWN) {
                    return;
                } else if (status != PackageManager.INSTALL_SUCCEEDED) {
                    success = false;
                    completeStatus = status;
                    break;
                }
            }
            final List<InstallRequest> installRequests = new ArrayList<>(mCurrentState.size());
            for (Map.Entry<InstallArgs, Integer> entry : mCurrentState.entrySet()) {
                installRequests.add(new InstallRequest(entry.getKey(),
                        createPackageInstalledInfo(entry.getValue())));
                        createPackageInstalledInfo(completeStatus)));
            }
            processInstallRequestsAsync(success, installRequests);
            processInstallRequestsAsync(
                    completeStatus == PackageManager.INSTALL_SUCCEEDED,
                    installRequests);
        }
    }