diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 60d3d1ec349b1..1b552b5375e79 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -29,6 +29,7 @@ import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE; import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING; import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; import static android.content.res.Configuration.SCREENLAYOUT_UNDEFINED; +import static android.view.Display.DEFAULT_DISPLAY; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ADD_REMOVE; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL; import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_APP; @@ -68,6 +69,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBILIT import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.am.ActivityManagerService.LOCK_SCREEN_SHOWN; +import static com.android.server.am.ActivityManagerService.TAKE_FULLSCREEN_SCREENSHOTS; import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.STARTING_WINDOW_REMOVED; @@ -669,7 +671,7 @@ final class ActivityStack { final boolean isOnHomeDisplay() { return isAttached() && - mActivityContainer.mActivityDisplay.mDisplayId == Display.DEFAULT_DISPLAY; + mActivityContainer.mActivityDisplay.mDisplayId == DEFAULT_DISPLAY; } void moveToFront(String reason) { @@ -1041,22 +1043,32 @@ final class ActivityStack { int w = mService.mThumbnailWidth; int h = mService.mThumbnailHeight; - float scale = 1f; - if (w > 0) { - if (DEBUG_SCREENSHOTS) Slog.d(TAG_SCREENSHOTS, "\tTaking screenshot"); - // When this flag is set, we currently take the fullscreen screenshot of the activity - // but scaled to half the size. This gives us a "good-enough" fullscreen thumbnail to - // use within SystemUI while keeping memory usage low. - if (ActivityManagerService.TAKE_FULLSCREEN_SCREENSHOTS) { - w = h = -1; - scale = mService.mFullscreenThumbnailScale; - } - return mWindowManager.screenshotApplications(who.appToken, Display.DEFAULT_DISPLAY, - w, h, scale); + if (w <= 0) { + Slog.e(TAG, "\tInvalid thumbnail dimensions: " + w + "x" + h); + return null; } - Slog.e(TAG, "Invalid thumbnail dimensions: " + w + "x" + h); - return null; + + if (mStackId == DOCKED_STACK_ID && mStackSupervisor.mIsDockMinimized) { + // When the docked stack is minimized its app windows are cropped significantly so any + // screenshot taken will not display the apps contain. So, we avoid taking a screenshot + // in that case. + if (DEBUG_SCREENSHOTS) Slog.e(TAG, "\tIn minimized docked stack"); + return null; + } + + float scale = 1f; + if (DEBUG_SCREENSHOTS) Slog.d(TAG_SCREENSHOTS, "\tTaking screenshot"); + + // When this flag is set, we currently take the fullscreen screenshot of the activity but + // scaled to half the size. This gives us a "good-enough" fullscreen thumbnail to use within + // SystemUI while keeping memory usage low. + if (TAKE_FULLSCREEN_SCREENSHOTS) { + w = h = -1; + scale = mService.mFullscreenThumbnailScale; + } + + return mWindowManager.screenshotApplications(who.appToken, DEFAULT_DISPLAY, w, h, scale); } /**