From f83c555d8a153662d067702c0df5761b5e71b1bf Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 31 Mar 2010 22:19:32 -0700 Subject: [PATCH] Fix issue #2561067: Screen Display half faded... Also a little tweak to the activity manager to behave better when an application crash, to hopefully mostly avoid situations where you get into a crash loop. Change-Id: I627cc1da3a0f16a180957f02bfbe5c81ecd31758 --- .../android/server/WindowManagerService.java | 8 +++++ .../server/am/ActivityManagerService.java | 32 +++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 0e4b38d6d5848..a1a8bf27e65c2 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -11269,6 +11269,8 @@ public class WindowManagerService extends IWindowManager.Stub float mDimTargetAlpha; float mDimDeltaPerMs; long mLastDimAnimTime; + + int mLastDimWidth, mLastDimHeight; DimAnimator (SurfaceSession session) { if (mDimSurface == null) { @@ -11294,12 +11296,18 @@ public class WindowManagerService extends IWindowManager.Stub dw + "x" + dh + ")"); mDimShown = true; try { + mLastDimWidth = dw; + mLastDimHeight = dh; mDimSurface.setPosition(0, 0); mDimSurface.setSize(dw, dh); mDimSurface.show(); } catch (RuntimeException e) { Slog.w(TAG, "Failure showing dim surface", e); } + } else if (mLastDimWidth != dw || mLastDimHeight != dh) { + mLastDimWidth = dw; + mLastDimHeight = dh; + mDimSurface.setSize(dw, dh); } } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index d59dd2184eb64..3b655fa7265b3 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -2996,7 +2996,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen if (!ret.finishing) { int index = indexOfTokenLocked(ret); if (index >= 0) { - finishActivityLocked(ret, 0, Activity.RESULT_CANCELED, + finishActivityLocked(ret, index, Activity.RESULT_CANCELED, null, "clear"); } return null; @@ -8910,6 +8910,34 @@ public final class ActivityManagerService extends ActivityManagerNative implemen removeProcessLocked(app, false); return false; } + } else { + HistoryRecord r = topRunningActivityLocked(null); + if (r.app == app) { + // If the top running activity is from this crashing + // process, then terminate it to avoid getting in a loop. + Slog.w(TAG, " Force finishing activity " + + r.intent.getComponent().flattenToShortString()); + int index = indexOfTokenLocked(r); + finishActivityLocked(r, index, + Activity.RESULT_CANCELED, null, "crashed"); + // Also terminate an activities below it that aren't yet + // stopped, to avoid a situation where one will get + // re-start our crashing activity once it gets resumed again. + index--; + if (index >= 0) { + r = (HistoryRecord)mHistory.get(index); + if (r.state == ActivityState.RESUMED + || r.state == ActivityState.PAUSING + || r.state == ActivityState.PAUSED) { + if (!r.isHomeActivity) { + Slog.w(TAG, " Force finishing activity " + + r.intent.getComponent().flattenToShortString()); + finishActivityLocked(r, index, + Activity.RESULT_CANCELED, null, "crashed"); + } + } + } + } } // Bump up the crash count of any services currently running in the proc. @@ -10228,12 +10256,10 @@ public final class ActivityManagerService extends ActivityManagerNative implemen int count = mHistory.size(); // convert the token to an entry in the history. - HistoryRecord r = null; int index = -1; for (int i=count-1; i>=0; i--) { Object o = mHistory.get(i); if (o == token) { - r = (HistoryRecord)o; index = i; break; }