Fixes NPE thrown in sort if new targets are added.

Test: manually tested it to verify that it works as expected.

Bug: 65035399
Change-Id: Ie99b05c5324f47cbac66687d7301ef62a7c83e55
This commit is contained in:
Kang Li
2017-08-30 14:18:11 -07:00
parent d9abde75e8
commit 0935f152c7

View File

@@ -337,11 +337,13 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> {
final ResolverTarget rhsTarget = mTargetsDict.get(new ComponentName(
rhs.activityInfo.packageName, rhs.activityInfo.name));
final int selectProbabilityDiff = Float.compare(
if (lhsTarget != null && rhsTarget != null) {
final int selectProbabilityDiff = Float.compare(
rhsTarget.getSelectProbability(), lhsTarget.getSelectProbability());
if (selectProbabilityDiff != 0) {
return selectProbabilityDiff > 0 ? 1 : -1;
if (selectProbabilityDiff != 0) {
return selectProbabilityDiff > 0 ? 1 : -1;
}
}
}
}