summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdgar Arriaga <edgararriaga@google.com>2022-09-09 00:14:02 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-09-09 00:14:02 +0000
commit525904a2b7c67d546d953fa0d58351ec5073665c (patch)
tree950774428b19398e52ecd36429ebd30602ba475a
parent8a53b91de1b3a719060986757a2beeafd72d1f6a (diff)
parent5c66406c9a829ac071e973702c2cbee114980d39 (diff)
downloadplatform_testing-525904a2b7c67d546d953fa0d58351ec5073665c.tar.gz
Fix for showmap collector exception for non mixed arch devices am: 5c66406c9a
Original change: https://googleplex-android-review.googlesource.com/c/platform/platform_testing/+/19902674 Change-Id: Ie5265c24029ccd7619d05c087e128b5abaa7ef08 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libraries/collectors-helper/memory/src/com/android/helpers/ShowmapSnapshotHelper.java11
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;
}