Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bf67a29 authored by Kang Li's avatar Kang Li Committed by Android (Google) Code Review
Browse files

Merge "Adds annotations to Intent, and enables ChooserActivity to rank apps...

Merge "Adds annotations to Intent, and enables ChooserActivity to rank apps according to annotations."
parents 38b17ad2 9fa2a2cd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8959,6 +8959,7 @@ package android.content {
    field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
    field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
    field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
    field public static final java.lang.String EXTRA_CONTENT_ANNOTATIONS = "android.intent.extra.CONTENT_ANNOTATIONS";
    field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
    field public static final java.lang.String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
    field public static final int EXTRA_DOCK_STATE_CAR = 2; // 0x2
+1 −0
Original line number Diff line number Diff line
@@ -9335,6 +9335,7 @@ package android.content {
    field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
    field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
    field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
    field public static final java.lang.String EXTRA_CONTENT_ANNOTATIONS = "android.intent.extra.CONTENT_ANNOTATIONS";
    field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
    field public static final java.lang.String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
    field public static final int EXTRA_DOCK_STATE_CAR = 2; // 0x2
+1 −0
Original line number Diff line number Diff line
@@ -8984,6 +8984,7 @@ package android.content {
    field public static final java.lang.String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
    field public static final java.lang.String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
    field public static final java.lang.String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER = "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
    field public static final java.lang.String EXTRA_CONTENT_ANNOTATIONS = "android.intent.extra.CONTENT_ANNOTATIONS";
    field public static final java.lang.String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
    field public static final java.lang.String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
    field public static final int EXTRA_DOCK_STATE_CAR = 2; // 0x2
+46 −0
Original line number Diff line number Diff line
@@ -3842,6 +3842,52 @@ public class Intent implements Parcelable, Cloneable {
    public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
            = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";

    /**
     * An {@code ArrayList} of {@code String} annotations describing content for
     * {@link #ACTION_CHOOSER}.
     *
     * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
     * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
     *
     * <p>Annotations should describe the major components or topics of the content. It is up to
     * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
     * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
     * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
     * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
     * use the following annotations when applicable:</p>
     * <ul>
     *     <li>"product": represents that the topic of the content is mainly about products, e.g.,
     *     health & beauty, and office supplies.</li>
     *     <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
     *     happy, and sad.</li>
     *     <li>"person": represents that the topic of the content is mainly about persons, e.g.,
     *     face, finger, standing, and walking.</li>
     *     <li>"child": represents that the topic of the content is mainly about children, e.g.,
     *     child, and baby.</li>
     *     <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
     *     <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
     *     <li>"party": represents that the topic of the content is mainly about parties.</li>
     *     <li>"animal": represent that the topic of the content is mainly about animals.</li>
     *     <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
     *     flowers.</li>
     *     <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
     *     <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
     *     sunglasses, jewelry, handbags and clothing.</li>
     *     <li>"material": represents that the topic of the content is mainly about materials, e.g.,
     *     paper, and silk.</li>
     *     <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
     *     cars, and boats.</li>
     *     <li>"document": represents that the topic of the content is mainly about documents, e.g.
     *     posters.</li>
     *     <li>"design": represents that the topic of the content is mainly about design, e.g. arts
     *     and designs of houses.</li>
     *     <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
     *     Christmas and Thanksgiving.</li>
     * </ul>
     */
    public static final String EXTRA_CONTENT_ANNOTATIONS
            = "android.intent.extra.CONTENT_ANNOTATIONS";

    /**
     * A {@link ResultReceiver} used to return data back to the sender.
     *
+5 −14
Original line number Diff line number Diff line
@@ -418,7 +418,7 @@ public class ChooserActivity extends ResolverActivity {
                }
            }
        }
        updateChooserCounts(target);
        updateModelAndChooserCounts(target);
        return super.onTargetSelected(target, alwaysCheck);
    }

@@ -575,27 +575,18 @@ public class ChooserActivity extends ResolverActivity {
        // Do nothing. We'll send the voice stuff ourselves.
    }

    void updateChooserCounts(TargetInfo info) {
    void updateModelAndChooserCounts(TargetInfo info) {
        if (info != null) {
            UsageStatsManager usageStatsManager =
                    (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
            if (usageStatsManager == null) {
                if (DEBUG) {
                    Log.d(TAG, "Can not start UsageStatsManager");
                }
                return;
            }
            final ResolveInfo ri = info.getResolveInfo();
            Intent targetIntent = getTargetIntent();
            if (ri != null && ri.activityInfo != null && targetIntent != null) {
                usageStatsManager.reportChooserSelection(ri.activityInfo.packageName, getUserId(),
                        targetIntent.getType(), null, targetIntent.getAction());
                if (mAdapter != null) {
                    mAdapter.updateModel(info.getResolvedComponentName());
                    mAdapter.updateChooserCounts(ri.activityInfo.packageName, getUserId(),
                            targetIntent.getAction());
                }
                if (DEBUG) {
                    Log.d(TAG, "ResolveInfo Package is " + ri.activityInfo.packageName);
                    Log.d(TAG, "Annotation to be updated is " + targetIntent.getType());
                    Log.d(TAG, "Action to be updated is " + targetIntent.getAction());
                }
            } else if(DEBUG) {
@@ -618,7 +609,7 @@ public class ChooserActivity extends ResolverActivity {
        } else {
            TargetInfo clonedTarget = selectedTarget.cloneFilledIn(matchingIntent, 0);
            if (super.onTargetSelected(clonedTarget, false)) {
                updateChooserCounts(clonedTarget);
                updateModelAndChooserCounts(clonedTarget);
                finish();
                return;
            }
Loading