From 25994b4306a256b88d79159106834c9f114e6943 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 4 Sep 2009 14:21:19 -0700 Subject: [PATCH] Wallpapers: new transitions, hiding when not visible, other cleanup. This is work on the transitions with wallpapers. There are now new animations specifically for leaving the wallpaper and returning to it, which allow us to have a consistent animation when entering home and returning to it. I also renamed the existing animations across wallpapers, and cleaned up some junk in the various interpolators. This also now hides the wallpaper surface when it is not visible, to get rid of the wallpaper flickers people complained about albeit in a somewhat brutal way. :) (Though really returning us to the previous behavior with the same previous bugs and name back to them not being very visible, yay!) There is are also some bug fixes here and there about managing the wallpaper visibility that this change revealed. Change-Id: I913990a9a81651728122ed2e1101b75ed2c36fcb --- api/current.xml | 58 +++++++- .../android/view/WindowManagerPolicy.java | 10 +- .../accelerate_decelerate_interpolator.xml | 2 +- core/res/res/anim/accelerate_interpolator.xml | 2 +- core/res/res/anim/anticipate_interpolator.xml | 2 +- .../anticipate_overshoot_interpolator.xml | 2 +- core/res/res/anim/bounce_interpolator.xml | 2 +- core/res/res/anim/decelerate_interpolator.xml | 2 +- core/res/res/anim/linear_interpolator.xml | 2 +- core/res/res/anim/overshoot_interpolator.xml | 2 +- core/res/res/anim/wallpaper_close_enter.xml | 25 ++++ core/res/res/anim/wallpaper_close_exit.xml | 30 ++++ ...er.xml => wallpaper_intra_close_enter.xml} | 2 +- ...xit.xml => wallpaper_intra_close_exit.xml} | 2 +- ...ter.xml => wallpaper_intra_open_enter.xml} | 2 +- ...exit.xml => wallpaper_intra_open_exit.xml} | 2 +- core/res/res/anim/wallpaper_open_enter.xml | 30 ++++ core/res/res/anim/wallpaper_open_exit.xml | 25 ++++ core/res/res/values/attrs.xml | 37 ++++- core/res/res/values/public.xml | 12 +- core/res/res/values/styles.xml | 12 +- .../android/server/WindowManagerService.java | 138 ++++++++++++------ 22 files changed, 318 insertions(+), 83 deletions(-) create mode 100644 core/res/res/anim/wallpaper_close_enter.xml create mode 100644 core/res/res/anim/wallpaper_close_exit.xml rename core/res/res/anim/{wallpaper_activity_close_enter.xml => wallpaper_intra_close_enter.xml} (96%) rename core/res/res/anim/{wallpaper_activity_close_exit.xml => wallpaper_intra_close_exit.xml} (96%) rename core/res/res/anim/{wallpaper_activity_open_enter.xml => wallpaper_intra_open_enter.xml} (96%) rename core/res/res/anim/{wallpaper_activity_open_exit.xml => wallpaper_intra_open_exit.xml} (96%) create mode 100644 core/res/res/anim/wallpaper_open_enter.xml create mode 100644 core/res/res/anim/wallpaper_open_exit.xml diff --git a/api/current.xml b/api/current.xml index 438acaabebc8d..a122bd9dfcfd4 100644 --- a/api/current.xml +++ b/api/current.xml @@ -4699,7 +4699,7 @@ type="int" transient="false" volatile="false" - value="16843416" + value="16843420" static="true" final="true" deprecated="not deprecated" @@ -6492,7 +6492,7 @@ type="int" transient="false" volatile="false" - value="16843417" + value="16843421" static="true" final="true" deprecated="not deprecated" @@ -7526,7 +7526,7 @@ type="int" transient="false" volatile="false" - value="16843415" + value="16843419" static="true" final="true" deprecated="not deprecated" @@ -8611,7 +8611,7 @@ visibility="public" > - - - + + + + + + + + - - + diff --git a/core/res/res/anim/accelerate_interpolator.xml b/core/res/res/anim/accelerate_interpolator.xml index c689c352c7f77..13f87f311487f 100644 --- a/core/res/res/anim/accelerate_interpolator.xml +++ b/core/res/res/anim/accelerate_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/anticipate_interpolator.xml b/core/res/res/anim/anticipate_interpolator.xml index 50a555a6766c0..7a16b5f4ab1f3 100644 --- a/core/res/res/anim/anticipate_interpolator.xml +++ b/core/res/res/anim/anticipate_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/anticipate_overshoot_interpolator.xml b/core/res/res/anim/anticipate_overshoot_interpolator.xml index 440a899f95491..d61ddd102cfac 100644 --- a/core/res/res/anim/anticipate_overshoot_interpolator.xml +++ b/core/res/res/anim/anticipate_overshoot_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/bounce_interpolator.xml b/core/res/res/anim/bounce_interpolator.xml index 406fbb9fd1591..d89ba491b6b56 100644 --- a/core/res/res/anim/bounce_interpolator.xml +++ b/core/res/res/anim/bounce_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/decelerate_interpolator.xml b/core/res/res/anim/decelerate_interpolator.xml index fff6616e51bbe..7b29fb3f85af0 100644 --- a/core/res/res/anim/decelerate_interpolator.xml +++ b/core/res/res/anim/decelerate_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/linear_interpolator.xml b/core/res/res/anim/linear_interpolator.xml index 70bbeccad52d5..f4d256a61a180 100644 --- a/core/res/res/anim/linear_interpolator.xml +++ b/core/res/res/anim/linear_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/overshoot_interpolator.xml b/core/res/res/anim/overshoot_interpolator.xml index c614e0b8f0d33..725ea4899faf3 100644 --- a/core/res/res/anim/overshoot_interpolator.xml +++ b/core/res/res/anim/overshoot_interpolator.xml @@ -18,4 +18,4 @@ */ --> - + diff --git a/core/res/res/anim/wallpaper_close_enter.xml b/core/res/res/anim/wallpaper_close_enter.xml new file mode 100644 index 0000000000000..8e7d049ce8537 --- /dev/null +++ b/core/res/res/anim/wallpaper_close_enter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/core/res/res/anim/wallpaper_close_exit.xml b/core/res/res/anim/wallpaper_close_exit.xml new file mode 100644 index 0000000000000..0a63990a15de9 --- /dev/null +++ b/core/res/res/anim/wallpaper_close_exit.xml @@ -0,0 +1,30 @@ + + + + + + + diff --git a/core/res/res/anim/wallpaper_activity_close_enter.xml b/core/res/res/anim/wallpaper_intra_close_enter.xml similarity index 96% rename from core/res/res/anim/wallpaper_activity_close_enter.xml rename to core/res/res/anim/wallpaper_intra_close_enter.xml index 9e9bd802fe1a0..b75745d20db14 100644 --- a/core/res/res/anim/wallpaper_activity_close_enter.xml +++ b/core/res/res/anim/wallpaper_intra_close_enter.xml @@ -23,7 +23,7 @@ android:zAdjustment="top"> diff --git a/core/res/res/anim/wallpaper_activity_close_exit.xml b/core/res/res/anim/wallpaper_intra_close_exit.xml similarity index 96% rename from core/res/res/anim/wallpaper_activity_close_exit.xml rename to core/res/res/anim/wallpaper_intra_close_exit.xml index badbbf02c0068..6a4e276ea632e 100644 --- a/core/res/res/anim/wallpaper_activity_close_exit.xml +++ b/core/res/res/anim/wallpaper_intra_close_exit.xml @@ -22,7 +22,7 @@ android:interpolator="@anim/accelerate_interpolator"> diff --git a/core/res/res/anim/wallpaper_activity_open_enter.xml b/core/res/res/anim/wallpaper_intra_open_enter.xml similarity index 96% rename from core/res/res/anim/wallpaper_activity_open_enter.xml rename to core/res/res/anim/wallpaper_intra_open_enter.xml index e60bac28776eb..a46bc42f45979 100644 --- a/core/res/res/anim/wallpaper_activity_open_enter.xml +++ b/core/res/res/anim/wallpaper_intra_open_enter.xml @@ -22,7 +22,7 @@ android:interpolator="@anim/decelerate_interpolator"> diff --git a/core/res/res/anim/wallpaper_activity_open_exit.xml b/core/res/res/anim/wallpaper_intra_open_exit.xml similarity index 96% rename from core/res/res/anim/wallpaper_activity_open_exit.xml rename to core/res/res/anim/wallpaper_intra_open_exit.xml index 01abbb717a8f0..0e9bc4a2d180e 100644 --- a/core/res/res/anim/wallpaper_activity_open_exit.xml +++ b/core/res/res/anim/wallpaper_intra_open_exit.xml @@ -23,7 +23,7 @@ android:zAdjustment="top"> diff --git a/core/res/res/anim/wallpaper_open_enter.xml b/core/res/res/anim/wallpaper_open_enter.xml new file mode 100644 index 0000000000000..9daf9257f8df2 --- /dev/null +++ b/core/res/res/anim/wallpaper_open_enter.xml @@ -0,0 +1,30 @@ + + + + + + + diff --git a/core/res/res/anim/wallpaper_open_exit.xml b/core/res/res/anim/wallpaper_open_exit.xml new file mode 100644 index 0000000000000..96fff94a27b10 --- /dev/null +++ b/core/res/res/anim/wallpaper_open_exit.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 7e7bfca7ae7e0..1e71a99f19c70 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -979,26 +979,47 @@ (which is exiting the screen). --> + + + + + + + + + - + (which is entering the screen). The wallpaper remains + static behind the animation. --> + - + (which is exiting the screen). The wallpaper remains + static behind the animation. --> + - + (which is entering the screen). The wallpaper remains + static behind the animation. --> + - + (which is exiting the screen). The wallpaper remains + static behind the animation. --> + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 1a362f7e1acd3..3be3ef8b8b43f 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1151,10 +1151,14 @@ - - - - + + + + + + + + diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 55f81675ec3af..18b97657a533a 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -66,10 +66,14 @@ @anim/task_open_exit @anim/task_close_enter @anim/task_close_exit - @anim/wallpaper_activity_open_enter - @anim/wallpaper_activity_open_exit - @anim/wallpaper_activity_close_enter - @anim/wallpaper_activity_close_exit + @anim/wallpaper_open_enter + @anim/wallpaper_open_exit + @anim/wallpaper_close_enter + @anim/wallpaper_close_exit + @anim/wallpaper_intra_open_enter + @anim/wallpaper_intra_open_exit + @anim/wallpaper_intra_close_enter + @anim/wallpaper_intra_close_exit diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 1ea1b3193c2fa..b4f47681f665d 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -1193,6 +1193,20 @@ public class WindowManagerService extends IWindowManager.Stub moveInputMethodDialogsLocked(findDesiredInputMethodWindowIndexLocked(true)); } + final boolean isWallpaperVisible(WindowState wallpaperTarget) { + if (DEBUG_WALLPAPER) Log.v(TAG, "Wallpaper vis: target obscured=" + + (wallpaperTarget != null ? Boolean.toString(wallpaperTarget.mObscured) : "??") + + " anim=" + ((wallpaperTarget != null && wallpaperTarget.mAppToken != null) + ? wallpaperTarget.mAppToken.animation : null) + + " upper=" + mUpperWallpaperTarget + + " lower=" + mLowerWallpaperTarget); + return (wallpaperTarget != null + && (!wallpaperTarget.mObscured || (wallpaperTarget.mAppToken != null + && wallpaperTarget.mAppToken.animation != null))) + || mUpperWallpaperTarget != null + || mLowerWallpaperTarget != null; + } + boolean adjustWallpaperWindowsLocked() { boolean changed = false; @@ -1352,7 +1366,7 @@ public class WindowManagerService extends IWindowManager.Stub if (visible) { // The window is visible to the compositor... but is it visible // to the user? That is what the wallpaper cares about. - visible = !foundW.mObscured; + visible = isWallpaperVisible(foundW); if (DEBUG_WALLPAPER) Log.v(TAG, "Wallpaper visibility: " + visible); // If the wallpaper target is animating, we may need to copy @@ -1377,6 +1391,8 @@ public class WindowManagerService extends IWindowManager.Stub foundW = wb; foundI--; } + } else { + if (DEBUG_WALLPAPER) Log.v(TAG, "Wallpaper not visible"); } // Okay i is the position immediately above the wallpaper. Look at @@ -1394,6 +1410,8 @@ public class WindowManagerService extends IWindowManager.Stub while (curTokenIndex > 0) { curTokenIndex--; WindowToken token = mWallpaperTokens.get(curTokenIndex); + token.hidden = !visible; + int curWallpaperIndex = token.windows.size(); while (curWallpaperIndex > 0) { curWallpaperIndex--; @@ -1548,8 +1566,7 @@ public class WindowManagerService extends IWindowManager.Stub } void updateWallpaperVisibilityLocked() { - final boolean visible = mWallpaperTarget != null - && !mWallpaperTarget.mObscured; + final boolean visible = isWallpaperVisible(mWallpaperTarget); final int dw = mDisplay.getWidth(); final int dh = mDisplay.getHeight(); @@ -1557,6 +1574,8 @@ public class WindowManagerService extends IWindowManager.Stub while (curTokenIndex > 0) { curTokenIndex--; WindowToken token = mWallpaperTokens.get(curTokenIndex); + token.hidden = !visible; + int curWallpaperIndex = token.windows.size(); while (curWallpaperIndex > 0) { curWallpaperIndex--; @@ -1569,7 +1588,7 @@ public class WindowManagerService extends IWindowManager.Stub wallpaper.mWallpaperVisible = visible; try { if (DEBUG_VISIBILITY || DEBUG_WALLPAPER) Log.v(TAG, - "Setting visibility of wallpaper " + wallpaper + "Updating visibility of wallpaper " + wallpaper + ": " + visible); wallpaper.mClient.dispatchAppVisibility(visible); } catch (RemoteException e) { @@ -2408,15 +2427,25 @@ public class WindowManagerService extends IWindowManager.Stub ? com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation : com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation; break; - case WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_OPEN: + case WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN: animAttr = enter - ? com.android.internal.R.styleable.WindowAnimation_wallpaperActivityOpenEnterAnimation - : com.android.internal.R.styleable.WindowAnimation_wallpaperActivityOpenExitAnimation; + ? com.android.internal.R.styleable.WindowAnimation_wallpaperOpenEnterAnimation + : com.android.internal.R.styleable.WindowAnimation_wallpaperOpenExitAnimation; break; - case WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_CLOSE: + case WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE: animAttr = enter - ? com.android.internal.R.styleable.WindowAnimation_wallpaperActivityCloseEnterAnimation - : com.android.internal.R.styleable.WindowAnimation_wallpaperActivityCloseExitAnimation; + ? com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation + : com.android.internal.R.styleable.WindowAnimation_wallpaperCloseExitAnimation; + break; + case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN: + animAttr = enter + ? com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenEnterAnimation + : com.android.internal.R.styleable.WindowAnimation_wallpaperIntraOpenExitAnimation; + break; + case WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE: + animAttr = enter + ? com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseEnterAnimation + : com.android.internal.R.styleable.WindowAnimation_wallpaperIntraCloseExitAnimation; break; } a = loadAnimation(lp, animAttr); @@ -7346,11 +7375,15 @@ public class WindowManagerService extends IWindowManager.Stub } /** - * Return true if the window is opaque and fully drawn. + * Return true if the window is opaque and fully drawn. This indicates + * it may obscure windows behind it. */ boolean isOpaqueDrawn() { - return mAttrs.format == PixelFormat.OPAQUE && mSurface != null - && mAnimation == null && !mDrawPending && !mCommitDrawPending; + return (mAttrs.format == PixelFormat.OPAQUE + || mAttrs.type == TYPE_WALLPAPER) + && mSurface != null && mAnimation == null + && (mAppToken == null || mAppToken.animation == null) + && !mDrawPending && !mCommitDrawPending; } boolean needsBackgroundFiller(int screenWidth, int screenHeight) { @@ -8964,6 +8997,8 @@ public class WindowManagerService extends IWindowManager.Stub mToTopApps.clear(); } + WindowState oldWallpaper = mWallpaperTarget; + adjustWallpaperWindowsLocked(); wallpaperMayChange = false; @@ -8971,54 +9006,66 @@ public class WindowManagerService extends IWindowManager.Stub "New wallpaper target=" + mWallpaperTarget + ", lower target=" + mLowerWallpaperTarget + ", upper target=" + mUpperWallpaperTarget); + int foundWallpapers = 0; if (mLowerWallpaperTarget != null) { // Need to determine if both the closing and // opening app token sets are wallpaper targets, // in which case special animations are needed // (since the wallpaper needs to stay static // behind them). - int found = 0; - NN = mOpeningApps.size(); - for (i=0; i