ShortcutInfo.java revision 4fbc3828c5ae1e8c5789ede974447fa365f3c5a1
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
19349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyalimport android.content.ComponentName;
200589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.content.ContentValues;
211e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport android.content.Context;
220589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.content.Intent;
230589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.graphics.Bitmap;
240589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.util.Log;
250589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
264fbc3828c5ae1e8c5789ede974447fa365f3c5a1Sunny Goyalimport com.android.launcher3.LauncherSettings.Favorites;
27ed13187a745866483139e2878037e1f8427ce567Kenny Guyimport com.android.launcher3.compat.UserHandleCompat;
28ed13187a745866483139e2878037e1f8427ce567Kenny Guy
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
37349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public static final int DEFAULT = 0;
38aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
39349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    /**
40349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * The shortcut was restored from a backup and it not ready to be used. This is automatically
41349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * set during backup/restore
42349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     */
43349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public static final int FLAG_RESTORED_ICON = 1;
44aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
45349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    /**
46349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * The icon was added as an auto-install app, and is not ready to be used. This flag can't
47349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * be present along with {@link #FLAG_RESTORED_ICON}, and is set during default layout
48349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * parsing.
49349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     */
50bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal    public static final int FLAG_AUTOINTALL_ICON = 2; //0B10;
51aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
52349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    /**
53349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * The icon is being installed. If {@link FLAG_RESTORED_ICON} or {@link FLAG_AUTOINTALL_ICON}
54349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * is set, then the icon is either being installed or is in a broken state.
55349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     */
56bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal    public static final int FLAG_INSTALL_SESSION_ACTIVE = 4; // 0B100;
57aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
580589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
599448536b113afa6ceefce26604a1b44618d1d4f2Sunny Goyal     * Indicates that the widget restore has started.
609448536b113afa6ceefce26604a1b44618d1d4f2Sunny Goyal     */
61bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal    public static final int FLAG_RESTORE_STARTED = 8; //0B1000;
62bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal
63bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal    /**
64bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal     * Indicates if it represents a common type mentioned in {@link CommonAppTypeParser}.
65bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal     * Upto 15 different types supported.
66bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal     */
67bb3b02f562bef4de063099c085d3199a77d06cfdSunny Goyal    public static final int FLAG_RESTORED_APP_TYPE = 0B0011110000;
689448536b113afa6ceefce26604a1b44618d1d4f2Sunny Goyal
699448536b113afa6ceefce26604a1b44618d1d4f2Sunny Goyal    /**
700589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * The intent used to start the application.
710589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
720589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    Intent intent;
730589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
740589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
750589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * Indicates whether the icon comes from an application's resource (if false)
760589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * or from a custom Bitmap (if true.)
770589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
780589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    boolean customIcon;
790589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
800589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
8156d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato     * Indicates whether we're using the default fallback icon instead of something from the
8256d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato     * app.
8356d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato     */
8456d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato    boolean usingFallbackIcon;
8556d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato
8656d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato    /**
870589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * If isShortcut=true and customIcon=false, this contains a reference to the
880589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * shortcut icon as an application's resource.
890589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
900589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    Intent.ShortcutIconResource iconResource;
910589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
920589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /**
930589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     * The application icon.
940589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato     */
950589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    private Bitmap mIcon;
960589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
9740c5ed303909c4df71037be3429aa1423e59585fChris Wren    /**
981a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal     * Indicates that the icon is disabled due to safe mode restrictions.
991a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal     */
1001a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal    public static final int FLAG_DISABLED_SAFEMODE = 1;
1011a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal
1021a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal    /**
1031a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal     * Indicates that the icon is disabled as the app is not available.
1041a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal     */
1051a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal    public static final int FLAG_DISABLED_NOT_AVAILABLE = 2;
1061a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal
1071a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal    /**
108c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal     * Could be disabled, if the the app is installed but unavailable (eg. in safe mode or when
109c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal     * sd-card is not available).
110c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal     */
1111a745e8f18e54aff152ff51743ae7595adde6927Sunny Goyal    int isDisabled = DEFAULT;
112c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal
113349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    int status;
11440c5ed303909c4df71037be3429aa1423e59585fChris Wren
115e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal    /**
116e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal     * The installation progress [0-100] of the package that this shortcut represents.
117e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal     */
118349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    private int mInstallProgress;
119e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal
120349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    /**
121349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * Refer {@link AppInfo#firstInstallTime}.
122349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     */
1231e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    long firstInstallTime;
1241e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka
125b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren    /**
126349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * TODO move this to {@link status}
127b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren     */
128349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    int flags = 0;
129b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren
1303484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal    /**
131349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * If this shortcut is a placeholder, then intent will be a market intent for the package, and
132349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * this will hold the original intent from the database.  Otherwise, null.
133349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal     * Refer {@link #FLAG_RESTORE_PENDING}, {@link #FLAG_INSTALL_PENDING}
1343484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal     */
135349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    Intent promisedIntent;
1363484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal
137c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka    ShortcutInfo() {
1380589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
1390589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
140997a92348a6d6e061737399321393449c16cd4d8Winson Chung
141e3e646e1f05caa2b500cc3deecc3a31457c83302Anjali Koppal    public Intent getIntent() {
142997a92348a6d6e061737399321393449c16cd4d8Winson Chung        return intent;
143997a92348a6d6e061737399321393449c16cd4d8Winson Chung    }
14472fbec17e09a1120971621587d5005f683baafd1Mathew Inwood
145d6fe52636dcaa96ec1e10ce2daebe98b820c9739Kenny Guy    ShortcutInfo(Intent intent, CharSequence title, CharSequence contentDescription,
146c2bd8101b8e26b9ebb2c079ae6867229dad3f196Kenny Guy            Bitmap icon, UserHandleCompat user) {
14772fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        this();
14872fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        this.intent = intent;
14972fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        this.title = title;
150c2bd8101b8e26b9ebb2c079ae6867229dad3f196Kenny Guy        this.contentDescription = contentDescription;
15172fbec17e09a1120971621587d5005f683baafd1Mathew Inwood        mIcon = icon;
152ed13187a745866483139e2878037e1f8427ce567Kenny Guy        this.user = user;
15372fbec17e09a1120971621587d5005f683baafd1Mathew Inwood    }
15472fbec17e09a1120971621587d5005f683baafd1Mathew Inwood
1551e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    public ShortcutInfo(Context context, ShortcutInfo info) {
156c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka        super(info);
1570589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        title = info.title.toString();
1580589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent = new Intent(info.intent);
1590589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        if (info.iconResource != null) {
1600589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            iconResource = new Intent.ShortcutIconResource();
1610589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            iconResource.packageName = info.iconResource.packageName;
1620589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            iconResource.resourceName = info.iconResource.resourceName;
1630589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
1640589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        mIcon = info.mIcon; // TODO: should make a copy here.  maybe we don't need this ctor at all
1650589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        customIcon = info.customIcon;
166ed13187a745866483139e2878037e1f8427ce567Kenny Guy        flags = info.flags;
167ed13187a745866483139e2878037e1f8427ce567Kenny Guy        firstInstallTime = info.firstInstallTime;
168ed13187a745866483139e2878037e1f8427ce567Kenny Guy        user = info.user;
169349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        status = info.status;
1700589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1710589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1720589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    /** TODO: Remove this.  It's only called by ApplicationInfo.makeShortcut. */
173eadbfc564d84aaf1d800da3d0d6edf6312f89648Michael Jurka    public ShortcutInfo(AppInfo info) {
174c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka        super(info);
1750589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        title = info.title.toString();
1760589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        intent = new Intent(info.intent);
1770589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        customIcon = false;
1781e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        flags = info.flags;
1791e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka        firstInstallTime = info.firstInstallTime;
1801e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka    }
1811e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka
1820589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public void setIcon(Bitmap b) {
1830589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        mIcon = b;
1840589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1850589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1860589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public Bitmap getIcon(IconCache iconCache) {
1870589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        if (mIcon == null) {
188e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka            updateIcon(iconCache);
1890589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
1900589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        return mIcon;
1910589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1920589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
193e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka    public void updateIcon(IconCache iconCache) {
1944fbc3828c5ae1e8c5789ede974447fa365f3c5a1Sunny Goyal        if (itemType == Favorites.ITEM_TYPE_APPLICATION) {
1954fbc3828c5ae1e8c5789ede974447fa365f3c5a1Sunny Goyal            iconCache.getTitleAndIcon(this, promisedIntent != null ? promisedIntent : intent, user);
1964fbc3828c5ae1e8c5789ede974447fa365f3c5a1Sunny Goyal        }
1970589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
1980589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
1990589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    @Override
200ed13187a745866483139e2878037e1f8427ce567Kenny Guy    void onAddToDatabase(Context context, ContentValues values) {
201ed13187a745866483139e2878037e1f8427ce567Kenny Guy        super.onAddToDatabase(context, values);
2020589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2030589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        String titleStr = title != null ? title.toString() : null;
2040589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr);
2050589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
206349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        String uri = promisedIntent != null ? promisedIntent.toUri(0)
2079623a9951acd3e2e7ceb4c8551e3bff4b35001ddSunny Goyal                : (intent != null ? intent.toUri(0) : null);
2080589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);
2090589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2100589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        if (customIcon) {
2110589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
2120589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                    LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP);
21356d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato            writeBitmap(values, mIcon);
2140589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        } else {
215ddc9c1fb1ab426772add520d277ea9c2cd674094Joe Onorato            if (!usingFallbackIcon) {
21656d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato                writeBitmap(values, mIcon);
21756d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato            }
2180589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            if (iconResource != null) {
2194fbc3828c5ae1e8c5789ede974447fa365f3c5a1Sunny Goyal                values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
2204fbc3828c5ae1e8c5789ede974447fa365f3c5a1Sunny Goyal                        LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE);
2210589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE,
2220589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                        iconResource.packageName);
2230589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE,
2240589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                        iconResource.resourceName);
2250589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            }
2260589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
2270589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
2280589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2290589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    @Override
2300589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public String toString() {
231ed13187a745866483139e2878037e1f8427ce567Kenny Guy        return "ShortcutInfo(title=" + title + "intent=" + intent + "id=" + this.id
232dcd297f05a866e07090d6e2af8fb4b15f28cb555Adam Cohen                + " type=" + this.itemType + " container=" + this.container + " screen=" + screenId
233db8a8944ede3be4ee63b43e24c407a3aaabee4deWinson Chung                + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY
234ed13187a745866483139e2878037e1f8427ce567Kenny Guy                + " dropPos=" + Arrays.toString(dropPos) + " user=" + user + ")";
2350589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
2360589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
2370589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    public static void dumpShortcutInfoList(String tag, String label,
2380589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            ArrayList<ShortcutInfo> list) {
2390589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        Log.d(tag, label + " size=" + list.size());
2400589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        for (ShortcutInfo info: list) {
2410589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato            Log.d(tag, "   title=\"" + info.title + " icon=" + info.mIcon
2420589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato                    + " customIcon=" + info.customIcon);
2430589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato        }
2440589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato    }
245aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
246349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public ComponentName getTargetComponent() {
247349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        return promisedIntent != null ? promisedIntent.getComponent() : intent.getComponent();
248aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    }
249aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren
250349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public boolean hasStatusFlag(int flag) {
251349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        return (status & flag) != 0;
252aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren    }
25340c5ed303909c4df71037be3429aa1423e59585fChris Wren
254e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal
255349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public final boolean isPromise() {
256349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        return hasStatusFlag(FLAG_RESTORED_ICON | FLAG_AUTOINTALL_ICON);
25740c5ed303909c4df71037be3429aa1423e59585fChris Wren    }
25840c5ed303909c4df71037be3429aa1423e59585fChris Wren
259349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public int getInstallProgress() {
260349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        return mInstallProgress;
26140c5ed303909c4df71037be3429aa1423e59585fChris Wren    }
262e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal
263349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal    public void setInstallProgress(int progress) {
264349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        mInstallProgress = progress;
265349426234e8c5a0e5bcf2c8d94dbb9844b5f724aSunny Goyal        status |= FLAG_INSTALL_SESSION_ACTIVE;
266e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal    }
2670589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato}
2680589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato
269