ShortcutInfo.java revision e755d469d40b95e763a9dcb67d0e4f511d1948dd
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.ContentValues; 201e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport android.content.Context; 210589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.content.Intent; 220589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.graphics.Bitmap; 230589f0f66ce498512c6ee47482c649d88294c9d0Joe Onoratoimport android.util.Log; 240589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 25ed13187a745866483139e2878037e1f8427ce567Kenny Guyimport com.android.launcher3.compat.UserHandleCompat; 26ed13187a745866483139e2878037e1f8427ce567Kenny Guy 271e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurkaimport java.util.ArrayList; 28be3e410b7a62fa64ffda825b824862eb9d0c98c5Sameer Padalaimport java.util.Arrays; 291e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka 300589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato/** 310589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * Represents a launchable icon on the workspaces and in folders. 320589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */ 337b168a1bb94044d9ae11004bae18beba9eed46fdAnjali Koppalpublic class ShortcutInfo extends ItemInfo { 340589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 3540c5ed303909c4df71037be3429aa1423e59585fChris Wren /** {@link #mState} meaning this package is not installed, and there is no other information. */ 36aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren public static final int PACKAGE_STATE_UNKNOWN = -2; 37aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren 3840c5ed303909c4df71037be3429aa1423e59585fChris Wren /** {@link #mState} meaning this package is not installed, because installation failed. */ 39aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren public static final int PACKAGE_STATE_ERROR = -1; 40aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren 4140c5ed303909c4df71037be3429aa1423e59585fChris Wren /** {@link #mState} meaning this package is installed. This is the typical case. */ 42aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren public static final int PACKAGE_STATE_DEFAULT = 0; 43aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren 4440c5ed303909c4df71037be3429aa1423e59585fChris Wren /** {@link #mState} meaning some external entity has promised to install this package. */ 45e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal public static final int PACKAGE_STATE_INSTALLING = 1; 46aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren 470589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato /** 480589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * The intent used to start the application. 490589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */ 500589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato Intent intent; 510589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 520589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato /** 530589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * Indicates whether the icon comes from an application's resource (if false) 540589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * or from a custom Bitmap (if true.) 550589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */ 560589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato boolean customIcon; 570589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 580589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato /** 5956d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato * Indicates whether we're using the default fallback icon instead of something from the 6056d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato * app. 6156d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato */ 6256d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato boolean usingFallbackIcon; 6356d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato 6456d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato /** 650589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * If isShortcut=true and customIcon=false, this contains a reference to the 660589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * shortcut icon as an application's resource. 670589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */ 680589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato Intent.ShortcutIconResource iconResource; 690589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 700589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato /** 710589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato * The application icon. 720589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato */ 730589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato private Bitmap mIcon; 740589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 7540c5ed303909c4df71037be3429aa1423e59585fChris Wren /** 76c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal * Could be disabled, if the the app is installed but unavailable (eg. in safe mode or when 77c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal * sd-card is not available). 78c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal */ 79c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal boolean isDisabled = false; 80c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal 81c5c60ad3592f53549c9ffaa58e9a87b0480080e8Sunny Goyal /** 8240c5ed303909c4df71037be3429aa1423e59585fChris Wren * The installation state of the package that this shortcut represents. 8340c5ed303909c4df71037be3429aa1423e59585fChris Wren */ 8440c5ed303909c4df71037be3429aa1423e59585fChris Wren protected int mState; 8540c5ed303909c4df71037be3429aa1423e59585fChris Wren 86e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal /** 87e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal * The installation progress [0-100] of the package that this shortcut represents. 88e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal */ 89e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal protected int mProgress; 90e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal 911e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka long firstInstallTime; 921e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka int flags = 0; 931e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka 94b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren /** 95b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren * If this shortcut is a placeholder, then intent will be a market intent for the package, and 96b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren * this will hold the original intent from the database. Otherwise, null. 97b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren */ 98b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren Intent restoredIntent; 99b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren 1003484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal /** 1013484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal * This is set once to indicate that it was a promise info at some point of its life. 1023484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal */ 1033484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal boolean wasPromise = false; 1043484638cad97e255a412b0489a63873fb3ca4218Sunny Goyal 105c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka ShortcutInfo() { 1060589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT; 1070589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 108997a92348a6d6e061737399321393449c16cd4d8Winson Chung 109e3e646e1f05caa2b500cc3deecc3a31457c83302Anjali Koppal public Intent getIntent() { 110997a92348a6d6e061737399321393449c16cd4d8Winson Chung return intent; 111997a92348a6d6e061737399321393449c16cd4d8Winson Chung } 11272fbec17e09a1120971621587d5005f683baafd1Mathew Inwood 113b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren protected Intent getRestoredIntent() { 114b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren return restoredIntent; 115b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren } 116b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren 117b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren /** 118b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren * Overwrite placeholder data with restored data, or do nothing if this is not a placeholder. 119b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren */ 120b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren public void restore() { 121b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren if (restoredIntent != null) { 122b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren intent = restoredIntent; 123b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren restoredIntent = null; 12440c5ed303909c4df71037be3429aa1423e59585fChris Wren mState = PACKAGE_STATE_DEFAULT; 125b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren } 126b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren } 127b6d4c2827a1514432b5eda46ff7d484d6cf244acChris Wren 128d6fe52636dcaa96ec1e10ce2daebe98b820c9739Kenny Guy ShortcutInfo(Intent intent, CharSequence title, CharSequence contentDescription, 129c2bd8101b8e26b9ebb2c079ae6867229dad3f196Kenny Guy Bitmap icon, UserHandleCompat user) { 13072fbec17e09a1120971621587d5005f683baafd1Mathew Inwood this(); 13172fbec17e09a1120971621587d5005f683baafd1Mathew Inwood this.intent = intent; 13272fbec17e09a1120971621587d5005f683baafd1Mathew Inwood this.title = title; 133c2bd8101b8e26b9ebb2c079ae6867229dad3f196Kenny Guy this.contentDescription = contentDescription; 13472fbec17e09a1120971621587d5005f683baafd1Mathew Inwood mIcon = icon; 135ed13187a745866483139e2878037e1f8427ce567Kenny Guy this.user = user; 13672fbec17e09a1120971621587d5005f683baafd1Mathew Inwood } 13772fbec17e09a1120971621587d5005f683baafd1Mathew Inwood 1381e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka public ShortcutInfo(Context context, ShortcutInfo info) { 139c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka super(info); 1400589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato title = info.title.toString(); 1410589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato intent = new Intent(info.intent); 1420589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato if (info.iconResource != null) { 1430589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato iconResource = new Intent.ShortcutIconResource(); 1440589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato iconResource.packageName = info.iconResource.packageName; 1450589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato iconResource.resourceName = info.iconResource.resourceName; 1460589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 1470589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato mIcon = info.mIcon; // TODO: should make a copy here. maybe we don't need this ctor at all 1480589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato customIcon = info.customIcon; 149ed13187a745866483139e2878037e1f8427ce567Kenny Guy flags = info.flags; 150ed13187a745866483139e2878037e1f8427ce567Kenny Guy firstInstallTime = info.firstInstallTime; 151ed13187a745866483139e2878037e1f8427ce567Kenny Guy user = info.user; 1520589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 1530589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 1540589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato /** TODO: Remove this. It's only called by ApplicationInfo.makeShortcut. */ 155eadbfc564d84aaf1d800da3d0d6edf6312f89648Michael Jurka public ShortcutInfo(AppInfo info) { 156c9d95c5897fc5ebbf53903d4ab18ad13d196f643Michael Jurka super(info); 1570589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato title = info.title.toString(); 1580589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato intent = new Intent(info.intent); 1590589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato customIcon = false; 1601e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka flags = info.flags; 1611e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka firstInstallTime = info.firstInstallTime; 1621e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka } 1631e2f465f46ded990ea30516cdb7f0fcf3280411fMichael Jurka 1640589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato public void setIcon(Bitmap b) { 1650589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato mIcon = b; 1660589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 1670589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 1680589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato public Bitmap getIcon(IconCache iconCache) { 1690589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato if (mIcon == null) { 170e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka updateIcon(iconCache); 1710589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 1720589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato return mIcon; 1730589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 1740589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 175e384affda684a48c61d99ebfe8be40fb7d46d761Michael Jurka public void updateIcon(IconCache iconCache) { 176ed13187a745866483139e2878037e1f8427ce567Kenny Guy mIcon = iconCache.getIcon(intent, user); 177ed13187a745866483139e2878037e1f8427ce567Kenny Guy usingFallbackIcon = iconCache.isDefaultIcon(mIcon, user); 1780589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 1790589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 1800589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato @Override 181ed13187a745866483139e2878037e1f8427ce567Kenny Guy void onAddToDatabase(Context context, ContentValues values) { 182ed13187a745866483139e2878037e1f8427ce567Kenny Guy super.onAddToDatabase(context, values); 1830589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 1840589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato String titleStr = title != null ? title.toString() : null; 1850589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr); 1860589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 1879623a9951acd3e2e7ceb4c8551e3bff4b35001ddSunny Goyal String uri = restoredIntent != null ? restoredIntent.toUri(0) 1889623a9951acd3e2e7ceb4c8551e3bff4b35001ddSunny Goyal : (intent != null ? intent.toUri(0) : null); 1890589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri); 1900589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 1910589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato if (customIcon) { 1920589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE, 1930589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP); 19456d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato writeBitmap(values, mIcon); 1950589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } else { 196ddc9c1fb1ab426772add520d277ea9c2cd674094Joe Onorato if (!usingFallbackIcon) { 19756d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato writeBitmap(values, mIcon); 19856d8291af6a28c6ba64113120efdf84a785e816cJoe Onorato } 1990589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE, 2000589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE); 2010589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato if (iconResource != null) { 2020589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE, 2030589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato iconResource.packageName); 2040589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE, 2050589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato iconResource.resourceName); 2060589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 2070589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 2080589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 2090589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 2100589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato @Override 2110589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato public String toString() { 212ed13187a745866483139e2878037e1f8427ce567Kenny Guy return "ShortcutInfo(title=" + title + "intent=" + intent + "id=" + this.id 213dcd297f05a866e07090d6e2af8fb4b15f28cb555Adam Cohen + " type=" + this.itemType + " container=" + this.container + " screen=" + screenId 214db8a8944ede3be4ee63b43e24c407a3aaabee4deWinson Chung + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY 215ed13187a745866483139e2878037e1f8427ce567Kenny Guy + " dropPos=" + Arrays.toString(dropPos) + " user=" + user + ")"; 2160589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 2170589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 2180589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato public static void dumpShortcutInfoList(String tag, String label, 2190589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato ArrayList<ShortcutInfo> list) { 2200589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato Log.d(tag, label + " size=" + list.size()); 2210589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato for (ShortcutInfo info: list) { 2220589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato Log.d(tag, " title=\"" + info.title + " icon=" + info.mIcon 2230589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato + " customIcon=" + info.customIcon); 2240589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 2250589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato } 226aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren 227aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren public boolean isPromise() { 228aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren return restoredIntent != null; 229aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren } 230aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren 231aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren public boolean isPromiseFor(String pkgName) { 232aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren return restoredIntent != null 233aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren && pkgName != null 234aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren && pkgName.equals(restoredIntent.getComponent().getPackageName()); 235aeff7ea43409d817490fbb8c22b8d4b9725bb54fChris Wren } 23640c5ed303909c4df71037be3429aa1423e59585fChris Wren 23740c5ed303909c4df71037be3429aa1423e59585fChris Wren public boolean isAbandoned() { 23840c5ed303909c4df71037be3429aa1423e59585fChris Wren return isPromise() 239e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal && (mState == PACKAGE_STATE_ERROR 240e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal || mState == PACKAGE_STATE_UNKNOWN); 24140c5ed303909c4df71037be3429aa1423e59585fChris Wren } 24240c5ed303909c4df71037be3429aa1423e59585fChris Wren 243e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal public int getProgress() { 244e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal return mProgress; 245e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal } 246e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal 247e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal public void setProgress(int progress) { 248e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal mProgress = progress; 24940c5ed303909c4df71037be3429aa1423e59585fChris Wren } 25040c5ed303909c4df71037be3429aa1423e59585fChris Wren 25140c5ed303909c4df71037be3429aa1423e59585fChris Wren public void setState(int state) { 25240c5ed303909c4df71037be3429aa1423e59585fChris Wren mState = state; 25340c5ed303909c4df71037be3429aa1423e59585fChris Wren } 254e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal 255e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal public int getState() { 256e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal return mState; 257e755d469d40b95e763a9dcb67d0e4f511d1948ddSunny Goyal } 2580589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato} 2590589f0f66ce498512c6ee47482c649d88294c9d0Joe Onorato 260