diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-11 21:40:55 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-09-11 21:40:55 +0000 |
commit | faaacdb2efbebc5c0bffe8bb722e985ba44667e0 (patch) | |
tree | 950774428b19398e52ecd36429ebd30602ba475a | |
parent | 7b5a91a0717ffd9c2192ab31666a1fcaad0f13aa (diff) | |
parent | 525904a2b7c67d546d953fa0d58351ec5073665c (diff) | |
download | platform_testing-faaacdb2efbebc5c0bffe8bb722e985ba44667e0.tar.gz |
Snap for 9050763 from 525904a2b7c67d546d953fa0d58351ec5073665c to mainline-mediaprovider-releaseaml_mpr_331112050aml_mpr_331112030
Change-Id: I7930af1831e44a4f77be191e264dacca0efb8e98
-rw-r--r-- | libraries/collectors-helper/memory/src/com/android/helpers/ShowmapSnapshotHelper.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libraries/collectors-helper/memory/src/com/android/helpers/ShowmapSnapshotHelper.java b/libraries/collectors-helper/memory/src/com/android/helpers/ShowmapSnapshotHelper.java index a7500a4e9..ad6b9a97f 100644 --- a/libraries/collectors-helper/memory/src/com/android/helpers/ShowmapSnapshotHelper.java +++ b/libraries/collectors-helper/memory/src/com/android/helpers/ShowmapSnapshotHelper.java @@ -219,7 +219,7 @@ public class ShowmapSnapshotHelper implements ICollectorHelper<String> { public HashSet<Integer> getChildrenPids(String processName) { HashSet<Integer> childrenPids = new HashSet<>(); - String childrenCmdOutput = null; + String childrenCmdOutput = ""; try { // Execute shell does not support shell substitution so it has to be executed twice. childrenCmdOutput = mUiDevice.executeShellCommand( @@ -229,7 +229,14 @@ public class ShowmapSnapshotHelper implements ICollectorHelper<String> { } String[] lines = childrenCmdOutput.split("\\R"); for (String line : lines) { - childrenPids.add(Integer.parseInt(line)); + try { + int pid = Integer.parseInt(line); + childrenPids.add(pid); + } catch (NumberFormatException e) { + // If the process does not exist or the shell command fails + // just skip the pid, this is because there could be some + // devices that contain a process while others do not. + } } return childrenPids; } |