fc02c1b446
This ensures that the intent has the package corresponding to the shortcut publisher, rather than a market intent. It also ensures that the intent has the EXTRA_SHORTCUT_ID attached. Bug: 31123204 Change-Id: I05d56396b629880322e915f52bfc0605b921b0b1
39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
package com.android.launcher3.shortcuts;
|
|
|
|
import android.content.ComponentName;
|
|
import android.content.Intent;
|
|
|
|
import com.android.launcher3.ShortcutInfo;
|
|
import com.android.launcher3.compat.UserHandleCompat;
|
|
import com.android.launcher3.util.ComponentKey;
|
|
|
|
/**
|
|
* A key that uniquely identifies a shortcut using its package, id, and user handle.
|
|
*/
|
|
public class ShortcutKey extends ComponentKey {
|
|
|
|
public ShortcutKey(String packageName, UserHandleCompat user, String id) {
|
|
// Use the id as the class name.
|
|
super(new ComponentName(packageName, id), user);
|
|
}
|
|
|
|
public String getId() {
|
|
return componentName.getClassName();
|
|
}
|
|
|
|
public static ShortcutKey fromInfo(ShortcutInfoCompat shortcutInfo) {
|
|
return new ShortcutKey(shortcutInfo.getPackage(), shortcutInfo.getUserHandle(),
|
|
shortcutInfo.getId());
|
|
}
|
|
|
|
public static ShortcutKey fromIntent(Intent intent, UserHandleCompat user) {
|
|
String shortcutId = intent.getStringExtra(
|
|
ShortcutInfoCompat.EXTRA_SHORTCUT_ID);
|
|
return new ShortcutKey(intent.getPackage(), user, shortcutId);
|
|
}
|
|
|
|
public static ShortcutKey fromShortcutInfo(ShortcutInfo info) {
|
|
return fromIntent(info.getPromisedIntent(), info.user);
|
|
}
|
|
}
|