summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2014-04-11 00:33:44 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-04-11 00:33:44 +0000
commitf781a9b6d8f8e48847dc95b5a1e9e9c84d352687 (patch)
tree5e22ed83a3b89e1f84ba3f3b0ac0588389e0a752 /packages/SystemUI
parent94d3f30ec3bed5003ffb8a1c5c49b19541e4845b (diff)
parentc095ca1cb8877121f768b5b6940e4025e810d4ba (diff)
downloadframeworks_base-f781a9b6d8f8e48847dc95b5a1e9e9c84d352687.zip
frameworks_base-f781a9b6d8f8e48847dc95b5a1e9e9c84d352687.tar.gz
frameworks_base-f781a9b6d8f8e48847dc95b5a1e9e9c84d352687.tar.bz2
am c095ca1c: Merge "Corp badging for Recents"
* commit 'c095ca1cb8877121f768b5b6940e4025e810d4ba': Corp badging for Recents
Diffstat (limited to 'packages/SystemUI')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java39
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/Task.java18
4 files changed, 63 insertions, 20 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
index eb09335..aa4e69a 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentTasksLoader.java
@@ -17,10 +17,12 @@
package com.android.systemui.recent;
import android.app.ActivityManager;
+import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -30,7 +32,9 @@ import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Process;
+import android.os.RemoteException;
import android.os.UserHandle;
+import android.os.UserManager;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@@ -162,9 +166,14 @@ public class RecentTasksLoader implements View.OnTouchListener {
intent.setComponent(origActivity);
}
final PackageManager pm = mContext.getPackageManager();
+ final IPackageManager ipm = AppGlobals.getPackageManager();
intent.setFlags((intent.getFlags()&~Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
| Intent.FLAG_ACTIVITY_NEW_TASK);
- final ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
+ ResolveInfo resolveInfo = null;
+ try {
+ resolveInfo = ipm.resolveIntent(intent, null, 0, userId);
+ } catch (RemoteException re) {
+ }
if (resolveInfo != null) {
final ActivityInfo info = resolveInfo.activityInfo;
final String title = info.loadLabel(pm).toString();
@@ -192,7 +201,11 @@ public class RecentTasksLoader implements View.OnTouchListener {
final PackageManager pm = mContext.getPackageManager();
Bitmap thumbnail = am.getTaskTopThumbnail(td.persistentTaskId);
Drawable icon = getFullResIcon(td.resolveInfo, pm);
-
+ if (td.userId != UserHandle.myUserId()) {
+ // Need to badge the icon
+ final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+ icon = um.getBadgedDrawableForUser(icon, new UserHandle(td.userId));
+ }
if (DEBUG) Log.v(TAG, "Loaded bitmap for task "
+ td + ": " + thumbnail);
synchronized (td) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
index 3c34e90..fd0f6d1 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
@@ -192,8 +192,9 @@ class TaskResourceLoader implements Runnable {
" forceLoad: " + forceLoadTask);
// Load the application icon
if (loadIcon == null || forceLoadTask) {
- ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent());
- Drawable icon = ssp.getActivityIcon(info);
+ ActivityInfo info = ssp.getActivityInfo(t.key.baseIntent.getComponent(),
+ t.userId);
+ Drawable icon = ssp.getActivityIcon(info, t.userId);
if (!mCancelled) {
if (icon != null) {
Console.log(Constants.DebugFlags.App.TaskDataLoader,
@@ -411,7 +412,7 @@ public class RecentsTaskLoader {
int taskCount = tasks.size();
for (int i = 0; i < taskCount; i++) {
ActivityManager.RecentTaskInfo t = tasks.get(i);
- ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent());
+ ActivityInfo info = ssp.getActivityInfo(t.baseIntent.getComponent(), t.userId);
String activityLabel = (t.activityLabel == null ? ssp.getActivityLabel(info) :
t.activityLabel.toString());
Bitmap activityIcon = t.activityIcon;
@@ -437,7 +438,7 @@ public class RecentsTaskLoader {
}
}
if (task.applicationIcon == null) {
- task.applicationIcon = ssp.getActivityIcon(info);
+ task.applicationIcon = ssp.getActivityIcon(info, task.userId);
if (task.applicationIcon != null) {
mApplicationIconCache.put(task.key, task.applicationIcon);
} else {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
index 505238d..7f0d9ee 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/SystemServicesProxy.java
@@ -18,14 +18,19 @@ package com.android.systemui.recents;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.os.UserManager;
import java.util.ArrayList;
import java.util.List;
@@ -38,6 +43,8 @@ import java.util.Random;
public class SystemServicesProxy {
ActivityManager mAm;
PackageManager mPm;
+ IPackageManager mIpm;
+ UserManager mUm;
String mPackage;
Bitmap mDummyIcon;
@@ -46,6 +53,8 @@ public class SystemServicesProxy {
public SystemServicesProxy(Context context) {
mAm = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
mPm = context.getPackageManager();
+ mUm = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ mIpm = AppGlobals.getPackageManager();
mPackage = context.getPackageName();
if (Constants.DebugFlags.App.EnableSystemServicesProxy) {
@@ -142,14 +151,19 @@ public class SystemServicesProxy {
mAm.removeTask(taskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
}
- /** Returns the activity info for a given component name */
- public ActivityInfo getActivityInfo(ComponentName cn) {
- if (mPm == null) return null;
+ /**
+ * Returns the activity info for a given component name.
+ *
+ * @param ComponentName The component name of the activity.
+ * @param userId The userId of the user that this is for.
+ */
+ public ActivityInfo getActivityInfo(ComponentName cn, int userId) {
+ if (mIpm == null) return null;
if (Constants.DebugFlags.App.EnableSystemServicesProxy) return null;
try {
- return mPm.getActivityInfo(cn, PackageManager.GET_META_DATA);
- } catch (PackageManager.NameNotFoundException e) {
+ return mIpm.getActivityInfo(cn, PackageManager.GET_META_DATA, userId);
+ } catch (RemoteException e) {
e.printStackTrace();
return null;
}
@@ -167,15 +181,22 @@ public class SystemServicesProxy {
return info.loadLabel(mPm).toString();
}
- /** Returns the activity icon */
- public Drawable getActivityIcon(ActivityInfo info) {
- if (mPm == null) return null;
+ /**
+ * Returns the activity icon for the ActivityInfo for a user, badging if
+ * necessary.
+ */
+ public Drawable getActivityIcon(ActivityInfo info, int userId) {
+ if (mPm == null || mUm == null) return null;
// If we are mocking, then return a mock label
if (Constants.DebugFlags.App.EnableSystemServicesProxy) {
return new ColorDrawable(0xFF666666);
}
- return info.loadIcon(mPm);
+ Drawable icon = info.loadIcon(mPm);
+ if (userId != UserHandle.myUserId()) {
+ icon = mUm.getBadgedDrawableForUser(icon, new UserHandle(userId));
+ }
+ return icon;
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index 189f358..ff062f6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -37,25 +37,33 @@ public class Task {
public static class TaskKey {
public final int id;
public final Intent baseIntent;
+ public final int userId;
- public TaskKey(int id, Intent intent) {
+ public TaskKey(int id, Intent intent, int userId) {
this.id = id;
this.baseIntent = intent;
+ this.userId = userId;
}
@Override
public boolean equals(Object o) {
- return hashCode() == o.hashCode();
+ if (!(o instanceof TaskKey)) {
+ return false;
+ }
+ return id == ((TaskKey) o).id
+ && userId == ((TaskKey) o).userId;
}
@Override
public int hashCode() {
- return id;
+ return (id << 5) + userId;
}
@Override
public String toString() {
- return "Task.Key: " + id + ", " + baseIntent.getComponent().getPackageName();
+ return "Task.Key: " + id + ", "
+ + "u" + userId + ", "
+ + baseIntent.getComponent().getPackageName();
}
}
@@ -75,7 +83,7 @@ public class Task {
public Task(int id, boolean isActive, Intent intent, String activityTitle,
Bitmap activityIcon, int userId) {
- this.key = new TaskKey(id, intent);
+ this.key = new TaskKey(id, intent, userId);
this.activityLabel = activityTitle;
this.activityIcon = activityIcon;
this.isActive = isActive;