diff options
Diffstat (limited to 'src/com/android/launcher3/AppInfo.java')
-rw-r--r-- | src/com/android/launcher3/AppInfo.java | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java index c16e98f0c..40e8e6d0e 100644 --- a/src/com/android/launcher3/AppInfo.java +++ b/src/com/android/launcher3/AppInfo.java @@ -17,14 +17,18 @@ package com.android.launcher3; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.graphics.Bitmap; import android.util.Log; +import com.android.launcher3.compat.LauncherActivityInfoCompat; +import com.android.launcher3.compat.UserManagerCompat; +import com.android.launcher3.compat.UserHandleCompat; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -72,28 +76,24 @@ public class AppInfo extends ItemInfo { /** * Must not hold the Context. */ - public AppInfo(PackageManager pm, ResolveInfo info, IconCache iconCache, - HashMap<Object, CharSequence> labelCache) { - final String packageName = info.activityInfo.applicationInfo.packageName; - - this.componentName = new ComponentName(packageName, info.activityInfo.name); + public AppInfo(Context context, LauncherActivityInfoCompat info, UserHandleCompat user, + IconCache iconCache, HashMap<Object, CharSequence> labelCache) { + this.componentName = info.getComponentName(); this.container = ItemInfo.NO_ID; - this.setActivity(componentName, - Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); - - try { - PackageInfo pi = pm.getPackageInfo(packageName, 0); - flags = initFlags(pi); - firstInstallTime = initFirstInstallTime(pi); - } catch (NameNotFoundException e) { - Log.d(TAG, "PackageManager.getApplicationInfo failed for " + packageName); - } + flags = initFlags(info); + firstInstallTime = info.getFirstInstallTime(); iconCache.getTitleAndIcon(this, info, labelCache); + intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_LAUNCHER); + intent.setComponent(info.getComponentName()); + long serialNumber = UserManagerCompat.getInstance(context).getSerialNumberForUser(user); + intent.putExtra(EXTRA_PROFILE, serialNumber); + this.user = user; } - public static int initFlags(PackageInfo pi) { - int appFlags = pi.applicationInfo.flags; + private static int initFlags(LauncherActivityInfoCompat info) { + int appFlags = info.getApplicationFlags(); int flags = 0; if ((appFlags & android.content.pm.ApplicationInfo.FLAG_SYSTEM) == 0) { flags |= DOWNLOADED_FLAG; @@ -105,10 +105,6 @@ public class AppInfo extends ItemInfo { return flags; } - public static long initFirstInstallTime(PackageInfo pi) { - return pi.firstInstallTime; - } - public AppInfo(AppInfo info) { super(info); componentName = info.componentName; @@ -116,21 +112,7 @@ public class AppInfo extends ItemInfo { intent = new Intent(info.intent); flags = info.flags; firstInstallTime = info.firstInstallTime; - } - - /** - * Creates the application intent based on a component name and various launch flags. - * Sets {@link #itemType} to {@link LauncherSettings.BaseLauncherColumns#ITEM_TYPE_APPLICATION}. - * - * @param className the class name of the component representing the intent - * @param launchFlags the launch flags - */ - final void setActivity(ComponentName className, int launchFlags) { - intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_LAUNCHER); - intent.setComponent(className); - intent.setFlags(launchFlags); - itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_APPLICATION; + iconBitmap = info.iconBitmap; } @Override @@ -139,7 +121,7 @@ public class AppInfo extends ItemInfo { + " type=" + this.itemType + " container=" + this.container + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos) - + ")"; + + " user=" + user + ")"; } public static void dumpApplicationInfoList(String tag, String label, ArrayList<AppInfo> list) { |