Always take an activity screenshot when pausing. automerge: 37f2718

automerge: bfa6059

* commit 'bfa6059b78dfe0a40e71df055c60e431478a3e9d':
  Always take an activity screenshot when pausing.
This commit is contained in:
Wale Ogunwale
2014-12-10 01:00:52 +00:00
committed by android-build-merger

View File

@@ -222,13 +222,6 @@ final class ActivityStack {
long mLaunchStartTime = 0; long mLaunchStartTime = 0;
long mFullyDrawnStartTime = 0; long mFullyDrawnStartTime = 0;
/**
* Save the most recent screenshot for reuse. This keeps Recents from taking two identical
* screenshots, one for the Recents thumbnail and one for the pauseActivity thumbnail.
*/
private ActivityRecord mLastScreenshotActivity = null;
private Bitmap mLastScreenshotBitmap = null;
int mCurrentUser; int mCurrentUser;
final int mStackId; final int mStackId;
@@ -741,18 +734,6 @@ final class ActivityStack {
} }
} }
/**
* This resets the saved state from the last screenshot, forcing a new screenshot to be taken
* again when requested.
*/
private void invalidateLastScreenshot() {
mLastScreenshotActivity = null;
if (mLastScreenshotBitmap != null) {
mLastScreenshotBitmap.recycle();
}
mLastScreenshotBitmap = null;
}
public final Bitmap screenshotActivities(ActivityRecord who) { public final Bitmap screenshotActivities(ActivityRecord who) {
if (DEBUG_SCREENSHOTS) Slog.d(TAG, "screenshotActivities: " + who); if (DEBUG_SCREENSHOTS) Slog.d(TAG, "screenshotActivities: " + who);
if (who.noDisplay) { if (who.noDisplay) {
@@ -762,30 +743,17 @@ final class ActivityStack {
if (isHomeStack()) { if (isHomeStack()) {
// This is an optimization -- since we never show Home or Recents within Recents itself, // This is an optimization -- since we never show Home or Recents within Recents itself,
// we can just go ahead and skip taking the screenshot if this is the home stack. In // we can just go ahead and skip taking the screenshot if this is the home stack.
// the case where the most recent task is not the task that was supplied, then the stack if (DEBUG_SCREENSHOTS) Slog.d(TAG, "\tHome stack");
// has changed, so invalidate the last screenshot().
invalidateLastScreenshot();
if (DEBUG_SCREENSHOTS) Slog.d(TAG, "\tIs Home stack? " + isHomeStack());
return null; return null;
} }
int w = mService.mThumbnailWidth; int w = mService.mThumbnailWidth;
int h = mService.mThumbnailHeight; int h = mService.mThumbnailHeight;
if (w > 0) { if (w > 0) {
if (who != mLastScreenshotActivity || mLastScreenshotBitmap == null if (DEBUG_SCREENSHOTS) Slog.d(TAG, "\tTaking screenshot");
|| mLastScreenshotActivity.state == ActivityState.RESUMED return mWindowManager.screenshotApplications(who.appToken, Display.DEFAULT_DISPLAY,
|| mLastScreenshotBitmap.getWidth() != w w, h, SCREENSHOT_FORCE_565);
|| mLastScreenshotBitmap.getHeight() != h) {
if (DEBUG_SCREENSHOTS) Slog.d(TAG, "\tUpdating screenshot");
mLastScreenshotActivity = who;
mLastScreenshotBitmap = mWindowManager.screenshotApplications(
who.appToken, Display.DEFAULT_DISPLAY, w, h, SCREENSHOT_FORCE_565);
}
if (mLastScreenshotBitmap != null) {
if (DEBUG_SCREENSHOTS) Slog.d(TAG, "\tReusing last screenshot");
return mLastScreenshotBitmap.copy(mLastScreenshotBitmap.getConfig(), true);
}
} }
Slog.e(TAG, "Invalid thumbnail dimensions: " + w + "x" + h); Slog.e(TAG, "Invalid thumbnail dimensions: " + w + "x" + h);
return null; return null;
@@ -1103,11 +1071,6 @@ final class ActivityStack {
next.cpuTimeAtResume = 0; // Couldn't get the cpu time of process next.cpuTimeAtResume = 0; // Couldn't get the cpu time of process
} }
// If we are resuming the activity that we had last screenshotted, then we know it will be
// updated, so invalidate the last screenshot to ensure we take a fresh one when requested
if (next == mLastScreenshotActivity) {
invalidateLastScreenshot();
}
next.returningOptions = null; next.returningOptions = null;
if (mActivityContainer.mActivityDisplay.mVisibleBehindActivity == next) { if (mActivityContainer.mActivityDisplay.mVisibleBehindActivity == next) {
@@ -1824,9 +1787,6 @@ final class ActivityStack {
// Do over! // Do over!
mStackSupervisor.scheduleResumeTopActivities(); mStackSupervisor.scheduleResumeTopActivities();
} }
if (next == mLastScreenshotActivity) {
invalidateLastScreenshot();
}
if (mStackSupervisor.reportResumedActivityLocked(next)) { if (mStackSupervisor.reportResumedActivityLocked(next)) {
mNoAnimActivities.clear(); mNoAnimActivities.clear();
if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked(); if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked();