From 12030008093b5a699b856782596f35b021e199e1 Mon Sep 17 00:00:00 2001 From: weijuncheng Date: Tue, 30 Oct 2018 14:07:53 +0800 Subject: [PATCH] Fix adb shell cmd activity get-config --proto --device fail Root cause: If the system features got from pm.getSystemAvailableFeatures() have some features with no name, it may cause adb shell cmd activity get-config --proto --device fails, the second parameter in the compator should also be judged with o2.name == null Bug: 118662777 Test: run cts -m CtsActivityManagerDeviceTestCases -t android.server.am.ActivityManagerGetConfigTests#testDeviceConfig Change-Id: Iee22cdf2e69104d3d9480971655b0be66ff84e46 Signed-off-by: weijuncheng --- .../android/server/am/ActivityManagerShellCommand.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java index dc9a5adb5a0cb..7fb161c8c4ae0 100644 --- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java +++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java @@ -2069,8 +2069,13 @@ final class ActivityManagerShellCommand extends ShellCommand { } FeatureInfo[] features = pm.getSystemAvailableFeatures(); - Arrays.sort(features, (o1, o2) -> - (o1.name == o2.name ? 0 : (o1.name == null ? -1 : o1.name.compareTo(o2.name)))); + Arrays.sort(features, (o1, o2) -> { + if (o1.name == o2.name) return 0; + if (o1.name == null) return -1; + if (o2.name == null) return 1; + return o1.name.compareTo(o2.name); + }); + for (int i = 0; i < features.length; i++) { if (features[i].name != null) { if (protoOutputStream != null) {