summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2016-06-17 13:47:40 -0700
committerMakoto Onuki <omakoto@google.com>2016-06-20 09:28:05 -0700
commit4d6b87ffdf06df3303239130ced685bc1a3fae50 (patch)
tree72c2c443ee212712c5381398b13690c1a7d22dfd /core/java
parenta65d8b660986520a8d7b6ec4c363ce13e4560667 (diff)
Launcher shortcut callback should deliver manifest shortcuts too
- Also include "activity" in the key fields, as this is now an important field. - Also optimize ShortcutInfo parceling for the "key field only" case. Bug 29394043 Bug 29451629 Change-Id: I61b2bc2f61ad6ebdcbaf6d02f1bd88777c45a7f0
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/pm/LauncherApps.java13
-rw-r--r--core/java/android/content/pm/ShortcutInfo.java27
2 files changed, 29 insertions, 11 deletions
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index 6cb50fc1576b..a76bf2462121 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -171,8 +171,9 @@ public class LauncherApps {
* as defined in {@link #hasShortcutHostPermission()}, will receive it.
*
* @param packageName The name of the package that has the shortcuts.
- * @param shortcuts all shortcuts from the package (dynamic and/or pinned). Only "key"
- * information will be provided, as defined in {@link ShortcutInfo#hasKeyFieldsOnly()}.
+ * @param shortcuts all shortcuts from the package (dynamic, manifest and/or pinned).
+ * Only "key" information will be provided, as defined in
+ * {@link ShortcutInfo#hasKeyFieldsOnly()}.
* @param user The UserHandle of the profile that generated the change.
*/
public void onShortcutsChanged(@NonNull String packageName,
@@ -199,6 +200,10 @@ public class LauncherApps {
*/
public static final int FLAG_GET_MANIFEST = 1 << 3;
+ /** @hide */
+ public static final int FLAG_GET_ALL_KINDS =
+ FLAG_GET_DYNAMIC | FLAG_GET_PINNED | FLAG_GET_MANIFEST;
+
/**
* Requests "key" fields only. See {@link ShortcutInfo#hasKeyFieldsOnly()} for which
* fields are available.
@@ -485,7 +490,7 @@ public class LauncherApps {
final ShortcutQuery q = new ShortcutQuery();
q.setPackage(packageName);
q.setShortcutIds(ids);
- q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED);
+ q.setQueryFlags(ShortcutQuery.FLAG_GET_ALL_KINDS);
return getShortcuts(q, user);
}
@@ -526,7 +531,7 @@ public class LauncherApps {
final ShortcutQuery q = new ShortcutQuery();
q.setPackage(packageName);
q.setShortcutIds(Arrays.asList(shortcutId));
- q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED);
+ q.setQueryFlags(ShortcutQuery.FLAG_GET_ALL_KINDS);
final List<ShortcutInfo> shortcuts = getShortcuts(q, user);
return shortcuts.size() > 0 ? shortcuts.get(0).getIconResourceId() : 0;
diff --git a/core/java/android/content/pm/ShortcutInfo.java b/core/java/android/content/pm/ShortcutInfo.java
index 064b9090c444..8492fd8ceae2 100644
--- a/core/java/android/content/pm/ShortcutInfo.java
+++ b/core/java/android/content/pm/ShortcutInfo.java
@@ -294,6 +294,7 @@ public final class ShortcutInfo implements Parcelable {
mUserId = source.mUserId;
mId = source.mId;
mPackageName = source.mPackageName;
+ mActivity = source.mActivity;
mFlags = source.mFlags;
mLastChangedTimestamp = source.mLastChangedTimestamp;
@@ -301,7 +302,6 @@ public final class ShortcutInfo implements Parcelable {
mIconResId = source.mIconResId;
if ((cloneFlags & CLONE_REMOVE_NON_KEY_INFO) == 0) {
- mActivity = source.mActivity;
if ((cloneFlags & CLONE_REMOVE_ICON) == 0) {
mIcon = source.mIcon;
@@ -1252,6 +1252,7 @@ public final class ShortcutInfo implements Parcelable {
* <ul>
* <li>{@link #getId()}
* <li>{@link #getPackage()}
+ * <li>{@link #getActivity()}
* <li>{@link #getLastChangedTimestamp()}
* <li>{@link #isDynamic()}
* <li>{@link #isPinned()}
@@ -1403,6 +1404,14 @@ public final class ShortcutInfo implements Parcelable {
mId = source.readString();
mPackageName = source.readString();
mActivity = source.readParcelable(cl);
+ mFlags = source.readInt();
+ mIconResId = source.readInt();
+ mLastChangedTimestamp = source.readLong();
+
+ if (source.readInt() == 0) {
+ return; // key information only.
+ }
+
mIcon = source.readParcelable(cl);
mTitle = source.readCharSequence();
mTitleResId = source.readInt();
@@ -1414,9 +1423,6 @@ public final class ShortcutInfo implements Parcelable {
mIntentPersistableExtras = source.readParcelable(cl);
mRank = source.readInt();
mExtras = source.readParcelable(cl);
- mLastChangedTimestamp = source.readLong();
- mFlags = source.readInt();
- mIconResId = source.readInt();
mBitmapPath = source.readString();
mIconResName = source.readString();
@@ -1441,6 +1447,16 @@ public final class ShortcutInfo implements Parcelable {
dest.writeString(mId);
dest.writeString(mPackageName);
dest.writeParcelable(mActivity, flags);
+ dest.writeInt(mFlags);
+ dest.writeInt(mIconResId);
+ dest.writeLong(mLastChangedTimestamp);
+
+ if (hasKeyFieldsOnly()) {
+ dest.writeInt(0);
+ return;
+ }
+ dest.writeInt(1);
+
dest.writeParcelable(mIcon, flags);
dest.writeCharSequence(mTitle);
dest.writeInt(mTitleResId);
@@ -1453,9 +1469,6 @@ public final class ShortcutInfo implements Parcelable {
dest.writeParcelable(mIntentPersistableExtras, flags);
dest.writeInt(mRank);
dest.writeParcelable(mExtras, flags);
- dest.writeLong(mLastChangedTimestamp);
- dest.writeInt(mFlags);
- dest.writeInt(mIconResId);
dest.writeString(mBitmapPath);
dest.writeString(mIconResName);