From 89ba6750e5310c4da51786bd7eb559a43cab3982 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Sun, 23 Jan 2011 16:51:16 -0800 Subject: [PATCH] Fix issue #3215261: NPE in WiFi Settings And also fix #3343369: EGL_BAD_DISPLAY and/or broadcast intent TIME_SET before boot completion And a few more tweaks to animations to keep the wallpaper displayed when needed. And make more use of the drag and drop "rotation disabled" thing to also use it while animating the screen rotation, since if we try to start a new rotation while doing the animation we end up with a mess. Change-Id: I373af305a6e23a92835abed96229a83e173f67ce --- core/java/android/app/LoadedApk.java | 2 +- core/res/res/anim/wallpaper_close_enter.xml | 2 +- .../res/anim/wallpaper_intra_close_enter.xml | 2 +- .../res/anim/wallpaper_intra_open_exit.xml | 2 +- core/res/res/anim/wallpaper_open_exit.xml | 2 +- .../android/server/AlarmManagerService.java | 3 +- .../android/server/WindowManagerService.java | 72 +++++++++++-------- 7 files changed, 51 insertions(+), 34 deletions(-) diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 03a98d15ac2d0..60213f81e3164 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -696,7 +696,7 @@ final class LoadedApk { final Intent intent = mCurIntent; mCurIntent = null; - if (receiver == null) { + if (receiver == null || !mRegistered) { if (mRegistered && ordered) { if (ActivityThread.DEBUG_BROADCAST) Slog.i(ActivityThread.TAG, "Finishing null broadcast to " + mReceiver); diff --git a/core/res/res/anim/wallpaper_close_enter.xml b/core/res/res/anim/wallpaper_close_enter.xml index 42a9d389ade4d..e05345dc16cb3 100644 --- a/core/res/res/anim/wallpaper_close_enter.xml +++ b/core/res/res/anim/wallpaper_close_enter.xml @@ -18,7 +18,7 @@ --> + android:detachWallpaper="true" android:shareInterpolator="false"> + android:detachWallpaper="true" android:shareInterpolator="false"> + android:detachWallpaper="true" android:shareInterpolator="false"> + android:detachWallpaper="true" android:shareInterpolator="false"> mRotationWatchers = new ArrayList(); + int mDeferredRotation; + int mDeferredRotationAnimFlags; boolean mLayoutNeeded = true; boolean mAnimationPending = false; @@ -516,10 +518,6 @@ public class WindowManagerService extends IWindowManager.Stub ArrayList mNotifiedWindows; boolean mDragInProgress; - boolean mPerformDeferredRotation; - int mRotation; - int mAnimFlags; - private final Region mTmpRegion = new Region(); DragState(IBinder token, Surface surface, int flags, IBinder localWin) { @@ -541,7 +539,6 @@ public class WindowManagerService extends IWindowManager.Stub mData = null; mThumbOffsetX = mThumbOffsetY = 0; mNotifiedWindows = null; - mPerformDeferredRotation = false; } void register() { @@ -683,24 +680,15 @@ public class WindowManagerService extends IWindowManager.Stub mInputMonitor.setUpdateInputWindowsNeededLw(); mInputMonitor.updateInputWindowsLw(); - // Retain the parameters of any deferred rotation operation so - // that we can perform it after the reset / unref of the drag state - final boolean performRotation = mPerformDeferredRotation; - final int rotation = mRotation; - final int animFlags = mAnimFlags; - // free our resources and drop all the object references mDragState.reset(); mDragState = null; - // Now that we've officially ended the drag, execute any - // deferred rotation - if (performRotation) { - if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-drag rotation"); - boolean changed = setRotationUncheckedLocked(rotation, animFlags, false); - if (changed) { - sendNewConfiguration(); - } + if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-drag rotation"); + boolean changed = setRotationUncheckedLocked( + WindowManagerPolicy.USE_LAST_ROTATION, 0, false); + if (changed) { + sendNewConfiguration(); } } @@ -836,12 +824,6 @@ public class WindowManagerService extends IWindowManager.Stub return touchedWin; } - - void setDeferredRotation(int rotation, int animFlags) { - mRotation = rotation; - mAnimFlags = animFlags; - mPerformDeferredRotation = true; - } } DragState mDragState = null; @@ -5168,21 +5150,30 @@ public class WindowManagerService extends IWindowManager.Stub * MUST CALL setNewConfiguration() TO UNFREEZE THE SCREEN. */ public boolean setRotationUncheckedLocked(int rotation, int animFlags, boolean inTransaction) { - if (mDragState != null) { + if (mDragState != null || mScreenRotationAnimation != null) { // Potential rotation during a drag. Don't do the rotation now, but make // a note to perform the rotation later. - if (DEBUG_ORIENTATION) Slog.v(TAG, "Deferring rotation during drag"); - mDragState.setDeferredRotation(rotation, animFlags); + if (DEBUG_ORIENTATION) Slog.v(TAG, "Deferring rotation."); + if (rotation != WindowManagerPolicy.USE_LAST_ROTATION) { + mDeferredRotation = rotation; + mDeferredRotationAnimFlags = animFlags; + } return false; } boolean changed; if (rotation == WindowManagerPolicy.USE_LAST_ROTATION) { + if (mDeferredRotation != WindowManagerPolicy.USE_LAST_ROTATION) { + rotation = mDeferredRotation; + mRequestedRotation = rotation; + mLastRotationFlags = mDeferredRotationAnimFlags; + } rotation = mRequestedRotation; } else { mRequestedRotation = rotation; mLastRotationFlags = animFlags; } + mDeferredRotation = WindowManagerPolicy.USE_LAST_ROTATION; if (DEBUG_ORIENTATION) Slog.v(TAG, "Overwriting rotation value from " + rotation); rotation = mPolicy.rotationForOrientationLw(mForcedAppOrientation, mRotation, mDisplayEnabled); @@ -9634,6 +9625,7 @@ public class WindowManagerService extends IWindowManager.Stub boolean focusDisplayed = false; boolean animating = false; boolean createWatermark = false; + boolean updateRotation = false; if (mFxSession == null) { mFxSession = new SurfaceSession(); @@ -9731,6 +9723,7 @@ public class WindowManagerService extends IWindowManager.Stub animating = true; } else { mScreenRotationAnimation = null; + updateRotation = true; } } } @@ -10892,6 +10885,15 @@ public class WindowManagerService extends IWindowManager.Stub mTurnOnScreen = false; } + if (updateRotation) { + if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); + boolean changed = setRotationUncheckedLocked( + WindowManagerPolicy.USE_LAST_ROTATION, 0, false); + if (changed) { + sendNewConfiguration(); + } + } + // Check to see if we are now in a state where the screen should // be enabled, because the window obscured flags have changed. enableScreenIfNeededLocked(); @@ -11218,6 +11220,8 @@ public class WindowManagerService extends IWindowManager.Stub Debug.stopMethodTracing(); } + boolean updateRotation = false; + if (CUSTOM_SCREEN_ROTATION) { if (mScreenRotationAnimation != null) { if (mScreenRotationAnimation.dismiss(MAX_ANIMATION_DURATION, @@ -11225,6 +11229,7 @@ public class WindowManagerService extends IWindowManager.Stub requestAnimationLocked(0); } else { mScreenRotationAnimation = null; + updateRotation = true; } } } else { @@ -11251,6 +11256,15 @@ public class WindowManagerService extends IWindowManager.Stub 2000); mScreenFrozenLock.release(); + + if (updateRotation) { + if (DEBUG_ORIENTATION) Slog.d(TAG, "Performing post-rotate rotation"); + boolean changed = setRotationUncheckedLocked( + WindowManagerPolicy.USE_LAST_ROTATION, 0, false); + if (changed) { + sendNewConfiguration(); + } + } } static int getPropertyInt(String[] tokens, int index, int defUnits, int defDps, @@ -11629,6 +11643,8 @@ public class WindowManagerService extends IWindowManager.Stub pw.print(" mRotation="); pw.print(mRotation); pw.print(", mForcedAppOrientation="); pw.print(mForcedAppOrientation); pw.print(", mRequestedRotation="); pw.println(mRequestedRotation); + pw.print(" mDeferredRotation="); pw.print(mDeferredRotation); + pw.print(", mDeferredRotationAnimFlags="); pw.print(mDeferredRotationAnimFlags); pw.print(" mAnimationPending="); pw.print(mAnimationPending); pw.print(" mWindowAnimationScale="); pw.print(mWindowAnimationScale); pw.print(" mTransitionWindowAnimationScale="); pw.println(mTransitionAnimationScale);