Restrict ChooserTargets provided by a single service

Only allow one row's worth of targets from any one
ChooserTargetService and lower the weight for app recency in resolver
sorting. Along with a previous change to only consider the past 1 week
of app activity, this is to help improve the quality of direct share
targets shown.

Bug 26562857

Change-Id: I0f9a8ca8ccfb655261421e29fef7909cadd318f1
This commit is contained in:
Adam Powell
2016-02-03 16:01:09 -08:00
parent 47148a7987
commit bba0030a85
2 changed files with 3 additions and 2 deletions

View File

@@ -761,6 +761,7 @@ public class ChooserActivity extends ResolverActivity {
public static final int TARGET_STANDARD = 2;
private static final int MAX_SERVICE_TARGETS = 8;
private static final int MAX_TARGETS_PER_SERVICE = 4;
private final List<ChooserTargetInfo> mServiceTargets = new ArrayList<>();
private final List<TargetInfo> mCallerTargets = new ArrayList<>();
@@ -925,7 +926,7 @@ public class ChooserActivity extends ResolverActivity {
final float parentScore = getScore(origTarget);
Collections.sort(targets, mBaseTargetComparator);
float lastScore = 0;
for (int i = 0, N = targets.size(); i < N; i++) {
for (int i = 0, N = Math.min(targets.size(), MAX_TARGETS_PER_SERVICE); i < N; i++) {
final ChooserTarget target = targets.get(i);
float targetScore = target.getScore();
targetScore *= parentScore;

View File

@@ -52,7 +52,7 @@ class ResolverComparator implements Comparator<ResolvedComponentInfo> {
private static final long RECENCY_TIME_PERIOD = 1000 * 60 * 60 * 12;
private static final float RECENCY_MULTIPLIER = 3.f;
private static final float RECENCY_MULTIPLIER = 2.f;
private final Collator mCollator;
private final boolean mHttp;