diff options
Diffstat (limited to 'android/content/pm/ShortcutInfo.java')
-rw-r--r-- | android/content/pm/ShortcutInfo.java | 207 |
1 files changed, 5 insertions, 202 deletions
diff --git a/android/content/pm/ShortcutInfo.java b/android/content/pm/ShortcutInfo.java index 9ff07757..6b9c7537 100644 --- a/android/content/pm/ShortcutInfo.java +++ b/android/content/pm/ShortcutInfo.java @@ -18,7 +18,6 @@ package android.content.pm; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; -import android.annotation.TestApi; import android.annotation.UserIdInt; import android.app.TaskStackBuilder; import android.content.ComponentName; @@ -101,13 +100,6 @@ public final class ShortcutInfo implements Parcelable { /** @hide When this is set, the bitmap icon is waiting to be saved. */ public static final int FLAG_ICON_FILE_PENDING_SAVE = 1 << 11; - /** - * "Shadow" shortcuts are the ones that are restored, but the owner package hasn't been - * installed yet. - * @hide - */ - public static final int FLAG_SHADOW = 1 << 12; - /** @hide */ @IntDef(flag = true, value = { @@ -166,124 +158,6 @@ public final class ShortcutInfo implements Parcelable { public @interface CloneFlags {} /** - * Shortcut is not disabled. - */ - public static final int DISABLED_REASON_NOT_DISABLED = 0; - - /** - * Shortcut has been disabled by the publisher app with the - * {@link ShortcutManager#disableShortcuts(List)} API. - */ - public static final int DISABLED_REASON_BY_APP = 1; - - /** - * Shortcut has been disabled due to changes to the publisher app. (e.g. a manifest shortcut - * no longer exists.) - */ - public static final int DISABLED_REASON_APP_CHANGED = 2; - - /** - * A disabled reason that's equal to or bigger than this is due to backup and restore issue. - * A shortcut with such a reason wil be visible to the launcher, but not to the publisher. - * ({@link #isVisibleToPublisher()} will be false.) - */ - private static final int DISABLED_REASON_RESTORE_ISSUE_START = 100; - - /** - * Shortcut has been restored from the previous device, but the publisher app on the current - * device is of a lower version. The shortcut will not be usable until the app is upgraded to - * the same version or higher. - */ - public static final int DISABLED_REASON_VERSION_LOWER = 100; - - /** - * Shortcut has not been restored because the publisher app does not support backup and restore. - */ - public static final int DISABLED_REASON_BACKUP_NOT_SUPPORTED = 101; - - /** - * Shortcut has not been restored because the publisher app's signature has changed. - */ - public static final int DISABLED_REASON_SIGNATURE_MISMATCH = 102; - - /** - * Shortcut has not been restored for unknown reason. - */ - public static final int DISABLED_REASON_OTHER_RESTORE_ISSUE = 103; - - /** @hide */ - @IntDef(value = { - DISABLED_REASON_NOT_DISABLED, - DISABLED_REASON_BY_APP, - DISABLED_REASON_APP_CHANGED, - DISABLED_REASON_VERSION_LOWER, - DISABLED_REASON_BACKUP_NOT_SUPPORTED, - DISABLED_REASON_SIGNATURE_MISMATCH, - DISABLED_REASON_OTHER_RESTORE_ISSUE, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface DisabledReason{} - - /** - * Return a label for disabled reasons, which are *not* supposed to be shown to the user. - * @hide - */ - public static String getDisabledReasonDebugString(@DisabledReason int disabledReason) { - switch (disabledReason) { - case DISABLED_REASON_NOT_DISABLED: - return "[Not disabled]"; - case DISABLED_REASON_BY_APP: - return "[Disabled: by app]"; - case DISABLED_REASON_APP_CHANGED: - return "[Disabled: app changed]"; - case DISABLED_REASON_VERSION_LOWER: - return "[Disabled: lower version]"; - case DISABLED_REASON_BACKUP_NOT_SUPPORTED: - return "[Disabled: backup not supported]"; - case DISABLED_REASON_SIGNATURE_MISMATCH: - return "[Disabled: signature mismatch]"; - case DISABLED_REASON_OTHER_RESTORE_ISSUE: - return "[Disabled: unknown restore issue]"; - } - return "[Disabled: unknown reason:" + disabledReason + "]"; - } - - /** - * Return a label for a disabled reason for shortcuts that are disabled due to a backup and - * restore issue. If the reason is not due to backup & restore, then it'll return null. - * - * This method returns localized, user-facing strings, which will be returned by - * {@link #getDisabledMessage()}. - * - * @hide - */ - public static String getDisabledReasonForRestoreIssue(Context context, - @DisabledReason int disabledReason) { - final Resources res = context.getResources(); - - switch (disabledReason) { - case DISABLED_REASON_VERSION_LOWER: - return res.getString( - com.android.internal.R.string.shortcut_restored_on_lower_version); - case DISABLED_REASON_BACKUP_NOT_SUPPORTED: - return res.getString( - com.android.internal.R.string.shortcut_restore_not_supported); - case DISABLED_REASON_SIGNATURE_MISMATCH: - return res.getString( - com.android.internal.R.string.shortcut_restore_signature_mismatch); - case DISABLED_REASON_OTHER_RESTORE_ISSUE: - return res.getString( - com.android.internal.R.string.shortcut_restore_unknown_issue); - } - return null; - } - - /** @hide */ - public static boolean isDisabledForRestoreIssue(@DisabledReason int disabledReason) { - return disabledReason >= DISABLED_REASON_RESTORE_ISSUE_START; - } - - /** * Shortcut category for messaging related actions, such as chat. */ public static final String SHORTCUT_CATEGORY_CONVERSATION = "android.shortcut.conversation"; @@ -366,11 +240,6 @@ public final class ShortcutInfo implements Parcelable { private final int mUserId; - /** @hide */ - public static final int VERSION_CODE_UNKNOWN = -1; - - private int mDisabledReason; - private ShortcutInfo(Builder b) { mUserId = b.mContext.getUserId(); @@ -483,7 +352,6 @@ public final class ShortcutInfo implements Parcelable { mActivity = source.mActivity; mFlags = source.mFlags; mLastChangedTimestamp = source.mLastChangedTimestamp; - mDisabledReason = source.mDisabledReason; // Just always keep it since it's cheep. mIconResId = source.mIconResId; @@ -747,23 +615,13 @@ public final class ShortcutInfo implements Parcelable { /** * @hide - * - * @isUpdating set true if it's "update", as opposed to "replace". */ - public void ensureUpdatableWith(ShortcutInfo source, boolean isUpdating) { - if (isUpdating) { - Preconditions.checkState(isVisibleToPublisher(), - "[Framework BUG] Invisible shortcuts can't be updated"); - } + public void ensureUpdatableWith(ShortcutInfo source) { Preconditions.checkState(mUserId == source.mUserId, "Owner User ID must match"); Preconditions.checkState(mId.equals(source.mId), "ID must match"); Preconditions.checkState(mPackageName.equals(source.mPackageName), "Package name must match"); - - if (isVisibleToPublisher()) { - // Don't do this check for restore-blocked shortcuts. - Preconditions.checkState(!isImmutable(), "Target ShortcutInfo is immutable"); - } + Preconditions.checkState(!isImmutable(), "Target ShortcutInfo is immutable"); } /** @@ -780,7 +638,7 @@ public final class ShortcutInfo implements Parcelable { * @hide */ public void copyNonNullFieldsFrom(ShortcutInfo source) { - ensureUpdatableWith(source, /*isUpdating=*/ true); + ensureUpdatableWith(source); if (source.mActivity != null) { mActivity = source.mActivity; @@ -1311,19 +1169,6 @@ public final class ShortcutInfo implements Parcelable { return mDisabledMessageResId; } - /** @hide */ - public void setDisabledReason(@DisabledReason int reason) { - mDisabledReason = reason; - } - - /** - * Returns why a shortcut has been disabled. - */ - @DisabledReason - public int getDisabledReason() { - return mDisabledReason; - } - /** * Return the shortcut's categories. * @@ -1558,21 +1403,6 @@ public final class ShortcutInfo implements Parcelable { return hasFlags(FLAG_IMMUTABLE); } - /** @hide */ - public boolean isDynamicVisible() { - return isDynamic() && isVisibleToPublisher(); - } - - /** @hide */ - public boolean isPinnedVisible() { - return isPinned() && isVisibleToPublisher(); - } - - /** @hide */ - public boolean isManifestVisible() { - return isDeclaredInManifest() && isVisibleToPublisher(); - } - /** * Return if a shortcut is immutable, in which case it cannot be modified with any of * {@link ShortcutManager} APIs. @@ -1661,18 +1491,6 @@ public final class ShortcutInfo implements Parcelable { } /** - * When the system wasn't able to restore a shortcut, it'll still be registered to the system - * but disabled, and such shortcuts will not be visible to the publisher. They're still visible - * to launchers though. - * - * @hide - */ - @TestApi - public boolean isVisibleToPublisher() { - return !isDisabledForRestoreIssue(mDisabledReason); - } - - /** * Return whether a shortcut only contains "key" information only or not. If true, only the * following fields are available. * <ul> @@ -1850,7 +1668,6 @@ public final class ShortcutInfo implements Parcelable { mFlags = source.readInt(); mIconResId = source.readInt(); mLastChangedTimestamp = source.readLong(); - mDisabledReason = source.readInt(); if (source.readInt() == 0) { return; // key information only. @@ -1894,7 +1711,6 @@ public final class ShortcutInfo implements Parcelable { dest.writeInt(mFlags); dest.writeInt(mIconResId); dest.writeLong(mLastChangedTimestamp); - dest.writeInt(mDisabledReason); if (hasKeyFieldsOnly()) { dest.writeInt(0); @@ -1992,11 +1808,6 @@ public final class ShortcutInfo implements Parcelable { sb.append(", flags=0x"); sb.append(Integer.toHexString(mFlags)); sb.append(" ["); - if ((mFlags & FLAG_SHADOW) != 0) { - // Note the shadow flag isn't actually used anywhere and it's just for dumpsys, so - // we don't have an isXxx for this. - sb.append("Sdw"); - } if (!isEnabled()) { sb.append("Dis"); } @@ -2037,9 +1848,7 @@ public final class ShortcutInfo implements Parcelable { sb.append("packageName="); sb.append(mPackageName); - addIndentOrComma(sb, indent); - - sb.append("activity="); + sb.append(", activity="); sb.append(mActivity); addIndentOrComma(sb, indent); @@ -2074,11 +1883,6 @@ public final class ShortcutInfo implements Parcelable { addIndentOrComma(sb, indent); - sb.append("disabledReason="); - sb.append(getDisabledReasonDebugString(mDisabledReason)); - - addIndentOrComma(sb, indent); - sb.append("categories="); sb.append(mCategories); @@ -2149,7 +1953,7 @@ public final class ShortcutInfo implements Parcelable { CharSequence disabledMessage, int disabledMessageResId, String disabledMessageResName, Set<String> categories, Intent[] intentsWithExtras, int rank, PersistableBundle extras, long lastChangedTimestamp, - int flags, int iconResId, String iconResName, String bitmapPath, int disabledReason) { + int flags, int iconResId, String iconResName, String bitmapPath) { mUserId = userId; mId = id; mPackageName = packageName; @@ -2174,6 +1978,5 @@ public final class ShortcutInfo implements Parcelable { mIconResId = iconResId; mIconResName = iconResName; mBitmapPath = bitmapPath; - mDisabledReason = disabledReason; } } |