summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author JW Wang <wangchun@google.com> 2020-07-29 15:37:14 +0800
committer JW Wang <wangchun@google.com> 2020-08-07 07:59:49 +0800
commit34f74ff0d5dcb0d62dcf30c4011a1d650710ca8c (patch)
tree7b3e54a9e5bda327840241f216ba8ba5eec632c8
parentfff78b09e6ca7a125a76a7d09d6106aa16d25662 (diff)
Some code cleanup (3/n)
Now sealLocked(), verifyNonStaged() and installNonStaged() can retrieve child sessions on their own without being given by the caller. This improves cohesion of the methods. Bug: 162386287 Test: atest StagedInstallTest Change-Id: I33c6e9b68383b5348e839cfcfc72afd325452705
-rw-r--r--services/core/java/com/android/server/pm/PackageInstallerSession.java32
1 files changed, 17 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 4e64ab90fede..2dde24a38336 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -1437,7 +1437,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
try {
- sealLocked(getChildSessionsLocked());
+ sealLocked();
} catch (PackageManagerException e) {
return false;
}
@@ -1547,14 +1547,14 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
* session was sealed this is the only possible exception.
*/
@GuardedBy("mLock")
- private void sealLocked(List<PackageInstallerSession> childSessions)
+ private void sealLocked()
throws PackageManagerException {
try {
assertNoWriteFileTransfersOpenLocked();
assertPreparedAndNotDestroyedLocked("sealing of session");
mSealed = true;
-
+ List<PackageInstallerSession> childSessions = getChildSessionsLocked();
if (childSessions != null) {
assertMultiPackageConsistencyLocked(childSessions);
}
@@ -1666,7 +1666,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
synchronized (mLock) {
try {
- sealLocked(getChildSessionsLocked());
+ sealLocked();
if (isApexInstallation()) {
// APEX installations rely on certain fields to be populated after reboot.
@@ -1712,7 +1712,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
assertPreparedAndNotSealedLocked("transfer");
try {
- sealLocked(getChildSessionsLocked());
+ sealLocked();
} catch (PackageManagerException e) {
throw new IllegalArgumentException("Package is not valid", e);
}
@@ -1743,13 +1743,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return;
}
- final List<PackageInstallerSession> childSessions;
- synchronized (mLock) {
- childSessions = getChildSessionsLocked();
- }
-
try {
- verifyNonStaged(childSessions);
+ verifyNonStaged();
} catch (PackageManagerException e) {
final String completeMsg = ExceptionUtils.getCompleteMessage(e);
Slog.e(TAG, "Commit of session " + sessionId + " failed: " + completeMsg);
@@ -1758,7 +1753,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
}
- private void verifyNonStaged(List<PackageInstallerSession> childSessions)
+ private void verifyNonStaged()
throws PackageManagerException {
final PackageManagerService.VerificationParams verifyingSession =
makeVerificationParams();
@@ -1766,6 +1761,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return;
}
if (isMultiPackage()) {
+ final List<PackageInstallerSession> childSessions;
+ synchronized (mLock) {
+ childSessions = getChildSessionsLocked();
+ }
List<PackageManagerService.VerificationParams> verifyingChildSessions =
new ArrayList<>(childSessions.size());
boolean success = true;
@@ -1799,7 +1798,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
}
- private void installNonStaged(List<PackageInstallerSession> childSessions)
+ private void installNonStaged()
throws PackageManagerException {
final PackageManagerService.InstallParams installingSession =
makeInstallParams();
@@ -1807,6 +1806,10 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return;
}
if (isMultiPackage()) {
+ final List<PackageInstallerSession> childSessions;
+ synchronized (mLock) {
+ childSessions = getChildSessionsLocked();
+ }
List<PackageManagerService.InstallParams> installingChildSessions =
new ArrayList<>(childSessions.size());
boolean success = true;
@@ -2000,9 +2003,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
return;
}
- List<PackageInstallerSession> childSessions = getChildSessionsNotLocked();
try {
- installNonStaged(childSessions);
+ installNonStaged();
} catch (PackageManagerException e) {
final String completeMsg = ExceptionUtils.getCompleteMessage(e);
Slog.e(TAG, "Commit of session " + sessionId + " failed: " + completeMsg);