Skip to content
Snippets Groups Projects
Commit 028f33fd authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Automerger Merge Worker
Browse files

Merge changes from topic "dm-profile-validation" into main am: 7e72104d am:...

Merge changes from topic "dm-profile-validation" into main am: 7e72104d am: f0643a6b am: b16d9905

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2786343



Change-Id: I338fc316172c608954f0b9aa58967ef11b766460
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 99b6b234 b16d9905
No related branches found
No related tags found
No related merge requests found
......@@ -2739,15 +2739,40 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
* @return a future that will be completed when the whole process is completed.
*/
private CompletableFuture<Void> install() {
// `futures` either contains only one session (`this`) or contains one parent session
// (`this`) and n-1 child sessions.
List<CompletableFuture<InstallResult>> futures = installNonStaged();
CompletableFuture<InstallResult>[] arr = new CompletableFuture[futures.size()];
return CompletableFuture.allOf(futures.toArray(arr)).whenComplete((r, t) -> {
if (t == null) {
setSessionApplied();
var multiPackageWarnings = new ArrayList<String>();
if (isMultiPackage()) {
// This is a parent session. Collect warnings from children.
for (CompletableFuture<InstallResult> f : futures) {
InstallResult result = f.join();
if (result.session != this && result.extras != null) {
ArrayList<String> childWarnings = result.extras.getStringArrayList(
PackageInstaller.EXTRA_WARNINGS);
if (!ArrayUtils.isEmpty(childWarnings)) {
multiPackageWarnings.addAll(childWarnings);
}
}
}
}
for (CompletableFuture<InstallResult> f : futures) {
InstallResult result = f.join();
Bundle extras = result.extras;
if (isMultiPackage() && result.session == this
&& !multiPackageWarnings.isEmpty()) {
if (extras == null) {
extras = new Bundle();
}
extras.putStringArrayList(
PackageInstaller.EXTRA_WARNINGS, multiPackageWarnings);
}
result.session.dispatchSessionFinished(
INSTALL_SUCCEEDED, "Session installed", result.extras);
INSTALL_SUCCEEDED, "Session installed", extras);
}
} else {
PackageManagerException e = (PackageManagerException) t.getCause();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment