Always take an activity screenshot when pausing.
http://ag/261732 introduced an optimization where we only take
the activity screenshot if is is not the activity we took a
screenshot for last. This causes us to display a stale screenshot
for activities that change their display content (using fragments)
without going through the pause/resume cycle. It should be safe
to always take a screenshot when we are pausing since the code
path is only called once per pause/resume cycle.
Bug: 18682160
Change-Id: Ie5c43cfd806286808af4233c5917ae7071908ebb
(cherry picked from commit eacdf2ce04)
This commit is contained in:
committed by
Olawale Ogunwale
parent
dad85a6c4b
commit
37f271869e
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user