Loading core/api/current.txt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -12332,6 +12332,7 @@ package android.content.pm { method @Nullable public java.util.Set<java.lang.String> getCategories(); method @Nullable public java.util.Set<java.lang.String> getCategories(); method @Nullable public CharSequence getDisabledMessage(); method @Nullable public CharSequence getDisabledMessage(); method public int getDisabledReason(); method public int getDisabledReason(); method public int getExcludedFromSurfaces(); method @Nullable public android.os.PersistableBundle getExtras(); method @Nullable public android.os.PersistableBundle getExtras(); method @NonNull public String getId(); method @NonNull public String getId(); method @Nullable public android.content.Intent getIntent(); method @Nullable public android.content.Intent getIntent(); Loading @@ -12348,8 +12349,8 @@ package android.content.pm { method public boolean isDeclaredInManifest(); method public boolean isDeclaredInManifest(); method public boolean isDynamic(); method public boolean isDynamic(); method public boolean isEnabled(); method public boolean isEnabled(); method public boolean isExcludedFromSurfaces(int); method public boolean isImmutable(); method public boolean isImmutable(); method public boolean isIncludedIn(int); method public boolean isPinned(); method public boolean isPinned(); method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR; core/java/android/content/pm/ShortcutInfo.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -2241,10 +2241,20 @@ public final class ShortcutInfo implements Parcelable { } } /** /** * Return true if the shortcut is included in specified surface. * Return true if the shortcut is excluded from specified surface. */ */ public boolean isIncludedIn(@Surface int surface) { public boolean isExcludedFromSurfaces(@Surface int surface) { return (mExcludedSurfaces & surface) == 0; return (mExcludedSurfaces & surface) != 0; } /** * Returns a bitmask of all surfaces this shortcut is excluded from. * * @see ShortcutInfo.Builder#setExcludedFromSurfaces(int) */ @Surface public int getExcludedFromSurfaces() { return mExcludedSurfaces; } } /** /** Loading Loading @@ -2543,7 +2553,7 @@ public final class ShortcutInfo implements Parcelable { if (isLongLived()) { if (isLongLived()) { sb.append("Liv"); sb.append("Liv"); } } if (!isIncludedIn(SURFACE_LAUNCHER)) { if (isExcludedFromSurfaces(SURFACE_LAUNCHER)) { sb.append("Hid-L"); sb.append("Hid-L"); } } sb.append("]"); sb.append("]"); Loading services/core/java/com/android/server/pm/ShortcutPackage.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -338,7 +338,7 @@ class ShortcutPackage extends ShortcutPackageItem { public void ensureAllShortcutsVisibleToLauncher(@NonNull List<ShortcutInfo> shortcuts) { public void ensureAllShortcutsVisibleToLauncher(@NonNull List<ShortcutInfo> shortcuts) { for (ShortcutInfo shortcut : shortcuts) { for (ShortcutInfo shortcut : shortcuts) { if (!shortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER)) { if (shortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER)) { throw new IllegalArgumentException("Shortcut ID=" + shortcut.getId() throw new IllegalArgumentException("Shortcut ID=" + shortcut.getId() + " is hidden from launcher and may not be manipulated via APIs"); + " is hidden from launcher and may not be manipulated via APIs"); } } Loading Loading @@ -399,7 +399,7 @@ class ShortcutPackage extends ShortcutPackageItem { & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); } } if (!newShortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER)) { if (newShortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER)) { if (isAppSearchEnabled()) { if (isAppSearchEnabled()) { synchronized (mLock) { synchronized (mLock) { mTransientShortcuts.put(newShortcut.getId(), newShortcut); mTransientShortcuts.put(newShortcut.getId(), newShortcut); Loading Loading @@ -477,7 +477,7 @@ class ShortcutPackage extends ShortcutPackageItem { & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); } } if (!newShortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER)) { if (newShortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER)) { if (isAppSearchEnabled()) { if (isAppSearchEnabled()) { synchronized (mLock) { synchronized (mLock) { mTransientShortcuts.put(newShortcut.getId(), newShortcut); mTransientShortcuts.put(newShortcut.getId(), newShortcut); Loading services/core/java/com/android/server/pm/ShortcutService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -2228,7 +2228,7 @@ public class ShortcutService extends IShortcutService.Stub { Objects.requireNonNull(shortcut); Objects.requireNonNull(shortcut); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); Preconditions.checkArgument( Preconditions.checkArgument( shortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER), !shortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER), "Shortcut excluded from launcher cannot be pinned"); "Shortcut excluded from launcher cannot be pinned"); ret.complete(String.valueOf(requestPinItem( ret.complete(String.valueOf(requestPinItem( packageName, userId, shortcut, null, null, resultIntent))); packageName, userId, shortcut, null, null, resultIntent))); Loading Loading
core/api/current.txt +2 −1 Original line number Original line Diff line number Diff line Loading @@ -12332,6 +12332,7 @@ package android.content.pm { method @Nullable public java.util.Set<java.lang.String> getCategories(); method @Nullable public java.util.Set<java.lang.String> getCategories(); method @Nullable public CharSequence getDisabledMessage(); method @Nullable public CharSequence getDisabledMessage(); method public int getDisabledReason(); method public int getDisabledReason(); method public int getExcludedFromSurfaces(); method @Nullable public android.os.PersistableBundle getExtras(); method @Nullable public android.os.PersistableBundle getExtras(); method @NonNull public String getId(); method @NonNull public String getId(); method @Nullable public android.content.Intent getIntent(); method @Nullable public android.content.Intent getIntent(); Loading @@ -12348,8 +12349,8 @@ package android.content.pm { method public boolean isDeclaredInManifest(); method public boolean isDeclaredInManifest(); method public boolean isDynamic(); method public boolean isDynamic(); method public boolean isEnabled(); method public boolean isEnabled(); method public boolean isExcludedFromSurfaces(int); method public boolean isImmutable(); method public boolean isImmutable(); method public boolean isIncludedIn(int); method public boolean isPinned(); method public boolean isPinned(); method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.ShortcutInfo> CREATOR;
core/java/android/content/pm/ShortcutInfo.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -2241,10 +2241,20 @@ public final class ShortcutInfo implements Parcelable { } } /** /** * Return true if the shortcut is included in specified surface. * Return true if the shortcut is excluded from specified surface. */ */ public boolean isIncludedIn(@Surface int surface) { public boolean isExcludedFromSurfaces(@Surface int surface) { return (mExcludedSurfaces & surface) == 0; return (mExcludedSurfaces & surface) != 0; } /** * Returns a bitmask of all surfaces this shortcut is excluded from. * * @see ShortcutInfo.Builder#setExcludedFromSurfaces(int) */ @Surface public int getExcludedFromSurfaces() { return mExcludedSurfaces; } } /** /** Loading Loading @@ -2543,7 +2553,7 @@ public final class ShortcutInfo implements Parcelable { if (isLongLived()) { if (isLongLived()) { sb.append("Liv"); sb.append("Liv"); } } if (!isIncludedIn(SURFACE_LAUNCHER)) { if (isExcludedFromSurfaces(SURFACE_LAUNCHER)) { sb.append("Hid-L"); sb.append("Hid-L"); } } sb.append("]"); sb.append("]"); Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -338,7 +338,7 @@ class ShortcutPackage extends ShortcutPackageItem { public void ensureAllShortcutsVisibleToLauncher(@NonNull List<ShortcutInfo> shortcuts) { public void ensureAllShortcutsVisibleToLauncher(@NonNull List<ShortcutInfo> shortcuts) { for (ShortcutInfo shortcut : shortcuts) { for (ShortcutInfo shortcut : shortcuts) { if (!shortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER)) { if (shortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER)) { throw new IllegalArgumentException("Shortcut ID=" + shortcut.getId() throw new IllegalArgumentException("Shortcut ID=" + shortcut.getId() + " is hidden from launcher and may not be manipulated via APIs"); + " is hidden from launcher and may not be manipulated via APIs"); } } Loading Loading @@ -399,7 +399,7 @@ class ShortcutPackage extends ShortcutPackageItem { & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); } } if (!newShortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER)) { if (newShortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER)) { if (isAppSearchEnabled()) { if (isAppSearchEnabled()) { synchronized (mLock) { synchronized (mLock) { mTransientShortcuts.put(newShortcut.getId(), newShortcut); mTransientShortcuts.put(newShortcut.getId(), newShortcut); Loading Loading @@ -477,7 +477,7 @@ class ShortcutPackage extends ShortcutPackageItem { & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); } } if (!newShortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER)) { if (newShortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER)) { if (isAppSearchEnabled()) { if (isAppSearchEnabled()) { synchronized (mLock) { synchronized (mLock) { mTransientShortcuts.put(newShortcut.getId(), newShortcut); mTransientShortcuts.put(newShortcut.getId(), newShortcut); Loading
services/core/java/com/android/server/pm/ShortcutService.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -2228,7 +2228,7 @@ public class ShortcutService extends IShortcutService.Stub { Objects.requireNonNull(shortcut); Objects.requireNonNull(shortcut); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); Preconditions.checkArgument( Preconditions.checkArgument( shortcut.isIncludedIn(ShortcutInfo.SURFACE_LAUNCHER), !shortcut.isExcludedFromSurfaces(ShortcutInfo.SURFACE_LAUNCHER), "Shortcut excluded from launcher cannot be pinned"); "Shortcut excluded from launcher cannot be pinned"); ret.complete(String.valueOf(requestPinItem( ret.complete(String.valueOf(requestPinItem( packageName, userId, shortcut, null, null, resultIntent))); packageName, userId, shortcut, null, null, resultIntent))); Loading