Adds annotations to Intent, and enables ChooserActivity to rank apps
according to annotations.

Test: Unit tests and manul tests. More unit tests to be added.
Change-Id: I3cbfd0cc10007290585fa3e7e3c92e1731f1f7b8
diff --git a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
index 8385b69..aab4698 100644
--- a/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
+++ b/core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java
@@ -124,7 +124,7 @@
     }
 
     @Test
-    public void updateChooserCountsAfterUserSelection() throws InterruptedException {
+    public void updateChooserCountsAndModelAfterUserSelection() throws InterruptedException {
         Intent sendIntent = createSendImageIntent();
         List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(2);
 
@@ -142,19 +142,15 @@
         sOverrides.onSafelyStartCallback = targetInfo -> {
             return true;
         };
-        String action = sendIntent.getAction();
-        String annotation = sendIntent.getType();
         ResolveInfo toChoose = resolvedComponentInfos.get(0).getResolveInfoAt(0);
-        String packageName = toChoose.activityInfo.packageName;
-        long toChooseCount = getCount(usm, packageName, action, annotation);
         onView(withText(toChoose.activityInfo.name))
                 .perform(click());
         waitForIdle();
         verify(sOverrides.resolverListController, times(1))
+                .updateChooserCounts(Mockito.anyString(), Mockito.anyInt(), Mockito.anyString());
+        verify(sOverrides.resolverListController, times(1))
                 .updateModel(toChoose.activityInfo.getComponentName());
         assertThat(activity.getIsSelected(), is(true));
-        long updatedCount = getCount(usm, packageName, action, annotation);
-        assertThat(updatedCount, is(toChooseCount + 1l));
     }
 
     @Test