summaryrefslogtreecommitdiff
path: root/src/com/android/launcher2/ItemInfo.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2014-03-19 13:59:11 -0700
committerAmith Yamasani <yamasani@google.com>2014-04-29 14:13:00 -0700
commit374753cabf05cde1ad669d07bde47e34fdcbe499 (patch)
tree6d65cbe352d19aa04e3647e01e8a83b6bed9f0cb /src/com/android/launcher2/ItemInfo.java
parenta937a864f6f50a1920ae2038a8b1812deb647e64 (diff)
downloadLauncher2-374753cabf05cde1ad669d07bde47e34fdcbe499.tar.gz
Launcher2 multi-profile support
Use LauncherApps API and badging APIs instead of PackageManager. 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 are only supported for the current profile. Widgets from the managed profile are not available. TODO: Handle users appearing and disappearing. Change-Id: I732a476d68236f7de7eaa5a2105c868621c8a57e
Diffstat (limited to 'src/com/android/launcher2/ItemInfo.java')
-rw-r--r--src/com/android/launcher2/ItemInfo.java34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/com/android/launcher2/ItemInfo.java b/src/com/android/launcher2/ItemInfo.java
index 165c07b9..dc5d3c71 100644
--- a/src/com/android/launcher2/ItemInfo.java
+++ b/src/com/android/launcher2/ItemInfo.java
@@ -17,8 +17,11 @@
package com.android.launcher2;
import android.content.ContentValues;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.util.Log;
import java.io.ByteArrayOutputStream;
@@ -28,9 +31,14 @@ import java.io.IOException;
* Represents an item in the launcher.
*/
class ItemInfo {
-
+
+ /**
+ * Intent extra to store the profile. Format: UserHandle
+ */
+ static final String EXTRA_PROFILE = "profile";
+
static final int NO_ID = -1;
-
+
/**
* The id in the settings database for this item
*/
@@ -53,7 +61,7 @@ class ItemInfo {
long container = NO_ID;
/**
- * Iindicates the screen in which the shortcut appears.
+ * Indicates the screen in which the shortcut appears.
*/
int screen = -1;
@@ -102,7 +110,10 @@ class ItemInfo {
*/
int[] dropPos = null;
+ UserHandle user;
+
ItemInfo() {
+ user = android.os.Process.myUserHandle();
}
ItemInfo(ItemInfo info) {
@@ -114,6 +125,7 @@ class ItemInfo {
screen = info.screen;
itemType = info.itemType;
container = info.container;
+ user = info.user;
// tempdebug:
LauncherModel.checkItemInfo(this);
}
@@ -133,12 +145,20 @@ class ItemInfo {
return "";
}
+ protected void updateUser(Intent intent) {
+ if (intent != null && intent.hasExtra(EXTRA_PROFILE)) {
+ user = (UserHandle) intent.getParcelableExtra(EXTRA_PROFILE);
+ }
+ }
+
/**
* Write the fields of this item to the DB
*
+ * @param context A context object to use for getting a UserManager
+ * instance.
* @param values
*/
- void onAddToDatabase(ContentValues values) {
+ void onAddToDatabase(Context context, ContentValues values) {
values.put(LauncherSettings.BaseLauncherColumns.ITEM_TYPE, itemType);
values.put(LauncherSettings.Favorites.CONTAINER, container);
values.put(LauncherSettings.Favorites.SCREEN, screen);
@@ -146,6 +166,9 @@ class ItemInfo {
values.put(LauncherSettings.Favorites.CELLY, cellY);
values.put(LauncherSettings.Favorites.SPANX, spanX);
values.put(LauncherSettings.Favorites.SPANY, spanY);
+ long serialNumber = ((UserManager) context.getSystemService(Context.USER_SERVICE))
+ .getSerialNumberForUser(user);
+ values.put(LauncherSettings.Favorites.PROFILE_ID, serialNumber);
}
void updateValuesWithCoordinates(ContentValues values, int cellX, int cellY) {
@@ -189,6 +212,7 @@ class ItemInfo {
public String toString() {
return "Item(id=" + this.id + " type=" + this.itemType + " container=" + this.container
+ " screen=" + screen + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX
- + " spanY=" + spanY + " dropPos=" + dropPos + ")";
+ + " spanY=" + spanY + " dropPos=" + dropPos + " user=" + user
+ + ")";
}
}