Ensuring disabled apps don't appear in workspace (issue: 5557311)
Change-Id: I4a016b200945779f6e73b9c9d1c2a13c2b0fdef9
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index c06bc0c..1755903 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -28,7 +28,9 @@
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 @@
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.