Merge "Setup correct initial guest restrictions" into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index c5027ae..c425246 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -1435,8 +1435,12 @@
     field public static final int windowNoDisplay = 16843294; // 0x101021e
     field public static final int windowNoTitle = 16842838; // 0x1010056
     field public static final int windowOverscan = 16843727; // 0x10103cf
+    field public static final int windowReenterTransition = 16843954; // 0x10104b2
+    field public static final int windowReturnTransition = 16843953; // 0x10104b1
     field public static final int windowSharedElementEnterTransition = 16843835; // 0x101043b
     field public static final int windowSharedElementExitTransition = 16843836; // 0x101043c
+    field public static final int windowSharedElementReenterTransition = 16843956; // 0x10104b4
+    field public static final int windowSharedElementReturnTransition = 16843955; // 0x10104b3
     field public static final int windowShowAnimation = 16842934; // 0x10100b6
     field public static final int windowShowWallpaper = 16843410; // 0x1010292
     field public static final int windowSoftInputMode = 16843307; // 0x101022b
@@ -35319,8 +35323,12 @@
     method protected final int getLocalFeatures();
     method public android.media.session.MediaController getMediaController();
     method public abstract int getNavigationBarColor();
+    method public android.transition.Transition getReenterTransition();
+    method public android.transition.Transition getReturnTransition();
     method public android.transition.Transition getSharedElementEnterTransition();
     method public android.transition.Transition getSharedElementExitTransition();
+    method public android.transition.Transition getSharedElementReenterTransition();
+    method public android.transition.Transition getSharedElementReturnTransition();
     method public abstract int getStatusBarColor();
     method public long getTransitionBackgroundFadeDuration();
     method public android.transition.TransitionManager getTransitionManager();
@@ -35376,8 +35384,12 @@
     method public void setLogo(int);
     method public void setMediaController(android.media.session.MediaController);
     method public abstract void setNavigationBarColor(int);
+    method public void setReenterTransition(android.transition.Transition);
+    method public void setReturnTransition(android.transition.Transition);
     method public void setSharedElementEnterTransition(android.transition.Transition);
     method public void setSharedElementExitTransition(android.transition.Transition);
+    method public void setSharedElementReenterTransition(android.transition.Transition);
+    method public void setSharedElementReturnTransition(android.transition.Transition);
     method public void setSoftInputMode(int);
     method public abstract void setStatusBarColor(int);
     method public abstract void setTitle(java.lang.CharSequence);
diff --git a/core/java/android/app/EnterTransitionCoordinator.java b/core/java/android/app/EnterTransitionCoordinator.java
index 1326064..b5d362d 100644
--- a/core/java/android/app/EnterTransitionCoordinator.java
+++ b/core/java/android/app/EnterTransitionCoordinator.java
@@ -256,7 +256,7 @@
     @Override
     protected Transition getViewsTransition() {
         if (mIsReturning) {
-            return getWindow().getExitTransition();
+            return getWindow().getReenterTransition();
         } else {
             return getWindow().getEnterTransition();
         }
@@ -264,7 +264,7 @@
 
     protected Transition getSharedElementTransition() {
         if (mIsReturning) {
-            return getWindow().getSharedElementExitTransition();
+            return getWindow().getSharedElementReenterTransition();
         } else {
             return getWindow().getSharedElementEnterTransition();
         }
diff --git a/core/java/android/app/ExitTransitionCoordinator.java b/core/java/android/app/ExitTransitionCoordinator.java
index 2ce6018..b3fdcc7 100644
--- a/core/java/android/app/ExitTransitionCoordinator.java
+++ b/core/java/android/app/ExitTransitionCoordinator.java
@@ -395,7 +395,7 @@
     @Override
     protected Transition getViewsTransition() {
         if (mIsReturning) {
-            return getWindow().getEnterTransition();
+            return getWindow().getReturnTransition();
         } else {
             return getWindow().getExitTransition();
         }
@@ -403,7 +403,7 @@
 
     protected Transition getSharedElementTransition() {
         if (mIsReturning) {
-            return getWindow().getSharedElementEnterTransition();
+            return getWindow().getSharedElementReturnTransition();
         } else {
             return getWindow().getSharedElementExitTransition();
         }
diff --git a/core/java/android/hardware/location/GeofenceHardwareImpl.java b/core/java/android/hardware/location/GeofenceHardwareImpl.java
index 6734878..5c7a8da 100644
--- a/core/java/android/hardware/location/GeofenceHardwareImpl.java
+++ b/core/java/android/hardware/location/GeofenceHardwareImpl.java
@@ -139,8 +139,8 @@
     private void updateFusedHardwareAvailability() {
         boolean fusedSupported;
         try {
-            fusedSupported = mFusedService.isSupported();
-        } catch(RemoteException e) {
+            fusedSupported = (mFusedService != null ? mFusedService.isSupported() : false);
+        } catch (RemoteException e) {
             Log.e(TAG, "RemoteException calling LocationManagerService");
             fusedSupported = false;
         }
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index c169d35..e7b3152 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -1425,6 +1425,21 @@
     public void setEnterTransition(Transition transition) {}
 
     /**
+     * Sets the Transition that will be used to move Views out of the scene when the Window is
+     * preparing to close, for example after a call to
+     * {@link android.app.Activity#finishAfterTransition()}. The exiting
+     * Views will be those that are regular Views or ViewGroups that have
+     * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
+     * {@link android.transition.Visibility} as entering is governed by changing visibility from
+     * {@link View#VISIBLE} to {@link View#INVISIBLE}. If <code>transition</code> is null,
+     * entering Views will remain unaffected. If nothing is set, the default will be to
+     * use the same value as set in {@link #setEnterTransition(android.transition.Transition)}.
+     * @param transition The Transition to use to move Views out of the Scene when the Window
+     *                   is preparing to close.
+     */
+    public void setReturnTransition(Transition transition) {}
+
+    /**
      * Sets the Transition that will be used to move Views out of the scene when starting a
      * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
      * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
@@ -1437,6 +1452,20 @@
     public void setExitTransition(Transition transition) {}
 
     /**
+     * Sets the Transition that will be used to move Views in to the scene when returning from
+     * a previously-started Activity. The entering Views will be those that are regular Views
+     * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
+     * will extend {@link android.transition.Visibility} as exiting is governed by changing
+     * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}. If transition is null,
+     * the views will remain unaffected. If nothing is set, the default will be to use the same
+     * transition as {@link #setExitTransition(android.transition.Transition)}.
+     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
+     * @param transition The Transition to use to move Views into the scene when reentering from a
+     *                   previously-started Activity.
+     */
+    public void setReenterTransition(Transition transition) {}
+
+    /**
      * Returns the transition used to move Views into the initial scene. The entering
      * Views will be those that are regular Views or ViewGroups that have
      * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
@@ -1449,6 +1478,19 @@
     public Transition getEnterTransition() { return null; }
 
     /**
+     * Returns he Transition that will be used to move Views out of the scene when the Window is
+     * preparing to close, for example after a call to
+     * {@link android.app.Activity#finishAfterTransition()}. The exiting
+     * Views will be those that are regular Views or ViewGroups that have
+     * {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
+     * {@link android.transition.Visibility} as entering is governed by changing visibility from
+     * {@link View#VISIBLE} to {@link View#INVISIBLE}.
+     * @return The Transition to use to move Views out of the Scene when the Window
+     *         is preparing to close.
+     */
+    public Transition getReturnTransition() { return null; }
+
+    /**
      * Returns the Transition that will be used to move Views out of the scene when starting a
      * new Activity. The exiting Views will be those that are regular Views or ViewGroups that
      * have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions will extend
@@ -1461,6 +1503,18 @@
     public Transition getExitTransition() { return null; }
 
     /**
+     * Returns the Transition that will be used to move Views in to the scene when returning from
+     * a previously-started Activity. The entering Views will be those that are regular Views
+     * or ViewGroups that have {@link ViewGroup#isTransitionGroup} return true. Typical Transitions
+     * will extend {@link android.transition.Visibility} as exiting is governed by changing
+     * visibility from {@link View#VISIBLE} to {@link View#INVISIBLE}.
+     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
+     * @return The Transition to use to move Views into the scene when reentering from a
+     *         previously-started Activity.
+     */
+    public Transition getReenterTransition() { return null; }
+
+    /**
      * Sets the Transition that will be used for shared elements transferred into the content
      * Scene. Typical Transitions will affect size and location, such as
      * {@link android.transition.ChangeBounds}. A null
@@ -1472,6 +1526,19 @@
     public void setSharedElementEnterTransition(Transition transition) {}
 
     /**
+     * Sets the Transition that will be used for shared elements transferred back to a
+     * calling Activity. Typical Transitions will affect size and location, such as
+     * {@link android.transition.ChangeBounds}. A null
+     * value will cause transferred shared elements to blink to the final position.
+     * If no value is set, the default will be to use the same value as
+     * {@link #setSharedElementEnterTransition(android.transition.Transition)}.
+     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
+     * @param transition The Transition to use for shared elements transferred out of the content
+     *                   Scene.
+     */
+    public void setSharedElementReturnTransition(Transition transition) {}
+
+    /**
      * Returns the Transition that will be used for shared elements transferred into the content
      * Scene. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
      * @return Transition to use for sharend elements transferred into the content Scene.
@@ -1479,6 +1546,13 @@
     public Transition getSharedElementEnterTransition() { return null; }
 
     /**
+     * Returns the Transition that will be used for shared elements transferred back to a
+     * calling Activity. Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
+     * @return Transition to use for sharend elements transferred into the content Scene.
+     */
+    public Transition getSharedElementReturnTransition() { return null; }
+
+    /**
      * Sets the Transition that will be used for shared elements after starting a new Activity
      * before the shared elements are transferred to the called Activity. If the shared elements
      * must animate during the exit transition, this Transition should be used. Upon completion,
@@ -1490,6 +1564,17 @@
     public void setSharedElementExitTransition(Transition transition) {}
 
     /**
+     * Sets the Transition that will be used for shared elements reentering from a started
+     * Activity after it has returned the shared element to it start location. If no value
+     * is set, this will default to
+     * {@link #setSharedElementExitTransition(android.transition.Transition)}.
+     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
+     * @param transition The Transition to use for shared elements in the launching Window
+     *                   after the shared element has returned to the Window.
+     */
+    public void setSharedElementReenterTransition(Transition transition) {}
+
+    /**
      * Returns the Transition to use for shared elements in the launching Window prior
      * to transferring to the launched Activity's Window.
      * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
@@ -1500,6 +1585,16 @@
     public Transition getSharedElementExitTransition() { return null; }
 
     /**
+     * Returns the Transition that will be used for shared elements reentering from a started
+     * Activity after it has returned the shared element to it start location.
+     * Requires {@link #FEATURE_CONTENT_TRANSITIONS}.
+     *
+     * @return the Transition that will be used for shared elements reentering from a started
+     * Activity after it has returned the shared element to it start location.
+     */
+    public Transition getSharedElementReenterTransition() { return null; }
+
+    /**
      * Controls how the transition set in
      * {@link #setEnterTransition(android.transition.Transition)} overlaps with the exit
      * transition of the calling Activity. When true, the transition will start as soon as possible.
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 5cb3068..d07d0ab 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -464,24 +464,48 @@
         <attr name="windowEnterTransition" format="reference"/>
 
         <!-- Reference to a Transition XML resource defining the desired Transition
+             used to move Views out of the scene when the Window is
+             preparing to close. Corresponds to
+             {@link android.view.Window#setReturnTransition(android.transition.Transition)}. -->
+        <attr name="windowReturnTransition" format="reference"/>
+
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used to move Views out of the Window's content Scene when launching a new Activity.
              Corresponds to
              {@link android.view.Window#setExitTransition(android.transition.Transition)}. -->
         <attr name="windowExitTransition" format="reference"/>
 
         <!-- Reference to a Transition XML resource defining the desired Transition
+             used to move Views in to the scene when returning from a previously-started Activity.
+             Corresponds to
+             {@link android.view.Window#setReenterTransition(android.transition.Transition)}. -->
+        <attr name="windowReenterTransition" format="reference"/>
+
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used to move shared elements transferred into the Window's initial content Scene.
              Corresponds to {@link android.view.Window#setSharedElementEnterTransition(
              android.transition.Transition)}. -->
         <attr name="windowSharedElementEnterTransition" format="reference"/>
 
         <!-- Reference to a Transition XML resource defining the desired Transition
+             used to move shared elements transferred back to a calling Activity.
+             Corresponds to {@link android.view.Window#setSharedElementReturnTransition(
+             android.transition.Transition)}. -->
+        <attr name="windowSharedElementReturnTransition" format="reference"/>
+
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used when starting a new Activity to move shared elements prior to transferring
              to the called Activity.
              Corresponds to {@link android.view.Window#setSharedElementExitTransition(
              android.transition.Transition)}. -->
         <attr name="windowSharedElementExitTransition" format="reference"/>
 
+        <!-- Reference to a Transition XML resource defining the desired Transition
+             used for shared elements transferred back to a calling Activity.
+             Corresponds to {@link android.view.Window#setSharedElementReenterTransition(
+             android.transition.Transition)}. -->
+        <attr name="windowSharedElementReenterTransition" format="reference"/>
+
         <!-- Flag indicating whether this Window's transition should overlap with
              the exiting transition of the calling Activity. Corresponds to
              {@link android.view.Window#setAllowEnterTransitionOverlap(boolean)}. -->
@@ -1751,30 +1775,54 @@
              or a fraction of the screen size in that dimension. -->
         <attr name="windowFixedHeightMajor" format="dimension|fraction" />
         <attr name="windowOutsetBottom" format="dimension" />
-        <!-- Reference to a TransitionManager XML resource defining the desired Transition
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used to move Views into the initial Window's content Scene. Corresponds to
              {@link android.view.Window#setEnterTransition(android.transition.Transition)}. -->
         <attr name="windowEnterTransition"/>
 
-        <!-- Reference to a TransitionManager XML resource defining the desired Transition
+        <!-- Reference to a Transition XML resource defining the desired Transition
+             used to move Views out of the scene when the Window is
+             preparing to close. Corresponds to
+             {@link android.view.Window#setReturnTransition(android.transition.Transition)}. -->
+        <attr name="windowReturnTransition"/>
+
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used to move Views out of the Window's content Scene when launching a new Activity.
              Corresponds to
              {@link android.view.Window#setExitTransition(android.transition.Transition)}. -->
         <attr name="windowExitTransition"/>
 
-        <!-- Reference to a TransitionManager XML resource defining the desired Transition
+        <!-- Reference to a Transition XML resource defining the desired Transition
+             used to move Views in to the scene when returning from a previously-started Activity.
+             Corresponds to
+             {@link android.view.Window#setReenterTransition(android.transition.Transition)}. -->
+        <attr name="windowReenterTransition"/>
+
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used to move shared elements transferred into the Window's initial content Scene.
              Corresponds to {@link android.view.Window#setSharedElementEnterTransition(
              android.transition.Transition)}. -->
         <attr name="windowSharedElementEnterTransition"/>
 
-        <!-- Reference to a TransitionManager XML resource defining the desired Transition
+        <!-- Reference to a Transition XML resource defining the desired Transition
+             used to move shared elements transferred back to a calling Activity.
+             Corresponds to {@link android.view.Window#setSharedElementReturnTransition(
+             android.transition.Transition)}. -->
+        <attr name="windowSharedElementReturnTransition"/>
+
+        <!-- Reference to a Transition XML resource defining the desired Transition
              used when starting a new Activity to move shared elements prior to transferring
              to the called Activity.
              Corresponds to {@link android.view.Window#setSharedElementExitTransition(
              android.transition.Transition)}. -->
         <attr name="windowSharedElementExitTransition"/>
 
+        <!-- Reference to a Transition XML resource defining the desired Transition
+             used for shared elements transferred back to a calling Activity.
+             Corresponds to {@link android.view.Window#setSharedElementReenterTransition(
+             android.transition.Transition)}. -->
+        <attr name="windowSharedElementReenterTransition"/>
+
 
         <!-- Flag indicating whether this Window's transition should overlap with
              the exiting transition of the calling Activity. Corresponds to
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 0cb14e3..d8f9665 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2265,6 +2265,10 @@
   <public type="attr" name="windowClipToOutline" />
   <public type="attr" name="datePickerDialogTheme" />
   <public type="attr" name="showText" />
+  <public type="attr" name="windowReturnTransition" />
+  <public type="attr" name="windowReenterTransition" />
+  <public type="attr" name="windowSharedElementReturnTransition" />
+  <public type="attr" name="windowSharedElementReenterTransition" />
 
   <public-padding type="dimen" name="l_resource_pad" end="0x01050010" />
 
diff --git a/docs/html/preview/preview_toc.cs b/docs/html/preview/preview_toc.cs
index a505905..819976e 100644
--- a/docs/html/preview/preview_toc.cs
+++ b/docs/html/preview/preview_toc.cs
@@ -68,6 +68,8 @@
             Recommendations</a></li>
         </ul>
       </li>
+      <li><a href="<?cs var:toroot ?>preview/tv/tif/index.html">
+        TV Input Framework</a></li>
       <li><a href="<?cs var:toroot ?>preview/tv/games/index.html">
         Games on TV</a></li>
       <li><a href="<?cs var:toroot ?>preview/tv/start/hardware-features.html">
diff --git a/docs/html/preview/tv/images/tif-overview.png b/docs/html/preview/tv/images/tif-overview.png
new file mode 100644
index 0000000..197775e
--- /dev/null
+++ b/docs/html/preview/tv/images/tif-overview.png
Binary files differ
diff --git a/docs/html/preview/tv/tif/index.jd b/docs/html/preview/tv/tif/index.jd
new file mode 100644
index 0000000..ef02def
--- /dev/null
+++ b/docs/html/preview/tv/tif/index.jd
@@ -0,0 +1,38 @@
+page.title=TV Input Framework
+page.tags=tif
+
+@jd:body
+
+<p>
+  Watching live television shows and other continuous, channel-based content is a big part of the
+  TV experience. Android supports receiving and playback of live video content through the TV Input
+  Framework. This framework provides a unified method for receiving audio and video channel content
+  from hardware sources, such as HDMI ports and built-in-tuners, and software sources, such as
+  video streamed over the internet.
+</p>
+<p>
+  The framework enables developers to define live TV input sources by implementing a TV input
+  service. This service publishes a list of channels and programs to the TV Provider. The live TV
+  app on a TV device gets the list of available channels and programs from the TV Provider and
+  displays them to a user. When a user selects a specific channel, the live TV app creates a
+  session for the associated TV input service through the TV Input Manager, and tells the TV input
+  service to tune to the requested channel and play the content to a display surface provided by
+  the TV app.
+</p>
+
+<img src="{@docRoot}preview/tv/images/tif-overview.png" id="figure1">
+<p class="img-caption">
+  <strong>Figure 1.</strong> Functional diagram of the TV Input Framework
+</p>
+
+<p>
+  The TV Input Framework is designed to provide access to a wide variety of live TV input sources
+  and bring them together in a single user interface for users to browse, view, and enjoy content.
+  Building a TV input service for your content can help make it more accessible on TV devices.
+</p>
+
+<p>
+  The APIs for the TV Input Framework are available in the L Developer Preview and you can
+  review them in the preview API reference docs. However, more changes are planned, so stay tuned
+  for additional information with the official Android platform launch.
+</p>
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index f41b11a..be02c9b 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -364,13 +364,19 @@
     /** @hide */
     public static VectorDrawable create(Resources resources, int rid) {
         try {
-            final XmlPullParser xpp = resources.getXml(rid);
-            final AttributeSet attrs = Xml.asAttributeSet(xpp);
-            final XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
-            factory.setNamespaceAware(true);
+            final XmlPullParser parser = resources.getXml(rid);
+            final AttributeSet attrs = Xml.asAttributeSet(parser);
+            int type;
+            while ((type=parser.next()) != XmlPullParser.START_TAG &&
+                    type != XmlPullParser.END_DOCUMENT) {
+                // Empty loop
+            }
+            if (type != XmlPullParser.START_TAG) {
+                throw new XmlPullParserException("No start tag found");
+            }
 
             final VectorDrawable drawable = new VectorDrawable();
-            drawable.inflate(resources, xpp, attrs);
+            drawable.inflate(resources, parser, attrs);
 
             return drawable;
         } catch (XmlPullParserException e) {
@@ -436,10 +442,10 @@
 
         if (pathRenderer.mViewportWidth <= 0) {
             throw new XmlPullParserException(a.getPositionDescription() +
-                    "<viewport> tag requires viewportWidth > 0");
+                    "<vector> tag requires viewportWidth > 0");
         } else if (pathRenderer.mViewportHeight <= 0) {
             throw new XmlPullParserException(a.getPositionDescription() +
-                    "<viewport> tag requires viewportHeight > 0");
+                    "<vector> tag requires viewportHeight > 0");
         }
 
         pathRenderer.mBaseWidth = a.getDimension(
@@ -449,10 +455,10 @@
 
         if (pathRenderer.mBaseWidth <= 0) {
             throw new XmlPullParserException(a.getPositionDescription() +
-                    "<size> tag requires width > 0");
+                    "<vector> tag requires width > 0");
         } else if (pathRenderer.mBaseHeight <= 0) {
             throw new XmlPullParserException(a.getPositionDescription() +
-                    "<size> tag requires height > 0");
+                    "<vector> tag requires height > 0");
         }
     }
 
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index fdc91a4..ff3cd9d 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -50,7 +50,6 @@
 import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
 import android.media.session.MediaController;
-import android.media.session.MediaSession;
 import android.media.session.MediaSessionLegacyHelper;
 import android.net.Uri;
 import android.os.Bundle;
@@ -63,6 +62,7 @@
 import android.transition.Transition;
 import android.transition.TransitionInflater;
 import android.transition.TransitionManager;
+import android.transition.TransitionSet;
 import android.util.AndroidRuntimeException;
 import android.util.DisplayMetrics;
 import android.util.EventLog;
@@ -126,6 +126,8 @@
             (1 << FEATURE_CONTENT_TRANSITIONS) |
             (1 << FEATURE_ACTION_MODE_OVERLAY);
 
+    private static final Transition USE_DEFAULT_TRANSITION = new TransitionSet();
+
     /**
      * Simple callback used by the context menu and its submenus. The options
      * menu submenus do not use this (their behavior is more complex).
@@ -254,10 +256,14 @@
         }
     };
 
-    private Transition mEnterTransition;
-    private Transition mExitTransition;
-    private Transition mSharedElementEnterTransition;
-    private Transition mSharedElementExitTransition;
+    private Transition mEnterTransition = null;
+    private Transition mReturnTransition = USE_DEFAULT_TRANSITION;
+    private Transition mExitTransition = null;
+    private Transition mReenterTransition = USE_DEFAULT_TRANSITION;
+    private Transition mSharedElementEnterTransition = null;
+    private Transition mSharedElementReturnTransition = USE_DEFAULT_TRANSITION;
+    private Transition mSharedElementExitTransition = null;
+    private Transition mSharedElementReenterTransition = USE_DEFAULT_TRANSITION;
     private Boolean mAllowExitTransitionOverlap;
     private Boolean mAllowEnterTransitionOverlap;
     private long mBackgroundFadeDurationMillis = -1;
@@ -3513,40 +3519,47 @@
                     }
                 }
 
-                mEnterTransition = getTransition(mEnterTransition,
+                mEnterTransition = getTransition(mEnterTransition, null,
                         R.styleable.Window_windowEnterTransition);
-                mExitTransition = getTransition(mExitTransition,
+                mReturnTransition = getTransition(mReturnTransition, USE_DEFAULT_TRANSITION,
+                        R.styleable.Window_windowReturnTransition);
+                mExitTransition = getTransition(mExitTransition, null,
                         R.styleable.Window_windowExitTransition);
-                mSharedElementEnterTransition = getTransition(mSharedElementEnterTransition,
+                mReenterTransition = getTransition(mReenterTransition, USE_DEFAULT_TRANSITION,
+                        R.styleable.Window_windowReenterTransition);
+                mSharedElementEnterTransition = getTransition(mSharedElementEnterTransition, null,
                         R.styleable.Window_windowSharedElementEnterTransition);
-                mSharedElementExitTransition = getTransition(mSharedElementExitTransition,
+                mSharedElementReturnTransition = getTransition(mSharedElementReturnTransition,
+                        USE_DEFAULT_TRANSITION,
+                        R.styleable.Window_windowSharedElementReturnTransition);
+                mSharedElementExitTransition = getTransition(mSharedElementExitTransition, null,
                         R.styleable.Window_windowSharedElementExitTransition);
+                mSharedElementReenterTransition = getTransition(mSharedElementReenterTransition,
+                        USE_DEFAULT_TRANSITION,
+                        R.styleable.Window_windowSharedElementReenterTransition);
                 if (mAllowEnterTransitionOverlap == null) {
                     mAllowEnterTransitionOverlap = getWindowStyle().getBoolean(
-                            R.styleable.
-                                    Window_windowAllowEnterTransitionOverlap, true);
+                            R.styleable.Window_windowAllowEnterTransitionOverlap, true);
                 }
                 if (mAllowExitTransitionOverlap == null) {
                     mAllowExitTransitionOverlap = getWindowStyle().getBoolean(
-                            R.styleable.
-                                    Window_windowAllowExitTransitionOverlap, true);
+                            R.styleable.Window_windowAllowExitTransitionOverlap, true);
                 }
                 if (mBackgroundFadeDurationMillis < 0) {
                     mBackgroundFadeDurationMillis = getWindowStyle().getInteger(
-                            R.styleable.
-                                    Window_windowTransitionBackgroundFadeDuration,
+                            R.styleable.Window_windowTransitionBackgroundFadeDuration,
                             DEFAULT_BACKGROUND_FADE_DURATION_MS);
                 }
             }
         }
     }
 
-    private Transition getTransition(Transition currentValue, int id) {
-        if (currentValue != null) {
+    private Transition getTransition(Transition currentValue, Transition defaultValue, int id) {
+        if (currentValue != defaultValue) {
             return currentValue;
         }
         int transitionId = getWindowStyle().getResourceId(id, -1);
-        Transition transition = null;
+        Transition transition = defaultValue;
         if (transitionId != -1 && transitionId != R.transition.no_transition) {
             TransitionInflater inflater = TransitionInflater.from(getContext());
             transition = inflater.inflateTransition(transitionId);
@@ -3899,41 +3912,85 @@
     }
 
     @Override
+    public void setReturnTransition(Transition transition) {
+        mReturnTransition = transition;
+    }
+
+    @Override
     public void setExitTransition(Transition exitTransition) {
         mExitTransition = exitTransition;
     }
 
     @Override
+    public void setReenterTransition(Transition transition) {
+        mReenterTransition = transition;
+    }
+
+    @Override
     public void setSharedElementEnterTransition(Transition sharedElementEnterTransition) {
         mSharedElementEnterTransition = sharedElementEnterTransition;
     }
 
     @Override
+    public void setSharedElementReturnTransition(Transition transition) {
+        mSharedElementReturnTransition = transition;
+    }
+
+    @Override
     public void setSharedElementExitTransition(Transition sharedElementExitTransition) {
         mSharedElementExitTransition = sharedElementExitTransition;
     }
 
     @Override
+    public void setSharedElementReenterTransition(Transition transition) {
+        mSharedElementReenterTransition = transition;
+    }
+
+    @Override
     public Transition getEnterTransition() {
         return mEnterTransition;
     }
 
     @Override
+    public Transition getReturnTransition() {
+        return mReturnTransition == USE_DEFAULT_TRANSITION ? getEnterTransition()
+                : mReturnTransition;
+    }
+
+    @Override
     public Transition getExitTransition() {
         return mExitTransition;
     }
 
     @Override
+    public Transition getReenterTransition() {
+        return mReenterTransition == USE_DEFAULT_TRANSITION ? getExitTransition()
+                : mReenterTransition;
+    }
+
+    @Override
     public Transition getSharedElementEnterTransition() {
         return mSharedElementEnterTransition;
     }
 
     @Override
+    public Transition getSharedElementReturnTransition() {
+        return mSharedElementReturnTransition == USE_DEFAULT_TRANSITION
+                ? getSharedElementEnterTransition() : mSharedElementReturnTransition;
+    }
+
+    @Override
     public Transition getSharedElementExitTransition() {
         return mSharedElementExitTransition;
     }
 
     @Override
+    public Transition getSharedElementReenterTransition() {
+        return mSharedElementReenterTransition == USE_DEFAULT_TRANSITION
+                ? getSharedElementExitTransition() : mSharedElementReenterTransition;
+    }
+
+    @Override
     public void setAllowEnterTransitionOverlap(boolean allow) {
         mAllowEnterTransitionOverlap = allow;
     }
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index ee6d4d0..2b55bf5 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -8257,11 +8257,11 @@
 
                 // A restore should be performed at this point if (a) the install
                 // succeeded, (b) the operation is not an update, and (c) the new
-                // package has a backupAgent defined.
+                // package has not opted out of backup participation.
                 final boolean update = res.removedInfo.removedPackage != null;
-                boolean doRestore = (!update
-                        && res.pkg != null
-                        && res.pkg.applicationInfo.backupAgentName != null);
+                final int flags = (res.pkg == null) ? 0 : res.pkg.applicationInfo.flags;
+                boolean doRestore = !update
+                        && ((flags & ApplicationInfo.FLAG_ALLOW_BACKUP) != 0);
 
                 // Set up the post-install work request bookkeeping.  This will be used
                 // and cleaned up by the post-install event handling regardless of whether
diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java
index 67ff868..f0a7f38 100644
--- a/wifi/java/android/net/wifi/ScanResult.java
+++ b/wifi/java/android/net/wifi/ScanResult.java
@@ -185,6 +185,14 @@
     public static class InformationElement {
         public int id;
         public byte[] bytes;
+
+        public InformationElement() {
+        }
+
+        public InformationElement(InformationElement rhs) {
+            this.id = rhs.id;
+            this.bytes = rhs.bytes.clone();
+        }
     }
 
     /** information elements found in the beacon
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index 4cdbc44..c5c44b5 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -145,6 +145,8 @@
         public int periodInMs;
         /** must have a valid REPORT_EVENT value */
         public int reportEvents;
+        /** defines number of bssids to cache from each scan */
+        public int numBssidsPerScan;
 
         /** Implement the Parcelable interface {@hide} */
         public int describeContents() {
@@ -267,13 +269,6 @@
         public void onFullResult(ScanResult fullScanResult);
     }
 
-    /** @hide */
-    public void scan(ScanSettings settings, ScanListener listener) {
-        validateChannel();
-        settings.periodInMs = 0;
-        sAsyncChannel.sendMessage(CMD_SCAN, 0, putListener(listener), settings);
-    }
-
     /** start wifi scan in background
      * @param settings specifies various parameters for the scan; for more information look at
      * {@link ScanSettings}
@@ -305,7 +300,7 @@
     }
 
     /** specifies information about an access point of interest */
-    public static class HotspotInfo {
+    public static class BssidInfo {
         /** bssid of the access point; in XX:XX:XX:XX:XX:XX format */
         public String bssid;
         /** low signal strength threshold; more information at {@link ScanResult#level} */
@@ -324,7 +319,7 @@
         public int unchangedSampleSize;                     /* samples to confirm no change */
         public int minApsBreachingThreshold;                /* change threshold to trigger event */
         public int periodInMs;                              /* scan period in millisecond */
-        public HotspotInfo[] hotspotInfos;
+        public BssidInfo[] bssidInfos;
 
         /** Implement the Parcelable interface {@hide} */
         public int describeContents() {
@@ -338,10 +333,10 @@
             dest.writeInt(unchangedSampleSize);
             dest.writeInt(minApsBreachingThreshold);
             dest.writeInt(periodInMs);
-            if (hotspotInfos != null) {
-                dest.writeInt(hotspotInfos.length);
-                for (int i = 0; i < hotspotInfos.length; i++) {
-                    HotspotInfo info = hotspotInfos[i];
+            if (bssidInfos != null) {
+                dest.writeInt(bssidInfos.length);
+                for (int i = 0; i < bssidInfos.length; i++) {
+                    BssidInfo info = bssidInfos[i];
                     dest.writeString(info.bssid);
                     dest.writeInt(info.low);
                     dest.writeInt(info.high);
@@ -363,14 +358,14 @@
                         settings.minApsBreachingThreshold = in.readInt();
                         settings.periodInMs = in.readInt();
                         int len = in.readInt();
-                        settings.hotspotInfos = new HotspotInfo[len];
+                        settings.bssidInfos = new BssidInfo[len];
                         for (int i = 0; i < len; i++) {
-                            HotspotInfo info = new HotspotInfo();
+                            BssidInfo info = new BssidInfo();
                             info.bssid = in.readString();
                             info.low = in.readInt();
                             info.high = in.readInt();
                             info.frequencyHint = in.readInt();
-                            settings.hotspotInfos[i] = info;
+                            settings.bssidInfos[i] = info;
                         }
                         return settings;
                     }
@@ -389,7 +384,7 @@
      * @param minApsBreachingThreshold minimum number of access points that need to be
      *                                 out of range to detect WifiChange
      * @param periodInMs indicates period of scan to find changes
-     * @param hotspotInfos access points to watch
+     * @param bssidInfos access points to watch
      */
     public void configureWifiChange(
             int rssiSampleSize,                             /* sample size for RSSI averaging */
@@ -397,7 +392,7 @@
             int unchangedSampleSize,                        /* samples to confirm no change */
             int minApsBreachingThreshold,                   /* change threshold to trigger event */
             int periodInMs,                                 /* period of scan */
-            HotspotInfo[] hotspotInfos                      /* signal thresholds to crosss */
+            BssidInfo[] bssidInfos                          /* signal thresholds to crosss */
             )
     {
         validateChannel();
@@ -408,7 +403,7 @@
         settings.unchangedSampleSize = unchangedSampleSize;
         settings.minApsBreachingThreshold = minApsBreachingThreshold;
         settings.periodInMs = periodInMs;
-        settings.hotspotInfos = hotspotInfos;
+        settings.bssidInfos = bssidInfos;
 
         configureWifiChange(settings);
     }
@@ -455,7 +450,7 @@
     }
 
     /** interface to receive hotlist events on; use this on {@link #setHotlist} */
-    public static interface HotspotListener extends ActionListener {
+    public static interface BssidListener extends ActionListener {
         /** indicates that access points were found by on going scans
          * @param results list of scan results, one for each access point visible currently
          */
@@ -465,7 +460,7 @@
     /** @hide */
     @SystemApi
     public static class HotlistSettings implements Parcelable {
-        public HotspotInfo[] hotspotInfos;
+        public BssidInfo[] bssidInfos;
         public int apLostThreshold;
 
         /** Implement the Parcelable interface {@hide} */
@@ -477,10 +472,10 @@
         public void writeToParcel(Parcel dest, int flags) {
             dest.writeInt(apLostThreshold);
 
-            if (hotspotInfos != null) {
-                dest.writeInt(hotspotInfos.length);
-                for (int i = 0; i < hotspotInfos.length; i++) {
-                    HotspotInfo info = hotspotInfos[i];
+            if (bssidInfos != null) {
+                dest.writeInt(bssidInfos.length);
+                for (int i = 0; i < bssidInfos.length; i++) {
+                    BssidInfo info = bssidInfos[i];
                     dest.writeString(info.bssid);
                     dest.writeInt(info.low);
                     dest.writeInt(info.high);
@@ -498,14 +493,14 @@
                         HotlistSettings settings = new HotlistSettings();
                         settings.apLostThreshold = in.readInt();
                         int n = in.readInt();
-                        settings.hotspotInfos = new HotspotInfo[n];
+                        settings.bssidInfos = new BssidInfo[n];
                         for (int i = 0; i < n; i++) {
-                            HotspotInfo info = new HotspotInfo();
+                            BssidInfo info = new BssidInfo();
                             info.bssid = in.readString();
                             info.low = in.readInt();
                             info.high = in.readInt();
                             info.frequencyHint = in.readInt();
-                            settings.hotspotInfos[i] = info;
+                            settings.bssidInfos[i] = info;
                         }
                         return settings;
                     }
@@ -518,24 +513,24 @@
 
     /**
      * set interesting access points to find
-     * @param hotspots access points of interest
+     * @param bssidInfos access points of interest
      * @param apLostThreshold number of scans needed to indicate that AP is lost
      * @param listener object provided to report events on; this object must be unique and must
-     *                 also be provided on {@link #stopTrackingHotspots}
+     *                 also be provided on {@link #stopTrackingBssids}
      */
-    public void startTrackingHotspots(HotspotInfo[] hotspots,
-            int apLostThreshold, HotspotListener listener) {
+    public void startTrackingBssids(BssidInfo[] bssidInfos,
+                                    int apLostThreshold, BssidListener listener) {
         validateChannel();
         HotlistSettings settings = new HotlistSettings();
-        settings.hotspotInfos = hotspots;
+        settings.bssidInfos = bssidInfos;
         sAsyncChannel.sendMessage(CMD_SET_HOTLIST, 0, putListener(listener), settings);
     }
 
     /**
      * remove tracking of interesting access points
-     * @param listener same object provided in {@link #startTrackingHotspots}
+     * @param listener same object provided in {@link #startTrackingBssids}
      */
-    public void stopTrackingHotspots(HotspotListener listener) {
+    public void stopTrackingBssids(BssidListener listener) {
         validateChannel();
         sAsyncChannel.sendMessage(CMD_RESET_HOTLIST, 0, removeListener(listener));
     }
@@ -802,7 +797,7 @@
                     ((ScanListener) listener).onPeriodChanged(msg.arg1);
                     return;
                 case CMD_AP_FOUND:
-                    ((HotspotListener) listener).onFound(
+                    ((BssidListener) listener).onFound(
                             ((ParcelableScanResults) msg.obj).getResults());
                     return;
                 case CMD_WIFI_CHANGE_DETECTED: