diff options
| -rw-r--r-- | core/java/android/content/pm/AppSearchShortcutInfo.java | 5 | ||||
| -rw-r--r-- | core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/core/java/android/content/pm/AppSearchShortcutInfo.java b/core/java/android/content/pm/AppSearchShortcutInfo.java index 1b84686bbfcf..fb41b890ce9c 100644 --- a/core/java/android/content/pm/AppSearchShortcutInfo.java +++ b/core/java/android/content/pm/AppSearchShortcutInfo.java @@ -413,7 +413,10 @@ public class AppSearchShortcutInfo extends GenericDocument { final int iconResId = (int) getPropertyLong(KEY_ICON_RES_ID); final String iconResName = getPropertyString(KEY_ICON_RES_NAME); final String iconUri = getPropertyString(KEY_ICON_URI); - final int disabledReason = Integer.parseInt(getPropertyString(KEY_DISABLED_REASON)); + final String disabledReasonString = getPropertyString(KEY_DISABLED_REASON); + final int disabledReason = !TextUtils.isEmpty(disabledReasonString) + ? Integer.parseInt(getPropertyString(KEY_DISABLED_REASON)) + : ShortcutInfo.DISABLED_REASON_NOT_DISABLED; final Map<String, Map<String, List<String>>> capabilityBindings = parseCapabilityBindings(getPropertyStringArray(KEY_CAPABILITY_BINDINGS)); return new ShortcutInfo( diff --git a/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java b/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java index 969357f66dde..22feecbd899f 100644 --- a/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java +++ b/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java @@ -24,7 +24,6 @@ import android.content.Intent; import android.platform.test.annotations.Presubmit; import android.util.ArraySet; -import org.junit.Ignore; import org.junit.Test; import java.util.Set; @@ -32,7 +31,6 @@ import java.util.Set; @Presubmit public class AppSearchShortcutInfoTest { - @Ignore("b/208375334") @Test public void testBuildShortcutAndGetValue() { final String category = @@ -51,7 +49,7 @@ public class AppSearchShortcutInfoTest { final Intent shortcutIntent = new Intent(Intent.ACTION_VIEW); final ShortcutInfo shortcut = new AppSearchShortcutInfo.Builder(/*packageName=*/"", id) .setActivity(activity) - .setLongLabel(id) + .setShortLabel(id) .setIconResName(shortcutIconResName) .setIntent(shortcutIntent) .setPerson(person) @@ -64,11 +62,13 @@ public class AppSearchShortcutInfoTest { assertThat(shortcut.getId()).isEqualTo(id); assertThat(shortcut.getShortLabel()).isEqualTo(id); assertThat(shortcut.getIconResName()).isEqualTo(shortcutIconResName); - assertThat(shortcut.getIntent().toString()).isEqualTo(shortcut.toString()); + assertThat(shortcut.getIntent().toString()).isEqualTo(shortcutIntent.toString()); assertThat(shortcut.getPersons().length).isEqualTo(1); - assertThat(shortcut.getPersons()[0]).isEqualTo(person); + final Person target = shortcut.getPersons()[0]; + assertThat(target.getName()).isEqualTo(person.getName()); + assertThat(target.isBot()).isEqualTo(person.isBot()); + assertThat(target.isImportant()).isEqualTo(person.isImportant()); assertThat(shortcut.getCategories()).isEqualTo(categorySet); - assertThat(shortcut.getFlags()).isEqualTo(ShortcutInfo.FLAG_LONG_LIVED); assertThat(shortcut.getActivity()).isEqualTo(activity); } } |