From d2835935d2df8be70d1b37d3ef3b2fe0155b3422 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 13 Dec 2010 16:28:46 -0800 Subject: Fix issue #3258849: Grab thumbnail when exiting an app via back Also issue #3281400: Rotating a retained instance fragment leaks the fragment manager And turn off fragment debug logging. Change-Id: Ibdd7db82bb35618021bcba421ba92ced7cd691c2 --- core/java/android/app/ActivityManager.java | 42 +++++++++++++++++++++++++++--- core/java/android/app/BackStackRecord.java | 18 ++++++++----- core/java/android/app/Fragment.java | 11 +++++++- core/java/android/app/FragmentManager.java | 4 ++- core/java/android/view/IWindowManager.aidl | 2 +- core/java/android/view/Surface.java | 14 +++++++++- 6 files changed, 77 insertions(+), 14 deletions(-) (limited to 'core/java') diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index e168034..ebdc7fd 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -93,6 +93,17 @@ public class ActivityManager { * implementation that the alias referred to. Otherwise, this is null. */ public ComponentName origActivity; + + /** + * Thumbnail representation of the task's last state. Must + * use {@link ActivityManager#TASKS_GET_THUMBNAILS} to have this set. + */ + public Bitmap thumbnail; + + /** + * Description of the task's last state. + */ + public CharSequence description; public RecentTaskInfo() { } @@ -110,6 +121,14 @@ public class ActivityManager { dest.writeInt(0); } ComponentName.writeToParcel(origActivity, dest); + if (thumbnail != null) { + dest.writeInt(1); + thumbnail.writeToParcel(dest, 0); + } else { + dest.writeInt(0); + } + TextUtils.writeToParcel(description, dest, + Parcelable.PARCELABLE_WRITE_RETURN_VALUE); } public void readFromParcel(Parcel source) { @@ -120,6 +139,12 @@ public class ActivityManager { baseIntent = null; } origActivity = ComponentName.readFromParcel(source); + if (source.readInt() != 0) { + thumbnail = Bitmap.CREATOR.createFromParcel(source); + } else { + thumbnail = null; + } + description = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source); } public static final Creator CREATOR @@ -145,11 +170,16 @@ public class ActivityManager { public static final int RECENT_WITH_EXCLUDED = 0x0001; /** - * @hide - * TODO: Make this public. Provides a list that does not contain any + * Provides a list that does not contain any * recent tasks that currently are not available to the user. */ public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002; + + /** + * Flag for use with {@link #getRecentTasks}: also return the thumbnail + * bitmap (if available) for each recent task. + */ + public static final int TASKS_GET_THUMBNAILS = 0x0001000; /** * Return a list of the tasks that the user has recently launched, with @@ -158,6 +188,9 @@ public class ActivityManager { * @param maxNum The maximum number of entries to return in the list. The * actual number returned may be smaller, depending on how many tasks the * user has started and the maximum number the system can remember. + * @param flags Information about what to return. May be any combination + * of {@link #RECENT_WITH_EXCLUDED}, {@link #RECENT_IGNORE_UNAVAILABLE}, + * and {@link #TASKS_GET_THUMBNAILS}. * * @return Returns a list of RecentTaskInfo records describing each of * the recent tasks. @@ -203,7 +236,8 @@ public class ActivityManager { public ComponentName topActivity; /** - * Thumbnail representation of the task's current state. + * Thumbnail representation of the task's current state. Must + * use {@link ActivityManager#TASKS_GET_THUMBNAILS} to have this set. */ public Bitmap thumbnail; @@ -273,7 +307,7 @@ public class ActivityManager { readFromParcel(source); } } - + /** * Return a list of the tasks that are currently running, with * the most recent being first and older ones after in order. Note that diff --git a/core/java/android/app/BackStackRecord.java b/core/java/android/app/BackStackRecord.java index b47aefd..33b747c 100644 --- a/core/java/android/app/BackStackRecord.java +++ b/core/java/android/app/BackStackRecord.java @@ -233,19 +233,25 @@ final class BackStackRecord extends FragmentTransaction implements Op op = mHead; int num = 0; while (op != null) { - writer.print(prefix); writer.print(" #"); writer.print(num); - writer.print(" "); writer.print(op); writer.println(":"); + writer.print(prefix); writer.print(" Op #"); writer.print(num); + writer.println(":"); writer.print(innerPrefix); writer.print("cmd="); writer.print(op.cmd); - writer.println("fragment="); writer.println(op.fragment); + writer.print(" fragment="); writer.println(op.fragment); if (op.enterAnim != 0 || op.exitAnim != 0) { writer.print(prefix); writer.print("enterAnim="); writer.print(op.enterAnim); writer.print(" exitAnim="); writer.println(op.exitAnim); } if (op.removed != null && op.removed.size() > 0) { for (int i=0; i 0) { + simpleName = simpleName.substring(end+1); + } + } + sb.append(simpleName); + sb.append("{"); sb.append(Integer.toHexString(System.identityHashCode(this))); if (mIndex >= 0) { sb.append(" #"); diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 196e7b2..488b673 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -293,7 +293,7 @@ final class FragmentManagerState implements Parcelable { * Container for fragments associated with an activity. */ final class FragmentManagerImpl extends FragmentManager { - static final boolean DEBUG = true; + static final boolean DEBUG = false; static final String TAG = "FragmentManager"; static final String TARGET_REQUEST_CODE_STATE_TAG = "android:target_req_state"; @@ -562,6 +562,7 @@ final class FragmentManagerImpl extends FragmentManager { } } f.mActivity = mActivity; + f.mFragmentManager = mActivity.mFragments; f.mCalled = false; f.onAttach(mActivity); if (!f.mCalled) { @@ -737,6 +738,7 @@ final class FragmentManagerImpl extends FragmentManager { } f.mImmediateActivity = null; f.mActivity = null; + f.mFragmentManager = null; } } } diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index 2c8ca8b..8bdc1f8 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -186,5 +186,5 @@ interface IWindowManager /** * Create a screenshot of the applications currently displayed. */ - Bitmap screenshotApplications(int maxWidth, int maxHeight); + Bitmap screenshotApplications(IBinder appToken, int maxWidth, int maxHeight); } diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java index 86cd3b0..b8d72a6 100644 --- a/core/java/android/view/Surface.java +++ b/core/java/android/view/Surface.java @@ -377,17 +377,29 @@ public class Surface implements Parcelable { } /** + * Like {@link #screenshot(int, int, int, int)} but includes all + * Surfaces in the screenshot. + * + * @hide + */ + public static native Bitmap screenshot(int width, int height); + + /** * Copy the current screen contents into a bitmap and return it. * * @param width The desired width of the returned bitmap; the raw * screen will be scaled down to this size. * @param height The desired height of the returned bitmap; the raw * screen will be scaled down to this size. + * @param minLayer The lowest (bottom-most Z order) surface layer to + * include in the screenshot. + * @param maxLayer The highest (top-most Z order) surface layer to + * include in the screenshot. * @return Returns a Bitmap containing the screen contents. * * @hide */ - public static native Bitmap screenshot(int width, int height); + public static native Bitmap screenshot(int width, int height, int minLayer, int maxLayer); /** * set surface parameters. -- cgit v1.1