diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 4792dc98c0eeb..32751b2b47fe5 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -6628,9 +6628,7 @@ public class Activity extends ContextThemeWrapper mFragments.noteStateNotSaved(); if (mToken != null && mParent == null) { - // We might have view roots that were preserved during a relaunch, we need to start them - // again. We don't need to check mStopped, the roots will check if they were actually - // stopped. + // No need to check mStopped, the roots will check if they were actually stopped. WindowManagerGlobal.getInstance().setStoppedState(mToken, false /* stopped */); } @@ -6728,7 +6726,7 @@ public class Activity extends ContextThemeWrapper onUserLeaveHint(); } - final void performStop() { + final void performStop(boolean preserveWindow) { mDoReportFullyDrawn = false; mFragments.doLoaderStop(mChangingConfigurations /*retain*/); @@ -6737,7 +6735,10 @@ public class Activity extends ContextThemeWrapper mWindow.closeAllPanels(); } - if (mToken != null && mParent == null) { + // If we're preserving the window, don't setStoppedState to true, since we + // need the window started immediately again. Stopping the window will + // destroys hardware resources and causes flicker. + if (!preserveWindow && mToken != null && mParent == null) { WindowManagerGlobal.getInstance().setStoppedState(mToken, true); } diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index e0e41f115f71d..a38df615ceff1 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -3747,7 +3747,7 @@ public final class ActivityThread { if (!keepShown) { try { // Now we are idle. - r.activity.performStop(); + r.activity.performStop(false /*preserveWindow*/); } catch (Exception e) { if (!mInstrumentation.onException(r.activity, e)) { throw new RuntimeException( @@ -3888,7 +3888,7 @@ public final class ActivityThread { if (!r.stopped && !r.isPreHoneycomb()) { try { // Now we are idle. - r.activity.performStop(); + r.activity.performStop(false /*preserveWindow*/); } catch (Exception e) { if (!mInstrumentation.onException(r.activity, e)) { throw new RuntimeException( @@ -4058,7 +4058,7 @@ public final class ActivityThread { } if (!r.stopped) { try { - r.activity.performStop(); + r.activity.performStop(r.mPreserveWindow); } catch (SuperNotCalledException e) { throw e; } catch (Exception e) {