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

Commit 58fc95dc authored by Hakan Seyalioglu's avatar Hakan Seyalioglu
Browse files

Push chooser targets to the shortcut manager.

More info at go/direct-share-push

Test: Some basic testing currently in, more to be added.

Change-Id: I069f9779988c3eca2c4d8b83ec62501983854355
parent 592637dc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -10103,10 +10103,12 @@ package android.content.pm {
    ctor public LauncherApps.ShortcutQuery();
    method public android.content.pm.LauncherApps.ShortcutQuery setActivity(android.content.ComponentName);
    method public android.content.pm.LauncherApps.ShortcutQuery setChangedSince(long);
    method public android.content.pm.LauncherApps.ShortcutQuery setIntent(android.content.Intent);
    method public android.content.pm.LauncherApps.ShortcutQuery setPackage(java.lang.String);
    method public android.content.pm.LauncherApps.ShortcutQuery setQueryFlags(int);
    method public android.content.pm.LauncherApps.ShortcutQuery setShortcutIds(java.util.List<java.lang.String>);
    field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
    field public static final int FLAG_MATCH_CHOOSER = 16; // 0x10
    field public static final int FLAG_MATCH_DYNAMIC = 1; // 0x1
    field public static final int FLAG_MATCH_MANIFEST = 8; // 0x8
    field public static final int FLAG_MATCH_PINNED = 2; // 0x2
@@ -10645,6 +10647,9 @@ package android.content.pm {
    method public int describeContents();
    method public android.content.ComponentName getActivity();
    method public java.util.Set<java.lang.String> getCategories();
    method public android.content.ComponentName[] getChooserComponentNames();
    method public android.os.PersistableBundle getChooserExtras();
    method public android.content.IntentFilter[] getChooserIntentFilters();
    method public java.lang.CharSequence getDisabledMessage();
    method public android.os.PersistableBundle getExtras();
    method public java.lang.String getId();
@@ -10657,6 +10662,7 @@ package android.content.pm {
    method public java.lang.CharSequence getShortLabel();
    method public android.os.UserHandle getUserHandle();
    method public boolean hasKeyFieldsOnly();
    method public boolean isChooser();
    method public boolean isDeclaredInManifest();
    method public boolean isDynamic();
    method public boolean isEnabled();
@@ -10669,9 +10675,11 @@ package android.content.pm {
  public static class ShortcutInfo.Builder {
    ctor public ShortcutInfo.Builder(android.content.Context, java.lang.String);
    method public android.content.pm.ShortcutInfo.Builder addChooserIntentFilter(android.content.IntentFilter, android.content.ComponentName);
    method public android.content.pm.ShortcutInfo build();
    method public android.content.pm.ShortcutInfo.Builder setActivity(android.content.ComponentName);
    method public android.content.pm.ShortcutInfo.Builder setCategories(java.util.Set<java.lang.String>);
    method public android.content.pm.ShortcutInfo.Builder setChooserExtras(android.os.PersistableBundle);
    method public android.content.pm.ShortcutInfo.Builder setDisabledMessage(java.lang.CharSequence);
    method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
    method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
+8 −0
Original line number Diff line number Diff line
@@ -10640,10 +10640,12 @@ package android.content.pm {
    ctor public LauncherApps.ShortcutQuery();
    method public android.content.pm.LauncherApps.ShortcutQuery setActivity(android.content.ComponentName);
    method public android.content.pm.LauncherApps.ShortcutQuery setChangedSince(long);
    method public android.content.pm.LauncherApps.ShortcutQuery setIntent(android.content.Intent);
    method public android.content.pm.LauncherApps.ShortcutQuery setPackage(java.lang.String);
    method public android.content.pm.LauncherApps.ShortcutQuery setQueryFlags(int);
    method public android.content.pm.LauncherApps.ShortcutQuery setShortcutIds(java.util.List<java.lang.String>);
    field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
    field public static final int FLAG_MATCH_CHOOSER = 16; // 0x10
    field public static final int FLAG_MATCH_DYNAMIC = 1; // 0x1
    field public static final int FLAG_MATCH_MANIFEST = 8; // 0x8
    field public static final int FLAG_MATCH_PINNED = 2; // 0x2
@@ -11267,6 +11269,9 @@ package android.content.pm {
    method public int describeContents();
    method public android.content.ComponentName getActivity();
    method public java.util.Set<java.lang.String> getCategories();
    method public android.content.ComponentName[] getChooserComponentNames();
    method public android.os.PersistableBundle getChooserExtras();
    method public android.content.IntentFilter[] getChooserIntentFilters();
    method public java.lang.CharSequence getDisabledMessage();
    method public android.os.PersistableBundle getExtras();
    method public java.lang.String getId();
@@ -11279,6 +11284,7 @@ package android.content.pm {
    method public java.lang.CharSequence getShortLabel();
    method public android.os.UserHandle getUserHandle();
    method public boolean hasKeyFieldsOnly();
    method public boolean isChooser();
    method public boolean isDeclaredInManifest();
    method public boolean isDynamic();
    method public boolean isEnabled();
@@ -11291,9 +11297,11 @@ package android.content.pm {
  public static class ShortcutInfo.Builder {
    ctor public ShortcutInfo.Builder(android.content.Context, java.lang.String);
    method public android.content.pm.ShortcutInfo.Builder addChooserIntentFilter(android.content.IntentFilter, android.content.ComponentName);
    method public android.content.pm.ShortcutInfo build();
    method public android.content.pm.ShortcutInfo.Builder setActivity(android.content.ComponentName);
    method public android.content.pm.ShortcutInfo.Builder setCategories(java.util.Set<java.lang.String>);
    method public android.content.pm.ShortcutInfo.Builder setChooserExtras(android.os.PersistableBundle);
    method public android.content.pm.ShortcutInfo.Builder setDisabledMessage(java.lang.CharSequence);
    method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
    method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
+8 −0
Original line number Diff line number Diff line
@@ -10135,10 +10135,12 @@ package android.content.pm {
    ctor public LauncherApps.ShortcutQuery();
    method public android.content.pm.LauncherApps.ShortcutQuery setActivity(android.content.ComponentName);
    method public android.content.pm.LauncherApps.ShortcutQuery setChangedSince(long);
    method public android.content.pm.LauncherApps.ShortcutQuery setIntent(android.content.Intent);
    method public android.content.pm.LauncherApps.ShortcutQuery setPackage(java.lang.String);
    method public android.content.pm.LauncherApps.ShortcutQuery setQueryFlags(int);
    method public android.content.pm.LauncherApps.ShortcutQuery setShortcutIds(java.util.List<java.lang.String>);
    field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4
    field public static final int FLAG_MATCH_CHOOSER = 16; // 0x10
    field public static final int FLAG_MATCH_DYNAMIC = 1; // 0x1
    field public static final int FLAG_MATCH_MANIFEST = 8; // 0x8
    field public static final int FLAG_MATCH_PINNED = 2; // 0x2
@@ -10681,6 +10683,9 @@ package android.content.pm {
    method public int describeContents();
    method public android.content.ComponentName getActivity();
    method public java.util.Set<java.lang.String> getCategories();
    method public android.content.ComponentName[] getChooserComponentNames();
    method public android.os.PersistableBundle getChooserExtras();
    method public android.content.IntentFilter[] getChooserIntentFilters();
    method public java.lang.CharSequence getDisabledMessage();
    method public android.os.PersistableBundle getExtras();
    method public java.lang.String getId();
@@ -10693,6 +10698,7 @@ package android.content.pm {
    method public java.lang.CharSequence getShortLabel();
    method public android.os.UserHandle getUserHandle();
    method public boolean hasKeyFieldsOnly();
    method public boolean isChooser();
    method public boolean isDeclaredInManifest();
    method public boolean isDynamic();
    method public boolean isEnabled();
@@ -10705,9 +10711,11 @@ package android.content.pm {
  public static class ShortcutInfo.Builder {
    ctor public ShortcutInfo.Builder(android.content.Context, java.lang.String);
    method public android.content.pm.ShortcutInfo.Builder addChooserIntentFilter(android.content.IntentFilter, android.content.ComponentName);
    method public android.content.pm.ShortcutInfo build();
    method public android.content.pm.ShortcutInfo.Builder setActivity(android.content.ComponentName);
    method public android.content.pm.ShortcutInfo.Builder setCategories(java.util.Set<java.lang.String>);
    method public android.content.pm.ShortcutInfo.Builder setChooserExtras(android.os.PersistableBundle);
    method public android.content.pm.ShortcutInfo.Builder setDisabledMessage(java.lang.CharSequence);
    method public android.content.pm.ShortcutInfo.Builder setExtras(android.os.PersistableBundle);
    method public android.content.pm.ShortcutInfo.Builder setIcon(android.graphics.drawable.Icon);
+2 −1
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@ interface ILauncherApps {
            String callingPackage, String packageName, int flags, in UserHandle user);

    ParceledListSlice getShortcuts(String callingPackage, long changedSince, String packageName,
            in List shortcutIds, in ComponentName componentName, int flags, in UserHandle user);
            in List shortcutIds, in ComponentName componentName, in Intent intent, int flags,
            in UserHandle user);
    void pinShortcuts(String callingPackage, String packageName, in List<String> shortcutIds,
            in UserHandle user);
    boolean startShortcut(String callingPackage, String packageName, String id,
+25 −2
Original line number Diff line number Diff line
@@ -275,7 +275,18 @@ public class LauncherApps {
        @Deprecated
        public static final int FLAG_GET_MANIFEST = FLAG_MATCH_MANIFEST;

        /** @hide */
        /**
         * Include chooser shortcuts in the result.
         * STOPSHIP TODO: Unless explicitly requesting chooser fields, we should strip out chooser
         *           relevant fields from the Shortcut. This should also be adequately documented.
         */
        public static final int FLAG_MATCH_CHOOSER = 1 << 4;

        /**
         * Does not retrieve CHOOSER only shortcuts.
         * TODO: Add another flag for MATCH_ALL_PINNED
         * @hide
         */
        public static final int FLAG_MATCH_ALL_KINDS =
                FLAG_GET_DYNAMIC | FLAG_GET_PINNED | FLAG_GET_MANIFEST;

@@ -308,6 +319,7 @@ public class LauncherApps {
                        FLAG_MATCH_DYNAMIC,
                        FLAG_MATCH_PINNED,
                        FLAG_MATCH_MANIFEST,
                        FLAG_MATCH_CHOOSER,
                        FLAG_GET_KEY_FIELDS_ONLY,
                })
        @Retention(RetentionPolicy.SOURCE)
@@ -324,6 +336,9 @@ public class LauncherApps {
        @Nullable
        ComponentName mActivity;

        @Nullable
        Intent mIntent;

        @QueryFlags
        int mQueryFlags;

@@ -367,6 +382,14 @@ public class LauncherApps {
            return this;
        }

        /**
         * If non-null, returns only shortcuts with intent filters that match this intent.
         */
        public ShortcutQuery setIntent(@Nullable Intent intent) {
            mIntent = intent;
            return this;
        }

        /**
         * Set query options.  At least one of the {@code MATCH} flags should be set.  Otherwise,
         * no shortcuts will be returned.
@@ -681,7 +704,7 @@ public class LauncherApps {
        try {
            return mService.getShortcuts(mContext.getPackageName(),
                    query.mChangedSince, query.mPackage, query.mShortcutIds, query.mActivity,
                    query.mQueryFlags, user)
                    query.mIntent, query.mQueryFlags, user)
                    .getList();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
Loading