Merge "Clone Persons field in ShortcutInfo only for app prediction" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f1affe0d17
@@ -152,15 +152,22 @@ public final class ShortcutInfo implements Parcelable {
|
||||
/** @hide */
|
||||
public static final int CLONE_REMOVE_RES_NAMES = 1 << 3;
|
||||
|
||||
/** @hide */
|
||||
public static final int CLONE_REMOVE_PERSON = 1 << 4;
|
||||
|
||||
/** @hide */
|
||||
public static final int CLONE_REMOVE_FOR_CREATOR = CLONE_REMOVE_ICON | CLONE_REMOVE_RES_NAMES;
|
||||
|
||||
/** @hide */
|
||||
public static final int CLONE_REMOVE_FOR_LAUNCHER = CLONE_REMOVE_ICON | CLONE_REMOVE_INTENT
|
||||
| CLONE_REMOVE_RES_NAMES;
|
||||
| CLONE_REMOVE_RES_NAMES | CLONE_REMOVE_PERSON;
|
||||
|
||||
/** @hide */
|
||||
public static final int CLONE_REMOVE_FOR_LAUNCHER_APPROVAL = CLONE_REMOVE_INTENT
|
||||
| CLONE_REMOVE_RES_NAMES | CLONE_REMOVE_PERSON;
|
||||
|
||||
/** @hide */
|
||||
public static final int CLONE_REMOVE_FOR_APP_PREDICTION = CLONE_REMOVE_ICON
|
||||
| CLONE_REMOVE_RES_NAMES;
|
||||
|
||||
/** @hide */
|
||||
@@ -169,8 +176,11 @@ public final class ShortcutInfo implements Parcelable {
|
||||
CLONE_REMOVE_INTENT,
|
||||
CLONE_REMOVE_NON_KEY_INFO,
|
||||
CLONE_REMOVE_RES_NAMES,
|
||||
CLONE_REMOVE_PERSON,
|
||||
CLONE_REMOVE_FOR_CREATOR,
|
||||
CLONE_REMOVE_FOR_LAUNCHER
|
||||
CLONE_REMOVE_FOR_LAUNCHER,
|
||||
CLONE_REMOVE_FOR_LAUNCHER_APPROVAL,
|
||||
CLONE_REMOVE_FOR_APP_PREDICTION
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CloneFlags {}
|
||||
@@ -548,7 +558,9 @@ public final class ShortcutInfo implements Parcelable {
|
||||
mDisabledMessage = source.mDisabledMessage;
|
||||
mDisabledMessageResId = source.mDisabledMessageResId;
|
||||
mCategories = cloneCategories(source.mCategories);
|
||||
mPersons = clonePersons(source.mPersons);
|
||||
if ((cloneFlags & CLONE_REMOVE_PERSON) == 0) {
|
||||
mPersons = clonePersons(source.mPersons);
|
||||
}
|
||||
if ((cloneFlags & CLONE_REMOVE_INTENT) == 0) {
|
||||
mIntents = cloneIntents(source.mIntents);
|
||||
mIntentPersistableExtrases =
|
||||
|
||||
@@ -674,9 +674,10 @@ class ShortcutPackage extends ShortcutPackageItem {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// Get the list of all dynamic shortcuts in this package
|
||||
// Get the list of all dynamic shortcuts in this package.
|
||||
final ArrayList<ShortcutInfo> shortcuts = new ArrayList<>();
|
||||
findAll(shortcuts, ShortcutInfo::isDynamicVisible, ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER);
|
||||
findAll(shortcuts, ShortcutInfo::isDynamicVisible,
|
||||
ShortcutInfo.CLONE_REMOVE_FOR_APP_PREDICTION);
|
||||
|
||||
final List<ShortcutManager.ShareShortcutInfo> result = new ArrayList<>();
|
||||
for (int i = 0; i < shortcuts.size(); i++) {
|
||||
|
||||
@@ -423,9 +423,7 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
|
||||
assertEquals(set(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION, "xyz"), si.getCategories());
|
||||
assertEquals(null, si.getIntent());
|
||||
assertEquals(123, si.getRank());
|
||||
assertEquals("person", si.getPersons()[0].getName());
|
||||
assertEquals("personKey", si.getPersons()[0].getKey());
|
||||
assertEquals("personUri", si.getPersons()[0].getUri());
|
||||
assertEquals(null, si.getPersons());
|
||||
assertEquals(1, si.getExtras().getInt("k"));
|
||||
|
||||
assertEquals(ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_LONG_LIVED, si.getFlags());
|
||||
@@ -455,6 +453,30 @@ public class ShortcutManagerTest2 extends BaseShortcutManagerTest {
|
||||
|
||||
assertEquals(456, si.getIconResourceId());
|
||||
assertEquals(null, si.getIconResName());
|
||||
|
||||
si = sorig.clone(ShortcutInfo.CLONE_REMOVE_FOR_APP_PREDICTION);
|
||||
|
||||
assertEquals(mClientContext.getPackageName(), si.getPackage());
|
||||
assertEquals("id", si.getId());
|
||||
assertEquals(new ComponentName("a", "b"), si.getActivity());
|
||||
assertEquals(null, si.getIcon());
|
||||
assertEquals("title", si.getTitle());
|
||||
assertEquals("text", si.getText());
|
||||
assertEquals("dismes", si.getDisabledMessage());
|
||||
assertEquals(set(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION, "xyz"), si.getCategories());
|
||||
assertEquals("action", si.getIntent().getAction());
|
||||
assertEquals("val", si.getIntent().getStringExtra("key"));
|
||||
assertEquals(123, si.getRank());
|
||||
assertEquals("person", si.getPersons()[0].getName());
|
||||
assertEquals("personKey", si.getPersons()[0].getKey());
|
||||
assertEquals("personUri", si.getPersons()[0].getUri());
|
||||
assertEquals(1, si.getExtras().getInt("k"));
|
||||
|
||||
assertEquals(ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_LONG_LIVED, si.getFlags());
|
||||
assertEquals(null, si.getBitmapPath());
|
||||
|
||||
assertEquals(456, si.getIconResourceId());
|
||||
assertEquals(null, si.getIconResName());
|
||||
}
|
||||
|
||||
public void testShortcutInfoClone_resId() {
|
||||
|
||||
Reference in New Issue
Block a user