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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user