Nuke everything obsoleted by task snapshots
Test: go/wm-smoke
Change-Id: If9c9c2e66d97d6a5fa94d0d62ae7459fdde2a9a0
diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java
index f142ff6..f628d5e 100644
--- a/services/core/java/com/android/server/wm/AppWindowContainerController.java
+++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java
@@ -365,7 +365,6 @@
// Now that the app is going invisible, we can remove it. It will be restarted
// if made visible again.
wtoken.removeDeadWindows();
- wtoken.setVisibleBeforeClientHidden();
mService.mUnknownAppVisibilityController.appRemovedOrHidden(wtoken);
} else {
if (!mService.mAppTransition.isTransitionSet()
@@ -729,35 +728,6 @@
}
}
- /**
- * Takes a snapshot of the screen. In landscape mode this grabs the whole screen.
- * In portrait mode, it grabs the full screenshot.
- *
- * @param displayId the Display to take a screenshot of.
- * @param width the width of the target bitmap
- * @param height the height of the target bitmap
- * @param frameScale the scale to apply to the frame, only used when width = -1 and height = -1
- */
- public Bitmap screenshotApplications(int displayId, int width, int height, float frameScale) {
- try {
- Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenshotApplications");
- final DisplayContent dc;
- synchronized(mWindowMap) {
- dc = mRoot.getDisplayContentOrCreate(displayId);
- if (dc == null) {
- if (DEBUG_SCREENSHOT) Slog.i(TAG_WM, "Screenshot of " + mToken
- + ": returning null. No Display for displayId=" + displayId);
- return null;
- }
- }
- return dc.screenshotApplications(mToken.asBinder(), width, height,
- false /* includeFullDisplay */, frameScale, Bitmap.Config.RGB_565,
- false /* wallpaperOnly */, false /* includeDecor */);
- } finally {
- Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
- }
- }
-
void reportStartingWindowDrawn() {
mHandler.sendMessage(mHandler.obtainMessage(H.NOTIFY_STARTING_WINDOW_DRAWN));
}
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index 7545a10..d625003 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -78,8 +78,6 @@
import java.util.ArrayDeque;
import java.util.ArrayList;
-import static android.os.Build.VERSION_CODES.O;
-
class AppTokenList extends ArrayList<AppWindowToken> {
}
@@ -126,14 +124,6 @@
// case do not clear allDrawn until the animation completes.
boolean deferClearAllDrawn;
- /**
- * These are to track the app's real drawing status if there were no saved surfaces.
- * @see #updateDrawnWindowStates
- */
- boolean allDrawnExcludingSaved;
- private int mNumInterestingWindowsExcludingSaved;
- private int mNumDrawnWindowsExcludingSaved;
-
// Is this window's surface needed? This is almost like hidden, except
// it will sometimes be true a little earlier: when the token has
// been shown, but is still waiting for its app transition to execute
@@ -690,107 +680,9 @@
}
}
- /**
- * Checks whether we should save surfaces for this app.
- *
- * @return true if the surfaces should be saved, false otherwise.
- */
- boolean shouldSaveSurface() {
- // We want to save surface if the app's windows are "allDrawn".
- // (If we started entering animation early with saved surfaces, allDrawn
- // should have been restored to true. So we'll save again in that case
- // even if app didn't actually finish drawing.)
- return allDrawn;
- }
-
- private boolean canRestoreSurfaces() {
- for (int i = mChildren.size() -1; i >= 0; i--) {
- final WindowState w = mChildren.get(i);
- if (w.canRestoreSurface()) {
- return true;
- }
- }
- return false;
- }
-
- private void clearWasVisibleBeforeClientHidden() {
- for (int i = mChildren.size() - 1; i >= 0; i--) {
- final WindowState w = mChildren.get(i);
- w.clearWasVisibleBeforeClientHidden();
- }
- }
-
- /**
- * Whether the app has some window that is invisible in layout, but
- * animating with saved surface.
- */
- boolean isAnimatingInvisibleWithSavedSurface() {
- for (int i = mChildren.size() - 1; i >= 0; i--) {
- final WindowState w = mChildren.get(i);
- if (w.isAnimatingInvisibleWithSavedSurface()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Hide all window surfaces that's still invisible in layout but animating
- * with a saved surface, and mark them destroying.
- */
- void stopUsingSavedSurfaceLocked() {
- for (int i = mChildren.size() - 1; i >= 0; i--) {
- final WindowState w = mChildren.get(i);
- w.stopUsingSavedSurface();
- }
- destroySurfaces();
- }
-
- void markSavedSurfaceExiting() {
- for (int i = mChildren.size() - 1; i >= 0; i--) {
- final WindowState w = mChildren.get(i);
- w.markSavedSurfaceExiting();
- }
- }
-
- void restoreSavedSurfaceForInterestingWindows() {
- if (!canRestoreSurfaces()) {
- clearWasVisibleBeforeClientHidden();
- return;
- }
-
- // Check if all interesting windows are drawn and we can mark allDrawn=true.
- int interestingNotDrawn = -1;
-
- for (int i = mChildren.size() - 1; i >= 0; i--) {
- final WindowState w = mChildren.get(i);
- interestingNotDrawn = w.restoreSavedSurfaceForInterestingWindow();
- }
-
- if (!allDrawn) {
- allDrawn = (interestingNotDrawn == 0);
- if (allDrawn) {
- mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
- }
- }
- clearWasVisibleBeforeClientHidden();
-
- if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG,
- "restoreSavedSurfaceForInterestingWindows: " + this + " allDrawn=" + allDrawn
- + " interestingNotDrawn=" + interestingNotDrawn);
- }
-
- void destroySavedSurfaces() {
- for (int i = mChildren.size() - 1; i >= 0; i--) {
- final WindowState win = mChildren.get(i);
- win.destroySavedSurface();
- }
- }
-
void clearAllDrawn() {
allDrawn = false;
deferClearAllDrawn = false;
- allDrawnExcludingSaved = false;
}
Task getTask() {
@@ -1388,8 +1280,7 @@
private boolean allDrawnStatesConsidered() {
for (int i = mChildren.size() - 1; i >= 0; --i) {
final WindowState child = mChildren.get(i);
- if (child.mightAffectAllDrawn(false /*visibleOnly*/ )
- && !child.getDrawnStateEvaluated()) {
+ if (child.mightAffectAllDrawn() && !child.getDrawnStateEvaluated()) {
return false;
}
}
@@ -1429,23 +1320,6 @@
}
}
}
-
- if (!allDrawnExcludingSaved) {
- int numInteresting = mNumInterestingWindowsExcludingSaved;
- if (numInteresting > 0 && mNumDrawnWindowsExcludingSaved >= numInteresting) {
- if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawnExcludingSaved: " + this
- + " interesting=" + numInteresting
- + " drawn=" + mNumDrawnWindowsExcludingSaved);
- allDrawnExcludingSaved = true;
- if (mDisplayContent != null) {
- mDisplayContent.setLayoutNeeded();
- }
- if (isAnimatingInvisibleWithSavedSurface()
- && !mService.mFinishedEarlyAnim.contains(this)) {
- mService.mFinishedEarlyAnim.add(this);
- }
- }
- }
}
/**
@@ -1462,15 +1336,13 @@
+ " allDrawn=" + allDrawn + " freezingScreen=" + mAppAnimator.freezingScreen);
}
- if (allDrawn && allDrawnExcludingSaved && !mAppAnimator.freezingScreen) {
+ if (allDrawn && !mAppAnimator.freezingScreen) {
return false;
}
if (mLastTransactionSequence != mService.mTransactionSequence) {
mLastTransactionSequence = mService.mTransactionSequence;
mNumInterestingWindows = mNumDrawnWindows = 0;
- mNumInterestingWindowsExcludingSaved = 0;
- mNumDrawnWindowsExcludingSaved = 0;
startingDisplayed = false;
}
@@ -1478,7 +1350,7 @@
boolean isInterestingAndDrawn = false;
- if (!allDrawn && w.mightAffectAllDrawn(false /* visibleOnly */)) {
+ if (!allDrawn && w.mightAffectAllDrawn()) {
if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
Slog.v(TAG, "Eval win " + w + ": isDrawn=" + w.isDrawnLw()
+ ", isAnimationSet=" + winAnimator.isAnimationSet());
@@ -1513,23 +1385,6 @@
}
}
- if (!allDrawnExcludingSaved && w.mightAffectAllDrawn(true /* visibleOnly */)) {
- if (w != startingWindow && w.isInteresting()) {
- mNumInterestingWindowsExcludingSaved++;
- if (w.isDrawnLw() && !w.isAnimatingWithSavedSurface()) {
- mNumDrawnWindowsExcludingSaved++;
-
- if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Slog.v(TAG,
- "tokenMayBeDrawnExcludingSaved: " + this + " w=" + w
- + " numInteresting=" + mNumInterestingWindowsExcludingSaved
- + " freezingScreen=" + mAppAnimator.freezingScreen
- + " mAppFreezing=" + w.mAppFreezing);
-
- isInterestingAndDrawn = true;
- }
- }
- }
-
return isInterestingAndDrawn;
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index af86202..bd4aa97 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -1084,10 +1084,6 @@
}
forAllWindows(w -> {
- // Discard surface after orientation change, these can't be reused.
- if (w.mAppToken != null) {
- w.mAppToken.destroySavedSurfaces();
- }
if (w.mHasSurface && !rotateSeamlessly) {
if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Set mOrientationChanging of " + w);
w.setOrientationChanging(true);
@@ -2354,8 +2350,7 @@
} else if (w.mAppToken != null && w.mAppToken.isClientHidden()) {
Slog.w(TAG_WM, "LEAKED SURFACE (app token hidden): "
+ w + " surface=" + wsa.mSurfaceController
- + " token=" + w.mAppToken
- + " saved=" + w.hasSavedSurface());
+ + " token=" + w.mAppToken);
if (SHOW_TRANSACTIONS) logSurface(w, "LEAK DESTROY", false);
wsa.destroySurface();
mTmpWindow = w;
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 05ef1a5..b364fb9 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -18,7 +18,6 @@
import android.content.res.Configuration;
import android.graphics.Rect;
-import android.hardware.display.DisplayManager;
import android.hardware.power.V1_0.PowerHint;
import android.os.Binder;
import android.os.Debug;
@@ -671,10 +670,6 @@
// Don't remove this window until rotation has completed.
continue;
}
- // Discard the saved surface if window size is changed, it can't be reused.
- if (win.mAppToken != null) {
- win.mAppToken.destroySavedSurfaces();
- }
win.reportResized();
mService.mResizingWindows.remove(i);
}
@@ -704,7 +699,7 @@
if (win.getDisplayContent().mWallpaperController.isWallpaperTarget(win)) {
wallpaperDestroyed = true;
}
- win.destroyOrSaveSurfaceUnchecked();
+ win.destroySurfaceUnchecked();
} while (i > 0);
mService.mDestroySurface.clear();
}
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index ecf9067..4632402 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -16,8 +16,6 @@
package com.android.server.wm;
-import static android.app.ActivityManager.ENABLE_TASK_SNAPSHOTS;
-
import static com.android.server.wm.TaskSnapshotPersister.DISABLE_FULL_SIZED_BITMAPS;
import static com.android.server.wm.TaskSnapshotPersister.REDUCED_SCALE;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -225,7 +223,7 @@
}
private boolean shouldDisableSnapshots() {
- return !ENABLE_TASK_SNAPSHOTS || mIsRunningOnWear || mIsRunningOnTv || mIsRunningOnIoT;
+ return mIsRunningOnWear || mIsRunningOnTv || mIsRunningOnIoT;
}
private Rect minRect(Rect rect1, Rect rect2) {
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index 079ae40..c01ee31 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -272,7 +272,6 @@
mRemoveReplacedWindows = false;
}
- mService.stopUsingSavedSurfaceLocked();
mService.destroyPreservedSurfaceLocked();
mService.mWindowPlacerLocked.destroyPendingSurfaces();
diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java
index bf79dfa..926719d 100644
--- a/services/core/java/com/android/server/wm/WindowContainer.java
+++ b/services/core/java/com/android/server/wm/WindowContainer.java
@@ -363,13 +363,6 @@
}
}
- void setVisibleBeforeClientHidden() {
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowContainer wc = mChildren.get(i);
- wc.setVisibleBeforeClientHidden();
- }
- }
-
/**
* Returns true if the container or one of its children as some content it can display or wants
* to display (e.g. app views or saved surface).
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 8e741c5..32ee51c 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -445,13 +445,6 @@
final ArrayList<AppWindowToken> mFinishedStarting = new ArrayList<>();
/**
- * List of window tokens that have finished drawing their own windows and
- * no longer need to show any saved surfaces. Windows that's still showing
- * saved surfaces will be cleaned up after next animation pass.
- */
- final ArrayList<AppWindowToken> mFinishedEarlyAnim = new ArrayList<>();
-
- /**
* List of app window tokens that are waiting for replacing windows. If the
* replacement doesn't come in time the stale windows needs to be disposed of.
*/
@@ -2078,17 +2071,8 @@
winAnimator.mEnterAnimationPending = false;
winAnimator.mEnteringAnimation = false;
- final boolean usingSavedSurfaceBeforeVisible =
- oldVisibility != View.VISIBLE && win.isAnimatingWithSavedSurface();
- if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
- if (winAnimator.hasSurface() && !win.mAnimatingExit
- && usingSavedSurfaceBeforeVisible) {
- Slog.d(TAG, "Ignoring layout to invisible when using saved surface " + win);
- }
- }
- if (winAnimator.hasSurface() && !win.mAnimatingExit
- && !usingSavedSurfaceBeforeVisible) {
+ if (winAnimator.hasSurface() && !win.mAnimatingExit) {
if (DEBUG_VISIBILITY) Slog.i(TAG_WM, "Relayout invis " + win
+ ": mAnimatingExit=" + win.mAnimatingExit);
// If we are not currently running the exit animation, we
@@ -5374,14 +5358,6 @@
mDestroyPreservedSurface.clear();
}
- void stopUsingSavedSurfaceLocked() {
- for (int i = mFinishedEarlyAnim.size() - 1; i >= 0 ; i--) {
- final AppWindowToken wtoken = mFinishedEarlyAnim.get(i);
- wtoken.stopUsingSavedSurfaceLocked();
- }
- mFinishedEarlyAnim.clear();
- }
-
// -------------------------------------------------------------
// IWindowManager API
// -------------------------------------------------------------
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index f7ab534..e8e40a7 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -16,12 +16,10 @@
package com.android.server.wm;
-import static android.app.ActivityManager.ENABLE_TASK_SNAPSHOTS;
import static android.app.ActivityManager.StackId;
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
-import static android.app.ActivityManager.isLowRamDeviceStatic;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT;
@@ -38,7 +36,6 @@
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
-import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
import static android.view.WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
@@ -138,8 +135,8 @@
import android.os.Trace;
import android.os.UserHandle;
import android.os.WorkSource;
-import android.util.MergedConfiguration;
import android.util.DisplayMetrics;
+import android.util.MergedConfiguration;
import android.util.Slog;
import android.util.TimeUtils;
import android.util.proto.ProtoOutputStream;
@@ -182,9 +179,6 @@
// to capture touch events in that area.
static final int RESIZE_HANDLE_WIDTH_IN_DP = 30;
- private static final boolean DEBUG_DISABLE_SAVING_SURFACES = false ||
- ENABLE_TASK_SNAPSHOTS;
-
final WindowManagerService mService;
final WindowManagerPolicy mPolicy;
final Context mContext;
@@ -521,15 +515,6 @@
/** When true this window can be displayed on screens owther than mOwnerUid's */
private boolean mShowToOwnerOnly;
- // Whether the window has a saved surface from last pause, which can be
- // used to start an entering animation earlier.
- private boolean mSurfaceSaved = false;
-
- // Whether we're performing an entering animation with a saved surface. This flag is
- // true during the time we're showing a window with a previously saved surface. It's
- // cleared when surface is destroyed, saved, or re-drawn by the app.
- private boolean mAnimatingWithSavedSurface;
-
// Whether the window was visible when we set the app to invisible last time. WM uses
// this as a hint to restore the surface (if available) for early animation next time
// the app is brought visible.
@@ -585,8 +570,6 @@
*/
boolean mSeamlesslyRotated = false;
- private static final Region sEmptyRegion = new Region();
-
/**
* Surface insets from the previous call to relayout(), used to track
* if we are changing the Surface insets.
@@ -1370,10 +1353,7 @@
@Override
boolean hasContentToDisplay() {
- // If we're animating with a saved surface, we're already visible.
- // Return true so that the alpha doesn't get cleared.
- if (!mAppFreezing && isDrawnLw()
- && (mViewVisibility == View.VISIBLE || isAnimatingWithSavedSurface()
+ if (!mAppFreezing && isDrawnLw() && (mViewVisibility == View.VISIBLE
|| (mWinAnimator.isAnimationSet() && !mService.mAppTransition.isTransitionSet()))) {
return true;
}
@@ -1461,19 +1441,12 @@
/**
* Whether this window's drawn state might affect the drawn states of the app token.
*
- * @param visibleOnly Whether we should consider only the windows that's currently
- * visible in layout. If true, windows that has not relayout to VISIBLE
- * would always return false.
- *
* @return true if the window should be considered while evaluating allDrawn flags.
*/
- boolean mightAffectAllDrawn(boolean visibleOnly) {
- final boolean isViewVisible = (mAppToken == null || !mAppToken.isClientHidden())
- && (mViewVisibility == View.VISIBLE) && !mWindowRemovalAllowed;
- return (isOnScreen() && (!visibleOnly || isViewVisible)
- || mWinAnimator.mAttrType == TYPE_BASE_APPLICATION
- || mWinAnimator.mAttrType == TYPE_DRAWN_APPLICATION)
- && !mAnimatingExit && !mDestroying;
+ boolean mightAffectAllDrawn() {
+ final boolean isAppType = mWinAnimator.mAttrType == TYPE_BASE_APPLICATION
+ || mWinAnimator.mAttrType == TYPE_DRAWN_APPLICATION;
+ return (isOnScreen() || isAppType) && !mAnimatingExit && !mDestroying;
}
/**
@@ -1667,10 +1640,6 @@
@Override
void onResize() {
- // Some windows won't go through the resizing process, if they don't have a surface, so
- // destroy all saved surfaces here.
- destroySavedSurface();
-
final ArrayList<WindowState> resizingWindows = mService.mResizingWindows;
if (mHasSurface && !resizingWindows.contains(this)) {
if (DEBUG_RESIZE) Slog.d(TAG, "onResize: Resizing " + this);
@@ -1919,19 +1888,6 @@
return;
}
- if (isAnimatingWithSavedSurface() && !mAppToken.allDrawnExcludingSaved) {
- // We started enter animation early with a saved surface, now the app asks to remove
- // this window. If we remove it now and the app is not yet drawn, we'll show a
- // flicker. Delay the removal now until it's really drawn.
- if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM,
- "removeWindowLocked: delay removal of " + this + " due to early animation");
- // Do not set mAnimatingExit to true here, it will cause the surface to be hidden
- // immediately after the enter animation is done. If the app is not yet drawn then
- // it will show up as a flicker.
- setupWindowForRemoveOnExit();
- Binder.restoreCallingIdentity(origId);
- return;
- }
// If we are not currently running the exit animation, we need to see about starting one
wasVisible = isWinVisibleLw();
@@ -2634,10 +2590,6 @@
return mAnimatingExit || (mService.mClosingApps.contains(mAppToken));
}
- boolean isAnimatingWithSavedSurface() {
- return mAnimatingWithSavedSurface;
- }
-
@Override
boolean isAnimating() {
if (mWinAnimator.isAnimationSet() || mAnimatingExit) {
@@ -2646,48 +2598,6 @@
return super.isAnimating();
}
- boolean isAnimatingInvisibleWithSavedSurface() {
- if (mAnimatingWithSavedSurface
- && (mViewVisibility != View.VISIBLE || mWindowRemovalAllowed)) {
- return true;
- }
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- if (c.isAnimatingInvisibleWithSavedSurface()) {
- return true;
- }
- }
- return false;
- }
-
- void stopUsingSavedSurface() {
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- c.stopUsingSavedSurface();
- }
-
- if (!isAnimatingInvisibleWithSavedSurface()) {
- return;
- }
-
- if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.d(TAG, "stopUsingSavedSurface: " + this);
- clearAnimatingWithSavedSurface();
- mDestroying = true;
- mWinAnimator.hide("stopUsingSavedSurface");
- getDisplayContent().mWallpaperController.hideWallpapers(this);
- }
-
- void markSavedSurfaceExiting() {
- if (isAnimatingInvisibleWithSavedSurface()) {
- mAnimatingExit = true;
- mWinAnimator.mAnimating = true;
- }
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- c.markSavedSurfaceExiting();
- }
- }
-
void addWinAnimatorToList(ArrayList<WindowStateAnimator> animators) {
animators.add(mWinAnimator);
@@ -2726,25 +2636,6 @@
}
}
- public void setVisibleBeforeClientHidden() {
- mWasVisibleBeforeClientHidden |=
- (mViewVisibility == View.VISIBLE || mAnimatingWithSavedSurface);
-
- super.setVisibleBeforeClientHidden();
- }
-
- public void clearWasVisibleBeforeClientHidden() {
- mWasVisibleBeforeClientHidden = false;
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- c.clearWasVisibleBeforeClientHidden();
- }
- }
-
- public boolean wasVisibleBeforeClientHidden() {
- return mWasVisibleBeforeClientHidden;
- }
-
void onStartFreezingScreen() {
mAppFreezing = true;
for (int i = mChildren.size() - 1; i >= 0; --i) {
@@ -2777,48 +2668,6 @@
return true;
}
- private boolean shouldSaveSurface() {
- if (mWinAnimator.mSurfaceController == null) {
- // Don't bother if the surface controller is gone for any reason.
- return false;
- }
-
- if (!mWasVisibleBeforeClientHidden) {
- return false;
- }
-
- if ((mAttrs.flags & FLAG_SECURE) != 0) {
- // We don't save secure surfaces since their content shouldn't be shown while the app
- // isn't on screen and content might leak through during the transition animation with
- // saved surface.
- return false;
- }
-
- if (isLowRamDeviceStatic()) {
- // Don't save surfaces on Svelte devices.
- return false;
- }
-
- final Task task = getTask();
- final AppWindowToken taskTop = task.getTopVisibleAppToken();
- if (taskTop != null && taskTop != mAppToken) {
- // Don't save if the window is not the topmost window.
- return false;
- }
-
- if (mResizedWhileGone) {
- // Somebody resized our window while we were gone for layout, which means that the
- // client got an old size, so we have an outdated surface here.
- return false;
- }
-
- if (DEBUG_DISABLE_SAVING_SURFACES) {
- return false;
- }
-
- return mAppToken.shouldSaveSurface();
- }
-
boolean destroySurface(boolean cleanupOnResume, boolean appStopped) {
boolean destroyedSomething = false;
for (int i = mChildren.size() - 1; i >= 0; --i) {
@@ -2840,7 +2689,7 @@
+ " win.mWindowRemovalAllowed=" + mWindowRemovalAllowed
+ " win.mRemoveOnExit=" + mRemoveOnExit);
if (!cleanupOnResume || mRemoveOnExit) {
- destroyOrSaveSurfaceUnchecked();
+ destroySurfaceUnchecked();
}
if (mRemoveOnExit) {
removeImmediately();
@@ -2858,156 +2707,14 @@
// Destroy or save the application surface without checking
// various indicators of whether the client has released the surface.
// This is in general unsafe, and most callers should use {@link #destroySurface}
- void destroyOrSaveSurfaceUnchecked() {
- mSurfaceSaved = shouldSaveSurface();
- if (mSurfaceSaved) {
- if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
- Slog.v(TAG, "Saving surface: " + this);
- }
- // Previous user of the surface may have set a transparent region signaling a portion
- // doesn't need to be composited, so reset to default empty state.
- mSession.setTransparentRegion(mClient, sEmptyRegion);
+ void destroySurfaceUnchecked() {
+ mWinAnimator.destroySurfaceLocked();
- mWinAnimator.hide("saved surface");
- mWinAnimator.mDrawState = WindowStateAnimator.NO_SURFACE;
- setHasSurface(false);
- // The client should have disconnected at this point, but if it doesn't,
- // we need to make sure it's disconnected. Otherwise when we reuse the surface
- // the client can't reconnect to the buffer queue, and rendering will fail.
- if (mWinAnimator.mSurfaceController != null) {
- mWinAnimator.mSurfaceController.disconnectInTransaction();
- }
- mAnimatingWithSavedSurface = false;
- } else {
- mWinAnimator.destroySurfaceLocked();
- }
// Clear animating flags now, since the surface is now gone. (Note this is true even
// if the surface is saved, to outside world the surface is still NO_SURFACE.)
mAnimatingExit = false;
}
- void destroySavedSurface() {
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- c.destroySavedSurface();
- }
-
- if (mSurfaceSaved) {
- if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) Slog.v(TAG, "Destroying saved surface: " + this);
- mWinAnimator.destroySurfaceLocked();
- mSurfaceSaved = false;
- }
- mWasVisibleBeforeClientHidden = false;
- }
-
- /** Returns -1 if there are no interesting windows or number of interesting windows not drawn.*/
- int restoreSavedSurfaceForInterestingWindow() {
- int interestingNotDrawn = -1;
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- final int childInterestingNotDrawn = c.restoreSavedSurfaceForInterestingWindow();
- if (childInterestingNotDrawn != -1) {
- if (interestingNotDrawn == -1) {
- interestingNotDrawn = childInterestingNotDrawn;
- } else {
- interestingNotDrawn += childInterestingNotDrawn;
- }
- }
- }
-
- if (mAttrs.type == TYPE_APPLICATION_STARTING
- || mAppDied || !wasVisibleBeforeClientHidden()
- || (mAppToken.mAppAnimator.freezingScreen && mAppFreezing)) {
- // Window isn't interesting...
- return interestingNotDrawn;
- }
-
- restoreSavedSurface();
-
- if (!isDrawnLw()) {
- if (interestingNotDrawn == -1) {
- interestingNotDrawn = 1;
- } else {
- interestingNotDrawn++;
- }
- }
- return interestingNotDrawn;
- }
-
- /** Returns true if the saved surface was restored. */
- boolean restoreSavedSurface() {
- if (!mSurfaceSaved) {
- return false;
- }
-
- // Sometimes we save surfaces due to layout invisible directly after rotation occurs.
- // However this means the surface was never laid out in the new orientation.
- // We can only restore to the last rotation we were laid out as visible in.
- if (mLastVisibleLayoutRotation != getDisplayContent().getRotation()) {
- destroySavedSurface();
- return false;
- }
- mSurfaceSaved = false;
-
- if (mWinAnimator.mSurfaceController != null) {
- setHasSurface(true);
- mWinAnimator.mDrawState = READY_TO_SHOW;
- mAnimatingWithSavedSurface = true;
-
- requestUpdateWallpaperIfNeeded();
-
- if (DEBUG_APP_TRANSITIONS || DEBUG_ANIM) {
- Slog.v(TAG, "Restoring saved surface: " + this);
- }
- } else {
- // mSurfaceController shouldn't be null if mSurfaceSaved was still true at
- // this point. Even if we destroyed the saved surface because of rotation
- // or resize, mSurfaceSaved flag should have been cleared. So this is a wtf.
- Slog.wtf(TAG, "Failed to restore saved surface: surface gone! " + this);
- }
-
- return true;
- }
-
- boolean canRestoreSurface() {
- if (mWasVisibleBeforeClientHidden && mSurfaceSaved) {
- return true;
- }
-
- for (int i = mChildren.size() - 1; i >= 0; --i) {
- final WindowState c = mChildren.get(i);
- if (c.canRestoreSurface()) {
- return true;
- }
- }
-
- return false;
- }
-
- boolean hasSavedSurface() {
- return mSurfaceSaved;
- }
-
- void clearHasSavedSurface() {
- mSurfaceSaved = false;
- mAnimatingWithSavedSurface = false;
- if (mWasVisibleBeforeClientHidden) {
- mAppToken.destroySavedSurfaces();
- }
- }
-
- boolean clearAnimatingWithSavedSurface() {
- if (mAnimatingWithSavedSurface) {
- // App has drawn something to its windows, we're no longer animating with
- // the saved surfaces.
- if (DEBUG_ANIM) Slog.d(TAG,
- "clearAnimatingWithSavedSurface(): win=" + this);
- mAnimatingWithSavedSurface = false;
- return true;
- }
- return false;
- }
-
@Override
public boolean isDefaultDisplay() {
final DisplayContent displayContent = getDisplayContent();
@@ -3487,12 +3194,11 @@
if (mAppToken != null) {
pw.print(prefix); pw.print("mAppToken="); pw.println(mAppToken);
pw.print(prefix); pw.print(" isAnimatingWithSavedSurface()=");
- pw.print(isAnimatingWithSavedSurface());
pw.print(" mAppDied=");pw.print(mAppDied);
pw.print(prefix); pw.print("drawnStateEvaluated=");
pw.print(getDrawnStateEvaluated());
pw.print(prefix); pw.print("mightAffectAllDrawn=");
- pw.println(mightAffectAllDrawn(false /*visibleOnly*/));
+ pw.println(mightAffectAllDrawn());
}
pw.print(prefix); pw.print("mViewVisibility=0x");
pw.print(Integer.toHexString(mViewVisibility));
@@ -3543,7 +3249,6 @@
pw.print(prefix); pw.print("mHasSurface="); pw.print(mHasSurface);
pw.print(" mShownPosition="); mShownPosition.printShortString(pw);
pw.print(" isReadyForDisplay()="); pw.print(isReadyForDisplay());
- pw.print(" hasSavedSurface()="); pw.print(hasSavedSurface());
pw.print(" mWindowRemovalAllowed="); pw.println(mWindowRemovalAllowed);
if (dumpAll) {
pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
@@ -4601,11 +4306,6 @@
&& getResizeMode() == DRAG_RESIZE_MODE_DOCKED_DIVIDER;
result |= freeformResizing ? RELAYOUT_RES_DRAG_RESIZING_FREEFORM : 0;
result |= dockedResizing ? RELAYOUT_RES_DRAG_RESIZING_DOCKED : 0;
- if (isAnimatingWithSavedSurface()) {
- // If we're animating with a saved surface now, request client to report draw.
- // We still need to know when the real thing is drawn.
- result |= RELAYOUT_RES_FIRST_TIME;
- }
return result;
}
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 5f1e42c..ddb8df2 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -16,7 +16,6 @@
package com.android.server.wm;
-import static android.app.ActivityManager.StackId;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
@@ -347,7 +346,7 @@
mAnimation.cancel();
mAnimation = null;
mLocalAnimating = false;
- mWin.destroyOrSaveSurfaceUnchecked();
+ mWin.destroySurfaceUnchecked();
}
}
@@ -507,7 +506,7 @@
+ drawStateToString());
}
- boolean layoutNeeded = mWin.clearAnimatingWithSavedSurface();
+ boolean layoutNeeded = false;
if (mDrawState == DRAW_PENDING) {
if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
@@ -626,11 +625,6 @@
WindowSurfaceController createSurfaceLocked(int windowType, int ownerUid) {
final WindowState w = mWin;
- if (w.restoreSavedSurface()) {
- if (DEBUG_ANIM) Slog.i(TAG,
- "createSurface: " + this + ": called when we had a saved surface");
- return mSurfaceController;
- }
if (mSurfaceController != null) {
return mSurfaceController;
@@ -789,8 +783,7 @@
}
boolean hasSurface() {
- return !mWin.hasSavedSurface()
- && mSurfaceController != null && mSurfaceController.hasSurface();
+ return mSurfaceController != null && mSurfaceController.hasSurface();
}
void destroySurfaceLocked() {
@@ -801,8 +794,6 @@
}
}
- mWin.clearHasSavedSurface();
-
if (mSurfaceController == null) {
return;
}
diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
index 581b044..88625d3 100644
--- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
+++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java
@@ -2,7 +2,6 @@
package com.android.server.wm;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
-import static android.app.ActivityManagerInternal.APP_TRANSITION_SAVED_SURFACE;
import static android.app.ActivityManagerInternal.APP_TRANSITION_SNAPSHOT;
import static android.app.ActivityManagerInternal.APP_TRANSITION_SPLASH_SCREEN;
import static android.app.ActivityManagerInternal.APP_TRANSITION_WINDOWS_DRAWN;
@@ -445,13 +444,6 @@
for (int i = 0; i < appsCount; i++) {
AppWindowToken wtoken = mService.mClosingApps.valueAt(i);
- // If we still have some windows animating with saved surfaces that's
- // either invisible or already removed, mark them exiting so that they
- // are disposed of after the exit animation. These are not supposed to
- // be shown, or are delayed removal until app is actually drawn (in which
- // case the window will be removed after the animation).
- wtoken.markSavedSurfaceExiting();
-
final AppWindowAnimator appAnimator = wtoken.mAppAnimator;
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Now closing app " + wtoken);
appAnimator.clearThumbnail();
@@ -539,8 +531,6 @@
+ wtoken.startingMoved + " isRelaunching()="
+ wtoken.isRelaunching());
- final boolean drawnBeforeRestoring = wtoken.allDrawn;
- wtoken.restoreSavedSurfaceForInterestingWindows();
final boolean allDrawn = wtoken.allDrawn && !wtoken.isRelaunching();
if (!allDrawn && !wtoken.startingDisplayed && !wtoken.startingMoved) {
@@ -549,8 +539,7 @@
final TaskStack stack = wtoken.getStack();
final int stackId = stack != null ? stack.mStackId : INVALID_STACK_ID;
if (allDrawn) {
- outReasons.put(stackId, drawnBeforeRestoring ? APP_TRANSITION_WINDOWS_DRAWN
- : APP_TRANSITION_SAVED_SURFACE);
+ outReasons.put(stackId, APP_TRANSITION_WINDOWS_DRAWN);
} else {
outReasons.put(stackId, wtoken.startingData instanceof SplashScreenStartingData
? APP_TRANSITION_SPLASH_SCREEN