summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/AppInfo.java')
-rw-r--r--src/com/android/launcher3/AppInfo.java65
1 files changed, 25 insertions, 40 deletions
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index da222f11f..bfcad84b3 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -17,21 +17,26 @@
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;
/**
* Represents an app in AllAppsView.
*/
-class AppInfo extends ItemInfo {
+public class AppInfo extends ItemInfo {
private static final String TAG = "Launcher3.AppInfo";
/**
@@ -60,7 +65,7 @@ class AppInfo extends ItemInfo {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
- protected Intent getIntent() {
+ public Intent getIntent() {
return intent;
}
@@ -71,28 +76,25 @@ 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());
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+ 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.getApplicationInfo().flags;
int flags = 0;
if ((appFlags & android.content.pm.ApplicationInfo.FLAG_SYSTEM) == 0) {
flags |= DOWNLOADED_FLAG;
@@ -104,10 +106,6 @@ class AppInfo extends ItemInfo {
return flags;
}
- public static long initFirstInstallTime(PackageInfo pi) {
- return pi.firstInstallTime;
- }
-
public AppInfo(AppInfo info) {
super(info);
componentName = info.componentName;
@@ -115,21 +113,7 @@ 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
@@ -137,7 +121,8 @@ class AppInfo extends ItemInfo {
return "ApplicationInfo(title=" + title.toString() + " id=" + this.id
+ " type=" + this.itemType + " container=" + this.container
+ " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY
- + " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + dropPos + ")";
+ + " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos)
+ + " user=" + user + ")";
}
public static void dumpApplicationInfoList(String tag, String label, ArrayList<AppInfo> list) {