OSDN Git Service

Infrastructure for supporting wallpaper previews.
authorDianne Hackborn <hackbod@google.com>
Fri, 21 Aug 2009 02:31:38 +0000 (19:31 -0700)
committerDianne Hackborn <hackbod@google.com>
Fri, 21 Aug 2009 03:34:42 +0000 (20:34 -0700)
Various things that will allow us to show previews of wallpapers.
Also some fixes to animations across wallpapers.

api/current.xml
core/java/android/app/Activity.java
core/java/android/app/Dialog.java
core/java/android/app/LauncherActivity.java
core/java/android/service/wallpaper/IWallpaperService.aidl
core/java/android/service/wallpaper/WallpaperService.java
core/java/android/view/Window.java
services/java/com/android/server/WallpaperManagerService.java
services/java/com/android/server/WindowManagerService.java

index 1b2080c..805917b 100644 (file)
 <parameter name="data" type="android.content.Intent">
 </parameter>
 </method>
+<method name="onAttachedToWindow"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onChildTitleChanged"
  return="void"
  abstract="false"
  visibility="protected"
 >
 </method>
+<method name="onDetachedFromWindow"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onKeyDown"
  return="boolean"
  abstract="false"
  visibility="public"
 >
 </method>
+<method name="onAttachedToWindow"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onContentChanged"
  return="void"
  abstract="false"
 <parameter name="featureId" type="int">
 </parameter>
 </method>
+<method name="onDetachedFromWindow"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onKeyDown"
  return="boolean"
  abstract="false"
  visibility="public"
 >
 </method>
+<method name="onQueryPackageManager"
+ return="java.util.List&lt;android.content.pm.ResolveInfo&gt;"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+<parameter name="queryIntent" type="android.content.Intent">
+</parameter>
+</method>
+<method name="onSetContentView"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="protected"
+>
+</method>
 </class>
 <class name="LauncherActivity.IconResizer"
  extends="java.lang.Object"
 <parameter name="event" type="android.view.MotionEvent">
 </parameter>
 </method>
+<method name="onAttachedToWindow"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onContentChanged"
  return="void"
  abstract="true"
 <parameter name="featureId" type="int">
 </parameter>
 </method>
+<method name="onDetachedFromWindow"
+ return="void"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="onMenuItemSelected"
  return="boolean"
  abstract="true"
index 10e6299..80d7285 100644 (file)
@@ -1930,11 +1930,32 @@ public class Activity extends ContextThemeWrapper
      * 
      * @see #hasWindowFocus()
      * @see #onResume
+     * @see View#onWindowFocusChanged(boolean)
      */
     public void onWindowFocusChanged(boolean hasFocus) {
     }
     
     /**
+     * Called when the main window associated with the activity has been
+     * attached to the window manager.
+     * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
+     * for more information.
+     * @see View#onAttachedToWindow
+     */
+    public void onAttachedToWindow() {
+    }
+    
+    /**
+     * Called when the main window associated with the activity has been
+     * detached from the window manager.
+     * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
+     * for more information.
+     * @see View#onDetachedFromWindow
+     */
+    public void onDetachedFromWindow() {
+    }
+    
+    /**
      * Returns true if this activity's <em>main</em> window currently has window focus.
      * Note that this is not the same as the view itself having focus.
      * 
index 9432755..35d1004 100644 (file)
@@ -576,6 +576,12 @@ public class Dialog implements DialogInterface, Window.Callback,
     public void onWindowFocusChanged(boolean hasFocus) {
     }
 
+    public void onAttachedToWindow() {
+    }
+    
+    public void onDetachedFromWindow() {
+    }
+    
     /**
      * Called to process key events.  You can override this to intercept all 
      * key events before they are dispatched to the window.  Be sure to call 
index d788c43..a83f4e8 100644 (file)
@@ -18,6 +18,7 @@ package android.app;
 
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ComponentInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
 import android.content.res.Resources;
@@ -70,13 +71,15 @@ public abstract class LauncherActivity extends ListActivity {
         ListItem(PackageManager pm, ResolveInfo resolveInfo, IconResizer resizer) {
             this.resolveInfo = resolveInfo;
             label = resolveInfo.loadLabel(pm);
-            if (label == null && resolveInfo.activityInfo != null) {
+            ComponentInfo ci = resolveInfo.activityInfo;
+            if (ci == null) ci = resolveInfo.serviceInfo;
+            if (label == null && ci != null) {
                 label = resolveInfo.activityInfo.name;
             }
             
             icon = resizer.createIconThumbnail(resolveInfo.loadIcon(pm));
-            packageName = resolveInfo.activityInfo.applicationInfo.packageName;
-            className = resolveInfo.activityInfo.name;
+            packageName = ci.applicationInfo.packageName;
+            className = ci.name;
         }
 
         public ListItem() {
@@ -325,8 +328,7 @@ public abstract class LauncherActivity extends ListActivity {
     
         requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
         setProgressBarIndeterminateVisibility(true);
-        setContentView(com.android.internal.R.layout.activity_list);
-        
+        onSetContentView();
             
         mIntent = new Intent(getTargetIntent());
         mIntent.setComponent(null);
@@ -338,10 +340,17 @@ public abstract class LauncherActivity extends ListActivity {
         setProgressBarIndeterminateVisibility(false);
     }
 
+    /**
+     * Override to call setContentView() with your own content view to
+     * customize the list layout.
+     */
+    protected void onSetContentView() {
+        setContentView(com.android.internal.R.layout.activity_list);
+    }
+
     @Override
     protected void onListItemClick(ListView l, View v, int position, long id) {
-        Intent intent = ((ActivityAdapter)mAdapter).intentForPosition(position);
-
+        Intent intent = intentForPosition(position);
         startActivity(intent);
     }
     
@@ -374,12 +383,19 @@ public abstract class LauncherActivity extends ListActivity {
     }
 
     /**
+     * Perform query on package manager for list items.  The default
+     * implementation queries for activities.
+     */
+    protected List<ResolveInfo> onQueryPackageManager(Intent queryIntent) {
+        return mPackageManager.queryIntentActivities(queryIntent, /* no flags */ 0);
+    }
+    
+    /**
      * Perform the query to determine which results to show and return a list of them.
      */
     public List<ListItem> makeListItems() {
         // Load all matching activities and sort correctly
-        List<ResolveInfo> list = mPackageManager.queryIntentActivities(mIntent,
-                /* no flags */ 0);
+        List<ResolveInfo> list = onQueryPackageManager(mIntent);
         Collections.sort(list, new ResolveInfo.DisplayNameComparator(mPackageManager));
         
         IconResizer resizer = new IconResizer();
index eb58c3b..bc7a1d7 100644 (file)
@@ -23,5 +23,6 @@ import android.service.wallpaper.IWallpaperConnection;
  */
 oneway interface IWallpaperService {
     void attach(IWallpaperConnection connection,
-               IBinder windowToken, int reqWidth, int reqHeight);
+               IBinder windowToken, int windowType, boolean isPreview,
+               int reqWidth, int reqHeight);
 }
index 5bb07f3..629e97e 100644 (file)
@@ -212,6 +212,15 @@ public abstract class WallpaperService extends Service {
         }
         
         /**
+         * Returns true if this engine is running in preview mode -- that is,
+         * it is being shown to the user before they select it as the actual
+         * wallpaper.
+         */
+        public boolean isPreview() {
+            return mIWallpaperEngine.mIsPreview;
+        }
+        
+        /**
          * Control whether this wallpaper will receive raw touch events
          * from the window manager as the user interacts with the window
          * that is currently displaying the wallpaper.  By default they
@@ -332,7 +341,7 @@ public abstract class WallpaperService extends Service {
                     mLayout.token = mWindowToken;
 
                     if (!mCreated) {
-                        mLayout.type = WindowManager.LayoutParams.TYPE_WALLPAPER;
+                        mLayout.type = mIWallpaperEngine.mWindowType;
                         mLayout.gravity = Gravity.LEFT|Gravity.TOP;
                         mSession.add(mWindow, mLayout, View.VISIBLE, mContentInsets);
                     }
@@ -465,6 +474,8 @@ public abstract class WallpaperService extends Service {
 
         final IWallpaperConnection mConnection;
         final IBinder mWindowToken;
+        final int mWindowType;
+        final boolean mIsPreview;
         int mReqWidth;
         int mReqHeight;
         
@@ -472,10 +483,12 @@ public abstract class WallpaperService extends Service {
         
         IWallpaperEngineWrapper(WallpaperService context,
                 IWallpaperConnection conn, IBinder windowToken,
-                int reqWidth, int reqHeight) {
+                int windowType, boolean isPreview, int reqWidth, int reqHeight) {
             mCaller = new HandlerCaller(context, this);
             mConnection = conn;
             mWindowToken = windowToken;
+            mWindowType = windowType;
+            mIsPreview = isPreview;
             mReqWidth = reqWidth;
             mReqHeight = reqHeight;
             
@@ -567,10 +580,10 @@ public abstract class WallpaperService extends Service {
             mTarget = context;
         }
 
-        public void attach(IWallpaperConnection conn,
-                IBinder windowToken, int reqWidth, int reqHeight) {
-            new IWallpaperEngineWrapper(
-                    mTarget, conn, windowToken, reqWidth, reqHeight);
+        public void attach(IWallpaperConnection conn, IBinder windowToken,
+                int windowType, boolean isPreview, int reqWidth, int reqHeight) {
+            new IWallpaperEngineWrapper(mTarget, conn, windowToken,
+                    windowType, isPreview, reqWidth, reqHeight);
         }
     }
     
index 02e0515..1932765 100644 (file)
@@ -237,7 +237,6 @@ public abstract class Window {
         /**
          * This is called whenever the current window attributes change.
          *
-
          */
         public void onWindowAttributesChanged(WindowManager.LayoutParams attrs);
 
@@ -252,13 +251,29 @@ public abstract class Window {
         public void onContentChanged();
 
         /**
-         * This hook is called whenever the window focus changes.
+         * This hook is called whenever the window focus changes.  See
+         * {@link View#onWindowFocusChanged(boolean)
+         * View.onWindowFocusChanged(boolean)} for more information.
          *
          * @param hasFocus Whether the window now has focus.
          */
         public void onWindowFocusChanged(boolean hasFocus);
 
         /**
+         * Called when the window has been attached to the window manager.
+         * See {@link View#onAttachedToWindow() View.onAttachedToWindow()}
+         * for more information.
+         */
+        public void onAttachedToWindow();
+        
+        /**
+         * Called when the window has been attached to the window manager.
+         * See {@link View#onDetachedFromWindow() View.onDetachedFromWindow()}
+         * for more information.
+         */
+        public void onDetachedFromWindow();
+        
+        /**
          * Called when a panel is being closed.  If another logical subsequent
          * panel is being opened (and this panel is being closed to make room for the subsequent
          * panel), this method will NOT be called.
index 07bab18..3c62aa0 100644 (file)
@@ -404,7 +404,9 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
     
     void attachServiceLocked(WallpaperConnection conn) {
         try {
-            conn.mService.attach(conn, conn.mToken, mWidth, mHeight);
+            conn.mService.attach(conn, conn.mToken,
+                    WindowManager.LayoutParams.TYPE_WALLPAPER, false,
+                    mWidth, mHeight);
         } catch (RemoteException e) {
             Log.w(TAG, "Failed attaching wallpaper; clearing", e);
             bindWallpaperComponentLocked(null);
index 7ca8b52..f8ba058 100644 (file)
@@ -405,7 +405,12 @@ public class WindowManagerService extends IWindowManager.Stub
     // If non-null, this is the currently visible window that is associated
     // with the wallpaper.
     WindowState mWallpaperTarget = null;
-    WindowState mUpcomingWallpaperTarget = null;
+    // If non-null, we are in the middle of animating from one wallpaper target
+    // to another, and this is the lower one in Z-order.
+    WindowState mLowerWallpaperTarget = null;
+    // If non-null, we are in the middle of animating from one wallpaper target
+    // to another, and this is the higher one in Z-order.
+    WindowState mUpperWallpaperTarget = null;
     int mWallpaperAnimLayerAdjustment;
     
     AppWindowToken mFocusedApp = null;
@@ -1179,7 +1184,8 @@ public class WindowManagerService extends IWindowManager.Stub
     boolean adjustWallpaperWindowsLocked() {
         boolean changed = false;
         
-        mUpcomingWallpaperTarget = null;
+        final int dw = mDisplay.getWidth();
+        final int dh = mDisplay.getHeight();
         
         // First find top-most window that has asked to be on top of the
         // wallpaper; all wallpapers go behind it.
@@ -1188,60 +1194,41 @@ public class WindowManagerService extends IWindowManager.Stub
         WindowState w = null;
         WindowState foundW = null;
         int foundI = 0;
-        AppWindowToken topToken = null;
-        AppWindowToken behindToken = null;
         int i = N;
         while (i > 0) {
             i--;
             w = (WindowState)localmWindows.get(i);
-            if (topToken != null) {
-                if (w.mAppToken == topToken) {
+            if (w.mAppToken != null) {
+                // If this window's app token is hidden and not animating,
+                // it is of no interest to us.
+                if (w.mAppToken.hidden && w.mAppToken.animation == null) {
+                    if (DEBUG_WALLPAPER) Log.v(TAG,
+                            "Skipping hidden or animating token: " + w);
                     continue;
                 }
-                if (w.mAppToken != null) {
-                    if (behindToken == null) {
-                        // We need to look through for what is behind the
-                        // potential new wallpaper target...  skip all tokens
-                        // that are hidden and not animating, since they can't
-                        // be involved with the transition.
-                        if (w.mAppToken.hidden && w.mAppToken.animation == null) {
-                            continue;
-                        }
-                        behindToken = w.mAppToken;
-                    }
-                    if (w.mAppToken != behindToken) {
-                        break;
-                    }
+                // If this window's app token is ot fullscreen, also irrelevant.
+                if (!w.mAppToken.appFullscreen) {
+                    if (DEBUG_WALLPAPER) Log.v(TAG,
+                            "Skipping non-fullscreen token: " + w);
+                    continue;
                 }
             }
+            if (DEBUG_WALLPAPER) Log.v(TAG, "Win " + w + ": readyfordisplay="
+                    + w.isReadyForDisplay() + " drawpending=" + w.mDrawPending
+                    + " commitdrawpending=" + w.mCommitDrawPending);
             if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
                     && !w.mDrawPending && !w.mCommitDrawPending) {
-                if (behindToken != null && w.mAppToken == behindToken) {
-                    // We had previously found a wallpaper window that was
-                    // animating, and now we found one behind it.  We could
-                    // be doing an animation between two windows on top of
-                    // the wallpaper!
-                    if (mWallpaperTarget == w || mWallpaperTarget == foundW) {
-                        // Retain the current wallpaper target (don't move
-                        // the wallpaper yet), but note the window that is
-                        // going to become the wallpaper target so that
-                        // others know about this special state.
-                        if (DEBUG_WALLPAPER) Log.v(TAG,
-                                "Switching wallpaper activities: cur#" + i + "="
-                                + w + " upcoming#" + foundI + "=" + foundW);
-                        mUpcomingWallpaperTarget = foundW;
-                        foundW = w;
-                        foundI = i;
-                        break;
-                    }
-                }
+                if (DEBUG_WALLPAPER) Log.v(TAG,
+                        "Found wallpaper activity: #" + i + "=" + w);
                 foundW = w;
                 foundI = i;
-                if (w.mAppToken != null && w.mAppToken.animation != null) {
-                    // If this app token is animating, we want to keep the
-                    // wallpaper below it if it is animating on top of another
-                    // app with a wallpaper.
-                    topToken = w.mAppToken;
+                if (w == mWallpaperTarget && w.mAppToken != null
+                        && w.mAppToken.animation != null) {
+                    // The current wallpaper target is animating, so we'll
+                    // look behind it for another possible target and figure
+                    // out what is going on below.
+                    if (DEBUG_WALLPAPER) Log.v(TAG, "Win " + w
+                            + ": token animating, looking behind.");
                     continue;
                 }
                 break;
@@ -1258,20 +1245,93 @@ public class WindowManagerService extends IWindowManager.Stub
             // enough (we'll just wait until whatever transition is pending
             // executes).
             if (mWallpaperTarget != null && mWallpaperTarget.mAppToken != null) {
+                if (DEBUG_WALLPAPER) Log.v(TAG,
+                        "Wallpaper not changing: waiting for app anim in current target");
                 return false;
             }
             if (foundW != null && foundW.mAppToken != null) {
-                return false;
-            }
-            if (mUpcomingWallpaperTarget != null && mUpcomingWallpaperTarget.mAppToken != null) {
+                if (DEBUG_WALLPAPER) Log.v(TAG,
+                        "Wallpaper not changing: waiting for app anim in found target");
                 return false;
             }
         }
         
         if (mWallpaperTarget != foundW) {
-            mWallpaperTarget = foundW;
             if (DEBUG_WALLPAPER) {
-                Log.v(TAG, "New wallpaper target: " + foundW);
+                Log.v(TAG, "New wallpaper target: " + foundW
+                        + " oldTarget: " + mWallpaperTarget);
+            }
+            
+            mLowerWallpaperTarget = null;
+            mUpperWallpaperTarget = null;
+            
+            WindowState oldW = mWallpaperTarget;
+            mWallpaperTarget = foundW;
+            
+            // Now what is happening...  if the current and new targets are
+            // animating, then we are in our super special mode!
+            if (foundW != null && foundW.mAppToken != null && oldW != null
+                    && oldW.mAppToken != null) {
+                if (DEBUG_WALLPAPER) {
+                    Log.v(TAG, "New animation: " + foundW.mAppToken.animation
+                            + " old animation: " + oldW.mAppToken.animation);
+                }
+                if (foundW.mAppToken.animation != null
+                        && oldW.mAppToken.animation != null) {
+                    int oldI = localmWindows.indexOf(oldW);
+                    if (DEBUG_WALLPAPER) {
+                        Log.v(TAG, "New i: " + foundI + " old i: " + oldI);
+                    }
+                    if (oldI >= 0) {
+                        if (DEBUG_WALLPAPER) {
+                            Log.v(TAG, "Animating wallpapers: old#" + oldI
+                                    + "=" + oldW + "; new#" + foundI
+                                    + "=" + foundW);
+                        }
+                        
+                        // Set the new target correctly.
+                        if (foundW.mAppToken.hiddenRequested) {
+                            if (DEBUG_WALLPAPER) {
+                                Log.v(TAG, "Old wallpaper still the target.");
+                            }
+                            mWallpaperTarget = oldW;
+                        }
+                        
+                        // Now set the upper and lower wallpaper targets
+                        // correctly, and make sure that we are positioning
+                        // the wallpaper below the lower.
+                        if (foundI > oldI) {
+                            // The new target is on top of the old one.
+                            if (DEBUG_WALLPAPER) {
+                                Log.v(TAG, "Found target above old target.");
+                            }
+                            mUpperWallpaperTarget = foundW;
+                            mLowerWallpaperTarget = oldW;
+                            foundW = oldW;
+                            foundI = oldI;
+                        } else {
+                            // The new target is below the old one.
+                            if (DEBUG_WALLPAPER) {
+                                Log.v(TAG, "Found target below old target.");
+                            }
+                            mUpperWallpaperTarget = oldW;
+                            mLowerWallpaperTarget = foundW;
+                        }
+                    }
+                }
+            }
+            
+        } else {
+            // Is it time to stop animating?
+            if (mLowerWallpaperTarget == null
+                    || mLowerWallpaperTarget.mAppToken.animation == null
+                    || mUpperWallpaperTarget == null
+                    || mUpperWallpaperTarget.mAppToken.animation == null) {
+                if (DEBUG_WALLPAPER) {
+                    Log.v(TAG, "No longer animating wallpaper targets!");
+                }
+                mLowerWallpaperTarget = null;
+                mUpperWallpaperTarget = null;
             }
         }
         
@@ -1286,7 +1346,7 @@ public class WindowManagerService extends IWindowManager.Stub
             // its layer adjustment.  Only do this if we are not transfering
             // between two wallpaper targets.
             mWallpaperAnimLayerAdjustment =
-                    (mUpcomingWallpaperTarget == null && foundW.mAppToken != null)
+                    (mLowerWallpaperTarget == null && foundW.mAppToken != null)
                     ? foundW.mAppToken.animLayerAdjustment : 0;
             
             // Now w is the window we are supposed to be behind...  but we
@@ -1310,9 +1370,6 @@ public class WindowManagerService extends IWindowManager.Stub
         // what is below it for later.
         foundW = foundI > 0 ? (WindowState)localmWindows.get(foundI-1) : null;
         
-        final int dw = mDisplay.getWidth();
-        final int dh = mDisplay.getHeight();
-        
         // Start stepping backwards from here, ensuring that our wallpaper windows
         // are correctly placed.
         int curTokenIndex = mWallpaperTokens.size();
@@ -6676,11 +6733,14 @@ public class WindowManagerService extends IWindowManager.Stub
                 mAppToken.startingDisplayed = false;
             }
 
-            if (localLOGV) Log.v(
-                TAG, "Window " + this
-                + " destroying surface " + mSurface + ", session " + mSession);
             if (mSurface != null) {
                 try {
+                    if (DEBUG_VISIBILITY) {
+                        RuntimeException e = new RuntimeException();
+                        e.fillInStackTrace();
+                        Log.w(TAG, "Window " + this + " destroying surface "
+                                + mSurface + ", session " + mSession, e);
+                    }
                     if (SHOW_TRANSACTIONS) {
                         RuntimeException ex = new RuntimeException();
                         ex.fillInStackTrace();
@@ -6829,7 +6889,7 @@ public class WindowManagerService extends IWindowManager.Stub
                 }
                 mHasLocalTransformation = false;
                 if ((!mLocalAnimating || mAnimationIsEntrance) && mAppToken != null
-                        && mAppToken.hasTransformation) {
+                        && mAppToken.animation != null) {
                     // When our app token is animating, we kind-of pretend like
                     // we are as well.  Note the mLocalAnimating mAnimationIsEntrance
                     // part of this check means that we will only do this if
@@ -6962,7 +7022,7 @@ public class WindowManagerService extends IWindowManager.Stub
             
             // Wallpapers are animated based on the "real" window they
             // are currently targeting.
-            if (mAttrs.type == TYPE_WALLPAPER && mUpcomingWallpaperTarget == null
+            if (mAttrs.type == TYPE_WALLPAPER && mLowerWallpaperTarget == null
                     && mWallpaperTarget != null) {
                 if (mWallpaperTarget.mHasLocalTransformation) {
                     attachedTransformation = mWallpaperTarget.mTransformation;
@@ -7600,7 +7660,7 @@ public class WindowManagerService extends IWindowManager.Stub
                 if (w == mInputMethodTarget) {
                     setInputMethodAnimLayerAdjustment(adj);
                 }
-                if (w == mWallpaperTarget && mUpcomingWallpaperTarget == null) {
+                if (w == mWallpaperTarget && mLowerWallpaperTarget == null) {
                     setWallpaperAnimLayerAdjustmentLocked(adj);
                 }
             }
@@ -7640,7 +7700,7 @@ public class WindowManagerService extends IWindowManager.Stub
 
                 if (animation == sDummyAnimation) {
                     // This guy is going to animate, but not yet.  For now count
-                    // it is not animating for purposes of scheduling transactions;
+                    // it as not animating for purposes of scheduling transactions;
                     // when it is really time to animate, this will be set to
                     // a real animation and the next call will execute normally.
                     return false;
@@ -7780,6 +7840,7 @@ public class WindowManagerService extends IWindowManager.Stub
                 pw.print(prefix); pw.print("allAppWindows="); pw.println(allAppWindows);
             }
             pw.print(prefix); pw.print("groupId="); pw.print(groupId);
+                    pw.print(" appFullscreen="); pw.println(appFullscreen);
                     pw.print(" requestedOrientation="); pw.println(requestedOrientation);
             pw.print(prefix); pw.print("hiddenRequested="); pw.print(hiddenRequested);
                     pw.print(" clientHidden="); pw.print(clientHidden);
@@ -8725,13 +8786,12 @@ public class WindowManagerService extends IWindowManager.Stub
 
                         mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
 
-                        boolean wallpaperMoved = adjustWallpaperWindowsLocked();
+                        adjustWallpaperWindowsLocked();
                         if (DEBUG_APP_TRANSITIONS) Log.v(TAG,
-                                "Old wallpaper target=" + mWallpaperTarget
-                                + ", upcoming target=" + mUpcomingWallpaperTarget);
-                        if (mUpcomingWallpaperTarget != mWallpaperTarget &&
-                                mUpcomingWallpaperTarget != null &&
-                                mWallpaperTarget != null) {
+                                "New wallpaper target=" + mWallpaperTarget
+                                + ", lower target=" + mLowerWallpaperTarget
+                                + ", upper target=" + mUpperWallpaperTarget);
+                        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
@@ -8741,20 +8801,20 @@ public class WindowManagerService extends IWindowManager.Stub
                             NN = mOpeningApps.size();
                             for (i=0; i<NN; i++) {
                                 AppWindowToken wtoken = mOpeningApps.get(i);
-                                if (mUpcomingWallpaperTarget.mAppToken == wtoken) {
+                                if (mLowerWallpaperTarget.mAppToken == wtoken) {
                                     found |= 1;
                                 }
-                                if (mWallpaperTarget.mAppToken == wtoken) {
+                                if (mUpperWallpaperTarget.mAppToken == wtoken) {
                                     found |= 1;
                                 }
                             }
                             NN = mClosingApps.size();
                             for (i=0; i<NN; i++) {
                                 AppWindowToken wtoken = mClosingApps.get(i);
-                                if (mUpcomingWallpaperTarget.mAppToken == wtoken) {
+                                if (mLowerWallpaperTarget.mAppToken == wtoken) {
                                     found |= 2;
                                 }
-                                if (mWallpaperTarget.mAppToken == wtoken) {
+                                if (mUpperWallpaperTarget.mAppToken == wtoken) {
                                     found |= 2;
                                 }
                             }