Loading core/java/android/content/pm/LauncherApps.java +9 −4 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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. Loading Loading @@ -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); } Loading Loading @@ -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; Loading core/java/android/content/pm/ShortcutInfo.java +20 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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()} Loading Loading @@ -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(); Loading @@ -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(); Loading @@ -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); Loading @@ -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); Loading services/core/java/com/android/server/pm/LauncherAppsService.java +1 −2 Original line number Diff line number Diff line Loading @@ -775,8 +775,7 @@ public class LauncherAppsService extends SystemService { /* changedSince= */ 0, packageName, /* shortcutIds=*/ null, /* component= */ null, ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY | ShortcutQuery.FLAG_GET_PINNED | ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_ALL_KINDS , userId); try { listener.onShortcutChanged(user, packageName, Loading services/tests/servicestests/res/xml/shortcut_3.xml 0 → 100644 +56 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android" > <shortcut android:shortcutId="ms1" android:enabled="true" android:icon="@drawable/icon1" android:shortcutShortLabel="@string/shortcut_title1" android:shortcutLongLabel="@string/shortcut_text1" android:shortcutDisabledMessage="@string/shortcut_disabled_message1" > <intent android:action="action1" android:data="http://a.b.c/" > </intent> <categories android:name="android.shortcut.conversation" /> <categories android:name="android.shortcut.media" /> </shortcut> <shortcut android:shortcutId="ms2" android:enabled="true" android:icon="@drawable/icon2" android:shortcutShortLabel="@string/shortcut_title2" android:shortcutLongLabel="@string/shortcut_text2" android:shortcutDisabledMessage="@string/shortcut_disabled_message2" > <intent android:action="action2" android:data="http://a.b.c/2" > </intent> <categories android:name="android.shortcut.conversation" /> </shortcut> <shortcut android:shortcutId="ms3" android:enabled="true" android:icon="@drawable/icon3" android:shortcutShortLabel="@string/shortcut_title2" > <intent android:action="action3" /> </shortcut> </shortcuts> services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -532,7 +532,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { static { QUERY_ALL.setQueryFlags( ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED); ShortcutQuery.FLAG_GET_ALL_KINDS); } @Override Loading Loading @@ -1434,7 +1434,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected static ShortcutQuery buildAllQuery(String packageName) { final ShortcutQuery q = new ShortcutQuery(); q.setPackage(packageName); q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED); q.setQueryFlags(ShortcutQuery.FLAG_GET_ALL_KINDS); return q; } Loading @@ -1445,6 +1445,12 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { return q; } protected static ShortcutQuery buildQueryWithFlags(int queryFlags) { final ShortcutQuery q = new ShortcutQuery(); q.setQueryFlags(queryFlags); return q; } protected void backupAndRestore() { int prevUid = mInjectedCallingUid; Loading Loading
core/java/android/content/pm/LauncherApps.java +9 −4 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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. Loading Loading @@ -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); } Loading Loading @@ -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; Loading
core/java/android/content/pm/ShortcutInfo.java +20 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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()} Loading Loading @@ -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(); Loading @@ -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(); Loading @@ -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); Loading @@ -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); Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +1 −2 Original line number Diff line number Diff line Loading @@ -775,8 +775,7 @@ public class LauncherAppsService extends SystemService { /* changedSince= */ 0, packageName, /* shortcutIds=*/ null, /* component= */ null, ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY | ShortcutQuery.FLAG_GET_PINNED | ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_ALL_KINDS , userId); try { listener.onShortcutChanged(user, packageName, Loading
services/tests/servicestests/res/xml/shortcut_3.xml 0 → 100644 +56 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android" > <shortcut android:shortcutId="ms1" android:enabled="true" android:icon="@drawable/icon1" android:shortcutShortLabel="@string/shortcut_title1" android:shortcutLongLabel="@string/shortcut_text1" android:shortcutDisabledMessage="@string/shortcut_disabled_message1" > <intent android:action="action1" android:data="http://a.b.c/" > </intent> <categories android:name="android.shortcut.conversation" /> <categories android:name="android.shortcut.media" /> </shortcut> <shortcut android:shortcutId="ms2" android:enabled="true" android:icon="@drawable/icon2" android:shortcutShortLabel="@string/shortcut_title2" android:shortcutLongLabel="@string/shortcut_text2" android:shortcutDisabledMessage="@string/shortcut_disabled_message2" > <intent android:action="action2" android:data="http://a.b.c/2" > </intent> <categories android:name="android.shortcut.conversation" /> </shortcut> <shortcut android:shortcutId="ms3" android:enabled="true" android:icon="@drawable/icon3" android:shortcutShortLabel="@string/shortcut_title2" > <intent android:action="action3" /> </shortcut> </shortcuts>
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java +8 −2 Original line number Diff line number Diff line Loading @@ -532,7 +532,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { static { QUERY_ALL.setQueryFlags( ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED); ShortcutQuery.FLAG_GET_ALL_KINDS); } @Override Loading Loading @@ -1434,7 +1434,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { protected static ShortcutQuery buildAllQuery(String packageName) { final ShortcutQuery q = new ShortcutQuery(); q.setPackage(packageName); q.setQueryFlags(ShortcutQuery.FLAG_GET_DYNAMIC | ShortcutQuery.FLAG_GET_PINNED); q.setQueryFlags(ShortcutQuery.FLAG_GET_ALL_KINDS); return q; } Loading @@ -1445,6 +1445,12 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase { return q; } protected static ShortcutQuery buildQueryWithFlags(int queryFlags) { final ShortcutQuery q = new ShortcutQuery(); q.setQueryFlags(queryFlags); return q; } protected void backupAndRestore() { int prevUid = mInjectedCallingUid; Loading