diff options
| -rw-r--r-- | api/current.txt | 6 | ||||
| -rw-r--r-- | api/system-current.txt | 6 | ||||
| -rw-r--r-- | api/test-current.txt | 8 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 84 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java | 20 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityRecord.java | 9 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/TaskRecord.java | 8 |
7 files changed, 113 insertions, 28 deletions
diff --git a/api/current.txt b/api/current.txt index 79816ac17b67..0d22721be7c6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4006,8 +4006,10 @@ package android.app { } public static class ActivityManager.TaskDescription implements android.os.Parcelable { - ctor public ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap, int); - ctor public ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap); + ctor public deprecated ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap, int); + ctor public ActivityManager.TaskDescription(java.lang.String, int, int); + ctor public deprecated ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap); + ctor public ActivityManager.TaskDescription(java.lang.String, int); ctor public ActivityManager.TaskDescription(java.lang.String); ctor public ActivityManager.TaskDescription(); ctor public ActivityManager.TaskDescription(android.app.ActivityManager.TaskDescription); diff --git a/api/system-current.txt b/api/system-current.txt index 40683d359eaa..6fbb0ab04467 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4168,8 +4168,10 @@ package android.app { } public static class ActivityManager.TaskDescription implements android.os.Parcelable { - ctor public ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap, int); - ctor public ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap); + ctor public deprecated ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap, int); + ctor public ActivityManager.TaskDescription(java.lang.String, int, int); + ctor public deprecated ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap); + ctor public ActivityManager.TaskDescription(java.lang.String, int); ctor public ActivityManager.TaskDescription(java.lang.String); ctor public ActivityManager.TaskDescription(); ctor public ActivityManager.TaskDescription(android.app.ActivityManager.TaskDescription); diff --git a/api/test-current.txt b/api/test-current.txt index cb4a6f2f9414..4d5be2040297 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -4026,13 +4026,17 @@ package android.app { } public static class ActivityManager.TaskDescription implements android.os.Parcelable { - ctor public ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap, int); - ctor public ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap); + ctor public deprecated ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap, int); + ctor public ActivityManager.TaskDescription(java.lang.String, int, int); + ctor public deprecated ActivityManager.TaskDescription(java.lang.String, android.graphics.Bitmap); + ctor public ActivityManager.TaskDescription(java.lang.String, int); ctor public ActivityManager.TaskDescription(java.lang.String); ctor public ActivityManager.TaskDescription(); ctor public ActivityManager.TaskDescription(android.app.ActivityManager.TaskDescription); method public int describeContents(); method public android.graphics.Bitmap getIcon(); + method public java.lang.String getIconFilename(); + method public int getIconResource(); method public java.lang.String getLabel(); method public int getPrimaryColor(); method public void readFromParcel(android.os.Parcel); diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 027e811a3273..fc4c8d7f0666 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -17,6 +17,7 @@ package android.app; import android.Manifest; +import android.annotation.DrawableRes; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; @@ -941,11 +942,14 @@ public class ActivityManager { ATTR_TASKDESCRIPTION_PREFIX + "color"; private static final String ATTR_TASKDESCRIPTIONCOLOR_BACKGROUND = ATTR_TASKDESCRIPTION_PREFIX + "colorBackground"; - private static final String ATTR_TASKDESCRIPTIONICONFILENAME = + private static final String ATTR_TASKDESCRIPTIONICON_FILENAME = ATTR_TASKDESCRIPTION_PREFIX + "icon_filename"; + private static final String ATTR_TASKDESCRIPTIONICON_RESOURCE = + ATTR_TASKDESCRIPTION_PREFIX + "icon_resource"; private String mLabel; private Bitmap mIcon; + private int mIconRes; private String mIconFilename; private int mColorPrimary; private int mColorBackground; @@ -959,9 +963,27 @@ public class ActivityManager { * @param icon An icon that represents the current state of this task. * @param colorPrimary A color to override the theme's primary color. This color must be * opaque. + * @deprecated use TaskDescription constructor with icon resource instead */ + @Deprecated public TaskDescription(String label, Bitmap icon, int colorPrimary) { - this(label, icon, null, colorPrimary, 0, 0, 0); + this(label, icon, 0, null, colorPrimary, 0, 0, 0); + if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) { + throw new RuntimeException("A TaskDescription's primary color should be opaque"); + } + } + + /** + * Creates the TaskDescription to the specified values. + * + * @param label A label and description of the current state of this task. + * @param iconRes A drawable resource of an icon that represents the current state of this + * activity. + * @param colorPrimary A color to override the theme's primary color. This color must be + * opaque. + */ + public TaskDescription(String label, @DrawableRes int iconRes, int colorPrimary) { + this(label, null, iconRes, null, colorPrimary, 0, 0, 0); if ((colorPrimary != 0) && (Color.alpha(colorPrimary) != 255)) { throw new RuntimeException("A TaskDescription's primary color should be opaque"); } @@ -972,9 +994,22 @@ public class ActivityManager { * * @param label A label and description of the current state of this activity. * @param icon An icon that represents the current state of this activity. + * @deprecated use TaskDescription constructor with icon resource instead */ + @Deprecated public TaskDescription(String label, Bitmap icon) { - this(label, icon, null, 0, 0, 0, 0); + this(label, icon, 0, null, 0, 0, 0, 0); + } + + /** + * Creates the TaskDescription to the specified values. + * + * @param label A label and description of the current state of this activity. + * @param iconRes A drawable resource of an icon that represents the current state of this + * activity. + */ + public TaskDescription(String label, @DrawableRes int iconRes) { + this(label, null, iconRes, null, 0, 0, 0, 0); } /** @@ -983,21 +1018,22 @@ public class ActivityManager { * @param label A label and description of the current state of this activity. */ public TaskDescription(String label) { - this(label, null, null, 0, 0, 0, 0); + this(label, null, 0, null, 0, 0, 0, 0); } /** * Creates an empty TaskDescription. */ public TaskDescription() { - this(null, null, null, 0, 0, 0, 0); + this(null, null, 0, null, 0, 0, 0, 0); } /** @hide */ - public TaskDescription(String label, Bitmap icon, String iconFilename, int colorPrimary, - int colorBackground, int statusBarColor, int navigationBarColor) { + public TaskDescription(String label, Bitmap bitmap, int iconRes, String iconFilename, + int colorPrimary, int colorBackground, int statusBarColor, int navigationBarColor) { mLabel = label; - mIcon = icon; + mIcon = bitmap; + mIconRes = iconRes; mIconFilename = iconFilename; mColorPrimary = colorPrimary; mColorBackground = colorBackground; @@ -1019,6 +1055,7 @@ public class ActivityManager { public void copyFrom(TaskDescription other) { mLabel = other.mLabel; mIcon = other.mIcon; + mIconRes = other.mIconRes; mIconFilename = other.mIconFilename; mColorPrimary = other.mColorPrimary; mColorBackground = other.mColorBackground; @@ -1034,6 +1071,7 @@ public class ActivityManager { public void copyFromPreserveHiddenFields(TaskDescription other) { mLabel = other.mLabel; mIcon = other.mIcon; + mIconRes = other.mIconRes; mIconFilename = other.mIconFilename; mColorPrimary = other.mColorPrimary; if (other.mColorBackground != 0) { @@ -1106,6 +1144,14 @@ public class ActivityManager { } /** + * Sets the icon resource for this task description. + * @hide + */ + public void setIcon(int iconRes) { + mIconRes = iconRes; + } + + /** * Moves the icon bitmap reference from an actual Bitmap to a file containing the * bitmap. * @hide @@ -1133,6 +1179,13 @@ public class ActivityManager { } /** @hide */ + @TestApi + public int getIconResource() { + return mIconRes; + } + + /** @hide */ + @TestApi public String getIconFilename() { return mIconFilename; } @@ -1198,7 +1251,10 @@ public class ActivityManager { Integer.toHexString(mColorBackground)); } if (mIconFilename != null) { - out.attribute(null, ATTR_TASKDESCRIPTIONICONFILENAME, mIconFilename); + out.attribute(null, ATTR_TASKDESCRIPTIONICON_FILENAME, mIconFilename); + } + if (mIconRes != 0) { + out.attribute(null, ATTR_TASKDESCRIPTIONICON_RESOURCE, Integer.toString(mIconRes)); } } @@ -1210,8 +1266,10 @@ public class ActivityManager { setPrimaryColor((int) Long.parseLong(attrValue, 16)); } else if (ATTR_TASKDESCRIPTIONCOLOR_BACKGROUND.equals(attrName)) { setBackgroundColor((int) Long.parseLong(attrValue, 16)); - } else if (ATTR_TASKDESCRIPTIONICONFILENAME.equals(attrName)) { + } else if (ATTR_TASKDESCRIPTIONICON_FILENAME.equals(attrName)) { setIconFilename(attrValue); + } else if (ATTR_TASKDESCRIPTIONICON_RESOURCE.equals(attrName)) { + setIcon(Integer.parseInt(attrValue, 10)); } } @@ -1234,6 +1292,7 @@ public class ActivityManager { dest.writeInt(1); mIcon.writeToParcel(dest, 0); } + dest.writeInt(mIconRes); dest.writeInt(mColorPrimary); dest.writeInt(mColorBackground); dest.writeInt(mStatusBarColor); @@ -1249,6 +1308,7 @@ public class ActivityManager { public void readFromParcel(Parcel source) { mLabel = source.readInt() > 0 ? source.readString() : null; mIcon = source.readInt() > 0 ? Bitmap.CREATOR.createFromParcel(source) : null; + mIconRes = source.readInt(); mColorPrimary = source.readInt(); mColorBackground = source.readInt(); mStatusBarColor = source.readInt(); @@ -1269,8 +1329,8 @@ public class ActivityManager { @Override public String toString() { return "TaskDescription Label: " + mLabel + " Icon: " + mIcon + - " IconFilename: " + mIconFilename + " colorPrimary: " + mColorPrimary + - " colorBackground: " + mColorBackground + + " IconRes: " + mIconRes + " IconFilename: " + mIconFilename + + " colorPrimary: " + mColorPrimary + " colorBackground: " + mColorBackground + " statusBarColor: " + mColorBackground + " navigationBarColor: " + mNavigationBarColor; } diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index a392effb1bca..2f21148e63f3 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -45,6 +45,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.res.Resources; +import android.content.res.Resources.NotFoundException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -234,7 +235,6 @@ public class SystemServicesProxy { */ public List<ActivityManager.RecentTaskInfo> getRecentTasks(int numTasks, int userId) { if (mAm == null) return null; - try { List<ActivityManager.RecentTaskInfo> tasks = mIam.getRecentTasks(numTasks, RECENT_IGNORE_UNAVAILABLE, userId).getList(); @@ -627,12 +627,24 @@ public class SystemServicesProxy { public Drawable getBadgedTaskDescriptionIcon(ActivityManager.TaskDescription taskDescription, int userId, Resources res) { Bitmap tdIcon = taskDescription.getInMemoryIcon(); - if (tdIcon == null) { + Drawable dIcon = null; + if (tdIcon != null) { + dIcon = new BitmapDrawable(res, tdIcon); + } else if (taskDescription.getIconResource() != 0) { + try { + dIcon = mContext.getDrawable(taskDescription.getIconResource()); + } catch (NotFoundException e) { + Log.e(TAG, "Could not find icon drawable from resource", e); + } + } else { tdIcon = ActivityManager.TaskDescription.loadTaskDescriptionIcon( taskDescription.getIconFilename(), userId); + if (tdIcon != null) { + dIcon = new BitmapDrawable(res, tdIcon); + } } - if (tdIcon != null) { - return getBadgedIcon(new BitmapDrawable(res, tdIcon), userId); + if (dIcon != null) { + return getBadgedIcon(dIcon, userId); } return null; } diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 40e568c27900..a18b99472ffc 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -423,9 +423,13 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo if (iconFilename != null || taskDescription.getLabel() != null || taskDescription.getPrimaryColor() != 0) { pw.print(prefix); pw.print("taskDescription:"); - pw.print(" iconFilename="); pw.print(taskDescription.getIconFilename()); pw.print(" label=\""); pw.print(taskDescription.getLabel()); pw.print("\""); + pw.print(" icon="); pw.print(taskDescription.getInMemoryIcon() != null + ? taskDescription.getInMemoryIcon().getByteCount() + " bytes" + : "null"); + pw.print(" iconResource="); pw.print(taskDescription.getIconResource()); + pw.print(" iconFilename="); pw.print(taskDescription.getIconFilename()); pw.print(" primaryColor="); pw.println(Integer.toHexString(taskDescription.getPrimaryColor())); pw.print(prefix + " backgroundColor="); @@ -435,9 +439,6 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo pw.print(prefix + " navigationBarColor="); pw.println(Integer.toHexString(taskDescription.getNavigationBarColor())); } - if (iconFilename == null && taskDescription.getIcon() != null) { - pw.print(prefix); pw.println("taskDescription contains Bitmap"); - } } if (results != null) { pw.print(prefix); pw.print("results="); pw.println(results); diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 0bc30cf4110b..a1b45a1e1757 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -1559,6 +1559,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi // values in the TaskRecord. String label = null; String iconFilename = null; + int iconResource = -1; int colorPrimary = 0; int colorBackground = 0; int statusBarColor = 0; @@ -1570,6 +1571,9 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi if (label == null) { label = r.taskDescription.getLabel(); } + if (iconResource == -1) { + iconResource = r.taskDescription.getIconResource(); + } if (iconFilename == null) { iconFilename = r.taskDescription.getIconFilename(); } @@ -1584,8 +1588,8 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi } topActivity = false; } - lastTaskDescription = new TaskDescription(label, null, iconFilename, colorPrimary, - colorBackground, statusBarColor, navigationBarColor); + lastTaskDescription = new TaskDescription(label, null, iconResource, iconFilename, + colorPrimary, colorBackground, statusBarColor, navigationBarColor); if (mWindowContainerController != null) { mWindowContainerController.setTaskDescription(lastTaskDescription); } |