summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2011-10-04 19:18:25 -0700
committerDanny Baumann <dannybaumann@web.de>2012-02-20 10:48:10 +0100
commit5eeec666b0b3fb03f27ae00d967a63bebd55d214 (patch)
tree8816c59ad79fc9aea37eb16e4477dc62003f3e84
parent866fe0d156ff3e054cfb30dee0364078e4f5dfa9 (diff)
downloadframeworks_base-5eeec666b0b3fb03f27ae00d967a63bebd55d214.zip
frameworks_base-5eeec666b0b3fb03f27ae00d967a63bebd55d214.tar.gz
frameworks_base-5eeec666b0b3fb03f27ae00d967a63bebd55d214.tar.bz2
Fix screen hang after dismissing a landscape alarm.
This is a squash commit of 3 ICS commits backported to gingerbread: - Always unfreeze display. Commit 161dc80ea754d987a905bc5814872168d581040d AOSP-Change-Id: I7a0f3be49fe723fe59cf6268861bc5fe7f49bc62 - Fix issue #3330037: Unnecessary orientations appear... ...when the device's physical orientation is portrait. We now hold off on computing app token orientation while preparing to open or close app tokens. Also clean up a few other little issues. Commit 94cb2ebfc3e789384a4c32b24ac1522cdcb3ae79 AOSP-Change-Id: Iae125a975c7706fb4d068c872fd172e69854ff15 Fix issue #5508024: Rotation jank seen in live wallpapers Fix a few places where we would unfreeze the screen too early. Now that we are no longer relying on surface flinger freezing, we can't depend on it keeping the screen frozen until surfaces get drawn. Commit 3ec891ae8067dd7afac5c0b5a8af0b726f4a4726 AOSP-Change-Id: Icb03bf30c9599a5e2016817bfa5ca6458adc7249 Change-Id: I8e716c71bb135d198fc5e9802ed13628461f11a9
-rw-r--r--services/java/com/android/server/ScreenRotationAnimation.java84
-rw-r--r--services/java/com/android/server/WindowManagerService.java143
-rwxr-xr-xservices/java/com/android/server/am/ActivityManagerService.java3
-rw-r--r--services/java/com/android/server/am/ActivityRecord.java9
-rw-r--r--services/java/com/android/server/am/ActivityStack.java3
5 files changed, 153 insertions, 89 deletions
diff --git a/services/java/com/android/server/ScreenRotationAnimation.java b/services/java/com/android/server/ScreenRotationAnimation.java
index 4290b89..b846b6f 100644
--- a/services/java/com/android/server/ScreenRotationAnimation.java
+++ b/services/java/com/android/server/ScreenRotationAnimation.java
@@ -59,7 +59,8 @@ class ScreenRotationAnimation {
final Matrix mSnapshotFinalMatrix = new Matrix();
final float[] mTmpFloats = new float[9];
- public ScreenRotationAnimation(Context context, Display display, SurfaceSession session) {
+ public ScreenRotationAnimation(Context context, Display display, SurfaceSession session,
+ boolean inTransaction) {
mContext = context;
mDisplay = display;
@@ -84,46 +85,59 @@ class ScreenRotationAnimation {
mOriginalWidth = mDisplayMetrics.widthPixels;
mOriginalHeight = mDisplayMetrics.heightPixels;
- Surface.openTransaction();
- if (mSurface != null) {
- mSurface.destroy();
- mSurface = null;
+ if (!inTransaction) {
+ if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG,
+ ">>> OPEN TRANSACTION ScreenRotationAnimation");
+ Surface.openTransaction();
}
- try {
- mSurface = new Surface(session, 0, "FreezeSurface",
- -1, mWidth, mHeight, PixelFormat.OPAQUE, 0);
- } catch (Surface.OutOfResourcesException e) {
- Slog.w(TAG, "Unable to allocate freeze surface", e);
- }
- mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 200);
- setRotation(display.getRotation());
- Rect dirty = new Rect(0, 0, mWidth, mHeight);
- Canvas c = null;
try {
- c = mSurface.lockCanvas(dirty);
- } catch (IllegalArgumentException e) {
- Slog.w(TAG, "Unable to lock surface", e);
- return;
- } catch (Surface.OutOfResourcesException e) {
- Slog.w(TAG, "Unable to lock surface", e);
- return;
- }
- if (c == null) {
- Slog.w(TAG, "Null surface");
- return;
- }
+ try {
+ mSurface = new Surface(session, 0, "FreezeSurface",
+ -1, mWidth, mHeight, PixelFormat.OPAQUE, 0);
+ mSurface.setLayer(WindowManagerService.TYPE_LAYER_MULTIPLIER * 200);
+ } catch (Surface.OutOfResourcesException e) {
+ Slog.w(TAG, "Unable to allocate freeze surface", e);
+ }
- if (screenshot != null) {
- c.drawBitmap(screenshot, 0, 0, new Paint(0));
- } else {
- c.drawColor(Color.GREEN);
- }
+ setRotation(display.getRotation());
- mSurface.unlockCanvasAndPost(c);
- Surface.closeTransaction();
+ if (mSurface != null) {
+ Rect dirty = new Rect(0, 0, mWidth, mHeight);
+ Canvas c = null;
+ try {
+ c = mSurface.lockCanvas(dirty);
+ } catch (IllegalArgumentException e) {
+ Slog.w(TAG, "Unable to lock surface", e);
+ return;
+ } catch (Surface.OutOfResourcesException e) {
+ Slog.w(TAG, "Unable to lock surface", e);
+ return;
+ }
+ if (c == null) {
+ Slog.w(TAG, "Null surface");
+ return;
+ }
+
+ if (screenshot != null) {
+ c.drawBitmap(screenshot, 0, 0, new Paint(0));
+ } else {
+ c.drawColor(Color.GREEN);
+ }
- screenshot.recycle();
+ mSurface.unlockCanvasAndPost(c);
+ }
+ } finally {
+ if (!inTransaction) {
+ Surface.closeTransaction();
+ if (WindowManagerService.SHOW_TRANSACTIONS) Slog.i(WindowManagerService.TAG,
+ "<<< CLOSE TRANSACTION ScreenRotationAnimation");
+ }
+
+ if (screenshot != null) {
+ screenshot.recycle();
+ }
+ }
}
static int deltaRotation(int oldRotation, int newRotation) {
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 45dc022..e136b72 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -2021,7 +2021,7 @@ public class WindowManagerService extends IWindowManager.Stub
TAG, "New client " + client.asBinder()
+ ": window=" + win);
- if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked()) {
+ if (win.isVisibleOrAdding() && updateOrientationFromAppTokensLocked(false)) {
reportNewConfig = true;
}
}
@@ -2112,7 +2112,7 @@ public class WindowManagerService extends IWindowManager.Stub
// So just update orientation if needed.
if (wasVisible && computeForcedAppOrientationLocked()
!= mForcedAppOrientation
- && updateOrientationFromAppTokensLocked()) {
+ && updateOrientationFromAppTokensLocked(false)) {
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
}
updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL);
@@ -2218,15 +2218,17 @@ public class WindowManagerService extends IWindowManager.Stub
synchronized (mWindowMap) {
WindowState w = windowForClientLocked(session, client, false);
if ((w != null) && (w.mSurface != null)) {
- if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION");
+ if (SHOW_TRANSACTIONS) Slog.i(TAG,
+ ">>> OPEN TRANSACTION setTransparentRegion");
Surface.openTransaction();
try {
if (SHOW_TRANSACTIONS) logSurface(w,
"transparentRegionHint=" + region, null);
w.mSurface.setTransparentRegionHint(region);
} finally {
- if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION");
Surface.closeTransaction();
+ if (SHOW_TRANSACTIONS) Slog.i(TAG,
+ "<<< CLOSE TRANSACTION setTransparentRegion");
}
}
}
@@ -2561,7 +2563,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (assignLayers) {
assignLayersLocked();
}
- configChanged = updateOrientationFromAppTokensLocked();
+ configChanged = updateOrientationFromAppTokensLocked(false);
performLayoutAndPlaceSurfacesLocked();
if (displayed && win.mIsWallpaper) {
updateWallpaperOffsetLocked(win, mDisplay.getWidth(),
@@ -3130,7 +3132,7 @@ public class WindowManagerService extends IWindowManager.Stub
long ident = Binder.clearCallingIdentity();
synchronized(mWindowMap) {
- if (updateOrientationFromAppTokensLocked()) {
+ if (updateOrientationFromAppTokensLocked(false)) {
if (freezeThisOneIfNeeded != null) {
AppWindowToken wtoken = findAppWindowToken(
freezeThisOneIfNeeded);
@@ -3152,7 +3154,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (currentConfig.diff(mTempConfiguration) != 0) {
mWaitingForConfig = true;
mLayoutNeeded = true;
- startFreezingDisplayLocked();
+ startFreezingDisplayLocked(false);
config = new Configuration(mTempConfiguration);
}
}
@@ -3177,7 +3179,7 @@ public class WindowManagerService extends IWindowManager.Stub
* @see android.view.IWindowManager#updateOrientationFromAppTokens(
* android.os.IBinder)
*/
- boolean updateOrientationFromAppTokensLocked() {
+ boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
if (mDisplayFrozen) {
// If the display is frozen, some activities may be in the middle
// of restarting, and thus have removed their old window. If the
@@ -3198,7 +3200,8 @@ public class WindowManagerService extends IWindowManager.Stub
//action like disabling/enabling sensors etc.,
mPolicy.setCurrentOrientationLw(req);
if (setRotationUncheckedLocked(WindowManagerPolicy.USE_LAST_ROTATION,
- mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE)) {
+ mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE,
+ inTransaction)) {
changed = true;
}
}
@@ -3734,6 +3737,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (w.mAppFreezing) {
w.mAppFreezing = false;
if (w.mSurface != null && !w.mOrientationChanging) {
+ if (DEBUG_ORIENTATION) Slog.v(TAG, "set mOrientationChanging of " + w);
w.mOrientationChanging = true;
}
unfrozeWindows = true;
@@ -3771,7 +3775,7 @@ public class WindowManagerService extends IWindowManager.Stub
wtoken.freezingScreen = true;
mAppsFreezingScreen++;
if (mAppsFreezingScreen == 1) {
- startFreezingDisplayLocked();
+ startFreezingDisplayLocked(false);
mH.removeMessages(H.APP_FREEZE_TIMEOUT);
mH.sendMessageDelayed(mH.obtainMessage(H.APP_FREEZE_TIMEOUT),
5000);
@@ -4539,7 +4543,7 @@ public class WindowManagerService extends IWindowManager.Stub
long origId = Binder.clearCallingIdentity();
boolean changed;
synchronized(mWindowMap) {
- changed = setRotationUncheckedLocked(rotation, animFlags);
+ changed = setRotationUncheckedLocked(rotation, animFlags, false);
}
if (changed || alwaysSendConfiguration) {
@@ -4557,7 +4561,7 @@ public class WindowManagerService extends IWindowManager.Stub
* Returns null if the rotation has been changed. In this case YOU
* MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN.
*/
- public boolean setRotationUncheckedLocked(int rotation, int animFlags) {
+ public boolean setRotationUncheckedLocked(int rotation, int animFlags, boolean inTransaction) {
boolean changed;
if (rotation == WindowManagerPolicy.USE_LAST_ROTATION) {
rotation = mRequestedRotation;
@@ -4584,17 +4588,28 @@ public class WindowManagerService extends IWindowManager.Stub
2000);
mWaitingForConfig = true;
mLayoutNeeded = true;
- startFreezingDisplayLocked();
+ startFreezingDisplayLocked(inTransaction);
Slog.i(TAG, "Setting rotation to " + rotation + ", animFlags=" + animFlags);
mInputManager.setDisplayOrientation(0, rotation);
if (mDisplayEnabled) {
if (CUSTOM_SCREEN_ROTATION && mPolicy.isScreenOn()) {
Surface.freezeDisplay(0);
- Surface.openTransaction();
- if (mScreenRotationAnimation != null) {
- mScreenRotationAnimation.setRotation(rotation);
+ if (!inTransaction) {
+ if (SHOW_TRANSACTIONS) Slog.i(TAG,
+ ">>> OPEN TRANSACTION setRotationUnchecked");
+ Surface.openTransaction();
+ }
+ try {
+ if (mScreenRotationAnimation != null) {
+ mScreenRotationAnimation.setRotation(rotation);
+ }
+ } finally {
+ if (!inTransaction) {
+ Surface.closeTransaction();
+ if (SHOW_TRANSACTIONS) Slog.i(TAG,
+ "<<< CLOSE TRANSACTION setRotationUnchecked");
+ }
}
- Surface.closeTransaction();
Surface.setOrientation(0, rotation, animFlags);
Surface.unfreezeDisplay(0);
} else {
@@ -4604,6 +4619,7 @@ public class WindowManagerService extends IWindowManager.Stub
for (int i=mWindows.size()-1; i>=0; i--) {
WindowState w = mWindows.get(i);
if (w.mSurface != null) {
+ if (DEBUG_ORIENTATION) Slog.v(TAG, "Set mOrientationChanging of " + w);
w.mOrientationChanging = true;
}
}
@@ -5049,7 +5065,13 @@ public class WindowManagerService extends IWindowManager.Stub
public Configuration computeNewConfiguration() {
synchronized (mWindowMap) {
- return computeNewConfigurationLocked();
+ Configuration config = computeNewConfigurationLocked();
+ if (config == null && mWaitingForConfig) {
+ // Nothing changed but we are waiting for something... stop that!
+ mWaitingForConfig = false;
+ performLayoutAndPlaceSurfacesLocked();
+ }
+ return config;
}
}
@@ -6359,6 +6381,8 @@ public class WindowManagerService extends IWindowManager.Stub
if (mSurface == null) {
mReportDestroySurface = false;
mSurfacePendingDestroy = false;
+ if (DEBUG_ORIENTATION) Slog.i(WindowManagerService.TAG,
+ "createSurface " + this + ": DRAW NOW PENDING");
mDrawPending = true;
mCommitDrawPending = false;
mReadyToShow = false;
@@ -6366,6 +6390,8 @@ public class WindowManagerService extends IWindowManager.Stub
mAppToken.allDrawn = false;
}
+ makeWindowFreezingScreenIfNeededLocked(this);
+
int flags = 0;
if (mAttrs.memoryType == MEMORY_TYPE_PUSH_BUFFERS) {
flags |= Surface.PUSH_BUFFERS;
@@ -6428,9 +6454,8 @@ public class WindowManagerService extends IWindowManager.Stub
+ ", set left=" + mFrame.left + " top=" + mFrame.top
+ ", animLayer=" + mAnimLayer);
if (SHOW_TRANSACTIONS) {
- Slog.i(TAG, ">>> OPEN TRANSACTION");
- if (SHOW_TRANSACTIONS) logSurface(this,
- "CREATE pos=(" + mFrame.left + "," + mFrame.top + ") (" +
+ Slog.i(TAG, ">>> OPEN TRANSACTION createSurfaceLocked");
+ logSurface(this, "CREATE pos=(" + mFrame.left + "," + mFrame.top + ") (" +
mFrame.width() + "x" + mFrame.height() + "), layer=" +
mAnimLayer + " HIDE", null);
}
@@ -6455,8 +6480,8 @@ public class WindowManagerService extends IWindowManager.Stub
}
mLastHidden = true;
} finally {
- if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION");
Surface.closeTransaction();
+ if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION createSurfaceLocked");
}
if (localLOGV) Slog.v(
TAG, "Created surface " + this);
@@ -6525,7 +6550,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean finishDrawingLocked() {
if (mDrawPending) {
if (SHOW_TRANSACTIONS || DEBUG_ORIENTATION) Slog.v(
- TAG, "finishDrawingLocked: " + mSurface);
+ TAG, "finishDrawingLocked: " + this + " in " + mSurface);
mCommitDrawPending = true;
mDrawPending = false;
return true;
@@ -8563,6 +8588,25 @@ public class WindowManagerService extends IWindowManager.Stub
return mPolicy.finishLayoutLw();
}
+ void makeWindowFreezingScreenIfNeededLocked(WindowState w) {
+ // If the screen is currently frozen, then keep
+ // it frozen until this window draws at its new
+ // orientation.
+ if (mDisplayFrozen) {
+ if (DEBUG_ORIENTATION) Slog.v(TAG,
+ "Resizing while display frozen: " + w);
+ w.mOrientationChanging = true;
+ if (!mWindowsFreezingScreen) {
+ mWindowsFreezingScreen = true;
+ // XXX should probably keep timeout from
+ // when we first froze the display.
+ mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
+ mH.sendMessageDelayed(mH.obtainMessage(
+ H.WINDOW_FREEZE_TIMEOUT), 2000);
+ }
+ }
+ }
+
private final void performLayoutAndPlaceSurfacesLockedInner(
boolean recoveringMemory) {
final long currentTime = SystemClock.uptimeMillis();
@@ -8599,7 +8643,7 @@ public class WindowManagerService extends IWindowManager.Stub
createWatermark = true;
}
- if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION");
+ if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION performLayoutAndPlaceSurfaces");
Surface.openTransaction();
@@ -8634,7 +8678,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
if ((changes&WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG) != 0) {
if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout");
- if (updateOrientationFromAppTokensLocked()) {
+ if (updateOrientationFromAppTokensLocked(true)) {
mLayoutNeeded = true;
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
}
@@ -8839,6 +8883,10 @@ public class WindowManagerService extends IWindowManager.Stub
+ " drawn=" + wtoken.numDrawnWindows);
wtoken.showAllWindowsLocked();
unsetAppFreezingScreenLocked(wtoken, false, true);
+ if (DEBUG_ORIENTATION) Slog.i(TAG,
+ "Setting orientationChangeComplete=true because wtoken "
+ + wtoken + " numInteresting=" + numInteresting
+ + " numDrawn=" + wtoken.numDrawnWindows);
orientationChangeComplete = true;
}
} else if (!wtoken.allDrawn) {
@@ -9064,7 +9112,8 @@ public class WindowManagerService extends IWindowManager.Stub
// This has changed the visibility of windows, so perform
// a new layout to get them all up-to-date.
- changes |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT;
+ changes |= PhoneWindowManager.FINISH_LAYOUT_REDO_LAYOUT
+ | WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG;
mLayoutNeeded = true;
if (!moveInputMethodWindowsIfNeededLocked(true)) {
assignLayersLocked();
@@ -9282,7 +9331,7 @@ public class WindowManagerService extends IWindowManager.Stub
// as running out of memory), don't take down the
// entire system.
Slog.e(TAG, "Failure updating surface of " + w
- + "size=(" + width + "x" + height
+ + " size=(" + width + "x" + height
+ "), pos=(" + w.mShownFrame.left
+ "," + w.mShownFrame.top + ")", e);
if (!recoveringMemory) {
@@ -9315,22 +9364,7 @@ public class WindowManagerService extends IWindowManager.Stub
w.mLastFrame.set(w.mFrame);
w.mLastContentInsets.set(w.mContentInsets);
w.mLastVisibleInsets.set(w.mVisibleInsets);
- // If the screen is currently frozen, then keep
- // it frozen until this window draws at its new
- // orientation.
- if (mDisplayFrozen) {
- if (DEBUG_ORIENTATION) Slog.v(TAG,
- "Resizing while display frozen: " + w);
- w.mOrientationChanging = true;
- if (!mWindowsFreezingScreen) {
- mWindowsFreezingScreen = true;
- // XXX should probably keep timeout from
- // when we first froze the display.
- mH.removeMessages(H.WINDOW_FREEZE_TIMEOUT);
- mH.sendMessageDelayed(mH.obtainMessage(
- H.WINDOW_FREEZE_TIMEOUT), 2000);
- }
- }
+ makeWindowFreezingScreenIfNeededLocked(w);
// If the orientation is changing, then we need to
// hold off on unfreezing the display until this
// window has been redrawn; to do that, we need
@@ -9646,8 +9680,6 @@ public class WindowManagerService extends IWindowManager.Stub
mPointerSurface.hide();
}
}
-
- if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION");
} catch (RuntimeException e) {
Slog.e(TAG, "Unhandled exception in Window Manager", e);
}
@@ -9656,6 +9688,8 @@ public class WindowManagerService extends IWindowManager.Stub
Surface.closeTransaction();
+ if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION performLayoutAndPlaceSurfaces");
+
if (mWatermark != null) {
mWatermark.drawIfNeeded();
}
@@ -9692,6 +9726,8 @@ public class WindowManagerService extends IWindowManager.Stub
+ Integer.toHexString(diff));
}
win.mConfiguration = mCurConfiguration;
+ if (DEBUG_ORIENTATION && win.mDrawPending) Slog.i(
+ TAG, "Resizing " + win + " WITH DRAW PENDING");
win.mClient.resized(win.mFrame.width(),
win.mFrame.height(), win.mLastContentInsets,
win.mLastVisibleInsets, win.mDrawPending,
@@ -9864,7 +9900,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
return true;
} catch (RuntimeException e) {
- Slog.w(TAG, "Failure showing surface " + win.mSurface + " in " + win);
+ Slog.w(TAG, "Failure showing surface " + win.mSurface + " in " + win, e);
}
reclaimSomeSurfaceMemoryLocked(win, "show");
@@ -9899,6 +9935,7 @@ public class WindowManagerService extends IWindowManager.Stub
+ " token=" + win.mToken
+ " pid=" + ws.mSession.mPid
+ " uid=" + ws.mSession.mUid);
+ if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
ws.mSurface.destroy();
ws.mSurfaceShown = false;
ws.mSurface = null;
@@ -9906,10 +9943,11 @@ public class WindowManagerService extends IWindowManager.Stub
i--;
N--;
leakedSurface = true;
- } else if (win.mAppToken != null && win.mAppToken.clientHidden) {
+ } else if (ws.mAppToken != null && ws.mAppToken.clientHidden) {
Slog.w(TAG, "LEAKED SURFACE (app token hidden): "
+ ws + " surface=" + ws.mSurface
+ " token=" + win.mAppToken);
+ if (SHOW_TRANSACTIONS) logSurface(ws, "LEAK DESTROY", null);
ws.mSurface.destroy();
ws.mSurfaceShown = false;
ws.mSurface = null;
@@ -9947,6 +9985,7 @@ public class WindowManagerService extends IWindowManager.Stub
// surface and ask the app to request another one.
Slog.w(TAG, "Looks like we have reclaimed some memory, clearing surface for retry.");
if (surface != null) {
+ if (SHOW_TRANSACTIONS) logSurface(win, "RECOVER DESTROY", null);
surface.destroy();
win.mSurfaceShown = false;
win.mSurface = null;
@@ -10074,7 +10113,7 @@ public class WindowManagerService extends IWindowManager.Stub
return result;
}
- private void startFreezingDisplayLocked() {
+ private void startFreezingDisplayLocked(boolean inTransaction) {
if (mDisplayFrozen) {
return;
}
@@ -10125,7 +10164,7 @@ public class WindowManagerService extends IWindowManager.Stub
if (CUSTOM_SCREEN_ROTATION && mPolicy.isScreenOn()) {
if (mScreenRotationAnimation == null) {
mScreenRotationAnimation = new ScreenRotationAnimation(mContext,
- mDisplay, mFxSession);
+ mDisplay, mFxSession, inTransaction);
}
} else {
Surface.freezeDisplay(0);
@@ -10150,15 +10189,15 @@ public class WindowManagerService extends IWindowManager.Stub
}
if (mScreenRotationAnimation != null) {
+ if (DEBUG_ORIENTATION) Slog.i(TAG, "**** Dismissing screen rotation animation");
if (mScreenRotationAnimation.dismiss(MAX_ANIMATION_DURATION,
mTransitionAnimationScale)) {
requestAnimationLocked(0);
} else {
mScreenRotationAnimation = null;
}
- } else {
- Surface.unfreezeDisplay(0);
}
+ Surface.unfreezeDisplay(0);
mInputMonitor.thawInputDispatchingLw();
@@ -10166,7 +10205,7 @@ public class WindowManagerService extends IWindowManager.Stub
// to avoid inconsistent states. However, something interesting
// could have actually changed during that time so re-evaluate it
// now to catch that.
- if (updateOrientationFromAppTokensLocked()) {
+ if (updateOrientationFromAppTokensLocked(false)) {
mH.sendEmptyMessage(H.SEND_NEW_CONFIGURATION);
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a165ebb..17f9214 100755
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2596,6 +2596,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (localLOGV) Slog.v(
TAG, "Removing this entry! frozen=" + r.haveState
+ " finishing=" + r.finishing);
+ r.makeFinishing();
mMainStack.mHistory.remove(i);
r.inHistory = false;
@@ -6450,7 +6451,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (r.state == ActivityState.RESUMED
|| r.state == ActivityState.PAUSING
|| r.state == ActivityState.PAUSED) {
- if (!r.isHomeActivity) {
+ if (!r.isHomeActivity || mHomeProcess != r.app) {
Slog.w(TAG, " Force finishing activity "
+ r.intent.getComponent().flattenToShortString());
r.stack.finishActivityLocked(r, index,
diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java
index 4d773e4..f0818d6 100644
--- a/services/java/com/android/server/am/ActivityRecord.java
+++ b/services/java/com/android/server/am/ActivityRecord.java
@@ -303,6 +303,15 @@ class ActivityRecord extends IApplicationToken.Stub {
}
}
+ void makeFinishing() {
+ if (!finishing) {
+ finishing = true;
+ if (task != null) {
+ task.numActivities--;
+ }
+ }
+ }
+
UriPermissionOwner getUriPermissionsLocked() {
if (uriPermissions == null) {
uriPermissions = new UriPermissionOwner(service, this);
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 95ef2ed..d1958f3 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -2891,7 +2891,7 @@ public class ActivityStack {
return false;
}
- r.finishing = true;
+ r.makeFinishing();
EventLog.writeEvent(EventLogTags.AM_FINISH_ACTIVITY,
System.identityHashCode(r),
r.task.taskId, r.shortComponentName, reason);
@@ -3100,6 +3100,7 @@ public class ActivityStack {
private final void removeActivityFromHistoryLocked(ActivityRecord r) {
if (r.state != ActivityState.DESTROYED) {
+ r.makeFinishing();
mHistory.remove(r);
r.inHistory = false;
r.resultTo = null;