A variety of work on animations.

- The lock screen now fades in and out.
- Fixed a bug where we would accidentally freeze the screen when switching
  to an activity with a different orientation than the current (but
  the screen itself is in the current orientation).  This would mess up
  the animations on the car dock.
- New API to force a particular animation for an activity transition
  (untested).
- New wallpaper animations.
- Resources now uses the next API version when in a development build,
  to help applications being developed against such builds.

Change-Id: I2d9998f8400967ff09a04d693dc4ce55f0dbef5b
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 4561899..8755477 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3015,6 +3015,23 @@
     }
 
     /**
+     * Call immediately after one of the flavors of {@link #startActivity(Intent)}
+     * or {@link #finish} to specify an explicit transition animation to
+     * perform next.
+     * @param enterAnim A resource ID of the animation resource to use for
+     * the incoming activity.
+     * @param exitAnim A resource ID of the animation resource to use for
+     * the outgoing activity.
+     */
+    public void overridePendingTransition(int enterAnim, int exitAnim) {
+        try {
+            ActivityManagerNative.getDefault().overridePendingTransition(
+                    mToken, getPackageName(), enterAnim, exitAnim);
+        } catch (RemoteException e) {
+        }
+    }
+    
+    /**
      * Call this to set the result that your activity will return to its
      * caller.
      * 
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 82d49e3..2d7658a 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1153,6 +1153,16 @@
             reply.writeNoException();
             return true;
         }
+        
+        case OVERRIDE_PENDING_TRANSITION_TRANSACTION: {
+            data.enforceInterface(IActivityManager.descriptor);
+            IBinder token = data.readStrongBinder();
+            String packageName = data.readString();
+            int enterAnim = data.readInt();
+            int exitAnim = data.readInt();
+            overridePendingTransition(token, packageName, enterAnim, exitAnim);
+            return true;
+        }
         }
         
         return super.onTransact(code, data, reply, flags);
@@ -2530,5 +2540,20 @@
         reply.recycle();
     }
         
+    public void overridePendingTransition(IBinder token, String packageName,
+            int enterAnim, int exitAnim) throws RemoteException {
+        Parcel data = Parcel.obtain();
+        Parcel reply = Parcel.obtain();
+        data.writeInterfaceToken(IActivityManager.descriptor);
+        data.writeStrongBinder(token);
+        data.writeString(packageName);
+        data.writeInt(enterAnim);
+        data.writeInt(exitAnim);
+        mRemote.transact(OVERRIDE_PENDING_TRANSITION_TRANSACTION, data, reply, 0);
+        reply.readException();
+        data.recycle();
+        reply.recycle();
+    }
+    
     private IBinder mRemote;
 }
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 110b72d..7ad7561 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -285,6 +285,9 @@
     public Debug.MemoryInfo[] getProcessMemoryInfo(int[] pids)
             throws RemoteException;
     
+    public void overridePendingTransition(IBinder token, String packageName,
+            int enterAnim, int exitAnim) throws RemoteException;
+    
     /*
      * Private non-Binder interfaces
      */
@@ -444,4 +447,5 @@
     int GET_PROCESS_MEMORY_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+97;
     int KILL_APPLICATION_PROCESS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+98;
     int START_ACTIVITY_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+99;
+    int OVERRIDE_PENDING_TRANSITION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+100;
 }
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 8839f95..7a65af8 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -253,7 +253,7 @@
     public int uid;
     
     /**
-     * The minimum SDK version this application targets.  It may run on earilier
+     * The minimum SDK version this application targets.  It may run on earlier
      * versions, but it knows how to work with any new behavior added at this
      * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
      * if this is a development build and the app is targeting that.  You should
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 3796201..00ab7de 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -25,6 +25,7 @@
 import android.graphics.Movie;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
 import android.os.Bundle;
 import android.os.SystemProperties;
 import android.util.AttributeSet;
@@ -50,8 +51,10 @@
     private static final boolean DEBUG_CONFIG = false;
     private static final boolean TRACE_FOR_PRELOAD = false;
 
-    private static final int sSdkVersion = SystemProperties.getInt(
-            "ro.build.version.sdk", 0);
+    // Use the current SDK version code.  If we are a development build,
+    // also allow the previous SDK version + 1.
+    private static final int sSdkVersion = Build.VERSION.SDK_INT
+            + ("REL".equals(Build.VERSION.CODENAME) ? 1 : 0);
     private static final Object mSync = new Object();
     private static Resources mSystem = null;
     
diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl
index 7d1872a..23e7fb7 100644
--- a/core/java/android/view/IWindowManager.aidl
+++ b/core/java/android/view/IWindowManager.aidl
@@ -71,6 +71,7 @@
     void setFocusedApp(IBinder token, boolean moveFocusNow);
     void prepareAppTransition(int transit);
     int getPendingAppTransition();
+    void overridePendingAppTransition(String packageName, int enterAnim, int exitAnim);
     void executeAppTransition();
     void setAppStartingWindow(IBinder token, String pkg, int theme,
             CharSequence nonLocalizedLabel, int labelRes,
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 396e380..7a22301 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -522,6 +522,13 @@
          * also been set. */
         public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
         
+        /** Window flag: *sigh* The lock screen wants to continue running its
+         * animation while it is fading.  A kind-of hack to allow this.  Maybe
+         * in the future we just make this the default behavior.
+         *
+         * {@hide} */
+        public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
+        
         /** Window flag: special flag to limit the size of the window to be
          * original size ([320x480] x density). Used to create window for applications
          * running under compatibility mode.
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index 1923743..b3125b2 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -314,50 +314,60 @@
         public boolean showLw(boolean doAnimation);
     }
 
+    /**
+     * Bit mask that is set for all enter transition.
+     */
+    public final int TRANSIT_ENTER_MASK = 0x1000;
+    
+    /**
+     * Bit mask that is set for all exit transitions.
+     */
+    public final int TRANSIT_EXIT_MASK = 0x2000;
+    
     /** Not set up for a transition. */
-    public final int TRANSIT_UNSET = 0;
+    public final int TRANSIT_UNSET = -1;
     /** No animation for transition. */
     public final int TRANSIT_NONE = 0;
     /** Window has been added to the screen. */
-    public final int TRANSIT_ENTER = 1;
+    public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
     /** Window has been removed from the screen. */
-    public final int TRANSIT_EXIT = 2;
+    public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
     /** Window has been made visible. */
-    public final int TRANSIT_SHOW = 3;
+    public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
     /** Window has been made invisible. */
-    public final int TRANSIT_HIDE = 4;
+    public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
     /** The "application starting" preview window is no longer needed, and will
      * animate away to show the real window. */
     public final int TRANSIT_PREVIEW_DONE = 5;
     /** A window in a new activity is being opened on top of an existing one
      * in the same task. */
-    public final int TRANSIT_ACTIVITY_OPEN = 6;
+    public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
     /** The window in the top-most activity is being closed to reveal the
      * previous activity in the same task. */
-    public final int TRANSIT_ACTIVITY_CLOSE = 7;
+    public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
     /** A window in a new task is being opened on top of an existing one
      * in another activity's task. */
-    public final int TRANSIT_TASK_OPEN = 8;
+    public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
     /** A window in the top-most activity is being closed to reveal the
      * previous activity in a different task. */
-    public final int TRANSIT_TASK_CLOSE = 9;
+    public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
     /** A window in an existing task is being displayed on top of an existing one
      * in another activity's task. */
-    public final int TRANSIT_TASK_TO_FRONT = 10;
+    public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
     /** A window in an existing task is being put below all other tasks. */
-    public final int TRANSIT_TASK_TO_BACK = 11;
+    public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
     /** 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;
+    public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
     /** 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;
+    public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
     /** 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_INTRA_OPEN = 14;
+    public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
     /** 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_INTRA_CLOSE = 15;
+    public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
     
     /** Screen turned off because of power button */
     public final int OFF_BECAUSE_OF_USER = 1;
@@ -444,6 +454,21 @@
     public int getMaxWallpaperLayer();
     
     /**
+     * Return whether the given window should forcibly hide everything
+     * behind it.  Typically returns true for the keyguard.
+     */
+    public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
+    
+    /**
+     * Determine if a window that is behind one that is force hiding
+     * (as determined by {@link #doesForceHide}) should actually be hidden.
+     * For example, typically returns false for the status bar.  Be careful
+     * to return false for any window that you may hide yourself, since this
+     * will conflict with what you set.
+     */
+    public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
+    
+    /**
      * Called when the system would like to show a UI to indicate that an
      * application is starting.  You can use this to add a
      * APPLICATION_STARTING_TYPE window with the given appToken to the window
@@ -524,6 +549,11 @@
     public int selectAnimationLw(WindowState win, int transit);
 
     /**
+     * Create and return an animation to re-display a force hidden window.
+     */
+    public Animation createForceHideEnterAnimation();
+    
+    /**
      * Called from the key queue thread before a key is dispatched to the
      * input thread.
      *
diff --git a/core/res/res/anim/lock_screen_behind_enter.xml b/core/res/res/anim/lock_screen_behind_enter.xml
new file mode 100644
index 0000000..9e03e15
--- /dev/null
+++ b/core/res/res/anim/lock_screen_behind_enter.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2007, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License"); 
+** you may not use this file except in compliance with the License. 
+** You may obtain a copy of the License at 
+**
+**     http://www.apache.org/licenses/LICENSE-2.0 
+**
+** Unless required by applicable law or agreed to in writing, software 
+** distributed under the License is distributed on an "AS IS" BASIS, 
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+** See the License for the specific language governing permissions and 
+** limitations under the License.
+*/
+-->
+
+<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@anim/accelerate_interpolator">
+    <alpha android:fromAlpha="0.0" android:toAlpha="1.0"
+            android:duration="@android:integer/config_mediumAnimTime" />
+</set>
diff --git a/core/res/res/anim/lock_screen_exit.xml b/core/res/res/anim/lock_screen_exit.xml
index 55c5ec9..0d32921 100644
--- a/core/res/res/anim/lock_screen_exit.xml
+++ b/core/res/res/anim/lock_screen_exit.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-/* //device/apps/common/res/anim/options_panel_exit.xml
-**
+/*
 ** Copyright 2007, The Android Open Source Project
 **
 ** Licensed under the Apache License, Version 2.0 (the "License"); 
diff --git a/core/res/res/anim/wallpaper_close_enter.xml b/core/res/res/anim/wallpaper_close_enter.xml
index 5bc299e..2329abb 100644
--- a/core/res/res/anim/wallpaper_close_enter.xml
+++ b/core/res/res/anim/wallpaper_close_enter.xml
@@ -17,8 +17,22 @@
 */
 -->
 
+<!-- This version zooms the new non-wallpaper up out of the
+     wallpaper, without zooming the wallpaper itself. -->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+        android:interpolator="@anim/decelerate_interpolator"
+        android:zAdjustment="top">
+    <scale android:fromXScale=".5" android:toXScale="1.0"
+           android:fromYScale=".5" android:toYScale="1.0"
+           android:pivotX="50%p" android:pivotY="50%p"
+           android:duration="@android:integer/config_mediumAnimTime" />
+    <alpha android:fromAlpha="0" android:toAlpha="1.0"
+            android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
+
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper, without zooming the wallpaper itself. -->
+<!--
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator"
         android:zAdjustment="top">
@@ -29,6 +43,7 @@
     <alpha android:fromAlpha="0" android:toAlpha="1.0"
             android:duration="@android:integer/config_mediumAnimTime"/>
 </set>
+-->
 
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper. -->
diff --git a/core/res/res/anim/wallpaper_close_exit.xml b/core/res/res/anim/wallpaper_close_exit.xml
index c3ae620..eccce81 100644
--- a/core/res/res/anim/wallpaper_close_exit.xml
+++ b/core/res/res/anim/wallpaper_close_exit.xml
@@ -17,8 +17,20 @@
 */
 -->
 
+<!-- This version zooms the new non-wallpaper up out of the
+     wallpaper, without zooming the wallpaper itself. -->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+        android:interpolator="@anim/decelerate_interpolator"
+        android:detachWallpaper="true">
+    <scale android:fromXScale="1.0" android:toXScale="2.0"
+           android:fromYScale="1.0" android:toYScale="2.0"
+           android:pivotX="50%p" android:pivotY="50%p"
+           android:duration="@android:integer/config_mediumAnimTime" />
+</set>
+
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper, without zooming the wallpaper itself. -->
+<!--
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator"
         android:detachWallpaper="true">
@@ -27,6 +39,7 @@
            android:pivotX="50%p" android:pivotY="50%p"
            android:duration="@android:integer/config_mediumAnimTime" />
 </set>
+-->
 
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper.  The wallpaper here just stays fixed behind. -->
diff --git a/core/res/res/anim/wallpaper_open_enter.xml b/core/res/res/anim/wallpaper_open_enter.xml
index 7fe7e1e..3a6fb05 100644
--- a/core/res/res/anim/wallpaper_open_enter.xml
+++ b/core/res/res/anim/wallpaper_open_enter.xml
@@ -17,8 +17,20 @@
 */
 -->
 
+<!-- This version zooms the new non-wallpaper up out of the
+     wallpaper, without zooming the wallpaper itself. -->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+        android:interpolator="@anim/decelerate_interpolator"
+        android:detachWallpaper="true">
+    <scale android:fromXScale="2.0" android:toXScale="1.0"
+           android:fromYScale="2.0" android:toYScale="1.0"
+           android:pivotX="50%p" android:pivotY="50%p"
+           android:duration="@android:integer/config_mediumAnimTime" />
+</set>
+
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper, without zooming the wallpaper itself. -->
+<!--
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator"
         android:detachWallpaper="true">
@@ -27,6 +39,7 @@
            android:pivotX="50%p" android:pivotY="50%p"
            android:duration="@android:integer/config_mediumAnimTime" />
 </set>
+-->
 
 <!-- This version zooms the new non-wallpaper up off the wallpaper the
      wallpaper.  The wallpaper here just stays fixed behind. -->
diff --git a/core/res/res/anim/wallpaper_open_exit.xml b/core/res/res/anim/wallpaper_open_exit.xml
index 9489c6d..e5b7007 100644
--- a/core/res/res/anim/wallpaper_open_exit.xml
+++ b/core/res/res/anim/wallpaper_open_exit.xml
@@ -16,9 +16,22 @@
 ** limitations under the License.
 */
 -->
+<!-- This version zooms the new non-wallpaper up out of the
+     wallpaper, without zooming the wallpaper itself. -->
+<set xmlns:android="http://schemas.android.com/apk/res/android"
+        android:interpolator="@anim/decelerate_interpolator"
+        android:zAdjustment="top">
+    <scale android:fromXScale="1.0" android:toXScale=".5"
+           android:fromYScale="1.0" android:toYScale=".5"
+           android:pivotX="50%p" android:pivotY="50%p"
+           android:duration="@android:integer/config_mediumAnimTime" />
+    <alpha android:fromAlpha="1.0" android:toAlpha="0"
+            android:duration="@android:integer/config_mediumAnimTime"/>
+</set>
 
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper, without zooming the wallpaper itself. -->
+<!--
 <set xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@anim/decelerate_interpolator"
         android:zAdjustment="top">
@@ -29,6 +42,7 @@
     <alpha android:fromAlpha="1.0" android:toAlpha="0"
             android:duration="@android:integer/config_mediumAnimTime"/>
 </set>
+-->
 
 <!-- This version zooms the new non-wallpaper down on top of the
      wallpaper. -->
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index b508372..cf0dfd7 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -33,7 +33,7 @@
     <integer name="config_mediumAnimTime">200</integer>
     
     <!-- The duration (in milliseconds) of a long animation. -->
-    <integer name="config_longAnimTime">400</integer>
+    <integer name="config_longAnimTime">350</integer>
 
     <!-- XXXXX NOTE THE FOLLOWING RESOURCES USE THE WRONG NAMING CONVENTION.
          Please don't copy them, copy anything else. -->