diff options
author | Kenny Guy <kennyguy@google.com> | 2014-04-30 03:02:21 +0100 |
---|---|---|
committer | Kenny Guy <kennyguy@google.com> | 2014-04-30 23:43:00 +0100 |
commit | ed13187a745866483139e2878037e1f8427ce567 (patch) | |
tree | a60e4ab78d5365095fe90026df4dfa4e98e80d46 /src/com/android/launcher3/AppInfo.java | |
parent | 70c3d1da65fcdaf32b860a5582b211c1f0ae8718 (diff) | |
download | android_packages_apps_Trebuchet-ed13187a745866483139e2878037e1f8427ce567.tar.gz android_packages_apps_Trebuchet-ed13187a745866483139e2878037e1f8427ce567.tar.bz2 android_packages_apps_Trebuchet-ed13187a745866483139e2878037e1f8427ce567.zip |
Launcher3 multi-profile support
Use LauncherApps API and badging APIs instead of PackageManager.
With compatability layer that uses PackageManager pre L.
Adds support to show apps from current user and any managed profiles.
Background: Managed profiles are user sandboxes that are visible from
the primary user and can be launched as if they are a part of this user.
A launcher should now be capable of listing apps from this user as well
as related profiles of this user.
Launching of activities is now via the LauncherApps interface, to allow
for cross-profile app launching. Only activities with category LAUNCHER
can be added as a shortcut on the workspace for a managed profile.
Widgets and non-application shortcuts are only supported for the
current profile. Widgets from the managed profile are not available.
Change-Id: I5f396b1bf7f91ad91a5710ea4a0fd14573972eb9
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) { |