* commit 'a4e1f4352149b15fa64e9b85928f0b1ba00486fb': Share pack historical sorting using wrong keys.
This commit is contained in:
@@ -938,29 +938,31 @@ public class ActivityChooserModel extends DataSetObservable {
|
||||
private final class DefaultSorter implements ActivitySorter {
|
||||
private static final float WEIGHT_DECAY_COEFFICIENT = 0.95f;
|
||||
|
||||
private final Map<String, ActivityResolveInfo> mPackageNameToActivityMap =
|
||||
new HashMap<String, ActivityResolveInfo>();
|
||||
private final Map<ComponentName, ActivityResolveInfo> mPackageNameToActivityMap =
|
||||
new HashMap<ComponentName, ActivityResolveInfo>();
|
||||
|
||||
public void sort(Intent intent, List<ActivityResolveInfo> activities,
|
||||
List<HistoricalRecord> historicalRecords) {
|
||||
Map<String, ActivityResolveInfo> packageNameToActivityMap =
|
||||
mPackageNameToActivityMap;
|
||||
packageNameToActivityMap.clear();
|
||||
Map<ComponentName, ActivityResolveInfo> componentNameToActivityMap =
|
||||
mPackageNameToActivityMap;
|
||||
componentNameToActivityMap.clear();
|
||||
|
||||
final int activityCount = activities.size();
|
||||
for (int i = 0; i < activityCount; i++) {
|
||||
ActivityResolveInfo activity = activities.get(i);
|
||||
activity.weight = 0.0f;
|
||||
String packageName = activity.resolveInfo.activityInfo.packageName;
|
||||
packageNameToActivityMap.put(packageName, activity);
|
||||
ComponentName componentName = new ComponentName(
|
||||
activity.resolveInfo.activityInfo.packageName,
|
||||
activity.resolveInfo.activityInfo.name);
|
||||
componentNameToActivityMap.put(componentName, activity);
|
||||
}
|
||||
|
||||
final int lastShareIndex = historicalRecords.size() - 1;
|
||||
float nextRecordWeight = 1;
|
||||
for (int i = lastShareIndex; i >= 0; i--) {
|
||||
HistoricalRecord historicalRecord = historicalRecords.get(i);
|
||||
String packageName = historicalRecord.activity.getPackageName();
|
||||
ActivityResolveInfo activity = packageNameToActivityMap.get(packageName);
|
||||
ComponentName componentName = historicalRecord.activity;
|
||||
ActivityResolveInfo activity = componentNameToActivityMap.get(componentName);
|
||||
if (activity != null) {
|
||||
activity.weight += historicalRecord.weight * nextRecordWeight;
|
||||
nextRecordWeight = nextRecordWeight * WEIGHT_DECAY_COEFFICIENT;
|
||||
|
||||
Reference in New Issue
Block a user