diff options
-rw-r--r-- | src/com/android/launcher3/AppInfo.java | 15 | ||||
-rw-r--r-- | src/com/android/launcher3/UninstallDropTarget.java | 18 | ||||
-rw-r--r-- | src/com/android/launcher3/logging/LoggerUtils.java | 8 |
3 files changed, 34 insertions, 7 deletions
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java index 3da199635..7d2f75385 100644 --- a/src/com/android/launcher3/AppInfo.java +++ b/src/com/android/launcher3/AppInfo.java @@ -19,6 +19,7 @@ package com.android.launcher3; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; import android.os.UserHandle; @@ -31,6 +32,10 @@ import com.android.launcher3.util.PackageManagerHelper; */ public class AppInfo extends ItemInfoWithIcon { + public static final int FLAG_SYSTEM_UNKNOWN = 0; + public static final int FLAG_SYSTEM_YES = 1 << 0; + public static final int FLAG_SYSTEM_NO = 1 << 1; + /** * The intent used to start the application. */ @@ -43,6 +48,11 @@ public class AppInfo extends ItemInfoWithIcon { */ public int isDisabled = ShortcutInfo.DEFAULT; + /** + * Stores if the app is a system app or not. + */ + public int isSystemApp; + public AppInfo() { itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; } @@ -71,6 +81,10 @@ public class AppInfo extends ItemInfoWithIcon { } intent = makeLaunchIntent(info); + + isSystemApp = (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0 + ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES; + } public AppInfo(AppInfo info) { @@ -79,6 +93,7 @@ public class AppInfo extends ItemInfoWithIcon { title = Utilities.trim(info.title); intent = new Intent(info.intent); isDisabled = info.isDisabled; + isSystemApp = info.isSystemApp; } @Override diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java index 84d6a9b34..902fd3439 100644 --- a/src/com/android/launcher3/UninstallDropTarget.java +++ b/src/com/android/launcher3/UninstallDropTarget.java @@ -21,6 +21,7 @@ import java.net.URISyntaxException; public class UninstallDropTarget extends ButtonDropTarget { private static final String TAG = "UninstallDropTarget"; + private static Boolean sUninstallDisabled; public UninstallDropTarget(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -48,13 +49,22 @@ public class UninstallDropTarget extends ButtonDropTarget { } public static boolean supportsDrop(Context context, ItemInfo info) { - UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); - Bundle restrictions = userManager.getUserRestrictions(); - if (restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) - || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false)) { + if (sUninstallDisabled == null) { + UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); + Bundle restrictions = userManager.getUserRestrictions(); + sUninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false) + || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false); + } + if (sUninstallDisabled) { return false; } + if (info instanceof AppInfo) { + AppInfo appInfo = (AppInfo) info; + if (appInfo.isSystemApp != AppInfo.FLAG_SYSTEM_UNKNOWN) { + return (appInfo.isSystemApp & AppInfo.FLAG_SYSTEM_NO) != 0; + } + } return getUninstallTarget(context, info) != null; } diff --git a/src/com/android/launcher3/logging/LoggerUtils.java b/src/com/android/launcher3/logging/LoggerUtils.java index ebb69c43b..81333b1a2 100644 --- a/src/com/android/launcher3/logging/LoggerUtils.java +++ b/src/com/android/launcher3/logging/LoggerUtils.java @@ -105,13 +105,13 @@ public class LoggerUtils { private static String getItemStr(Target t) { String typeStr = getFieldName(t.itemType, ItemType.class); if (t.packageNameHash != 0) { - typeStr += ", packageHash=" + t.packageNameHash; + typeStr += ", packageHash=" + t.packageNameHash + ", predictiveRank=" + t.predictedRank; } if (t.componentHash != 0) { - typeStr += ", componentHash=" + t.componentHash; + typeStr += ", componentHash=" + t.componentHash + ", predictiveRank=" + t.predictedRank; } if (t.intentHash != 0) { - typeStr += ", intentHash=" + t.intentHash; + typeStr += ", intentHash=" + t.intentHash + ", predictiveRank=" + t.predictedRank; } return typeStr + ", grid(" + t.gridX + "," + t.gridY + "), span(" + t.spanX + "," + t.spanY + "), pageIdx=" + t.pageIndex; @@ -125,9 +125,11 @@ public class LoggerUtils { public static Target newItemTarget(ItemInfo info) { Target t = newTarget(Target.Type.ITEM); + switch (info.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: t.itemType = ItemType.APP_ICON; + t.predictedRank = -100; // Never assigned break; case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: t.itemType = ItemType.SHORTCUT; |