From 00fcb49a4cf68b973ac488520f3ed20444c02f8d Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Wed, 2 Nov 2011 21:53:47 -0700 Subject: [PATCH] Ensuring disabled apps don't appear in workspace (issue: 5557311) Change-Id: I4a016b200945779f6e73b9c9d1c2a13c2b0fdef9 --- src/com/android/launcher2/LauncherModel.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index c06bc0c31f..1755903ec1 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -28,7 +28,9 @@ import android.content.Context; import android.content.Intent; import android.content.Intent.ShortcutIconResource; import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.content.res.Resources; @@ -1629,6 +1631,17 @@ public class LauncherModel extends BroadcastReceiver { return null; } + try { + PackageInfo pi = manager.getPackageInfo(componentName.getPackageName(), 0); + if (!pi.applicationInfo.enabled) { + // If we return null here, the corresponding item will be removed from the launcher + // db and will not appear in the workspace. + return null; + } + } catch (NameNotFoundException e) { + Log.d(TAG, "getPackInfo failed for package " + componentName.getPackageName()); + } + // TODO: See if the PackageManager knows about this case. If it doesn't // then return null & delete this.