OSDN Git Service

Restrict ChooserTargets provided by a single service
authorAdam Powell <adamp@google.com>
Thu, 4 Feb 2016 00:01:09 +0000 (16:01 -0800)
committerAdam Powell <adamp@google.com>
Thu, 4 Feb 2016 18:40:41 +0000 (10:40 -0800)
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

core/java/com/android/internal/app/ChooserActivity.java
core/java/com/android/internal/app/ResolverComparator.java

index cf13a13..b0fb93b 100644 (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;
index 0ae21c6..03a3a38 100644 (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;