Loading core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -163,6 +163,9 @@ class AppPredictionServiceResolverComparator extends AbstractResolverComparator @Override @Override List<ComponentName> getTopComponentNames(int topK) { List<ComponentName> getTopComponentNames(int topK) { if (mResolverRankerService != null) { return mResolverRankerService.getTopComponentNames(topK); } return mTargetRanks.entrySet().stream() return mTargetRanks.entrySet().stream() .sorted(Entry.comparingByValue()) .sorted(Entry.comparingByValue()) .limit(topK) .limit(topK) Loading core/java/com/android/internal/app/ChooserListAdapter.java +22 −10 Original line number Original line Diff line number Diff line Loading @@ -207,6 +207,9 @@ public class ChooserListAdapter extends ResolverListAdapter { if (mListViewDataChanged) { if (mListViewDataChanged) { if (mAppendDirectShareEnabled) { if (mAppendDirectShareEnabled) { appendServiceTargetsWithQuota(); appendServiceTargetsWithQuota(); if (mPendingChooserTargetService.isEmpty()) { fillAllServiceTargets(); } } } super.notifyDataSetChanged(); super.notifyDataSetChanged(); } } Loading Loading @@ -488,13 +491,14 @@ public class ChooserListAdapter extends ResolverListAdapter { Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos, Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos, List<ChooserActivity.ChooserTargetServiceConnection> List<ChooserActivity.ChooserTargetServiceConnection> pendingChooserTargetServiceConnections) { pendingChooserTargetServiceConnections) { ComponentName origComponentName = origTarget.getResolvedComponentName(); ComponentName origComponentName = origTarget != null ? origTarget.getResolvedComponentName() : !targets.isEmpty() ? targets.get(0).getComponentName() : null; mPendingChooserTargetService = pendingChooserTargetServiceConnections.stream() mPendingChooserTargetService = pendingChooserTargetServiceConnections.stream() .map(ChooserActivity.ChooserTargetServiceConnection::getComponentName) .map(ChooserActivity.ChooserTargetServiceConnection::getComponentName) .filter(componentName -> !componentName.equals(origComponentName)) .filter(componentName -> !componentName.equals(origComponentName)) .collect(Collectors.toSet()); .collect(Collectors.toSet()); // Park targets in memory // Park targets in memory if (!targets.isEmpty() && !mParkingDirectShareTargets.containsKey(origComponentName)) { if (!targets.isEmpty()) { final boolean isShortcutResult = final boolean isShortcutResult = (targetType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER (targetType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER || targetType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE); || targetType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE); Loading @@ -509,8 +513,11 @@ public class ChooserListAdapter extends ResolverListAdapter { : null)) : null)) ) ) .collect(Collectors.toList()); .collect(Collectors.toList()); mParkingDirectShareTargets.put(origComponentName, Pair<List<ChooserTargetInfo>, Integer> parkingTargetInfoPair = new Pair<>(parkingTargetInfos, 0)); mParkingDirectShareTargets.getOrDefault(origComponentName, new Pair<>(new ArrayList<>(), 0)); parkingTargetInfoPair.first.addAll(parkingTargetInfos); mParkingDirectShareTargets.put(origComponentName, parkingTargetInfoPair); if (isShortcutResult) { if (isShortcutResult) { mShortcutComponents.add(origComponentName); mShortcutComponents.add(origComponentName); } } Loading Loading @@ -558,6 +565,9 @@ public class ChooserListAdapter extends ResolverListAdapter { * Append all remaining targets (parking in memory) into direct share row as per their ranking. * Append all remaining targets (parking in memory) into direct share row as per their ranking. */ */ private void fillAllServiceTargets() { private void fillAllServiceTargets() { if (mParkingDirectShareTargets.isEmpty()) { return; } int maxRankedTargets = mChooserListCommunicator.getMaxRankedTargets(); int maxRankedTargets = mChooserListCommunicator.getMaxRankedTargets(); List<ComponentName> topComponentNames = getTopComponentNames(maxRankedTargets); List<ComponentName> topComponentNames = getTopComponentNames(maxRankedTargets); // Append all remaining targets of top recommended components into direct share row. // Append all remaining targets of top recommended components into direct share row. Loading @@ -576,16 +586,18 @@ public class ChooserListAdapter extends ResolverListAdapter { mParkingDirectShareTargets.remove(component); mParkingDirectShareTargets.remove(component); } } // Append all remaining shortcuts targets into direct share row. // Append all remaining shortcuts targets into direct share row. List<ChooserTargetInfo> remainingTargets = new ArrayList<>(); mParkingDirectShareTargets.entrySet().stream() mParkingDirectShareTargets.entrySet().stream() .filter(entry -> mShortcutComponents.contains(entry.getKey())) .filter(entry -> mShortcutComponents.contains(entry.getKey())) .map(entry -> entry.getValue()) .map(entry -> entry.getValue()) .map(pair -> pair.first) .map(pair -> pair.first) .forEach(remainingTargets::addAll); .forEach(targets -> { remainingTargets.sort( for (ChooserTargetInfo target : targets) { (t1, t2) -> -Float.compare(t1.getModifiedScore(), t2.getModifiedScore())); if (!checkDuplicateTarget(target)) { mServiceTargets.addAll(remainingTargets); mServiceTargets.add(target); mNumShortcutResults += remainingTargets.size(); mNumShortcutResults++; } } }); mParkingDirectShareTargets.clear(); mParkingDirectShareTargets.clear(); } } Loading Loading
core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -163,6 +163,9 @@ class AppPredictionServiceResolverComparator extends AbstractResolverComparator @Override @Override List<ComponentName> getTopComponentNames(int topK) { List<ComponentName> getTopComponentNames(int topK) { if (mResolverRankerService != null) { return mResolverRankerService.getTopComponentNames(topK); } return mTargetRanks.entrySet().stream() return mTargetRanks.entrySet().stream() .sorted(Entry.comparingByValue()) .sorted(Entry.comparingByValue()) .limit(topK) .limit(topK) Loading
core/java/com/android/internal/app/ChooserListAdapter.java +22 −10 Original line number Original line Diff line number Diff line Loading @@ -207,6 +207,9 @@ public class ChooserListAdapter extends ResolverListAdapter { if (mListViewDataChanged) { if (mListViewDataChanged) { if (mAppendDirectShareEnabled) { if (mAppendDirectShareEnabled) { appendServiceTargetsWithQuota(); appendServiceTargetsWithQuota(); if (mPendingChooserTargetService.isEmpty()) { fillAllServiceTargets(); } } } super.notifyDataSetChanged(); super.notifyDataSetChanged(); } } Loading Loading @@ -488,13 +491,14 @@ public class ChooserListAdapter extends ResolverListAdapter { Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos, Map<ChooserTarget, ShortcutInfo> directShareToShortcutInfos, List<ChooserActivity.ChooserTargetServiceConnection> List<ChooserActivity.ChooserTargetServiceConnection> pendingChooserTargetServiceConnections) { pendingChooserTargetServiceConnections) { ComponentName origComponentName = origTarget.getResolvedComponentName(); ComponentName origComponentName = origTarget != null ? origTarget.getResolvedComponentName() : !targets.isEmpty() ? targets.get(0).getComponentName() : null; mPendingChooserTargetService = pendingChooserTargetServiceConnections.stream() mPendingChooserTargetService = pendingChooserTargetServiceConnections.stream() .map(ChooserActivity.ChooserTargetServiceConnection::getComponentName) .map(ChooserActivity.ChooserTargetServiceConnection::getComponentName) .filter(componentName -> !componentName.equals(origComponentName)) .filter(componentName -> !componentName.equals(origComponentName)) .collect(Collectors.toSet()); .collect(Collectors.toSet()); // Park targets in memory // Park targets in memory if (!targets.isEmpty() && !mParkingDirectShareTargets.containsKey(origComponentName)) { if (!targets.isEmpty()) { final boolean isShortcutResult = final boolean isShortcutResult = (targetType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER (targetType == TARGET_TYPE_SHORTCUTS_FROM_SHORTCUT_MANAGER || targetType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE); || targetType == TARGET_TYPE_SHORTCUTS_FROM_PREDICTION_SERVICE); Loading @@ -509,8 +513,11 @@ public class ChooserListAdapter extends ResolverListAdapter { : null)) : null)) ) ) .collect(Collectors.toList()); .collect(Collectors.toList()); mParkingDirectShareTargets.put(origComponentName, Pair<List<ChooserTargetInfo>, Integer> parkingTargetInfoPair = new Pair<>(parkingTargetInfos, 0)); mParkingDirectShareTargets.getOrDefault(origComponentName, new Pair<>(new ArrayList<>(), 0)); parkingTargetInfoPair.first.addAll(parkingTargetInfos); mParkingDirectShareTargets.put(origComponentName, parkingTargetInfoPair); if (isShortcutResult) { if (isShortcutResult) { mShortcutComponents.add(origComponentName); mShortcutComponents.add(origComponentName); } } Loading Loading @@ -558,6 +565,9 @@ public class ChooserListAdapter extends ResolverListAdapter { * Append all remaining targets (parking in memory) into direct share row as per their ranking. * Append all remaining targets (parking in memory) into direct share row as per their ranking. */ */ private void fillAllServiceTargets() { private void fillAllServiceTargets() { if (mParkingDirectShareTargets.isEmpty()) { return; } int maxRankedTargets = mChooserListCommunicator.getMaxRankedTargets(); int maxRankedTargets = mChooserListCommunicator.getMaxRankedTargets(); List<ComponentName> topComponentNames = getTopComponentNames(maxRankedTargets); List<ComponentName> topComponentNames = getTopComponentNames(maxRankedTargets); // Append all remaining targets of top recommended components into direct share row. // Append all remaining targets of top recommended components into direct share row. Loading @@ -576,16 +586,18 @@ public class ChooserListAdapter extends ResolverListAdapter { mParkingDirectShareTargets.remove(component); mParkingDirectShareTargets.remove(component); } } // Append all remaining shortcuts targets into direct share row. // Append all remaining shortcuts targets into direct share row. List<ChooserTargetInfo> remainingTargets = new ArrayList<>(); mParkingDirectShareTargets.entrySet().stream() mParkingDirectShareTargets.entrySet().stream() .filter(entry -> mShortcutComponents.contains(entry.getKey())) .filter(entry -> mShortcutComponents.contains(entry.getKey())) .map(entry -> entry.getValue()) .map(entry -> entry.getValue()) .map(pair -> pair.first) .map(pair -> pair.first) .forEach(remainingTargets::addAll); .forEach(targets -> { remainingTargets.sort( for (ChooserTargetInfo target : targets) { (t1, t2) -> -Float.compare(t1.getModifiedScore(), t2.getModifiedScore())); if (!checkDuplicateTarget(target)) { mServiceTargets.addAll(remainingTargets); mServiceTargets.add(target); mNumShortcutResults += remainingTargets.size(); mNumShortcutResults++; } } }); mParkingDirectShareTargets.clear(); mParkingDirectShareTargets.clear(); } } Loading