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
diff --git a/api/current.xml b/api/current.xml
index 438acaa..a122bd9d 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"
 >
 </field>
-<field name="wallpaperActivityCloseEnterAnimation"
+<field name="wallpaperCloseEnterAnimation"
  type="int"
  transient="false"
  volatile="false"
@@ -8622,7 +8622,7 @@
  visibility="public"
 >
 </field>
-<field name="wallpaperActivityCloseExitAnimation"
+<field name="wallpaperCloseExitAnimation"
  type="int"
  transient="false"
  volatile="false"
@@ -8633,7 +8633,51 @@
  visibility="public"
 >
 </field>
-<field name="wallpaperActivityOpenEnterAnimation"
+<field name="wallpaperIntraCloseEnterAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843417"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperIntraCloseExitAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843418"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperIntraOpenEnterAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843415"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperIntraOpenExitAnimation"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="16843416"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="wallpaperOpenEnterAnimation"
  type="int"
  transient="false"
  volatile="false"
@@ -8644,7 +8688,7 @@
  visibility="public"
 >
 </field>
-<field name="wallpaperActivityOpenExitAnimation"
+<field name="wallpaperOpenExitAnimation"
  type="int"
  transient="false"
  volatile="false"
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index dd4b65f..c40107b 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -344,12 +344,18 @@
     public final int TRANSIT_TASK_TO_FRONT = 10;
     /** A window in an existing task is being put below all other tasks. */
     public final int TRANSIT_TASK_TO_BACK = 11;
+    /** A window in a new activity that doesn't have a wallpaper is being
+     * opened on top of one that does, effectively closing the wallpaper. */
+    public final int TRANSIT_WALLPAPER_CLOSE = 12;
+    /** A window in a new activity that does have a wallpaper is being
+     * opened on one that didn't, effectively opening the wallpaper. */
+    public final int TRANSIT_WALLPAPER_OPEN = 13;
     /** A window in a new activity is being opened on top of an existing one,
      * and both are on top of the wallpaper. */
-    public final int TRANSIT_WALLPAPER_ACTIVITY_OPEN = 12;
+    public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
     /** The window in the top-most activity is being closed to reveal the
      * previous activity, and both are on top of he wallpaper. */
-    public final int TRANSIT_WALLPAPER_ACTIVITY_CLOSE = 13;
+    public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
     
     /** Screen turned off because of power button */
     public final int OFF_BECAUSE_OF_USER = 1;
diff --git a/core/res/res/anim/accelerate_decelerate_interpolator.xml b/core/res/res/anim/accelerate_decelerate_interpolator.xml
index 724ed0a..4a0216b 100644
--- a/core/res/res/anim/accelerate_decelerate_interpolator.xml
+++ b/core/res/res/anim/accelerate_decelerate_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<accelerateDecelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android"/>
+<accelerateDecelerateInterpolator />
diff --git a/core/res/res/anim/accelerate_interpolator.xml b/core/res/res/anim/accelerate_interpolator.xml
index c689c35..13f87f3 100644
--- a/core/res/res/anim/accelerate_interpolator.xml
+++ b/core/res/res/anim/accelerate_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<accelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android" factor="1" />
+<accelerateInterpolator />
diff --git a/core/res/res/anim/anticipate_interpolator.xml b/core/res/res/anim/anticipate_interpolator.xml
index 50a555a..7a16b5f 100644
--- a/core/res/res/anim/anticipate_interpolator.xml
+++ b/core/res/res/anim/anticipate_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<anticipateInterpolator xmlns:android="http://schemas.android.com/apk/res/android" />
+<anticipateInterpolator />
diff --git a/core/res/res/anim/anticipate_overshoot_interpolator.xml b/core/res/res/anim/anticipate_overshoot_interpolator.xml
index 440a899..d61ddd1 100644
--- a/core/res/res/anim/anticipate_overshoot_interpolator.xml
+++ b/core/res/res/anim/anticipate_overshoot_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<anticipateOvershootInterpolator xmlns:android="http://schemas.android.com/apk/res/android" />
+<anticipateOvershootInterpolator />
diff --git a/core/res/res/anim/bounce_interpolator.xml b/core/res/res/anim/bounce_interpolator.xml
index 406fbb9..d89ba49 100644
--- a/core/res/res/anim/bounce_interpolator.xml
+++ b/core/res/res/anim/bounce_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<bounceInterpolator xmlns:android="http://schemas.android.com/apk/res/android" />
+<bounceInterpolator />
diff --git a/core/res/res/anim/decelerate_interpolator.xml b/core/res/res/anim/decelerate_interpolator.xml
index fff6616..7b29fb3 100644
--- a/core/res/res/anim/decelerate_interpolator.xml
+++ b/core/res/res/anim/decelerate_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<decelerateInterpolator xmlns:android="http://schemas.android.com/apk/res/android" factor="1" />
+<decelerateInterpolator />
diff --git a/core/res/res/anim/linear_interpolator.xml b/core/res/res/anim/linear_interpolator.xml
index 70bbecc..f4d256a 100644
--- a/core/res/res/anim/linear_interpolator.xml
+++ b/core/res/res/anim/linear_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<linearInterpolator xmlns:android="http://schemas.android.com/apk/res/android"/>
+<linearInterpolator />
diff --git a/core/res/res/anim/overshoot_interpolator.xml b/core/res/res/anim/overshoot_interpolator.xml
index c614e0b..725ea48 100644
--- a/core/res/res/anim/overshoot_interpolator.xml
+++ b/core/res/res/anim/overshoot_interpolator.xml
@@ -18,4 +18,4 @@
 */
 -->
 
-<overshootInterpolator xmlns:android="http://schemas.android.com/apk/res/android" />
+<overshootInterpolator />
diff --git a/core/res/res/anim/wallpaper_activity_open_enter.xml b/core/res/res/anim/wallpaper_close_enter.xml
similarity index 63%
copy from core/res/res/anim/wallpaper_activity_open_enter.xml
copy to core/res/res/anim/wallpaper_close_enter.xml
index e60bac2..8e7d049 100644
--- a/core/res/res/anim/wallpaper_activity_open_enter.xml
+++ b/core/res/res/anim/wallpaper_close_enter.xml
@@ -20,12 +20,6 @@
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator">
-    <scale android:fromXScale=".5" android:toXScale="1.0"
-           android:fromYScale=".5" android:toYScale="1.0"
-           android:pivotX="50%" android:pivotY="50%"
-           android:duration="@android:integer/config_mediumAnimTime" />
-    <translate android:fromXDelta="100%" android:toXDelta="0"
-            android:duration="@android:integer/config_mediumAnimTime"/>
-    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
-            android:duration="@android:integer/config_mediumAnimTime" />
+	<translate android:fromXDelta="33%" android:toXDelta="0"
+        android:duration="@android:integer/config_mediumAnimTime"/>
 </set>
diff --git a/core/res/res/anim/wallpaper_activity_close_enter.xml b/core/res/res/anim/wallpaper_close_exit.xml
similarity index 73%
copy from core/res/res/anim/wallpaper_activity_close_enter.xml
copy to core/res/res/anim/wallpaper_close_exit.xml
index 9e9bd80..0a63990 100644
--- a/core/res/res/anim/wallpaper_activity_close_enter.xml
+++ b/core/res/res/anim/wallpaper_close_exit.xml
@@ -21,12 +21,10 @@
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator"
         android:zAdjustment="top">
-    <scale android:fromXScale="2.0" android:toXScale="1.0"
-           android:fromYScale="2.0" android:toYScale="1.0"
-           android:pivotX="50%" android:pivotY="50%"
-           android:duration="@android:integer/config_mediumAnimTime" />
-	<translate android:fromXDelta="-150%" android:toXDelta="0"
+	<translate android:fromXDelta="0%" android:toXDelta="-100%"
         android:duration="@android:integer/config_mediumAnimTime"/>
-    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
-            android:duration="@android:integer/config_mediumAnimTime" />
+    <scale android:fromXScale="1.0" android:toXScale="2.0"
+           android:fromYScale="1.0" android:toYScale="2.0"
+           android:pivotX="0%" android:pivotY="50%"
+           android:duration="@android:integer/config_mediumAnimTime" />
 </set>
diff --git a/core/res/res/anim/wallpaper_activity_close_enter.xml b/core/res/res/anim/wallpaper_intra_close_enter.xml
similarity index 95%
rename from core/res/res/anim/wallpaper_activity_close_enter.xml
rename to core/res/res/anim/wallpaper_intra_close_enter.xml
index 9e9bd80..b75745d 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">
     <scale android:fromXScale="2.0" android:toXScale="1.0"
            android:fromYScale="2.0" android:toYScale="1.0"
-           android:pivotX="50%" android:pivotY="50%"
+           android:pivotX="100%" android:pivotY="50%"
            android:duration="@android:integer/config_mediumAnimTime" />
 	<translate android:fromXDelta="-150%" android:toXDelta="0"
         android:duration="@android:integer/config_mediumAnimTime"/>
diff --git a/core/res/res/anim/wallpaper_activity_close_exit.xml b/core/res/res/anim/wallpaper_intra_close_exit.xml
similarity index 95%
rename from core/res/res/anim/wallpaper_activity_close_exit.xml
rename to core/res/res/anim/wallpaper_intra_close_exit.xml
index badbbf0..6a4e276 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">
     <scale android:fromXScale="1.0" android:toXScale=".5"
            android:fromYScale="1.0" android:toYScale=".5"
-           android:pivotX="50%" android:pivotY="50%"
+           android:pivotX="0%" android:pivotY="50%"
            android:duration="@android:integer/config_mediumAnimTime" />
 	<translate android:fromXDelta="0%" android:toXDelta="100%"
         android:duration="@android:integer/config_mediumAnimTime"/>
diff --git a/core/res/res/anim/wallpaper_activity_open_enter.xml b/core/res/res/anim/wallpaper_intra_open_enter.xml
similarity index 95%
rename from core/res/res/anim/wallpaper_activity_open_enter.xml
rename to core/res/res/anim/wallpaper_intra_open_enter.xml
index e60bac2..a46bc42 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">
     <scale android:fromXScale=".5" android:toXScale="1.0"
            android:fromYScale=".5" android:toYScale="1.0"
-           android:pivotX="50%" android:pivotY="50%"
+           android:pivotX="0%" android:pivotY="50%"
            android:duration="@android:integer/config_mediumAnimTime" />
     <translate android:fromXDelta="100%" android:toXDelta="0"
             android:duration="@android:integer/config_mediumAnimTime"/>
diff --git a/core/res/res/anim/wallpaper_activity_open_exit.xml b/core/res/res/anim/wallpaper_intra_open_exit.xml
similarity index 95%
rename from core/res/res/anim/wallpaper_activity_open_exit.xml
rename to core/res/res/anim/wallpaper_intra_open_exit.xml
index 01abbb7..0e9bc4a 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">
     <scale android:fromXScale="1.0" android:toXScale="2.0"
            android:fromYScale="1.0" android:toYScale="2.0"
-           android:pivotX="50%" android:pivotY="50%"
+           android:pivotX="100%" android:pivotY="50%"
            android:duration="@android:integer/config_mediumAnimTime" />
     <translate android:fromXDelta="0" android:toXDelta="-150%"
             android:duration="@android:integer/config_mediumAnimTime"/>
diff --git a/core/res/res/anim/wallpaper_activity_close_enter.xml b/core/res/res/anim/wallpaper_open_enter.xml
similarity index 82%
copy from core/res/res/anim/wallpaper_activity_close_enter.xml
copy to core/res/res/anim/wallpaper_open_enter.xml
index 9e9bd80..9daf925 100644
--- a/core/res/res/anim/wallpaper_activity_close_enter.xml
+++ b/core/res/res/anim/wallpaper_open_enter.xml
@@ -21,12 +21,10 @@
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator"
         android:zAdjustment="top">
+	<translate android:fromXDelta="-100%" android:toXDelta="0"
+        android:duration="@android:integer/config_mediumAnimTime"/>
     <scale android:fromXScale="2.0" android:toXScale="1.0"
            android:fromYScale="2.0" android:toYScale="1.0"
-           android:pivotX="50%" android:pivotY="50%"
+           android:pivotX="0%" android:pivotY="50%"
            android:duration="@android:integer/config_mediumAnimTime" />
-	<translate android:fromXDelta="-150%" android:toXDelta="0"
-        android:duration="@android:integer/config_mediumAnimTime"/>
-    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
-            android:duration="@android:integer/config_mediumAnimTime" />
 </set>
diff --git a/core/res/res/anim/wallpaper_activity_close_exit.xml b/core/res/res/anim/wallpaper_open_exit.xml
similarity index 63%
copy from core/res/res/anim/wallpaper_activity_close_exit.xml
copy to core/res/res/anim/wallpaper_open_exit.xml
index badbbf0..96fff94 100644
--- a/core/res/res/anim/wallpaper_activity_close_exit.xml
+++ b/core/res/res/anim/wallpaper_open_exit.xml
@@ -19,13 +19,7 @@
 -->
 
 <set xmlns:android="http://schemas.android.com/apk/res/android"
-        android:interpolator="@anim/accelerate_interpolator">
-    <scale android:fromXScale="1.0" android:toXScale=".5"
-           android:fromYScale="1.0" android:toYScale=".5"
-           android:pivotX="50%" android:pivotY="50%"
-           android:duration="@android:integer/config_mediumAnimTime" />
-	<translate android:fromXDelta="0%" android:toXDelta="100%"
+        android:interpolator="@anim/decelerate_interpolator">
+	<translate android:fromXDelta="0%" android:toXDelta="33%"
         android:duration="@android:integer/config_mediumAnimTime"/>
-    <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
-            android:duration="@android:integer/config_mediumAnimTime"/>
 </set>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 7e7bfca..1e71a99 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -979,26 +979,47 @@
               (which is exiting the screen). -->
         <attr name="taskToBackExitAnimation" format="reference" />
         
+        <!--  When opening a new activity that shows the wallpaper, while
+              currently not showing the wallpaper, this is the animation that
+              is run on the new wallpaper activity (which is entering the screen). -->
+        <attr name="wallpaperOpenEnterAnimation" format="reference" />
+        <!--  When opening a new activity that shows the wallpaper, while
+              currently not showing the wallpaper, this is the animation that
+              is run on the current activity (which is exiting the screen). -->
+        <attr name="wallpaperOpenExitAnimation" format="reference" />
+        <!--  When opening a new activity that hides the wallpaper, while
+              currently showing the wallpaper, this is the animation that
+              is run on the new activity (which is entering the screen). -->
+        <attr name="wallpaperCloseEnterAnimation" format="reference" />
+        <!--  When opening a new activity that hides the wallpaper, while
+              currently showing the wallpaper, this is the animation that
+              is run on the old wallpaper activity (which is exiting the screen). -->
+        <attr name="wallpaperCloseExitAnimation" format="reference" />
+        
         <!--  When opening a new activity that is on top of the wallpaper
               when the current activity is also on top of the wallpaper,
               this is the animation that is run on the new activity
-              (which is entering the screen). -->
-        <attr name="wallpaperActivityOpenEnterAnimation" format="reference" />
+              (which is entering the screen).  The wallpaper remains
+              static behind the animation. -->
+        <attr name="wallpaperIntraOpenEnterAnimation" format="reference" />
         <!--  When opening a new activity that is on top of the wallpaper
               when the current activity is also on top of the wallpaper,
               this is the animation that is run on the current activity
-              (which is exiting the screen). -->
-        <attr name="wallpaperActivityOpenExitAnimation" format="reference" />
+              (which is exiting the screen).  The wallpaper remains
+              static behind the animation. -->
+        <attr name="wallpaperIntraOpenExitAnimation" format="reference" />
         <!--  When closing a foreround activity that is on top of the wallpaper
               when the previous activity is also on top of the wallpaper,
               this is the animation that is run on the previous activity
-              (which is entering the screen). -->
-        <attr name="wallpaperActivityCloseEnterAnimation" format="reference" />
+              (which is entering the screen).  The wallpaper remains
+              static behind the animation. -->
+        <attr name="wallpaperIntraCloseEnterAnimation" format="reference" />
         <!--  When closing a foreround activity that is on top of the wallpaper
               when the previous activity is also on top of the wallpaper,
               this is the animation that is run on the current activity
-              (which is exiting the screen). -->
-        <attr name="wallpaperActivityCloseExitAnimation" format="reference" />
+              (which is exiting the screen).  The wallpaper remains
+              static behind the animation. -->
+        <attr name="wallpaperIntraCloseExitAnimation" format="reference" />
     </declare-styleable>
 
     <!-- ============================= -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 1a362f7..3be3ef8 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -1151,10 +1151,14 @@
   <public type="attr" name="contentAuthority" />
   <public type="attr" name="userVisible" />
   <public type="attr" name="windowShowWallpaper" />
-  <public type="attr" name="wallpaperActivityOpenEnterAnimation" />
-  <public type="attr" name="wallpaperActivityOpenExitAnimation" />
-  <public type="attr" name="wallpaperActivityCloseEnterAnimation" />
-  <public type="attr" name="wallpaperActivityCloseExitAnimation" />
+  <public type="attr" name="wallpaperOpenEnterAnimation" />
+  <public type="attr" name="wallpaperOpenExitAnimation" />
+  <public type="attr" name="wallpaperCloseEnterAnimation" />
+  <public type="attr" name="wallpaperCloseExitAnimation" />
+  <public type="attr" name="wallpaperIntraOpenEnterAnimation" />
+  <public type="attr" name="wallpaperIntraOpenExitAnimation" />
+  <public type="attr" name="wallpaperIntraCloseEnterAnimation" />
+  <public type="attr" name="wallpaperIntraCloseExitAnimation" />
   <public type="attr" name="supportsUploading" />
   <public type="attr" name="killAfterRestore" />
   <public type="attr" name="restoreNeedsApplication" />
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 55f8167..18b97657 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -66,10 +66,14 @@
         <item name="taskToFrontExitAnimation">@anim/task_open_exit</item>
         <item name="taskToBackEnterAnimation">@anim/task_close_enter</item>
         <item name="taskToBackExitAnimation">@anim/task_close_exit</item>
-        <item name="wallpaperActivityOpenEnterAnimation">@anim/wallpaper_activity_open_enter</item>
-        <item name="wallpaperActivityOpenExitAnimation">@anim/wallpaper_activity_open_exit</item>
-        <item name="wallpaperActivityCloseEnterAnimation">@anim/wallpaper_activity_close_enter</item>
-        <item name="wallpaperActivityCloseExitAnimation">@anim/wallpaper_activity_close_exit</item>
+        <item name="wallpaperOpenEnterAnimation">@anim/wallpaper_open_enter</item>
+        <item name="wallpaperOpenExitAnimation">@anim/wallpaper_open_exit</item>
+        <item name="wallpaperCloseEnterAnimation">@anim/wallpaper_close_enter</item>
+        <item name="wallpaperCloseExitAnimation">@anim/wallpaper_close_exit</item>
+        <item name="wallpaperIntraOpenEnterAnimation">@anim/wallpaper_intra_open_enter</item>
+        <item name="wallpaperIntraOpenExitAnimation">@anim/wallpaper_intra_open_exit</item>
+        <item name="wallpaperIntraCloseEnterAnimation">@anim/wallpaper_intra_close_enter</item>
+        <item name="wallpaperIntraCloseExitAnimation">@anim/wallpaper_intra_close_exit</item>
     </style>
 
     <!-- Standard animations for a non-full-screen window or activity. -->
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 1ea1b31..b4f4768 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -1193,6 +1193,20 @@
         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 @@
         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 @@
                 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 @@
         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 @@
     }
     
     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 @@
         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 @@
                     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 @@
                                 ? 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 @@
         }
 
         /**
-         * 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 @@
                             mToTopApps.clear();
                         }
                         
+                        WindowState oldWallpaper = mWallpaperTarget;
+                        
                         adjustWallpaperWindowsLocked();
                         wallpaperMayChange = false;
                         
@@ -8971,54 +9006,66 @@
                                 "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<NN; i++) {
-                                AppWindowToken wtoken = mOpeningApps.get(i);
-                                if (mLowerWallpaperTarget.mAppToken == wtoken) {
-                                    found |= 1;
-                                }
-                                if (mUpperWallpaperTarget.mAppToken == wtoken) {
-                                    found |= 1;
-                                }
-                            }
                             NN = mClosingApps.size();
                             for (i=0; i<NN; i++) {
                                 AppWindowToken wtoken = mClosingApps.get(i);
                                 if (mLowerWallpaperTarget.mAppToken == wtoken) {
-                                    found |= 2;
+                                    foundWallpapers |= 1;
                                 }
                                 if (mUpperWallpaperTarget.mAppToken == wtoken) {
-                                    found |= 2;
+                                    foundWallpapers |= 1;
                                 }
                             }
-                            
-                            if (found == 3) {
-                                if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
-                                        "Wallpaper animation!");
-                                switch (transit) {
-                                    case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
-                                    case WindowManagerPolicy.TRANSIT_TASK_OPEN:
-                                    case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
-                                        transit = WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_OPEN;
-                                        break;
-                                    case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
-                                    case WindowManagerPolicy.TRANSIT_TASK_CLOSE:
-                                    case WindowManagerPolicy.TRANSIT_TASK_TO_BACK:
-                                        transit = WindowManagerPolicy.TRANSIT_WALLPAPER_ACTIVITY_CLOSE;
-                                        break;
+                            NN = mOpeningApps.size();
+                            for (i=0; i<NN; i++) {
+                                AppWindowToken wtoken = mOpeningApps.get(i);
+                                if (mLowerWallpaperTarget.mAppToken == wtoken) {
+                                    foundWallpapers |= 2;
                                 }
-                                if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
-                                        "New transit: " + transit);
+                                if (mUpperWallpaperTarget.mAppToken == wtoken) {
+                                    foundWallpapers |= 2;
+                                }
                             }
                         }
                         
+                        if (foundWallpapers == 3) {
+                            if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+                                    "Wallpaper animation!");
+                            switch (transit) {
+                                case WindowManagerPolicy.TRANSIT_ACTIVITY_OPEN:
+                                case WindowManagerPolicy.TRANSIT_TASK_OPEN:
+                                case WindowManagerPolicy.TRANSIT_TASK_TO_FRONT:
+                                    transit = WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_OPEN;
+                                    break;
+                                case WindowManagerPolicy.TRANSIT_ACTIVITY_CLOSE:
+                                case WindowManagerPolicy.TRANSIT_TASK_CLOSE:
+                                case WindowManagerPolicy.TRANSIT_TASK_TO_BACK:
+                                    transit = WindowManagerPolicy.TRANSIT_WALLPAPER_INTRA_CLOSE;
+                                    break;
+                            }
+                            if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+                                    "New transit: " + transit);
+                        } else if (oldWallpaper != null) {
+                            // We are transitioning from an activity with
+                            // a wallpaper to one without.
+                            transit = WindowManagerPolicy.TRANSIT_WALLPAPER_CLOSE;
+                            if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+                                    "New transit away from wallpaper: " + transit);
+                        } else if (mWallpaperTarget != null) {
+                            // We are transitioning from an activity without
+                            // a wallpaper to now showing the wallpaper
+                            transit = WindowManagerPolicy.TRANSIT_WALLPAPER_OPEN;
+                            if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
+                                    "New transit into wallpaper: " + transit);
+                        }
+                        
                         // We need to figure out which animation to use...
                         WindowManager.LayoutParams lp = findAnimations(mAppTokens,
                                 mOpeningApps, mClosingApps);
@@ -9381,9 +9428,8 @@
                         }
                     }
 
-                    boolean opaqueDrawn = w.isOpaqueDrawn();
-                    if ((opaqueDrawn && w.isFullscreen(dw, dh))
-                            || attrs.type == TYPE_WALLPAPER) {
+                    boolean opaqueDrawn = canBeSeen && w.isOpaqueDrawn();
+                    if (opaqueDrawn && w.isFullscreen(dw, dh)) {
                         // This window completely covers everything behind it,
                         // so we want to leave all of them as unblurred (for
                         // performance reasons).