Bug 880230 - Use ComponentName when sorting Activities. r=lucasr
authorWes Johnston <wjohnston@mozilla.com>
Mon, 25 Nov 2013 09:45:43 -0800
changeset 157489 b738cfb4e9d42394a9a121dab42b482dfa3264df
parent 157488 3fdcc69225209b2df842850296a804f451143e81
child 157490 d9ef33623670590f2c24bfdc8a1da1444c205e49
push id25714
push usercbook@mozilla.com
push dateTue, 26 Nov 2013 11:39:03 +0000
treeherdermozilla-central@4a8c40940659 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs880230
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 880230 - Use ComponentName when sorting Activities. r=lucasr
mobile/android/base/widget/ActivityChooserModel.java
--- a/mobile/android/base/widget/ActivityChooserModel.java
+++ b/mobile/android/base/widget/ActivityChooserModel.java
@@ -956,25 +956,30 @@ public class ActivityChooserModel extend
             Map<String, ActivityResolveInfo> packageNameToActivityMap =
                 mPackageNameToActivityMap;
             packageNameToActivityMap.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;
+
+                // Make sure we're using a non-ambiguous name here
+                ComponentName chosenName = new ComponentName(
+                        activity.resolveInfo.activityInfo.packageName,
+                        activity.resolveInfo.activityInfo.name);
+                String packageName = chosenName.flattenToString();
                 packageNameToActivityMap.put(packageName, 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();
+                String packageName = historicalRecord.activity.flattenToString();
                 ActivityResolveInfo activity = packageNameToActivityMap.get(packageName);
                 if (activity != null) {
                     activity.weight += historicalRecord.weight * nextRecordWeight;
                     nextRecordWeight = nextRecordWeight * WEIGHT_DECAY_COEFFICIENT;
                 }
             }
 
             Collections.sort(activities);