ShortcutInfo.java revision be3e410b7a62fa64ffda825b824862eb9d0c98c5
10589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato/*
20589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * Copyright (C) 2008 The Android Open Source Project
30589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato *
40589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * Licensed under the Apache License, Version 2.0 (the "License");
50589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * you may not use this file except in compliance with the License.
60589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * You may obtain a copy of the License at
70589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato *
80589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato *      http://www.apache.org/licenses/LICENSE-2.0
90589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato *
100589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * Unless required by applicable law or agreed to in writing, software
110589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * distributed under the License is distributed on an "AS IS" BASIS,
120589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * See the License for the specific language governing permissions and
140589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * limitations under the License.
150589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */
160589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
17325dc23624160689e59fbac708cf6f222b20d025Daniel Sandlerpackage com.android.launcher3;
180589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
190589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.content.ComponentName;
200589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.content.ContentValues;
211e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport android.content.Context;
220589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.content.Intent;
2334c2e6cf7af328aba25c98158161dbad15ae986dMichael Jurkaimport android.content.pm.PackageInfo;
241e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport android.content.pm.PackageManager;
251e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport android.content.pm.PackageManager.NameNotFoundException;
260589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.graphics.Bitmap;
270589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.util.Log;
280589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
291e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport java.util.ArrayList;
30be3e410b7a62fa64ffda825b824862eb9d0c98c5Sameer Padalaimport java.util.Arrays;
311e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka
320589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato/**
330589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * Represents a launchable icon on the workspaces and in folders.
340589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */
357b168a1bb94044d9ae11004bae18beba9eed46fdAnjali Koppalpublic class ShortcutInfo extends ItemInfo {
360589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
37aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    /** This package is not installed, and there is no other information available. */
38aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public static final int PACKAGE_STATE_UNKNOWN = -2;
39aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
40aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    /** This package is not installed, because installation failed. */
41aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public static final int PACKAGE_STATE_ERROR = -1;
42aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
43aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    /** This package is installed.  This is the typical case */
44aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public static final int PACKAGE_STATE_DEFAULT = 0;
45aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
46aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    /** This package is not installed, but some external entity has promised to install it. */
47aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public static final int PACKAGE_STATE_ENQUEUED = 1;
48aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
49aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    /** This package is not installed, but some external entity is downloading it. */
50aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public static final int PACKAGE_STATE_DOWNLOADING = 2;
51aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
52aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    /** This package is not installed, but some external entity is installing it. */
53aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public static final int PACKAGE_STATE_INSTALLING = 3;
54aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
550589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
560589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * The intent used to start the application.
570589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
580589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    Intent intent;
590589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
600589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
610589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * Indicates whether the icon comes from an application's resource (if false)
620589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * or from a custom Bitmap (if true.)
630589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
640589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    boolean customIcon;
650589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
660589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
6756d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato     * Indicates whether we're using the default fallback icon instead of something from the
6856d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato     * app.
6956d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato     */
7056d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato    boolean usingFallbackIcon;
7156d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato
7256d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato    /**
730589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * If isShortcut=true and customIcon=false, this contains a reference to the
740589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * shortcut icon as an application's resource.
750589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
760589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    Intent.ShortcutIconResource iconResource;
770589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
780589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
790589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * The application icon.
800589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
810589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    private Bitmap mIcon;
820589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
831e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    long firstInstallTime;
841e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    int flags = 0;
851e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka
86b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    /**
87b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren     * If this shortcut is a placeholder, then intent will be a market intent for the package, and
88b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren     * this will hold the original intent from the database.  Otherwise, null.
89b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren     */
90b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    Intent restoredIntent;
91b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren
92c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka    ShortcutInfo() {
930589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
940589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
95997a92348a6d6e061737399321393449c16cd4d8Winson Chung
96e3e646e1f05caa2b500cc3deecc3a31457c83302Anjali Koppal    public Intent getIntent() {
97997a92348a6d6e061737399321393449c16cd4d8Winson Chung        return intent;
98997a92348a6d6e061737399321393449c16cd4d8Winson Chung    }
9972fbec17e09a1120971621587d5005f683baafd1Mathew Inwood
100b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    protected Intent getRestoredIntent() {
101b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren        return restoredIntent;
102b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    }
103b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren
104b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    /**
105b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren     * Overwrite placeholder data with restored data, or do nothing if this is not a placeholder.
106b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren     */
107b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    public void restore() {
108b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren        if (restoredIntent != null) {
109b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren            intent = restoredIntent;
110b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren            restoredIntent = null;
111b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren        }
112b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    }
113b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren
114b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren
11572fbec17e09a1120971621587d5005f683baafd1Mathew Inwood    ShortcutInfo(Intent intent, CharSequence title, Bitmap icon) {
11672fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        this();
11772fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        this.intent = intent;
11872fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        this.title = title;
11972fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        mIcon = icon;
12072fbec17e09a1120971621587d5005f683baafd1Mathew Inwood    }
12172fbec17e09a1120971621587d5005f683baafd1Mathew Inwood
1221e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    public ShortcutInfo(Context context, ShortcutInfo info) {
123c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka        super(info);
1240589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        title = info.title.toString();
1250589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent = new Intent(info.intent);
1260589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        if (info.iconResource != null) {
1270589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            iconResource = new Intent.ShortcutIconResource();
1280589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            iconResource.packageName = info.iconResource.packageName;
1290589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            iconResource.resourceName = info.iconResource.resourceName;
1300589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
1310589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        mIcon = info.mIcon; // TODO: should make a copy here.  maybe we don't need this ctor at all
1320589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        customIcon = info.customIcon;
13324715c751513ea2b24058b8d1a1e5263f5c31607Michael Jurka        initFlagsAndFirstInstallTime(
13424715c751513ea2b24058b8d1a1e5263f5c31607Michael Jurka                getPackageInfo(context, intent.getComponent().getPackageName()));
1350589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1360589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1370589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /** TODO: Remove this.  It's only called by ApplicationInfo.makeShortcut. */
138eadbfc564d84aaf1d800da3d0d6edf6312f89648Michael Jurka    public ShortcutInfo(AppInfo info) {
139c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka        super(info);
1400589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        title = info.title.toString();
1410589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent = new Intent(info.intent);
1420589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        customIcon = false;
1431e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        flags = info.flags;
1441e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        firstInstallTime = info.firstInstallTime;
1451e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    }
1461e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka
1471e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    public static PackageInfo getPackageInfo(Context context, String packageName) {
1481e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        PackageInfo pi = null;
1491e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        try {
1501e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka            PackageManager pm = context.getPackageManager();
1511e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka            pi = pm.getPackageInfo(packageName, 0);
1521e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        } catch (NameNotFoundException e) {
1531e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka            Log.d("ShortcutInfo", "PackageManager.getPackageInfo failed for " + packageName);
1541e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        }
1551e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        return pi;
1561e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    }
1571e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka
1581e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    void initFlagsAndFirstInstallTime(PackageInfo pi) {
159eadbfc564d84aaf1d800da3d0d6edf6312f89648Michael Jurka        flags = AppInfo.initFlags(pi);
160eadbfc564d84aaf1d800da3d0d6edf6312f89648Michael Jurka        firstInstallTime = AppInfo.initFirstInstallTime(pi);
1610589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1620589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1630589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public void setIcon(Bitmap b) {
1640589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        mIcon = b;
1650589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1660589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1670589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public Bitmap getIcon(IconCache iconCache) {
1680589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        if (mIcon == null) {
169e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka            updateIcon(iconCache);
1700589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
1710589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        return mIcon;
1720589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1730589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
174e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka    public void updateIcon(IconCache iconCache) {
175e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka        mIcon = iconCache.getIcon(intent);
176e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka        usingFallbackIcon = iconCache.isDefaultIcon(mIcon);
177e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka    }
178e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka
1790589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
1800589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * Creates the application intent based on a component name and various launch flags.
1810589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * Sets {@link #itemType} to {@link LauncherSettings.BaseLauncherColumns#ITEM_TYPE_APPLICATION}.
1820589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     *
1830589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * @param className the class name of the component representing the intent
1840589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * @param launchFlags the launch flags
1850589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
1861e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    final void setActivity(Context context, ComponentName className, int launchFlags) {
1870589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent = new Intent(Intent.ACTION_MAIN);
1880589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent.addCategory(Intent.CATEGORY_LAUNCHER);
1890589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent.setComponent(className);
1900589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent.setFlags(launchFlags);
1910589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_APPLICATION;
19224715c751513ea2b24058b8d1a1e5263f5c31607Michael Jurka        initFlagsAndFirstInstallTime(
19324715c751513ea2b24058b8d1a1e5263f5c31607Michael Jurka                getPackageInfo(context, intent.getComponent().getPackageName()));
1940589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1950589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1960589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    @Override
1970589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    void onAddToDatabase(ContentValues values) {
1980589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        super.onAddToDatabase(values);
1990589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2000589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        String titleStr = title != null ? title.toString() : null;
2010589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr);
2020589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2030589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        String uri = intent != null ? intent.toUri(0) : null;
2040589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);
2050589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2060589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        if (customIcon) {
2070589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
2080589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                    LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP);
20956d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato            writeBitmap(values, mIcon);
2100589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        } else {
211ddc9c1fb1ab426772add520d277ea9c2cd674094Joe Onorato            if (!usingFallbackIcon) {
21256d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato                writeBitmap(values, mIcon);
21356d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato            }
2140589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
2150589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                    LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE);
2160589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            if (iconResource != null) {
2170589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE,
2180589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                        iconResource.packageName);
2190589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE,
2200589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                        iconResource.resourceName);
2210589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            }
2220589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
2230589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
2240589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2250589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    @Override
2260589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public String toString() {
227db8a8944ede3be4ee63b43e24c407a3aaabee4deWinson Chung        return "ShortcutInfo(title=" + title.toString() + "intent=" + intent + "id=" + this.id
228dcd297f05a866e07090d6e2af8fb4b15f28cb555Adam Cohen                + " type=" + this.itemType + " container=" + this.container + " screen=" + screenId
229db8a8944ede3be4ee63b43e24c407a3aaabee4deWinson Chung                + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY
230be3e410b7a62fa64ffda825b824862eb9d0c98c5Sameer Padala                + " dropPos=" + Arrays.toString(dropPos) + ")";
2310589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
2320589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2330589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public static void dumpShortcutInfoList(String tag, String label,
2340589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            ArrayList<ShortcutInfo> list) {
2350589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        Log.d(tag, label + " size=" + list.size());
2360589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        for (ShortcutInfo info: list) {
2370589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            Log.d(tag, "   title=\"" + info.title + " icon=" + info.mIcon
2380589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                    + " customIcon=" + info.customIcon);
2390589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
2400589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
241aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
242aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public boolean isPromise() {
243aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren        return restoredIntent != null;
244aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    }
245aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
246aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    public boolean isPromiseFor(String pkgName) {
247aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren        return restoredIntent != null
248aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren                && pkgName != null
249aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren                && pkgName.equals(restoredIntent.getComponent().getPackageName());
250aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    }
2510589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato}
2520589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
253