Dump orphaned sessions is separate block
A child wihout its parent can never be installed. As such, it can't be
"Active install session".
Presence of orphaned sessions indicate leak in cleanup for multi-package
sessions. Creating a separate dumping block for orphaned sessions so
that we can catch leaks more easily.
Bug: 162518337
Test: use `adb install-multi-package --staged` to create multi-package
session and then abandon the parent session to create orphaned
child sessions. Made sure dumpsys isn't printing them anymore.
Change-Id: I36d7e7a88409d3d1582cb0554da9ed91e94a508d
This commit is contained in:
@@ -1281,14 +1281,21 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
|
||||
pw.increaseIndent();
|
||||
|
||||
List<PackageInstallerSession> finalizedSessions = new ArrayList<>();
|
||||
List<PackageInstallerSession> orphanedChildSessions = new ArrayList<>();
|
||||
int N = mSessions.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
final PackageInstallerSession session = mSessions.valueAt(i);
|
||||
|
||||
// Do not print finalized staged session as active install sessions
|
||||
final PackageInstallerSession rootSession = session.hasParentSessionId()
|
||||
? getSession(session.getParentSessionId())
|
||||
: session;
|
||||
// Do not print orphaned child sessions as active install sessions
|
||||
if (rootSession == null) {
|
||||
orphanedChildSessions.add(session);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Do not print finalized staged session as active install sessions
|
||||
if (rootSession.isStagedAndInTerminalState()) {
|
||||
finalizedSessions.add(session);
|
||||
continue;
|
||||
@@ -1300,6 +1307,21 @@ public class PackageInstallerService extends IPackageInstaller.Stub implements
|
||||
pw.println();
|
||||
pw.decreaseIndent();
|
||||
|
||||
if (!orphanedChildSessions.isEmpty()) {
|
||||
// Presence of orphaned sessions indicate leak in cleanup for multi-package and
|
||||
// should be cleaned up.
|
||||
pw.println("Orphaned install sessions:");
|
||||
pw.increaseIndent();
|
||||
N = orphanedChildSessions.size();
|
||||
for (int i = 0; i < N; i++) {
|
||||
final PackageInstallerSession session = orphanedChildSessions.get(i);
|
||||
session.dump(pw);
|
||||
pw.println();
|
||||
}
|
||||
pw.println();
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
|
||||
pw.println("Finalized install sessions:");
|
||||
pw.increaseIndent();
|
||||
N = finalizedSessions.size();
|
||||
|
||||
Reference in New Issue
Block a user