Merge "Make APIs to get system phone accounts public" into lmp-mr1-dev
diff --git a/api/current.txt b/api/current.txt
index 3888c1f..8b577dd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5323,6 +5323,7 @@
     method public boolean getScreenCaptureDisabled(android.content.ComponentName);
     method public boolean getStorageEncryption(android.content.ComponentName);
     method public int getStorageEncryptionStatus();
+    method public java.util.List<android.os.PersistableBundle> getTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName);
     method public boolean hasCaCertInstalled(android.content.ComponentName, byte[]);
     method public boolean hasGrantedPolicy(android.content.ComponentName, int);
     method public boolean installCaCert(android.content.ComponentName, byte[]);
@@ -5371,6 +5372,7 @@
     method public void setScreenCaptureDisabled(android.content.ComponentName, boolean);
     method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
     method public int setStorageEncryption(android.content.ComponentName, boolean);
+    method public void setTrustAgentConfiguration(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle);
     method public void setUninstallBlocked(android.content.ComponentName, java.lang.String, boolean);
     method public boolean switchUser(android.content.ComponentName, android.os.UserHandle);
     method public void uninstallAllUserCaCerts(android.content.ComponentName);
@@ -16894,9 +16896,11 @@
     method public boolean isDefaultNetworkActive();
     method public static boolean isNetworkTypeValid(int);
     method public void registerNetworkCallback(android.net.NetworkRequest, android.net.ConnectivityManager.NetworkCallback);
+    method public void releaseNetworkRequest(android.app.PendingIntent);
     method public void removeDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener);
     method public void reportBadNetwork(android.net.Network);
     method public void requestNetwork(android.net.NetworkRequest, android.net.ConnectivityManager.NetworkCallback);
+    method public void requestNetwork(android.net.NetworkRequest, android.app.PendingIntent);
     method public deprecated boolean requestRouteToHost(int, int);
     method public deprecated void setNetworkPreference(int);
     method public static boolean setProcessDefaultNetwork(android.net.Network);
@@ -16909,6 +16913,8 @@
     field public static final java.lang.String EXTRA_EXTRA_INFO = "extraInfo";
     field public static final java.lang.String EXTRA_IS_FAILOVER = "isFailover";
     field public static final deprecated java.lang.String EXTRA_NETWORK_INFO = "networkInfo";
+    field public static final java.lang.String EXTRA_NETWORK_REQUEST_NETWORK = "networkRequestNetwork";
+    field public static final java.lang.String EXTRA_NETWORK_REQUEST_NETWORK_REQUEST = "networkRequestNetworkRequest";
     field public static final java.lang.String EXTRA_NETWORK_TYPE = "networkType";
     field public static final java.lang.String EXTRA_NO_CONNECTIVITY = "noConnectivity";
     field public static final java.lang.String EXTRA_OTHER_NETWORK_INFO = "otherNetwork";
@@ -28104,6 +28110,7 @@
     method public final int getCapabilities();
     method public final java.util.List<android.telecom.Connection> getConferenceableConnections();
     method public final java.util.List<android.telecom.Connection> getConnections();
+    method public final android.telecom.DisconnectCause getDisconnectCause();
     method public final android.telecom.PhoneAccountHandle getPhoneAccountHandle();
     method public android.telecom.Connection getPrimaryConnection();
     method public final int getState();
@@ -28223,6 +28230,7 @@
     method public void writeToParcel(android.os.Parcel, int);
     field public static final int BUSY = 7; // 0x7
     field public static final int CANCELED = 4; // 0x4
+    field public static final int CONNECTION_MANAGER_NOT_SUPPORTED = 10; // 0xa
     field public static final android.os.Parcelable.Creator<android.telecom.DisconnectCause> CREATOR;
     field public static final int ERROR = 1; // 0x1
     field public static final int LOCAL = 2; // 0x2
@@ -33405,7 +33413,6 @@
     method public int describeContents();
     method public boolean isValid();
     method public android.graphics.Canvas lockCanvas(android.graphics.Rect) throws java.lang.IllegalArgumentException, android.view.Surface.OutOfResourcesException;
-    method public android.graphics.Canvas lockHardwareCanvas();
     method public void readFromParcel(android.os.Parcel);
     method public void release();
     method public deprecated void unlockCanvas(android.graphics.Canvas);
diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java
index 500634c..59daaab 100644
--- a/core/java/android/animation/ObjectAnimator.java
+++ b/core/java/android/animation/ObjectAnimator.java
@@ -885,7 +885,8 @@
     }
 
     /**
-     * Sets the target object whose property will be animated by this animation
+     * Sets the target object whose property will be animated by this animation. If the
+     * animator has been started, it will be canceled.
      *
      * @param target The object being animated
      */
@@ -893,6 +894,9 @@
     public void setTarget(@Nullable Object target) {
         final Object oldTarget = getTarget();
         if (oldTarget != target) {
+            if (isStarted()) {
+                cancel();
+            }
             mTarget = target == null ? null : new WeakReference<Object>(target);
             // New target should cause re-initialization prior to starting
             mInitialized = false;
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 74502fc..d3ff79d 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -31,6 +31,7 @@
 import android.net.ProxyInfo;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.PersistableBundle;
 import android.os.Process;
 import android.os.RemoteCallback;
 import android.os.RemoteException;
@@ -40,6 +41,7 @@
 import android.provider.Settings;
 import android.security.Credentials;
 import android.service.restrictions.RestrictionsReceiver;
+import android.service.trust.TrustAgentService;
 import android.util.Log;
 
 import com.android.org.conscrypt.TrustedCertificateStore;
@@ -2604,25 +2606,29 @@
     }
 
     /**
-     * Sets a list of features to enable for a TrustAgent component. This is meant to be
-     * used in conjunction with {@link #KEYGUARD_DISABLE_TRUST_AGENTS}, which will disable all
-     * trust agents but those with features enabled by this function call.
+     * Sets a list of configuration features to enable for a TrustAgent component. This is meant
+     * to be used in conjunction with {@link #KEYGUARD_DISABLE_TRUST_AGENTS}, which disables all
+     * trust agents but those enabled by this function call. If flag
+     * {@link #KEYGUARD_DISABLE_TRUST_AGENTS} is not set, then this call has no effect.
      *
      * <p>The calling device admin must have requested
      * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} to be able to call
-     * this method; if it has not, a security exception will be thrown.
+     * this method; if not, a security exception will be thrown.
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
-     * @param agent Which component to enable features for.
-     * @param features List of features to enable. Consult specific TrustAgent documentation for
-     * the feature list.
-     * @hide
+     * @param target Component name of the agent to be enabled.
+     * @param options TrustAgent-specific feature bundle. If null for any admin, agent
+     * will be strictly disabled according to the state of the
+     *  {@link #KEYGUARD_DISABLE_TRUST_AGENTS} flag.
+     * <p>If {@link #KEYGUARD_DISABLE_TRUST_AGENTS} is set and options is not null for all admins,
+     * then it's up to the TrustAgent itself to aggregate the values from all device admins.
+     * <p>Consult documentation for the specific TrustAgent to determine legal options parameters.
      */
-    public void setTrustAgentFeaturesEnabled(ComponentName admin, ComponentName agent,
-            List<String> features) {
+    public void setTrustAgentConfiguration(ComponentName admin, ComponentName target,
+            PersistableBundle options) {
         if (mService != null) {
             try {
-                mService.setTrustAgentFeaturesEnabled(admin, agent, features, UserHandle.myUserId());
+                mService.setTrustAgentConfiguration(admin, target, options, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -2630,24 +2636,30 @@
     }
 
     /**
-     * Gets list of enabled features for the given TrustAgent component. If admin is
-     * null, this will return the intersection of all features enabled for the given agent by all
-     * admins.
+     * Gets configuration for the given trust agent based on aggregating all calls to
+     * {@link #setTrustAgentConfiguration(ComponentName, ComponentName, PersistableBundle)} for
+     * all device admins.
      *
      * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
      * @param agent Which component to get enabled features for.
-     * @return List of enabled features.
-     * @hide
+     * @return configuration for the given trust agent.
      */
-    public List<String> getTrustAgentFeaturesEnabled(ComponentName admin, ComponentName agent) {
+    public List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin,
+            ComponentName agent) {
+        return getTrustAgentConfiguration(admin, agent, UserHandle.myUserId());
+    }
+
+    /** @hide per-user version */
+    public List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin,
+            ComponentName agent, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getTrustAgentFeaturesEnabled(admin, agent, UserHandle.myUserId());
+                return mService.getTrustAgentConfiguration(admin, agent, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
         }
-        return new ArrayList<String>(); // empty list
+        return new ArrayList<PersistableBundle>(); // empty list
     }
 
     /**
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index c8e1780..07aa800 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -22,6 +22,7 @@
 import android.content.IntentFilter;
 import android.net.ProxyInfo;
 import android.os.Bundle;
+import android.os.PersistableBundle;
 import android.os.RemoteCallback;
 import android.os.UserHandle;
 import java.util.List;
@@ -183,8 +184,10 @@
     boolean getCrossProfileCallerIdDisabled(in ComponentName who);
     boolean getCrossProfileCallerIdDisabledForUser(int userId);
 
-    void setTrustAgentFeaturesEnabled(in ComponentName admin, in ComponentName agent, in List<String> features, int userId);
-    List<String> getTrustAgentFeaturesEnabled(in ComponentName admin, in ComponentName agent, int userId);
+    void setTrustAgentConfiguration(in ComponentName admin, in ComponentName agent,
+            in PersistableBundle args, int userId);
+    List<PersistableBundle> getTrustAgentConfiguration(in ComponentName admin,
+            in ComponentName agent, int userId);
 
     boolean addCrossProfileWidgetProvider(in ComponentName admin, String packageName);
     boolean removeCrossProfileWidgetProvider(in ComponentName admin, String packageName);
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index 2853c58..c8f9b7d 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -515,7 +515,10 @@
         }
 
         // last chance, check against any uri grants
-        if (context.checkUriPermission(uri, pid, uid, Intent.FLAG_GRANT_READ_URI_PERMISSION)
+        final int callingUserId = UserHandle.getUserId(uid);
+        final Uri userUri = (mSingleUser && !UserHandle.isSameUser(mMyUid, uid))
+                ? maybeAddUserId(uri, callingUserId) : uri;
+        if (context.checkUriPermission(userUri, pid, uid, Intent.FLAG_GRANT_READ_URI_PERMISSION)
                 == PERMISSION_GRANTED) {
             return;
         }
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 9194ca8..1c9f4c6 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1012,60 +1012,57 @@
         return null;
     }
 
+    /**
+     * Guess what the network request was trying to say so that the resulting
+     * network is accessible via the legacy (deprecated) API such as
+     * requestRouteToHost.
+     * This means we should try to be fairly preceise about transport and
+     * capability but ignore things such as networkSpecifier.
+     * If the request has more than one transport or capability it doesn't
+     * match the old legacy requests (they selected only single transport/capability)
+     * so this function cannot map the request to a single legacy type and
+     * the resulting network will not be available to the legacy APIs.
+     *
+     * TODO - This should be removed when the legacy APIs are removed.
+     */
     private int inferLegacyTypeForNetworkCapabilities(NetworkCapabilities netCap) {
         if (netCap == null) {
             return TYPE_NONE;
         }
+
         if (!netCap.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
             return TYPE_NONE;
         }
+
+        String type = null;
+        int result = TYPE_NONE;
+
         if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_CBS)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableCBS"))) {
-                return TYPE_MOBILE_CBS;
-            } else {
-                return TYPE_NONE;
-            }
+            type = "enableCBS";
+            result = TYPE_MOBILE_CBS;
+        } else if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)) {
+            type = "enableIMS";
+            result = TYPE_MOBILE_IMS;
+        } else if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_FOTA)) {
+            type = "enableFOTA";
+            result = TYPE_MOBILE_FOTA;
+        } else if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_DUN)) {
+            type = "enableDUN";
+            result = TYPE_MOBILE_DUN;
+        } else if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_SUPL)) {
+            type = "enableSUPL";
+            result = TYPE_MOBILE_SUPL;
+        } else if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_MMS)) {
+            type = "enableMMS";
+            result = TYPE_MOBILE_MMS;
+        } else if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
+            type = "enableHIPRI";
+            result = TYPE_MOBILE_HIPRI;
         }
-        if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableIMS"))) {
-                return TYPE_MOBILE_IMS;
-            } else {
-                return TYPE_NONE;
-            }
-        }
-        if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_FOTA)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableFOTA"))) {
-                return TYPE_MOBILE_FOTA;
-            } else {
-                return TYPE_NONE;
-            }
-        }
-        if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_DUN)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableDUN"))) {
-                return TYPE_MOBILE_DUN;
-            } else {
-                return TYPE_NONE;
-            }
-        }
-        if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_SUPL)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableSUPL"))) {
-                return TYPE_MOBILE_SUPL;
-            } else {
-                return TYPE_NONE;
-            }
-        }
-        if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_MMS)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableMMS"))) {
-                return TYPE_MOBILE_MMS;
-            } else {
-                return TYPE_NONE;
-            }
-        }
-        if (netCap.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)) {
-            if (netCap.equals(networkCapabilitiesForFeature(TYPE_MOBILE, "enableHIPRI"))) {
-                return TYPE_MOBILE_HIPRI;
-            } else {
-                return TYPE_NONE;
+        if (type != null) {
+            NetworkCapabilities testCap = networkCapabilitiesForFeature(TYPE_MOBILE, type);
+            if (testCap.equalsNetCapabilities(netCap) && testCap.equalsTransportTypes(netCap)) {
+                return result;
             }
         }
         return TYPE_NONE;
@@ -2381,17 +2378,15 @@
 
     /**
      * The lookup key for a {@link Network} object included with the intent after
-     * succesfully finding a network for the applications request.  Retrieve it with
+     * successfully finding a network for the applications request.  Retrieve it with
      * {@link android.content.Intent#getParcelableExtra(String)}.
-     * @hide
      */
     public static final String EXTRA_NETWORK_REQUEST_NETWORK = "networkRequestNetwork";
 
     /**
      * The lookup key for a {@link NetworkRequest} object included with the intent after
-     * succesfully finding a network for the applications request.  Retrieve it with
+     * successfully finding a network for the applications request.  Retrieve it with
      * {@link android.content.Intent#getParcelableExtra(String)}.
-     * @hide
      */
     public static final String EXTRA_NETWORK_REQUEST_NETWORK_REQUEST =
             "networkRequestNetworkRequest";
@@ -2400,7 +2395,7 @@
     /**
      * Request a network to satisfy a set of {@link NetworkCapabilities}.
      *
-     * This function behavies identically to the version that takes a NetworkCallback, but instead
+     * This function behaves identically to the version that takes a NetworkCallback, but instead
      * of {@link NetworkCallback} a {@link PendingIntent} is used.  This means
      * the request may outlive the calling application and get called back when a suitable
      * network is found.
@@ -2421,21 +2416,46 @@
      * two Intents defined by {@link Intent#filterEquals}), then it will be removed and
      * replaced by this one, effectively releasing the previous {@link NetworkRequest}.
      * <p>
-     * The request may be released normally by calling {@link #unregisterNetworkCallback}.
+     * The request may be released normally by calling
+     * {@link #releaseNetworkRequest(android.app.PendingIntent)}.
      *
      * @param request {@link NetworkRequest} describing this request.
      * @param operation Action to perform when the network is available (corresponds
      *                  to the {@link NetworkCallback#onAvailable} call.  Typically
-     *                  comes from {@link PendingIntent#getBroadcast}.
-     * @hide
+     *                  comes from {@link PendingIntent#getBroadcast}. Cannot be null.
      */
     public void requestNetwork(NetworkRequest request, PendingIntent operation) {
+        checkPendingIntent(operation);
         try {
             mService.pendingRequestForNetwork(request.networkCapabilities, operation);
         } catch (RemoteException e) {}
     }
 
     /**
+     * Removes a request made via {@link #requestNetwork(NetworkRequest, android.app.PendingIntent)}
+     * <p>
+     * This method has the same behavior as {@link #unregisterNetworkCallback} with respect to
+     * releasing network resources and disconnecting.
+     *
+     * @param operation A PendingIntent equal (as defined by {@link Intent#filterEquals}) to the
+     *                  PendingIntent passed to
+     *                  {@link #requestNetwork(NetworkRequest, android.app.PendingIntent)} with the
+     *                  corresponding NetworkRequest you'd like to remove. Cannot be null.
+     */
+    public void releaseNetworkRequest(PendingIntent operation) {
+        checkPendingIntent(operation);
+        try {
+            mService.releasePendingNetworkRequest(operation);
+        } catch (RemoteException e) {}
+    }
+
+    private void checkPendingIntent(PendingIntent intent) {
+        if (intent == null) {
+            throw new IllegalArgumentException("PendingIntent cannot be null.");
+        }
+    }
+
+    /**
      * Registers to receive notifications about all networks which satisfy the given
      * {@link NetworkRequest}.  The callbacks will continue to be called until
      * either the application exits or {@link #unregisterNetworkCallback} is called
@@ -2451,7 +2471,7 @@
     /**
      * Unregisters callbacks about and possibly releases networks originating from
      * {@link #requestNetwork} and {@link #registerNetworkCallback} calls.  If the
-     * given {@code NetworkCallback} had previosuly been used with {@code #requestNetwork},
+     * given {@code NetworkCallback} had previously been used with {@code #requestNetwork},
      * any networks that had been connected to only to satisfy that request will be
      * disconnected.
      *
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index a983d88..a7bbc53 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -156,6 +156,8 @@
     NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities,
             in PendingIntent operation);
 
+    void releasePendingNetworkRequest(in PendingIntent operation);
+
     NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities,
             in Messenger messenger, in IBinder binder);
 
diff --git a/core/java/android/net/NetworkCapabilities.java b/core/java/android/net/NetworkCapabilities.java
index 1efe478..ce7ad65 100644
--- a/core/java/android/net/NetworkCapabilities.java
+++ b/core/java/android/net/NetworkCapabilities.java
@@ -235,7 +235,8 @@
         return ((nc.mNetworkCapabilities & this.mNetworkCapabilities) == this.mNetworkCapabilities);
     }
 
-    private boolean equalsNetCapabilities(NetworkCapabilities nc) {
+    /** @hide */
+    public boolean equalsNetCapabilities(NetworkCapabilities nc) {
         return (nc.mNetworkCapabilities == this.mNetworkCapabilities);
     }
 
@@ -344,7 +345,8 @@
         return ((this.mTransportTypes == 0) ||
                 ((this.mTransportTypes & nc.mTransportTypes) != 0));
     }
-    private boolean equalsTransportTypes(NetworkCapabilities nc) {
+    /** @hide */
+    public boolean equalsTransportTypes(NetworkCapabilities nc) {
         return (nc.mTransportTypes == this.mTransportTypes);
     }
 
diff --git a/core/java/android/net/NetworkScoreManager.java b/core/java/android/net/NetworkScoreManager.java
index 03a2085..a939cce 100644
--- a/core/java/android/net/NetworkScoreManager.java
+++ b/core/java/android/net/NetworkScoreManager.java
@@ -192,12 +192,15 @@
     /**
      * Set the active scorer to a new package and clear existing scores.
      *
+     * <p>Should never be called directly without obtaining user consent. This can be done by using
+     * the {@link #ACTION_CHANGE_ACTIVE} broadcast, or using a custom configuration activity.
+     *
      * @return true if the operation succeeded, or false if the new package is not a valid scorer.
      * @throws SecurityException if the caller does not hold the
-     *         {@link android.Manifest.permission#BROADCAST_NETWORK_PRIVILEGED} permission
-     *         indicating that it can manage scorer applications.
+     *         {@link android.Manifest.permission#SCORE_NETWORKS} permission.
      * @hide
      */
+    @SystemApi
     public boolean setActiveScorer(String packageName) throws SecurityException {
         try {
             return mService.setActiveScorer(packageName);
diff --git a/core/java/android/service/trust/ITrustAgentService.aidl b/core/java/android/service/trust/ITrustAgentService.aidl
index bd80a3f..bb0c2b2 100644
--- a/core/java/android/service/trust/ITrustAgentService.aidl
+++ b/core/java/android/service/trust/ITrustAgentService.aidl
@@ -15,7 +15,7 @@
  */
 package android.service.trust;
 
-import android.os.Bundle;
+import android.os.PersistableBundle;
 import android.service.trust.ITrustAgentServiceCallback;
 
 /**
@@ -25,6 +25,6 @@
 interface ITrustAgentService {
     oneway void onUnlockAttempt(boolean successful);
     oneway void onTrustTimeout();
+    oneway void onConfigure(in List<PersistableBundle> options, IBinder token);
     oneway void setCallback(ITrustAgentServiceCallback callback);
-    oneway void setTrustAgentFeaturesEnabled(in Bundle options, IBinder token);
 }
diff --git a/core/java/android/service/trust/ITrustAgentServiceCallback.aidl b/core/java/android/service/trust/ITrustAgentServiceCallback.aidl
index b107bcc..76b2be0 100644
--- a/core/java/android/service/trust/ITrustAgentServiceCallback.aidl
+++ b/core/java/android/service/trust/ITrustAgentServiceCallback.aidl
@@ -27,5 +27,5 @@
     void grantTrust(CharSequence message, long durationMs, boolean initiatedByUser);
     void revokeTrust();
     void setManagingTrust(boolean managingTrust);
-    void onSetTrustAgentFeaturesEnabledCompleted(boolean result, IBinder token);
+    void onConfigureCompleted(boolean result, IBinder token);
 }
diff --git a/core/java/android/service/trust/TrustAgentService.java b/core/java/android/service/trust/TrustAgentService.java
index 3ef5b37..00d60c0 100644
--- a/core/java/android/service/trust/TrustAgentService.java
+++ b/core/java/android/service/trust/TrustAgentService.java
@@ -29,11 +29,14 @@
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
+import android.os.PersistableBundle;
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.util.Log;
 import android.util.Slog;
 
+import java.util.List;
+
 /**
  * A service that notifies the system about whether it believes the environment of the device
  * to be trusted.
@@ -86,17 +89,47 @@
      */
     public static final String TRUST_AGENT_META_DATA = "android.service.trust.trustagent";
 
-    /**
-     * A white list of features that the given trust agent should support when otherwise disabled
-     * by device policy.
-     * @hide
-     */
-    public static final String KEY_FEATURES = "trust_agent_features";
-
     private static final int MSG_UNLOCK_ATTEMPT = 1;
-    private static final int MSG_SET_TRUST_AGENT_FEATURES_ENABLED = 2;
+    private static final int MSG_CONFIGURE = 2;
     private static final int MSG_TRUST_TIMEOUT = 3;
 
+    /**
+     * Container class for a list of configuration options and helper methods
+     */
+    public static final class Configuration {
+        public final List<PersistableBundle> options;
+        public Configuration(List<PersistableBundle> opts) {
+            options = opts;
+        }
+
+        /**
+         * Very basic method to determine if all bundles have the given feature, regardless
+         * of type.
+         * @param option String to search for.
+         * @return true if found in all bundles.
+         */
+        public boolean hasOption(String option) {
+            if (options == null || options.size() == 0) return false;
+            final int N = options.size();
+            for (int i = 0; i < N; i++) {
+                if (!options.get(i).containsKey(option)) return false;
+            }
+            return true;
+        }
+    }
+
+    /**
+     * Class containing raw data for a given configuration request.
+     */
+    private static final class ConfigurationData {
+        final IBinder token;
+        final List<PersistableBundle> options;
+        ConfigurationData(List<PersistableBundle> opts, IBinder t) {
+            options = opts;
+            token = t;
+        }
+    }
+
     private ITrustAgentServiceCallback mCallback;
 
     private Runnable mPendingGrantTrustTask;
@@ -112,13 +145,12 @@
                 case MSG_UNLOCK_ATTEMPT:
                     onUnlockAttempt(msg.arg1 != 0);
                     break;
-                case MSG_SET_TRUST_AGENT_FEATURES_ENABLED:
-                    Bundle features = msg.peekData();
-                    IBinder token = (IBinder) msg.obj;
-                    boolean result = onSetTrustAgentFeaturesEnabled(features);
+                case MSG_CONFIGURE:
+                    ConfigurationData data = (ConfigurationData) msg.obj;
+                    boolean result = onConfigure(new Configuration(data.options));
                     try {
                         synchronized (mLock) {
-                            mCallback.onSetTrustAgentFeaturesEnabledCompleted(result, token);
+                            mCallback.onConfigureCompleted(result, data.token);
                         }
                     } catch (RemoteException e) {
                         onError("calling onSetTrustAgentFeaturesEnabledCompleted()");
@@ -171,23 +203,16 @@
     }
 
     /**
-     * Called when device policy wants to restrict features in the agent in response to
-     * {@link DevicePolicyManager#setTrustAgentFeaturesEnabled(ComponentName, ComponentName, java.util.List) }.
-     * Agents that support this feature should overload this method and return 'true'.
+     * Called when device policy admin wants to enable specific options for agent in response to
+     * {@link DevicePolicyManager#setKeyguardDisabledFeatures(ComponentName, int)} and
+     * {@link DevicePolicyManager#setTrustAgentConfiguration(ComponentName, ComponentName,
+     * PersistableBundle)}.
+     * <p>Agents that support configuration options should overload this method and return 'true'.
      *
-     * The list of options can be obtained by calling
-     * options.getStringArrayList({@link #KEY_FEATURES}). Presence of a feature string in the list
-     * means it should be enabled ("white-listed"). Absence of the feature means it should be
-     * disabled. An empty list means all features should be disabled.
-     *
-     * This function is only called if {@link DevicePolicyManager#KEYGUARD_DISABLE_TRUST_AGENTS} is
-     * set.
-     *
-     * @param options Option feature bundle.
-     * @return true if the {@link TrustAgentService} supports this feature.
-     * @hide
+     * @param options bundle containing all options or null if none.
+     * @return true if the {@link TrustAgentService} supports configuration options.
      */
-    public boolean onSetTrustAgentFeaturesEnabled(Bundle options) {
+    public boolean onConfigure(Configuration options) {
         return false;
     }
 
@@ -295,6 +320,12 @@
         }
 
         @Override /* Binder API */
+        public void onConfigure(List<PersistableBundle> args, IBinder token) {
+            mHandler.obtainMessage(MSG_CONFIGURE, new ConfigurationData(args, token))
+                    .sendToTarget();
+        }
+
+        @Override /* Binder API */
         public void setCallback(ITrustAgentServiceCallback callback) {
             synchronized (mLock) {
                 mCallback = callback;
@@ -313,13 +344,6 @@
                 }
             }
         }
-
-        @Override /* Binder API */
-        public void setTrustAgentFeaturesEnabled(Bundle features, IBinder token) {
-            Message msg = mHandler.obtainMessage(MSG_SET_TRUST_AGENT_FEATURES_ENABLED, token);
-            msg.setData(features);
-            msg.sendToTarget();
-        }
     }
 
 }
diff --git a/core/java/android/text/format/Formatter.java b/core/java/android/text/format/Formatter.java
index b0cbcd2..b467f5a 100644
--- a/core/java/android/text/format/Formatter.java
+++ b/core/java/android/text/format/Formatter.java
@@ -110,6 +110,7 @@
     private static final int SECONDS_PER_MINUTE = 60;
     private static final int SECONDS_PER_HOUR = 60 * 60;
     private static final int SECONDS_PER_DAY = 24 * 60 * 60;
+    private static final int MILLIS_PER_MINUTE = 1000 * 60;
 
     /**
      * Returns elapsed time for the given millis, in the following format:
@@ -171,4 +172,24 @@
             return context.getString(com.android.internal.R.string.durationSeconds, seconds);
         }
     }
+
+    /**
+     * Returns elapsed time for the given millis, in the following format:
+     * 1 day 5 hrs; will include at most two units, can go down to minutes precision.
+     * @param context the application context
+     * @param millis the elapsed time in milli seconds
+     * @return the formatted elapsed time
+     * @hide
+     */
+    public static String formatShortElapsedTimeRoundingUpToMinutes(Context context, long millis) {
+        long minutesRoundedUp = (millis + MILLIS_PER_MINUTE - 1) / MILLIS_PER_MINUTE;
+
+        if (minutesRoundedUp == 0) {
+            return context.getString(com.android.internal.R.string.durationMinutes, 0);
+        } else if (minutesRoundedUp == 1) {
+            return context.getString(com.android.internal.R.string.durationMinute, 1);
+        }
+
+        return formatShortElapsedTime(context, minutesRoundedUp * MILLIS_PER_MINUTE);
+    }
 }
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 562d138..90fdbe2 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -319,6 +319,7 @@
      * @return A canvas for drawing into the surface.
      *
      * @throws IllegalStateException If the canvas cannot be locked.
+     * @hide
      */
     public Canvas lockHardwareCanvas() {
         synchronized (mLock) {
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 70cf9a8..d7eef6e 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -17,7 +17,7 @@
 
 #include <jni.h>
 
-#include <Caches.h>
+#include <ResourceCache.h>
 
 #if 0
     #define TRACE_BITMAP(code)  code
@@ -365,8 +365,8 @@
 static void Bitmap_destructor(JNIEnv* env, jobject, jlong bitmapHandle) {
     SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
 #ifdef USE_OPENGL_RENDERER
-    if (android::uirenderer::Caches::hasInstance()) {
-        android::uirenderer::Caches::getInstance().resourceCache.destructor(bitmap);
+    if (android::uirenderer::ResourceCache::hasInstance()) {
+        android::uirenderer::ResourceCache::getInstance().destructor(bitmap);
         return;
     }
 #endif // USE_OPENGL_RENDERER
@@ -376,9 +376,9 @@
 static jboolean Bitmap_recycle(JNIEnv* env, jobject, jlong bitmapHandle) {
     SkBitmap* bitmap = reinterpret_cast<SkBitmap*>(bitmapHandle);
 #ifdef USE_OPENGL_RENDERER
-    if (android::uirenderer::Caches::hasInstance()) {
+    if (android::uirenderer::ResourceCache::hasInstance()) {
         bool result;
-        result = android::uirenderer::Caches::getInstance().resourceCache.recycle(bitmap);
+        result = android::uirenderer::ResourceCache::getInstance().recycle(bitmap);
         return result ? JNI_TRUE : JNI_FALSE;
     }
 #endif // USE_OPENGL_RENDERER
diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp
index cf23771..be62fdd 100644
--- a/core/jni/android/graphics/NinePatch.cpp
+++ b/core/jni/android/graphics/NinePatch.cpp
@@ -21,7 +21,7 @@
 #include <androidfw/ResourceTypes.h>
 #include <utils/Log.h>
 
-#include <Caches.h>
+#include <ResourceCache.h>
 
 #include "Paint.h"
 #include "Canvas.h"
@@ -80,9 +80,9 @@
     static void finalize(JNIEnv* env, jobject, jlong patchHandle) {
         int8_t* patch = reinterpret_cast<int8_t*>(patchHandle);
 #ifdef USE_OPENGL_RENDERER
-        if (android::uirenderer::Caches::hasInstance()) {
+        if (android::uirenderer::ResourceCache::hasInstance()) {
             Res_png_9patch* p = (Res_png_9patch*) patch;
-            android::uirenderer::Caches::getInstance().resourceCache.destructor(p);
+            android::uirenderer::ResourceCache::getInstance().destructor(p);
             return;
         }
 #endif // USE_OPENGL_RENDERER
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp
index 9d3e74b..30ce58d 100644
--- a/core/jni/android/graphics/Path.cpp
+++ b/core/jni/android/graphics/Path.cpp
@@ -27,7 +27,7 @@
 #include "SkPath.h"
 #include "SkPathOps.h"
 
-#include <Caches.h>
+#include <ResourceCache.h>
 #include <vector>
 #include <map>
 
@@ -39,8 +39,8 @@
     static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) {
         SkPath* obj = reinterpret_cast<SkPath*>(objHandle);
 #ifdef USE_OPENGL_RENDERER
-        if (android::uirenderer::Caches::hasInstance()) {
-            android::uirenderer::Caches::getInstance().resourceCache.destructor(obj);
+        if (android::uirenderer::ResourceCache::hasInstance()) {
+            android::uirenderer::ResourceCache::getInstance().destructor(obj);
             return;
         }
 #endif
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index c5bd495..9e25ee2 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -61,6 +61,9 @@
     <!-- [CHAR_LIMIT=10] Suffix added to signify duration in minutes -->
     <string name="durationMinutes"><xliff:g id="minutes">%1$d</xliff:g> mins</string>
 
+    <!-- [CHAR_LIMIT=10] Suffix added to signify duration of one minute -->
+    <string name="durationMinute"><xliff:g id="minutes">%1$d</xliff:g> min</string>
+
     <!-- [CHAR_LIMIT=10] Suffix added to signify duration of one minute with seconds -->
     <string name="durationMinuteSeconds"><xliff:g id="minutes">%1$d</xliff:g> min
             <xliff:g id="seconds">%2$d</xliff:g> secs</string>
diff --git a/core/res/res/values/styles_micro.xml b/core/res/res/values/styles_micro.xml
index 0c854d3..cf90b39 100644
--- a/core/res/res/values/styles_micro.xml
+++ b/core/res/res/values/styles_micro.xml
@@ -25,6 +25,14 @@
         <item name="taskOpenExitAnimation">@null</item>
         <item name="taskCloseEnterAnimation">@null</item>
         <item name="taskCloseExitAnimation">@anim/slide_out_micro</item>
+        <item name="wallpaperOpenEnterAnimation">@null</item>
+        <item name="wallpaperOpenExitAnimation">@anim/slide_out_micro</item>
+        <item name="wallpaperCloseEnterAnimation">@anim/slide_in_micro</item>
+        <item name="wallpaperCloseExitAnimation">@null</item>
+        <item name="wallpaperIntraOpenEnterAnimation">@null</item>
+        <item name="wallpaperIntraOpenExitAnimation">@anim/slide_out_micro</item>
+        <item name="wallpaperIntraCloseEnterAnimation">@anim/slide_in_micro</item>
+        <item name="wallpaperIntraCloseExitAnimation">@null</item>
     </style>
 
     <style name="AlertDialog.Micro" parent="AlertDialog.Holo.Light">
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 6e881a7..513510a 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -574,6 +574,7 @@
   <java-symbol type="string" name="durationHourMinutes" />
   <java-symbol type="string" name="durationHourMinute" />
   <java-symbol type="string" name="durationMinutes" />
+  <java-symbol type="string" name="durationMinute" />
   <java-symbol type="string" name="durationMinuteSeconds" />
   <java-symbol type="string" name="durationMinuteSecond" />
   <java-symbol type="string" name="durationSeconds" />
diff --git a/docs/html/about/about_toc.cs b/docs/html/about/about_toc.cs
index c025b61..9033d69 100644
--- a/docs/html/about/about_toc.cs
+++ b/docs/html/about/about_toc.cs
@@ -11,6 +11,7 @@
       <span class="en">Lollipop</span></a></div>
       <ul>
         <li><a href="<?cs var:toroot ?>about/versions/android-5.0.html">Android 5.0 APIs</a></li>
+        <li><a href="<?cs var:toroot ?>about/versions/android-5.0-changes.html">Android 5.0 Changes</a></li>
       </ul>
   </li>
   <li class="nav-section">
diff --git a/docs/html/about/versions/android-5.0-changes.jd b/docs/html/about/versions/android-5.0-changes.jd
new file mode 100644
index 0000000..c1b9f09
--- /dev/null
+++ b/docs/html/about/versions/android-5.0-changes.jd
@@ -0,0 +1,527 @@
+page.title=Android 5.0 Changes
+excludeFromSuggestions=true
+sdk.platform.version=5.0
+sdk.platform.apiLevel=21
+@jd:body
+
+
+<div id="qv-wrapper">
+<div id="qv">
+
+<h2>In this document</h2>
+
+<ol id="toc44" class="hide-nested">
+  <li><a href="#UI"><a href="#ART">ART Runtime</a></a></li>
+  <li><a href="#BehaviorNotifications">Notifications</a></li>
+  <li><a href="#BehaviorMediaControl">Media Controls</a></li>
+  <li><a href="#BehaviorGetRecentTasks">getRecentTasks()</a></li>
+  <li><a href="#64BitSupport">64-Bit Android NDK</a></li>
+  <li><a href="#BindService">Binding to a Service</a></li>
+  <li><a href="#Power"><a href="#BehaviorWebView">WebView</a></a></li>
+  <li><a href="#custom_permissions">Custom Permissions</a></li>
+  <li><a href="#ssl">TLS/SSL Configuration</a></li>
+</ol>
+
+<h2>API Differences</h2>
+<ol>
+<li><a href="{@docRoot}sdk/api_diff/21/changes.html">API level 20 to 21 &raquo;</a> </li>
+<li><a href="{@docRoot}sdk/api_diff/preview-21/changes.html">L Developer Preview to 21 &raquo;</a> </li>
+</ol>
+
+
+<h2>See Also</h2>
+<ol>
+<li><a href="{@docRoot}about/versions/lollipop.html">Android Lollipop Highlights</a> </li>
+<li><a href="{@docRoot}about/versions/android-5.0.html">Android 5.0 API Overview</a> </li>
+</ol>
+
+
+</div>
+</div>
+
+<p>API Level: {@sdkPlatformApiLevel}</p>
+<p>Along with new features and capabilities, Android 5.0 includes a variety of changes
+API changes,
+behavior changes, system enhancements, and bug fixes. This document highlights
+some of the key changes that you should be understand and account for in your apps.</p>
+
+<p>f you have previously published an app for Android, be aware that your app
+  might be affected by these changes in Android 5.0.</p>
+
+
+<p>For a high-level look at the new platform features, instead
+see the
+<a href="{@docRoot}about/versions/lollipop.html">Android Lollipop
+highlights</a>.</p>
+
+
+
+<h2 id="ART">Android Runtime (ART)</h2>
+
+<p>In Android 5.0 the ART runtime replaces Dalvik as the platform default. The ART runtime was
+introduced in Android 4.4 on an experimental basis.</p>
+
+<p>For an overview of ART's new features, see
+<a href="https://source.android.com/devices/tech/dalvik/art.html">Introducing
+ART</a>. Some of the major new features are:</p>
+
+<ul>
+  <li>Ahead-of-time (AOT) compilation</li>
+  <li>Improved garbage collection (GC)</li>
+  <li>Improved debugging support</li>
+</ul>
+
+<p>Most Android apps should just work without any changes under ART. However, some
+techniques that work on Dalvik do not work on ART. For information about the
+most important issues, see
+<a href="{@docRoot}guide/practices/verifying-apps-art.html">Verifying App
+Behavior on the Android Runtime (ART)</a>. Pay particular attention if:</p>
+
+<ul>
+  <li>Your app uses Java Native Interface (JNI) to run C/C++ code.</li>
+  <li>You use development tools that generate non-standard code (such as some
+      obfuscators).</li>
+  <li>You use techniques that are incompatible with compacting garbage
+      collection. (ART does not currently implement compacting GC, but
+      compacting GC is under development in the Android Open Source
+      Project.)</li>
+</ul>
+
+
+<h2 id="BehaviorNotifications">Notifications</h2>
+
+<p>Make sure your notifications take these Android 5.0 changes into account.
+ To learn more about designing your notifications for Android 5.0 and higher,
+ see the <a href="{@docRoot}design/patterns/notifications.html">notifications design guide</a>.
+</p>
+
+<h3 id="NotificationsMaterialDesignStyle">Material design style</h3>
+<p>Notifications are drawn with dark text atop white (or very light) backgrounds
+  to match the new material design widgets. Make sure that all your
+  notifications look right with the new color scheme. If your notifications
+look wrong, fix them:</p>
+
+<ul>
+  <li>Use {@link android.app.Notification.Builder#setColor(int) setColor()}
+    to set an accent color in a circle behind your icon image. </li>
+  <li>Update or remove assets that involve color. The system ignores all
+    non-alpha channels in action icons and in the main notification icon. You
+    should assume that these icons will be alpha-only. The system draws
+    notification icons in white and action icons in dark gray.</li>
+</ul>
+
+<h3 id="NotificationsSoundVibration">Sound and vibration</h3>
+<p>If you are currently adding sounds and vibrations to your notifications by
+using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer},
+or {@link android.os.Vibrator} classes, remove this code so that
+the system can present notifications correctly in
+<em>priority</em> mode. Instead, use
+{@link android.app.Notification.Builder} methods to add sounds and
+vibration.</p>
+
+<p>Setting the device to
+{@link android.media.AudioManager#RINGER_MODE_SILENT RINGER_MODE_SILENT} causes
+the device to enter the new priority mode. The device leaves priority
+mode if you set it to
+{@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_NORMAL} or
+{@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_VIBRATE}.</p>
+
+<p>Previously, Android used {@link android.media.AudioManager#STREAM_MUSIC STREAM_MUSIC}
+as the master stream to control volume on tablet devices. In Android 5.0, the
+master volume stream for both phone and tablet devices is now unified, and
+is controlled by {@link android.media.AudioManager#STREAM_RING STREAM_RING} or
+{@link android.media.AudioManager#STREAM_NOTIFICATION STREAM_NOTIFICATION}.</p>
+
+<h3 id="NotificationsLockscreenVisibility">Lock screen visibility</h3>
+<p>By default, notifications now appear on the user's lock screen in Android 5.0.
+Users can choose to protect sensitive information from being exposed, in which
+case the system automatically redacts the text displayed by the notification. To
+customize this redacted notification, use
+{@link android.app.Notification.Builder#setPublicVersion(android.app.Notification)
+  setPublicVersion()}.</p>
+<p>If the notification does not contain personal information, or if you want to
+allow media playback control on the notification, call the
+{@link android.app.Notification.Builder#setVisibility(int) setVisibility()}
+method and set the notification's visibility level to
+{@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC}.
+</p>
+
+<h3 id="NotificationsMediaPlayback">Media playback</h3>
+<p>If you are implementing notifications that present media playback
+status or transport controls, consider using the new
+{@link android.app.Notification.MediaStyle} template instead of a custom
+{@link android.widget.RemoteViews.RemoteView} object. Whichever approach you
+choose, make sure to set the notification's visibility to
+{@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC} so that
+your controls are accessible from the lock screen. Note that beginning in
+Android 5.0, the system no longer shows
+{@link android.media.RemoteControlClient} objects on the lock screen. For more
+information, see
+<a href="#BehaviorMediaControl">If your app uses RemoteControlClient</a>.</p>
+
+<h3 id="NotificationsHeadsup">Heads-up notification</h3>
+<p>Notifications may now appear in a small floating window (also called a
+  heads-up notification) when the device is active (that is, the device is
+  unlocked and its screen is on). These notifications appear similar to the
+  compact form of your notification, except that the heads-up notification also
+  shows action buttons. Users can act on, or dismiss, a heads-up notification
+  without leaving the current app.</p>
+
+<p>Examples of conditions that may trigger heads-up notifications include:</p>
+
+<ul>
+  <li>The user's activity is in fullscreen mode (the app uses
+{@link android.app.Notification#fullScreenIntent})</li>
+  <li>The notification has high priority and uses ringtones or vibrations</li>
+</ul>
+
+<p>If your app implements notifications under any of those scenarios, make sure
+that heads-up notifications are presented correctly.</p>
+
+<h2 id="BehaviorMediaControl">Media Controls and RemoteControlClient</h2>
+<p>The {@link android.media.RemoteControlClient} class is now deprecated. Switch
+  to the new {@link android.media.session.MediaSession} API as
+  soon as possible.</p>
+
+<p>Lock screens in Android 5.0 do not show transport controls for
+your {@link android.media.session.MediaSession} or
+{@link android.media.RemoteControlClient}. Instead, your app can provide
+media playback control from the lock screen through a notification. This
+gives your app more control over the presentation of media buttons, while
+providing a consistent experience for users across locked and
+unlocked devices.</p>
+
+<p>Android 5.0 introduces a new
+{@link android.app.Notification.MediaStyle} template for this purpose.
+{@link android.app.Notification.MediaStyle} converts notification
+actions that you added with
+{@link android.app.Notification.Builder#addAction(int, java.lang.CharSequence,
+  android.app.PendingIntent)
+Notification.Builder.addAction()} into compact buttons embedded in your app's
+media playback notifications. Pass your session token to the
+{@link android.app.Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token)
+  setSession()} method to inform the system that this notification controls an
+  ongoing media session.</p>
+
+<p>Make sure to set the notification's visibility to
+  {@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC}
+  to mark the notification as safe to show on any lock screen (secure or
+  otherwise). For more information, see
+  <a href="#LockscreenNotifications">Lock screen notifications</a>.</p>
+
+<p>To display media playback controls if your app is running on the
+Android <a href="{@docRoot}tv/index.html">TV</a> or
+<a href="{@docRoot}wear/index.html">Wear</a> platform, implement the
+{@link android.media.session.MediaSession} class. You should also implement
+{@link android.media.session.MediaSession} if your app needs to receive media
+button events on Android devices.</p>
+
+<h2 id="BehaviorGetRecentTasks">getRecentTasks()</h2>
+
+<p>With the introduction of the new <em>concurrent documents and activities
+tasks</em> feature in Android 5.0 (see <a href="#Recents">Concurrent
+documents and activities in the recents screen</a> below),
+the {@link android.app.ActivityManager#getRecentTasks
+ActivityManager.getRecentTasks()} method is now deprecated to improve user
+privacy. For backward compatibility, this method still returns a small subset of
+its data, including the calling application’s own tasks and possibly some other
+non-sensitive tasks (such as Home). If your app is using this method to retrieve
+its own tasks, use {@link android.app.ActivityManager#getAppTasks() getAppTasks()}
+instead to retrieve that information.</p>
+
+<h2 id="64BitSupport">64-Bit Support in the Android NDK</h2>
+
+<p>Android 5.0 introduces support for 64-bit systems. The 64-bit enhancement
+  increases address space and improves performance, while still supporting
+  existing 32-bit apps fully. The 64-bit support also improves the performance of
+  OpenSSL for cryptography. In addition, this release introduces new native
+  media NDK APIs, as well as native OpenGL ES (GLES) 3.1 support.</p>
+
+<p>To use the 64-bit support provided in Android 5.0, download and install NDK
+  Revision 10c from the
+<a href="{@docRoot}tools/sdk/ndk/index.html">Android NDK page</a>. Refer to the
+Revision 10c <a href="{@docRoot}tools/sdk/ndk/index.html#Revisions">release notes</a>
+for more information about important changes and bug fixes to the NDK.</p>
+
+<h2 id="BindService">Binding to a Service</h2>
+
+<p>The
+  {@link android.content.Context#bindService(android.content.Intent, android.content.ServiceConnection, int) Context.bindService()}
+  method now requires an explicit {@link android.content.Intent},
+and throws an exception if given an implicit intent.
+To ensure your app is secure, use an explicit intent when starting or binding
+your {@link android.app.Service}, and do not declare intent filters for the service.</p>
+
+<h2 id="BehaviorWebView">WebView</h2>
+
+<p>Android 5.0 changes the default behavior for your app.</p>
+<ul>
+<li><strong>If your app targets API level 21 or higher:</strong>
+  <ul>
+    <li>The system
+  blocks <a href="https://developer.mozilla.org/en-US/docs/Security/MixedContent"
+  class="external-link">mixed content</a> and third party cookies by default. To allow mixed
+  content and third party cookies, use the
+  {@link android.webkit.WebSettings#setMixedContentMode(int) setMixedContentMode()}
+and {@link android.webkit.CookieManager#setAcceptThirdPartyCookies(android.webkit.WebView, boolean) setAcceptThirdPartyCookies()}
+methods respectively.</li>
+    <li>The system now intelligently chooses portions of the HTML
+      document to draw. This new default behavior helps to reduce memory
+      footprint and increase performance. If you want to
+      render the whole document at once, disable this optimization by calling
+      {@link android.webkit.WebView#enableSlowWholeDocumentDraw()}.</li>
+  </ul>
+</li>
+<li><strong>If your app targets API levels lower than 21:</strong> The system
+  allows mixed content and third party cookies, and always renders the whole
+  document at once.</li>
+</ul>
+
+<h2 id="custom_permissions">Uniqueness Requirement for Custom Permissions</h2>
+
+<p>
+  As documented in the <a href=
+  "{@docRoot}guide/topics/manifest/manifest-intro.html#perms">Permissions</a>
+  overview, Android apps can define custom permissions as a means of managing
+  access to components in a proprietary way, without using the platform’s
+  pre-defined system permissions. Apps define custom permissions in <a href=
+  "http://developer.android.com/guide/topics/manifest/permission-element.html"><code>
+  &lt;permission&gt;</code></a> elements declared in their manifest files.
+</p>
+
+<p>
+  There are a small number of scenarios where defining custom permissions is a
+  legitimate and secure approach. However, creating custom permissions is
+  sometimes unnecessary and can even introduce potential risk to an app,
+  depending on the protection level assigned to the permissions.
+</p>
+
+<p>
+  Android 5.0 includes a behavior change to ensure
+  that only one app can define a given custom permission, unless signed with the 
+  same key as other apps defining the permission. 
+</p>
+
+<h3>
+  Apps using duplicate custom permissions
+</h3>
+
+<p>
+  Any app can define any custom permission it wants, so it can happen
+  that multiple apps might <strong>define the same custom permission</strong>.
+  For example, if two apps offer a similar capability, they might derive the
+  same logical name for their custom permissions. Apps might also incorporate
+  common public libraries or code examples that themselves include the same
+  custom permission definitions.
+</p>
+
+<p>
+  In Android 4.4 and earlier, users were able to install multiple such
+  apps on a given device, although the system assigned the protection level
+  specified by the first-installed app. 
+</p>
+
+<p>
+  Starting in Android 5.0, the system enforces a new
+  <strong>uniqueness restriction on custom permissions</strong> for
+  apps that are signed with different keys. Now only one app on a device can
+  define a given custom permission (as determined by its name), unless the
+  other app defining the permission is signed with the same key. If the user
+  tries to install an app with a duplicate custom permission and is not signed
+  with the same key as the resident app that defines the permission, the system
+  blocks the installation.
+</p>
+
+<h3>
+  Considerations for your app
+</h3>
+
+<p>
+  In Android 5.0 and later, apps can continue to define their own custom
+  permissions just as before and to request custom permissions from other apps
+  through the <code>&lt;uses-permission&gt;</code> mechanism. However with the
+  new requirement introduced in Android 5.0, you should carefully assess
+  possible impacts on your app.
+</p>
+
+<p>
+  Here are some points to consider:
+</p>
+
+<ul>
+  <li>Does your app declare any <a href=
+  "http://developer.android.com/guide/topics/manifest/permission-element.html">
+    <code>&lt;permission&gt;</code></a> elements in its manifest? If so, are
+    they actually necessary to the proper function of your app or service? Or
+    could you use a system default permission instead?
+  </li>
+
+  <li>If you have <a href=
+  "http://developer.android.com/guide/topics/manifest/permission-element.html">
+    <code>&lt;permission&gt;</code></a> elements in your app, do you know where
+    they came from?
+  </li>
+
+  <li>Do you actually intend for other apps to request your custom permissions
+  through <a href=
+  "http://developer.android.com/guide/topics/manifest/uses-permission-element.html">
+    <code>&lt;uses-permission&gt;</code></a>?
+  </li>
+
+  <li>Are you using boilerplate or example code in your app that includes
+  <a href=
+  "http://developer.android.com/guide/topics/manifest/permission-element.html">
+    <code>&lt;permission&gt;</code></a> elements? Are those permission elements
+    actually necessary?
+  </li>
+
+  <li>Do your custom permissions use names that are simple or based on common
+  terms that other apps might share?
+  </li>
+</ul>
+
+<h3>
+  New installs and updates
+</h3>
+
+<p>
+  As mentioned above, for new installs and updates of your app on devices
+  running Android 4.4 or earlier are unaffected and there is no change in
+  behavior. For new installs and updates on devices running Android 5.0 or
+  later, the system <strong>prevents installation of your app</strong> if it
+  defines a custom permission that is already defined by an existing resident
+  app.
+</p>
+
+<h3>
+  Existing installs with Android 5.0 system update
+</h3>
+
+<p>
+  If your app uses custom permissions and is widely distributed and installed,
+  there’s a chance that it will be affected when users receive update their
+  devices to Android 5.0. After the system update is installed, the system
+  revalidates installed apps, including a check of their custom permissions. If
+  your app defines a custom permission that is already defined by another app
+  that has already been validated, and your app is not signed with the same key
+  as the other app, the system <strong>does not re-install your app</strong>.
+</p>
+
+<h3>
+  Recommendations
+</h3>
+
+<p>
+  On devices running Android 5.0 or later, we recommend that you examine your
+  app immediately, make any adjustments needed, and publish the updated version
+  as soon as possible to your users.
+</p>
+
+<ul>
+  <li>If you are using custom permissions in your app, consider their origin
+  and whether you actually need them. Remove all <a href=
+  "http://developer.android.com/guide/topics/manifest/permission-element.html">
+    <code>&lt;permission&gt;</code></a> elements from your app, unless you are
+    certain that they are required for proper function of your app.
+  </li>
+
+  <li>Consider replacing your custom permissions with system default
+  permissions where possible.
+  </li>
+
+  <li>If your app requires custom permissions, rename your custom permissions
+  to be unique to your app, such as by appending them to the full package name
+  of your app.
+  </li>
+
+  <li>If you have a suite of apps <em>signed with different keys</em> and the apps
+  access a shared component by means of a custom permission, make sure that the
+  custom permission is only defined once, in the shared component. Apps that
+  use the shared component should not define the custom permission themselves,
+  but should instead request access through the <a href=
+  "{@docRoot}guide/topics/manifest/uses-permission-element.html">
+    <code>&lt;uses-permission&gt;</code></a> mechanism.
+  </li>
+
+  <li>If you have a suite of apps are <em>signed with the same key</em>,
+  each app can define the same custom permission(s) as <span style="white-space:nowrap;">needed
+  &mdash; the</span> system allows the apps to be installed in the usual way.
+  </li>
+
+</ul>
+
+
+<h2 id="ssl">
+  TLS/SSL Default Configuration Changes
+</h2>
+
+<p>
+  Android 5.0 introduces changes the default TLS/SSL configuration used by apps
+  for HTTPS and other TLS/SSL traffic:
+</p>
+
+<ul>
+  <li>TLSv1.2 and TLSv1.1 protocols are now enabled,</li>
+  <li>AES-GCM (AEAD) cipher suites are now enabled,</li>
+  <li>MD5, 3DES, export, and static key ECDH cipher suites are now disabled,</li>
+  <li>Forward Secrecy cipher suites (ECDHE and DHE) are preferred.</li>
+</ul>
+
+<p>
+  These changes may lead to breakages in HTTPS or TLS/SSL connectivity in a
+  small number of cases listed below.
+</p>
+
+<p>
+  Note that the security ProviderInstaller from Google Play services already
+  offers these changes across Android platform versions back to Android 2.3.
+</p>
+
+<h3>
+  Server does not support any of the enabled ciphers suites
+</h3>
+
+<p>
+  For example, a server might support only 3DES or MD5 cipher suites. The
+  preferred fix is to improve the server’s configuration to enable stronger and
+  more modern cipher suites and protocols. Ideally, TLSv1.2 and AES-GCM should
+  be enabled, and Forward Secrecy cipher suites (ECDHE, DHE) should be enabled
+  and preferred.
+</p>
+
+<p>
+  An alternative is to modify the app to use a custom SSLSocketFactory to
+  communicate with the server. The factory should be designed to create
+  SSLSocket instances which have some of the cipher suites required by the
+  server enabled in addition to default cipher suites.
+</p>
+
+<h3>
+  App is making wrong assumptions about cipher suites used to connect to server
+</h3>
+
+<p>
+  For example, some apps contain a custom X509TrustManager that breaks because
+  it expects the authType parameter to be RSA but encounters ECDHE_RSA or
+  DHE_RSA.
+</p>
+
+<h3>
+  Server is intolerant to TLSv1.1, TLSv1.2 or new TLS extensions
+</h3>
+
+<p>
+  For example, the TLS/SSL handshake with a server is erroneously rejected or
+  stalls. The preferred fix is to upgrade the server to comply with the TLS/SSL
+  protocol. This will make the server successfully negotiate these newer
+  protocols or negotiate TLSv1 or older protocols and ignore TLS extensions it
+  does not understand. In some cases disabling TLSv1.1 and TLSv1.2 on the
+  server may work as a stopgap measure until the server software is upgraded.
+</p>
+
+<p>
+  An alternative is to modify the app to use a custom SSLSocketFactory to
+  communicate with the server. The factory should be designed to create
+  SSLSocket instances with only those protocols enabled which are correctly
+  supported by the server.
+</p>
\ No newline at end of file
diff --git a/docs/html/about/versions/android-5.0.jd b/docs/html/about/versions/android-5.0.jd
index a438420..756b75f 100644
--- a/docs/html/about/versions/android-5.0.jd
+++ b/docs/html/about/versions/android-5.0.jd
@@ -15,17 +15,10 @@
 
 <ol id="toc44" class="hide-nested">
   <li><a href="#ApiLevel">Update your target API level</a></li>
-  <li><a href="#Behaviors">Important Behavior Changes</a>
-    <ol>
-      <li><a href="#ART">If you haven't tested your app against the new Android Runtime (ART)...</a></li>
-      <li><a href="#BehaviorNotifications">If your app implements notifications...</a></li>
-      <li><a href="#BehaviorMediaControl">If your app uses RemoteControlClient...</a></li>
-<li><a href="#BehaviorGetRecentTasks">If your app uses getRecentTasks()...</a></li>
-<li><a href="#64BitSupport">If you are using the Android Native Development Kit (NDK)...</a></li>
-<li><a href="#BindService">If your app binds to a Service...</a></li>
-<li><a href="#BehaviorWebView">If your app uses a WebView...</a></li>
-    </ol>
-  </li>
+
+
+
+
   <li><a href="#UI">User Interface</a>
     <ol>
       <li><a href="#MaterialDesign">Material design support</a></li>
@@ -113,6 +106,13 @@
 <li><a href="{@docRoot}sdk/api_diff/preview-21/changes.html">L Developer Preview to 21 &raquo;</a> </li>
 </ol>
 
+<h2>See Also</h2>
+<ol>
+<li><a href="{@docRoot}about/versions/android-5.0-changes.html">Android 5.0 Behavior Changes</a> </li>
+<li><a href="{@docRoot}about/versions/lollipop.html">Android Lollipop Highlights</a> </li>
+</ol>
+
+
 </div>
 </div>
 
@@ -122,12 +122,19 @@
   offers new features for users and app developers. This document provides an
   introduction to the most notable new APIs.</p>
 
+<p>
+  If you have a published app, make sure to check out the <a href=
+  "{@docRoot}about/versions/android-5.0-changes.html">Android 5.0 Behavior
+  Changes</a> that you should account for in your app. These behavior changes
+  may affect your app on Android 5.0 devices, even if you are not using new APIs
+  or targeting new functionality.
+</p>
+
 <p>For a high-level look at the new platform features, instead
 see the
 <a href="{@docRoot}about/versions/lollipop.html">Android Lollipop
 highlights</a>.</p>
 
-
 <h3 id="Start">Start developing</h3>
 
 <p>To start building apps for Android 5.0, you must first <a href="{@docRoot}sdk/index.html">get
@@ -143,8 +150,6 @@
 ">To test your apps on a real device, flash a Nexus 5 or Nexus 7 with the <br>
 <a href="/preview/index.html#Start"><b>ANDROID PREVIEW SYSTEM IMAGE</b></a>.</p>
 
-
-
 <h3 id="ApiLevel">Update your target API level</h3>
 
 <p>To better optimize your app for devices running Android {@sdkPlatformVersion},
@@ -166,237 +171,18 @@
 href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">What is API
 Level?</a></p>
 
-<h2 id="Behaviors">Important Behavior Changes</h2>
+<h3 id="Behaviors">Important behavior changes</h3>
 
-<p>If you have previously published an app for Android, be aware that your app
-  might be affected by changes in Android 5.0.</p>
+<p>If you have previously published an app for Android, be aware that your app might be affected by changes in Android 5.0.</p>
 
-<h3 id="ART">If you haven't tested your app against the new Android Runtime (ART)...</h3>
+<p>Please see <a href="{@docRoot}about/versions/android-5.0-changes.html">Android 5.0 Changes</a> for complete information.</p>
 
-<p>The 4.4 release introduced a new, experimental Android runtime, ART. Under
-4.4, ART was optional, and the default runtime remained Dalvik. With Android
-5.0, ART is now the default runtime.</p>
-
-<p>For an overview of ART's new features, see
-<a href="https://source.android.com/devices/tech/dalvik/art.html">Introducing
-ART</a>. Some of the major new features are:</p>
-
-<ul>
-  <li>Ahead-of-time (AOT) compilation</li>
-  <li>Improved garbage collection (GC)</li>
-  <li>Improved debugging support</li>
-</ul>
-
-<p>Most Android apps should just work without any changes under ART. However, some
-techniques that work on Dalvik do not work on ART. For information about the
-most important issues, see
-<a href="{@docRoot}guide/practices/verifying-apps-art.html">Verifying App
-Behavior on the Android Runtime (ART)</a>. Pay particular attention if:</p>
-
-<ul>
-  <li>Your app uses Java Native Interface (JNI) to run C/C++ code.</li>
-  <li>You use development tools that generate non-standard code (such as some
-      obfuscators).</li>
-  <li>You use techniques that are incompatible with compacting garbage
-      collection. (ART does not currently implement compacting GC, but
-      compacting GC is under development in the Android Open Source
-      Project.)</li>
-</ul>
-
-<h3 id="BehaviorNotifications">If your app implements notifications...</h3>
-
-<p>Make sure your notifications take these Android 5.0 changes into account.
- To learn more about designing your notifications for Android 5.0 and higher,
- see the <a href="{@docRoot}design/patterns/notifications.html">notifications design guide</a>.
-</p>
-
-<h4 id="NotificationsMaterialDesignStyle">Material design style</h4>
-<p>Notifications are drawn with dark text atop white (or very light) backgrounds
-  to match the new material design widgets. Make sure that all your
-  notifications look right with the new color scheme. If your notifications
-look wrong, fix them:</p>
-
-<ul>
-  <li>Use {@link android.app.Notification.Builder#setColor(int) setColor()}
-    to set an accent color in a circle behind your icon image. </li>
-  <li>Update or remove assets that involve color. The system ignores all
-    non-alpha channels in action icons and in the main notification icon. You
-    should assume that these icons will be alpha-only. The system draws
-    notification icons in white and action icons in dark gray.</li>
-</ul>
-
-<h4 id="NotificationsSoundVibration">Sound and vibration</h4>
-<p>If you are currently adding sounds and vibrations to your notifications by
-using the {@link android.media.Ringtone}, {@link android.media.MediaPlayer},
-or {@link android.os.Vibrator} classes, remove this code so that
-the system can present notifications correctly in
-<em>priority</em> mode. Instead, use
-{@link android.app.Notification.Builder} methods to add sounds and
-vibration.</p>
-
-<p>Setting the device to
-{@link android.media.AudioManager#RINGER_MODE_SILENT RINGER_MODE_SILENT} causes
-the device to enter the new priority mode. The device leaves priority
-mode if you set it to
-{@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_NORMAL} or
-{@link android.media.AudioManager#RINGER_MODE_NORMAL RINGER_MODE_VIBRATE}.</p>
-
-<p>Previously, Android used {@link android.media.AudioManager#STREAM_MUSIC STREAM_MUSIC}
-as the master stream to control volume on tablet devices. In Android 5.0, the
-master volume stream for both phone and tablet devices is now unified, and
-is controlled by {@link android.media.AudioManager#STREAM_RING STREAM_RING} or
-{@link android.media.AudioManager#STREAM_NOTIFICATION STREAM_NOTIFICATION}.</p>
-
-<h4 id="NotificationsLockscreenVisibility">Lock screen visibility</h4>
-<p>By default, notifications now appear on the user's lock screen in Android 5.0.
-Users can choose to protect sensitive information from being exposed, in which
-case the system automatically redacts the text displayed by the notification. To
-customize this redacted notification, use
-{@link android.app.Notification.Builder#setPublicVersion(android.app.Notification)
-  setPublicVersion()}.</p>
-<p>If the notification does not contain personal information, or if you want to
-allow media playback control on the notification, call the
-{@link android.app.Notification.Builder#setVisibility(int) setVisibility()}
-method and set the notification's visibility level to
-{@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC}.
-</p>
-
-<h4 id="NotificationsMediaPlayback">Media playback</h4>
-<p>If you are implementing notifications that present media playback
-status or transport controls, consider using the new
-{@link android.app.Notification.MediaStyle} template instead of a custom
-{@link android.widget.RemoteViews.RemoteView} object. Whichever approach you
-choose, make sure to set the notification's visibility to
-{@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC} so that
-your controls are accessible from the lock screen. Note that beginning in
-Android 5.0, the system no longer shows
-{@link android.media.RemoteControlClient} objects on the lock screen. For more
-information, see
-<a href="#BehaviorMediaControl">If your app uses RemoteControlClient</a>.</p>
-
-<h4 id="NotificationsHeadsup">Heads-up notification</h4>
-<p>Notifications may now appear in a small floating window (also called a
-  heads-up notification) when the device is active (that is, the device is
-  unlocked and its screen is on). These notifications appear similar to the
-  compact form of your notification, except that the heads-up notification also
-  shows action buttons. Users can act on, or dismiss, a heads-up notification
-  without leaving the current app.</p>
-
-<p>Examples of conditions that may trigger heads-up notifications include:</p>
-
-<ul>
-  <li>The user's activity is in fullscreen mode (the app uses
-{@link android.app.Notification#fullScreenIntent})</li>
-  <li>The notification has high priority and uses ringtones or vibrations</li>
-</ul>
-
-<p>If your app implements notifications under any of those scenarios, make sure
-that heads-up notifications are presented correctly.</p>
-
-<h3 id="BehaviorMediaControl">If your app uses RemoteControlClient...</h3>
-<p>The {@link android.media.RemoteControlClient} class is now deprecated. Switch
-  to the new {@link android.media.session.MediaSession} API as
-  soon as possible.</p>
-
-<p>Lock screens in Android 5.0 do not show transport controls for
-your {@link android.media.session.MediaSession} or
-{@link android.media.RemoteControlClient}. Instead, your app can provide
-media playback control from the lock screen through a notification. This
-gives your app more control over the presentation of media buttons, while
-providing a consistent experience for users across locked and
-unlocked devices.</p>
-
-<p>Android 5.0 introduces a new
-{@link android.app.Notification.MediaStyle} template for this purpose.
-{@link android.app.Notification.MediaStyle} converts notification
-actions that you added with
-{@link android.app.Notification.Builder#addAction(int, java.lang.CharSequence,
-  android.app.PendingIntent)
-Notification.Builder.addAction()} into compact buttons embedded in your app's
-media playback notifications. Pass your session token to the
-{@link android.app.Notification.MediaStyle#setMediaSession(android.media.session.MediaSession.Token)
-  setSession()} method to inform the system that this notification controls an
-  ongoing media session.</p>
-
-<p>Make sure to set the notification's visibility to
-  {@link android.app.Notification#VISIBILITY_PUBLIC VISIBILITY_PUBLIC}
-  to mark the notification as safe to show on any lock screen (secure or
-  otherwise). For more information, see
-  <a href="#LockscreenNotifications">Lock screen notifications</a>.</p>
-
-<p>To display media playback controls if your app is running on the
-Android <a href="{@docRoot}tv/index.html">TV</a> or
-<a href="{@docRoot}wear/index.html">Wear</a> platform, implement the
-{@link android.media.session.MediaSession} class. You should also implement
-{@link android.media.session.MediaSession} if your app needs to receive media
-button events on Android devices.</p>
-
-<h3 id="BehaviorGetRecentTasks">If your app uses getRecentTasks()...</h3>
-
-<p>With the introduction of the new <em>concurrent documents and activities
-tasks</em> feature in Android 5.0 (see <a href="#Recents">Concurrent
-documents and activities in the recents screen</a> below),
-the {@link android.app.ActivityManager#getRecentTasks
-ActivityManager.getRecentTasks()} method is now deprecated to improve user
-privacy. For backward compatibility, this method still returns a small subset of
-its data, including the calling application’s own tasks and possibly some other
-non-sensitive tasks (such as Home). If your app is using this method to retrieve
-its own tasks, use {@link android.app.ActivityManager#getAppTasks() getAppTasks()}
-instead to retrieve that information.</p>
-
-<h3 id="64BitSupport">If you are using the Android Native Development Kit (NDK)...</h3>
-
-<p>Android 5.0 introduces support for 64-bit systems. The 64-bit enhancement
-  increases address space and improves performance, while still supporting
-  existing 32-bit apps fully. The 64-bit support also improves the performance of
-  OpenSSL for cryptography. In addition, this release introduces new native
-  media NDK APIs, as well as native OpenGL ES (GLES) 3.1 support.</p>
-
-<p>To use the 64-bit support provided in Android 5.0, download and install NDK
-  Revision 10c from the
-<a href="{@docRoot}tools/sdk/ndk/index.html">Android NDK page</a>. Refer to the
-Revision 10c <a href="{@docRoot}tools/sdk/ndk/index.html#Revisions">release notes</a>
-for more information about important changes and bug fixes to the NDK.</p>
-
-<h3 id="BindService">If your app binds to a Service...</h3>
-
-<p>The
-  {@link android.content.Context#bindService(android.content.Intent, android.content.ServiceConnection, int) Context.bindService()}
-  method now requires an explicit {@link android.content.Intent},
-and throws an exception if given an implicit intent.
-To ensure your app is secure, use an explicit intent when starting or binding
-your {@link android.app.Service}, and do not declare intent filters for the service.</p>
-
-<h3 id="BehaviorWebView">If your app uses WebView...</h3>
-
-<p>Android 5.0 changes the default behavior for your app.</p>
-<ul>
-<li><strong>If your app targets API level 21 or higher:</strong>
-  <ul>
-    <li>The system
-  blocks <a href="https://developer.mozilla.org/en-US/docs/Security/MixedContent"
-  class="external-link">mixed content</a> and third party cookies by default. To allow mixed
-  content and third party cookies, use the
-  {@link android.webkit.WebSettings#setMixedContentMode(int) setMixedContentMode()}
-and {@link android.webkit.CookieManager#setAcceptThirdPartyCookies(android.webkit.WebView, boolean) setAcceptThirdPartyCookies()}
-methods respectively.</li>
-    <li>The system now intelligently chooses portions of the HTML
-      document to draw. This new default behavior helps to reduce memory
-      footprint and increase performance. If you want to
-      render the whole document at once, disable this optimization by calling
-      {@link android.webkit.WebView#enableSlowWholeDocumentDraw()}.</li>
-  </ul>
-</li>
-<li><strong>If your app targets API levels lower than 21:</strong> The system
-  allows mixed content and third party cookies, and always renders the whole
-  document at once.</li>
-</ul>
 
 <h2 id="UI">User Interface</h2>
 
 <h3 id="MaterialDesign">Material design support</h3>
 
-<p>The upcoming release adds support for Android's new <em>material design</em>
+<p>Android 5.0 adds support for Android's new <em>material design</em>
 style. You can create apps with material design that are visually dynamic and
 have UI element transitions that feel natural to users. This support includes:</p>
 
diff --git a/docs/html/distribute/googleplay/googleplay_toc.cs b/docs/html/distribute/googleplay/googleplay_toc.cs
index fc7cd11..b3aa9bf 100644
--- a/docs/html/distribute/googleplay/googleplay_toc.cs
+++ b/docs/html/distribute/googleplay/googleplay_toc.cs
@@ -18,6 +18,12 @@
     </div>
   </li>
   <li class="nav-section">
+    <div class="nav-section empty" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/guide.html">
+          <span class="en">Finding Success on Google Play</span>
+        </a>
+    </div>
+  </li>
+  <li class="nav-section">
     <div class="nav-section empty" style="font-weight:normal"><a href="<?cs var:toroot?>distribute/googleplay/tv.html">
           <span class="en">Distributing to <span style="white-space:nowrap">Android TV</span></span>
         </a>
diff --git a/docs/html/distribute/googleplay/guide.jd b/docs/html/distribute/googleplay/guide.jd
new file mode 100644
index 0000000..8317206
--- /dev/null
+++ b/docs/html/distribute/googleplay/guide.jd
@@ -0,0 +1,71 @@
+page.title=Finding Success on Google Play
+page.metaDescription=A guide to help you find success with your app or game business on Google Play.
+meta.tags="distribute", "bestpractices"
+page.tags="google play", "business", "monetize", "engagement"
+page.image=distribute/images/play_dev_guide.png
+
+@jd:body
+
+<p>
+  We’ve created a downloadable guide to help you find success with your app or
+  game business on Google Play. In it, you’ll find features, tips, and best
+  practices to help you build an effective strategy.
+</p>
+
+<p>
+  The guide is separated into the following sections:
+</p>
+<ul>
+  <li>
+    <strong>Publishing on Google Play</strong> &mdash; using the Google Play
+    Developer Console to distribute your app to over 1 billion Android users
+    worldwide.
+  </li>
+
+  <li>
+    <strong>Quality</strong> &mdash; The fundamentals of building a great app
+    and an insight into the Google Play guidelines and policies.
+  </li>
+
+  <li>
+    <strong>Discoverability &amp; reach</strong> &mdash; Maximizing your app's
+    discoverability and reaching the widest audience possible.
+  </li>
+
+  <li>
+    <strong>Engagement &amp; retention</strong> &mdash; Converting
+    installations into active users and improving user retention.
+  </li>
+
+  <li>
+    <strong>Monetization</strong> &mdash; Monetization strategies to generate
+    ongoing, growing revenue streams.
+  </li>
+
+  <li>
+    <strong>Measurement with Google Analytics</strong> &mdash; Understanding
+    your users and improving your app experience, conversions, and marketing.
+  </li>
+
+  <li>
+    <strong>Going global</strong> &mdash; Launching your app in local markets
+    around the world.
+  </li>
+</ul>
+
+<p>
+  Download the guide by clicking the image below or <a href=
+  "http://goo.gl/DFjbrS">get it on Google Play</a>.
+</p>
+
+<p>
+  We’ll release the guide in more languages in the coming months. Check back to
+  this website regularly as we post information on new features and best
+  practices to help you distribute and monetize your app.
+</p>
+  <div class="resource-widget resource-flow-layout col-16"
+    data-query="collection:play_dev_guide"
+    data-cardSizes="9x6"
+    data-maxResults="1">
+  </div>
+
diff --git a/docs/html/distribute/images/play_dev_guide.png b/docs/html/distribute/images/play_dev_guide.png
new file mode 100644
index 0000000..5b0c0d9
--- /dev/null
+++ b/docs/html/distribute/images/play_dev_guide.png
Binary files differ
diff --git a/docs/html/distribute/images/play_dev_guide_b.jpg b/docs/html/distribute/images/play_dev_guide_b.jpg
new file mode 100644
index 0000000..15fd59f
--- /dev/null
+++ b/docs/html/distribute/images/play_dev_guide_b.jpg
Binary files differ
diff --git a/docs/html/google/auth/api-client.jd b/docs/html/google/auth/api-client.jd
index 5331d1e..a0836d1 100644
--- a/docs/html/google/auth/api-client.jd
+++ b/docs/html/google/auth/api-client.jd
@@ -15,6 +15,7 @@
     <ol>
       <li><a href="#HandlingFailures">Handle connection failures</a></li>
       <li><a href="#MaintainingState">Maintain state while resolving an error</a></li>
+      <li><a href="#WearableApi">Access the Wearable API</a></li>
     </ol>
   </li>
   <li><a href="#Communicating">Communicate with Google Services</a>
@@ -104,7 +105,17 @@
 <a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.Builder.html#addScope(com.google.android.gms.common.api.Scope)"
 >{@code addScope()}</a>.</p>
 
-<p>However, before you can begin a connection by calling <a
+<p class="caution">
+<strong>Important:</strong> To avoid client connection errors on devices that do not have the
+<a href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android
+Wear app</a> installed, use a separate <a
+href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
+GoogleApiClient}</a> instance to access only the <a
+href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code
+Wearable}</a> API. For more information, see <a href="#WearableApi">Access the Wearable
+API</a>.</p>
+
+<p>Before you can begin a connection by calling <a
 href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html#connect()"
 >{@code connect()}</a> on the <a
 href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
@@ -408,6 +419,45 @@
 </p>
 
 
+<h3 id="WearableApi">Access the Wearable API</h3>
+
+<p>On devices that do not have the <a
+href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android
+Wear app</a> installed, connection requests that include the <a
+href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code
+Wearable}</a> API fail with the <a
+href="{@docRoot}reference/com/google/android/gms/common/ConnectionResult.html#API_UNAVAILABLE">
+<code>API_UNAVAILABLE</code></a> error code. If your app uses the <a
+href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code
+Wearable}</a> API in addition to other Google APIs, use a separate <a
+href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
+GoogleApiClient}</a> instance to access the <a
+href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code
+Wearable}</a> API. This approach enables you to access other Google APIs on devices that are not
+paired with a wearable device.</p>
+
+<p>When you use a separate <a
+href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
+GoogleApiClient}</a> instance to access only the Wearable API, you can determine
+whether the <a
+href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android
+Wear app</a> is installed on the device:</p>
+
+<pre>
+// Connection failed listener method for a client that only
+// requests access to the Wearable API
+&#64;Override
+public void onConnectionFailed(ConnectionResult result) {
+    if (result.getErrorCode() == ConnectionResult.API_UNAVAILABLE) {
+        // The Android Wear app is not installed
+    }
+    ...
+}
+</pre>
+
+
+
+
 
 
 <h2 id="Communicating">Communicate with Google Services</h2>
diff --git a/docs/html/jd_collections.js b/docs/html/jd_collections.js
index d63580e..a38b80b 100644
--- a/docs/html/jd_collections.js
+++ b/docs/html/jd_collections.js
@@ -57,9 +57,9 @@
   },
   "distribute/gp/gpfelanding": {
     "resources": [
+      "distribute/googleplay/guide.html",
       "distribute/googleplay/tv.html",
-      "distribute/googleplay/edu/about.html",
-      "distribute/googleplay/edu/videos.html"
+      "distribute/googleplay/edu/about.html"
     ]
   },
   "distribute/essentials": {
@@ -781,6 +781,12 @@
       "training/tv/index.html"
     ]
   },
+  "play_dev_guide": {
+    "title": "",
+    "resources": [
+      "shareables/distribute/play_dev_guide_secrets_en.pdf"
+    ]
+  },
   "distribute/stories/games": {
     "title": "",
     "resources": [
diff --git a/docs/html/jd_extras.js b/docs/html/jd_extras.js
index 89d9761..36f26e8 100644
--- a/docs/html/jd_extras.js
+++ b/docs/html/jd_extras.js
@@ -1394,5 +1394,18 @@
     "keywords": ["stories"],
     "type": "Case Study Deck",
     "titleFriendly": ""
+  },
+  {
+    "lang": "en",
+    "group": "",
+    "tags": [],
+    "url": "shareables/distribute/play_dev_guide_secrets_en.pdf",
+    "timestamp": null,
+    "image": "distribute/images/play_dev_guide_b.jpg",
+    "title": "The Secrets to App Success on Google Play",
+    "summary": "A guide to useful features, tips, and best practices that will help you grow a successful app business on Google Play.",
+    "keywords": ["distribute"],
+    "type": "PDF DOWNLOAD (11MB)",
+    "titleFriendly": ""
   }
 ]);
diff --git a/docs/html/training/articles/security-ssl.jd b/docs/html/training/articles/security-ssl.jd
index 0639fb0..7f43d9c 100644
--- a/docs/html/training/articles/security-ssl.jd
+++ b/docs/html/training/articles/security-ssl.jd
@@ -22,6 +22,7 @@
   <li><a href="#Blacklisting">Blacklisting</a></li>
   <li><a href="#Pinning">Pinning</a></li>
   <li><a href="#ClientCert">Client Certificates</a></li>
+  <li><a href="#nogotofail">Nogotofail: Network Security Testing</a></li>
 </ol>
 
 
@@ -511,8 +512,42 @@
 
 
 
+<h2 id="nogotofail">
+  Nogotofail: A Network Traffic Security Testing Tool
+</h2>
 
+<p>
+  Nogotofail is a tool gives you an easy way to confirm that your apps are safe
+  against known TLS/SSL vulnerabilities and misconfigurations. It's an
+  automated, powerful, and scalable tool for testing network security issues on
+  any device whose network traffic could be made to go through it. </p>
 
+  <p>Nogotofail is useful for three main use cases:
+</p>
+
+<ul>
+  <li>Finding bugs and vulnerabilities.
+  </li>
+
+  <li>Verifying fixes and watching for regressions.
+  </li>
+
+  <li>Understanding what applications and devices are generating what traffic.
+  </li>
+</ul>
+
+<p>
+  Nogotofail works for Android, iOS, Linux, Windows, Chrome OS, OSX, in fact
+  any device you use to connect to the Internet. There’s an easy-to-use client
+  to configure the settings and get notifications on Android and Linux, as well
+  as the attack engine itself which can be deployed as a router, VPN server, or
+  proxy.
+</p>
+
+<p>
+  You can access the tool at the <a href=
+  "https://github.com/google/nogotofail">Nogotofail open source project</a>.
+</p>
 
 
 
diff --git a/docs/html/training/tv/start/hardware.jd b/docs/html/training/tv/start/hardware.jd
index 33d396b..fc52602 100644
--- a/docs/html/training/tv/start/hardware.jd
+++ b/docs/html/training/tv/start/hardware.jd
@@ -85,27 +85,27 @@
   </tr>
   <tr>
     <td>Touchscreen</td>
-    <td>android.hardware.touchscreen</td>
+    <td>{@code android.hardware.touchscreen}</td>
   </tr>
   <tr>
     <td>Telephony</td>
-    <td>android.hardware.telephony</td>
+    <td>{@code android.hardware.telephony}</td>
   </tr>
   <tr>
     <td>Camera</td>
-    <td>android.hardware.camera</td>
+    <td>{@code android.hardware.camera}</td>
   </tr>
   <tr>
     <td>Near Field Communications (NFC)</td>
-    <td>android.hardware.nfc</td>
+    <td>{@code android.hardware.nfc}</td>
   </tr>
   <tr>
     <td>GPS</td>
-    <td>android.hardware.location.gps</td>
+    <td>{@code android.hardware.location.gps}</td>
   </tr>
   <tr>
     <td>Microphone</td>
-    <td>android.hardware.microphone</td>
+    <td>{@code android.hardware.microphone}</td>
   </tr>
 </table>
 
@@ -142,20 +142,17 @@
         android:required="false"/&gt;
 </pre>
 
-<p class="caution">
-  <strong>Caution:</strong> Declaring an unavailable hardware feature as required by setting its
-  value to {@code true} in your app manifest prevents your app from being installed on TV
-  devices or appearing in the Android TV home screen launcher.
+<p>
+  All apps intended for use on TV devices must declare that the touch screen feature is not required
+  as described in <a href="{@docRoot}training/tv/start/start.html#no-touchscreen">Get Started with
+  TV Apps</a>. If your app normally uses one or more of the features listed above, change the
+  {@code android:required} attribute setting to {@code false} for those features in your manifest.
 </p>
 
 <p class="caution">
-  <strong>Caution:</strong> Some <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code uses-permission}</a> manifest declarations <em>imply hardware use</em>, which can also
-  prevent your app from being installed and used on TV devices. For example, requesting the
-  {@link android.Manifest.permission#RECORD_AUDIO} permission in your app implies the
-  {@code android.hardware.microphone} hardware feature requirement. In which case, you must declare
-  the microphone feature as not required ({@code android:required="false"}) in your app manifest.
-  For a list of permission requests that imply a hardware feature requirement, see <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">
-  {@code uses-feature}</a> guide.
+  <strong>Caution:</strong> Declaring a hardware feature as required by setting its
+  value to {@code true}  prevents your app from being installed on TV
+  devices or appearing in the Android TV home screen launcher.
 </p>
 
 <p>
@@ -172,6 +169,52 @@
 </p>
 
 
+<h3 id="hardware-permissions">Declaring permissions that imply hardware features</h3>
+
+<p>
+  Some <a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code uses-permission}</a>
+  manifest declarations <em>imply hardware features</em>. This behavior means that requesting some
+  permissions in your app manifest can exclude your app from from being installed and used on TV
+  devices. The following commonly requested permissions create an implicit hardware feature
+  requirement:
+</p>
+
+<table>
+  <tr>
+    <th>Permission</th>
+    <th>Implied hardware feature</th>
+  </tr>
+  <tr>
+    <td>{@link android.Manifest.permission#RECORD_AUDIO}</td>
+    <td>{@code android.hardware.microphone}</td>
+  </tr>
+  <tr>
+    <td>{@link android.Manifest.permission#CAMERA}</td>
+    <td>{@code android.hardware.camera} <em>and</em> <br>
+      {@code android.hardware.camera.autofocus}</td>
+  </tr>
+  <tr>
+    <td>{@link android.Manifest.permission#ACCESS_COARSE_LOCATION}</td>
+    <td>{@code android.hardware.location} <em>and</em> <br>
+      {@code android.hardware.location.network}</td>
+  </tr>
+  <tr>
+    <td>{@link android.Manifest.permission#ACCESS_FINE_LOCATION}</td>
+    <td>{@code android.hardware.location} <em>and</em> <br>
+      {@code android.hardware.location.gps}</td>
+  </tr>
+</table>
+
+<p>
+  For a complete list of permission requests that imply a hardware feature requirement, see
+  <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-features">{@code
+  uses-feature}</a> guide. If your app requests one of the features listed above, include a
+  <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code uses-feature}</a>
+  declaration in your manifest for the implied hardware feature that indicates it is not
+  required ({@code android:required="false"}).
+</p>
+
+
 <h3 id="check-features">Checking for hardware features</h2>
 
 <p>
diff --git a/docs/html/training/tv/start/start.jd b/docs/html/training/tv/start/start.jd
index 3b26abf..aab1a39 100644
--- a/docs/html/training/tv/start/start.jd
+++ b/docs/html/training/tv/start/start.jd
@@ -11,6 +11,7 @@
   <h2>This lesson teaches you how to</h2>
   <ol>
     <li><a href="#dev-project">Setup a TV Project</a></li>
+    <li><a href="#tv-libraries">Add TV Support Libraries</a></li>
     <li><a href="#build-it">Build TV Apps</a></li>
     <li><a href="#run">Run TV Apps</a></li>
   </ol>
@@ -86,17 +87,10 @@
 
 <p>An application intended to run on TV devices must declare a launcher activity for TV
   in its manifest using a {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter.
-  This filter identifies your app as being enabled for TV, allowing it to be considered a TV app
-  in Google Play. Declaring this intent also identifies which activity
+  This filter identifies your app as being enabled for TV, and is required for your app to be
+  considered a TV app in Google Play. Declaring this intent also identifies which activity
   in your app to launch when a user selects its icon on the TV home screen.</p>
 
-<p class="caution">
-  <strong>Caution:</strong> If you do not include the {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter in
-  your app, it is not visible to users running the Google Play store on TV devices. Also, if your
-  app does not have this filter when you load it onto a TV device using developer tools, the app
-  does not appear in the TV user interface.
-</p>
-
 <p>The following code snippet shows how to include this intent filter in your manifest:</p>
 
 <pre>
@@ -132,6 +126,14 @@
   launch on a TV device.
 </p>
 
+<p class="caution">
+  <strong>Caution:</strong> If you do not include the
+  {@link android.content.Intent#CATEGORY_LEANBACK_LAUNCHER} intent filter in
+  your app, it is not visible to users running the Google Play store on TV devices. Also, if your
+  app does not have this filter when you load it onto a TV device using developer tools, the app
+  does not appear in the TV user interface.
+</p>
+
 <p>
   If you are modifying an existing app for use on TV, your app should not use the same
   activity layout for TV that it does for phones and tablets. The user interface of your TV app (or
@@ -142,6 +144,31 @@
   "{@docRoot}training/tv/start/layouts.html">Building TV Layouts</a>.
 </p>
 
+
+<h3 id="no-touchscreen">Declare touchscreen not required</h3>
+
+<p>
+  Applications that are intended to run on TV devices do not rely on touch screens for input. In
+  order to make this clear, the manifest of your TV app must declare that a the {@code
+  android.hardware.touchscreen} feature is not required. This setting identifies your app as being
+  able to work on a TV device, and is required for your app to be considered a TV app in Google
+  Play. The following code example shows how to include this manifest declaration:
+</p>
+
+<pre>
+&lt;manifest&gt;
+    <strong>&lt;uses-feature android:name="android.hardware.touchscreen"
+              android:required="false" /&gt;</strong>
+    ...
+&lt;/manifest&gt;
+</pre>
+
+<p class="caution">
+  <strong>Caution:</strong> You must declare that a touch screen is not required in your app
+  manifest, as shown this example code, or your app cannot appear in the Google Play store on TV
+  devices.
+</p>
+
 <h3 id="banner">Provide a home screen banner</h3>
 
 <p>
@@ -152,9 +179,10 @@
 
 <pre>
 &lt;application
-    . . .
+    ...
     android:banner="&#64;drawable/banner" &gt;
-    . . .
+
+    ...
 &lt;/application&gt;
 </pre>
 
@@ -171,7 +199,7 @@
   design guide.
 </p>
 
-<h3 id="tv-libraries">Add TV support libraries</h3>
+<h2 id="tv-libraries">Add TV Support Libraries</h3>
 
 <p>
   The Android SDK includes support libraries that are intended for use with TV apps. These
diff --git a/docs/html/training/wearables/data-layer/accessing.jd b/docs/html/training/wearables/data-layer/accessing.jd
index 36e3daa..bffd4c8 100644
--- a/docs/html/training/wearables/data-layer/accessing.jd
+++ b/docs/html/training/wearables/data-layer/accessing.jd
@@ -55,10 +55,21 @@
                     Log.d(TAG, "onConnectionFailed: " + result);
                 }
             })
+        // Request access only to the Wearable API
         .addApi(Wearable.API)
         .build();
 </pre>
 
+<p class="caution">
+<strong>Important:</strong> To avoid client connection errors on devices that do not have the
+<a href="https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en">Android
+Wear app</a> installed, use a separate <a
+href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html">{@code
+GoogleApiClient}</a> instance to access only the <a
+href="{@docRoot}reference/com/google/android/gms/wearable/Wearable.html">{@code
+Wearable}</a> API. For more information, see <a
+href="{@docRoot}google/auth/api-client.html#WearableApi">Access the Wearable API</a>.</p>
+
 <p>Before you use the data layer API, start a connection on your client by calling the
 <a href="{@docRoot}reference/com/google/android/gms/common/api/GoogleApiClient.html#connect()">connect()</a>
 method, as described in
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 7aa628c..e338686 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -340,7 +340,6 @@
     TessellationCache tessellationCache;
     TextDropShadowCache dropShadowCache;
     FboCache fboCache;
-    ResourceCache resourceCache;
 
     GammaFontRenderer* fontRenderer;
 
diff --git a/libs/hwui/DisplayList.cpp b/libs/hwui/DisplayList.cpp
index 4a927cf..8953166 100644
--- a/libs/hwui/DisplayList.cpp
+++ b/libs/hwui/DisplayList.cpp
@@ -39,29 +39,28 @@
 }
 
 void DisplayListData::cleanupResources() {
-    Caches& caches = Caches::getInstance();
-    caches.unregisterFunctors(functors.size());
-    caches.resourceCache.lock();
+    ResourceCache& resourceCache = ResourceCache::getInstance();
+    resourceCache.lock();
 
     for (size_t i = 0; i < bitmapResources.size(); i++) {
-        caches.resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i));
+        resourceCache.decrementRefcountLocked(bitmapResources.itemAt(i));
     }
 
     for (size_t i = 0; i < ownedBitmapResources.size(); i++) {
         const SkBitmap* bitmap = ownedBitmapResources.itemAt(i);
-        caches.resourceCache.decrementRefcountLocked(bitmap);
-        caches.resourceCache.destructorLocked(bitmap);
+        resourceCache.decrementRefcountLocked(bitmap);
+        resourceCache.destructorLocked(bitmap);
     }
 
     for (size_t i = 0; i < patchResources.size(); i++) {
-        caches.resourceCache.decrementRefcountLocked(patchResources.itemAt(i));
+        resourceCache.decrementRefcountLocked(patchResources.itemAt(i));
     }
 
     for (size_t i = 0; i < sourcePaths.size(); i++) {
-        caches.resourceCache.decrementRefcountLocked(sourcePaths.itemAt(i));
+        resourceCache.decrementRefcountLocked(sourcePaths.itemAt(i));
     }
 
-    caches.resourceCache.unlock();
+    resourceCache.unlock();
 
     for (size_t i = 0; i < paints.size(); i++) {
         delete paints.itemAt(i);
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index c17dd09..1b1f6cc 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -21,7 +21,7 @@
 
 #include <private/hwui/DrawGlInfo.h>
 
-#include "Caches.h"
+#include "ResourceCache.h"
 #include "DeferredDisplayList.h"
 #include "DisplayListLogBuffer.h"
 #include "DisplayListOp.h"
@@ -32,7 +32,7 @@
 namespace uirenderer {
 
 DisplayListRenderer::DisplayListRenderer()
-    : mCaches(Caches::getInstance())
+    : mResourceCache(ResourceCache::getInstance())
     , mDisplayListData(NULL)
     , mTranslateX(0.0f)
     , mTranslateY(0.0f)
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index 901e8f0..8068663 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -24,6 +24,7 @@
 
 #include "DisplayListLogBuffer.h"
 #include "RenderNode.h"
+#include "ResourceCache.h"
 
 namespace android {
 namespace uirenderer {
@@ -209,7 +210,7 @@
             mDisplayListData->paths.add(pathCopy);
         }
         if (mDisplayListData->sourcePaths.indexOf(path) < 0) {
-            mCaches.resourceCache.incrementRefcount(path);
+            mResourceCache.incrementRefcount(path);
             mDisplayListData->sourcePaths.add(path);
         }
         return pathCopy;
@@ -273,19 +274,19 @@
         // contents, and drawing again. The only fix would be to always copy it the first time,
         // which doesn't seem worth the extra cycles for this unlikely case.
         mDisplayListData->bitmapResources.add(bitmap);
-        mCaches.resourceCache.incrementRefcount(bitmap);
+        mResourceCache.incrementRefcount(bitmap);
         return bitmap;
     }
 
     inline const SkBitmap* refBitmapData(const SkBitmap* bitmap) {
         mDisplayListData->ownedBitmapResources.add(bitmap);
-        mCaches.resourceCache.incrementRefcount(bitmap);
+        mResourceCache.incrementRefcount(bitmap);
         return bitmap;
     }
 
     inline const Res_png_9patch* refPatch(const Res_png_9patch* patch) {
         mDisplayListData->patchResources.add(patch);
-        mCaches.resourceCache.incrementRefcount(patch);
+        mResourceCache.incrementRefcount(patch);
         return patch;
     }
 
@@ -293,7 +294,7 @@
     DefaultKeyedVector<const SkPath*, const SkPath*> mPathMap;
     DefaultKeyedVector<const SkRegion*, const SkRegion*> mRegionMap;
 
-    Caches& mCaches;
+    ResourceCache& mResourceCache;
     DisplayListData* mDisplayListData;
 
     float mTranslateX;
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index c9ed9a7..13c5499 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -98,9 +98,6 @@
     mNeedsDisplayListDataSync = true;
     delete mStagingDisplayListData;
     mStagingDisplayListData = data;
-    if (mStagingDisplayListData) {
-        Caches::getInstance().registerFunctors(mStagingDisplayListData->functors.size());
-    }
 }
 
 /**
@@ -305,6 +302,10 @@
         // changes in isRenderable or, in the future, bounds
         damageSelf(info);
         deleteDisplayListData();
+        // TODO: Remove this caches stuff
+        if (mStagingDisplayListData && mStagingDisplayListData->functors.size()) {
+            Caches::getInstance().registerFunctors(mStagingDisplayListData->functors.size());
+        }
         mDisplayListData = mStagingDisplayListData;
         mStagingDisplayListData = NULL;
         if (mDisplayListData) {
@@ -321,6 +322,9 @@
         for (size_t i = 0; i < mDisplayListData->children().size(); i++) {
             mDisplayListData->children()[i]->mRenderNode->decParentRefCount();
         }
+        if (mDisplayListData->functors.size()) {
+            Caches::getInstance().unregisterFunctors(mDisplayListData->functors.size());
+        }
     }
     delete mDisplayListData;
     mDisplayListData = NULL;
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 329d92f..12d4928 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -21,6 +21,12 @@
 #include "Caches.h"
 
 namespace android {
+
+#ifdef USE_OPENGL_RENDERER
+using namespace uirenderer;
+ANDROID_SINGLETON_STATIC_INSTANCE(ResourceCache);
+#endif
+
 namespace uirenderer {
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index 8539d12..a922d53 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -22,6 +22,7 @@
 #include <SkBitmap.h>
 
 #include <utils/KeyedVector.h>
+#include <utils/Singleton.h>
 
 #include <androidfw/ResourceTypes.h>
 
@@ -53,11 +54,14 @@
     ResourceType resourceType;
 };
 
-class ANDROID_API ResourceCache {
-public:
+class ANDROID_API ResourceCache: public Singleton<ResourceCache> {
     ResourceCache();
     ~ResourceCache();
 
+    friend class Singleton<ResourceCache>;
+
+public:
+
     /**
      * When using these two methods, make sure to only invoke the *Locked()
      * variants of increment/decrementRefcount(), recyle() and destructor()
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index 3b8cb19..7959841 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -572,6 +572,14 @@
      */
     public native List<byte[]> getSecureStops();
 
+    /**
+     * Access secure stop by secure stop ID.
+     *
+     * @param ssid - The secure stop ID provided by the license server.
+     *
+     * @hide - not part of the public API at this time
+     */
+    public native byte[] getSecureStop(byte[] ssid);
 
     /**
      * Process the SecureStop server response message ssRelease.  After authenticating
@@ -581,6 +589,12 @@
      */
     public native void releaseSecureStops(byte[] ssRelease);
 
+    /**
+     * Remove all secure stops without requiring interaction with the server.
+     *
+     * @hide - not part of the public API at this time
+     */
+     public native void releaseAllSecureStops();
 
     /**
      * String property name: identifies the maker of the DRM engine plugin
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index 0fed27e..8e07ec0 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -1003,6 +1003,27 @@
     return ListOfVectorsToArrayListOfByteArray(env, secureStops);
 }
 
+static jbyteArray android_media_MediaDrm_getSecureStop(
+    JNIEnv *env, jobject thiz, jbyteArray ssid) {
+    sp<IDrm> drm = GetDrm(env, thiz);
+
+    if (drm == NULL) {
+        jniThrowException(env, "java/lang/IllegalStateException",
+                          "MediaDrm obj is null");
+        return NULL;
+    }
+
+    Vector<uint8_t> secureStop;
+
+    status_t err = drm->getSecureStop(JByteArrayToVector(env, ssid), secureStop);
+
+    if (throwExceptionAsNecessary(env, err, "Failed to get secure stop")) {
+        return NULL;
+    }
+
+    return VectorToJByteArray(env, secureStop);
+}
+
 static void android_media_MediaDrm_releaseSecureStops(
     JNIEnv *env, jobject thiz, jbyteArray jssRelease) {
     sp<IDrm> drm = GetDrm(env, thiz);
@@ -1020,6 +1041,21 @@
     throwExceptionAsNecessary(env, err, "Failed to release secure stops");
 }
 
+static void android_media_MediaDrm_releaseAllSecureStops(
+    JNIEnv *env, jobject thiz) {
+    sp<IDrm> drm = GetDrm(env, thiz);
+
+    if (drm == NULL) {
+        jniThrowException(env, "java/lang/IllegalStateException",
+                          "MediaDrm obj is null");
+        return;
+    }
+
+    status_t err = drm->releaseAllSecureStops();
+
+    throwExceptionAsNecessary(env, err, "Failed to release all secure stops");
+}
+
 static jstring android_media_MediaDrm_getPropertyString(
     JNIEnv *env, jobject thiz, jstring jname) {
     sp<IDrm> drm = GetDrm(env, thiz);
@@ -1384,9 +1420,15 @@
     { "getSecureStops", "()Ljava/util/List;",
       (void *)android_media_MediaDrm_getSecureStops },
 
+    { "getSecureStop", "([B)[B",
+      (void *)android_media_MediaDrm_getSecureStop },
+
     { "releaseSecureStops", "([B)V",
       (void *)android_media_MediaDrm_releaseSecureStops },
 
+    { "releaseAllSecureStops", "()V",
+      (void *)android_media_MediaDrm_releaseAllSecureStops },
+
     { "getPropertyString", "(Ljava/lang/String;)Ljava/lang/String;",
       (void *)android_media_MediaDrm_getPropertyString },
 
diff --git a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java
index c650a0f..09c7165 100644
--- a/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java
+++ b/packages/Keyguard/test/SampleTrustAgent/src/com/android/trustagent/test/SampleTrustAgent.java
@@ -21,7 +21,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
-import android.os.Bundle;
+import android.os.PersistableBundle;
 import android.preference.PreferenceManager;
 import android.service.trust.TrustAgentService;
 import android.support.v4.content.LocalBroadcastManager;
@@ -90,8 +90,15 @@
     }
 
     @Override
-    public boolean onSetTrustAgentFeaturesEnabled(Bundle options) {
-        Log.v(TAG, "Policy options received: " + options.getStringArrayList(KEY_FEATURES));
+    public boolean onConfigure(Configuration config) {
+        if (config != null && config.options != null) {
+           for (int i = 0; i < config.options.size(); i++) {
+               PersistableBundle options = config.options.get(i);
+               Log.v(TAG, "Policy options received: " + options.toString());
+           }
+        } else {
+            Log.w(TAG, "onConfigure() called with no options");
+        }
         // TODO: Handle options
         return true; // inform DPM that we support it
     }
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 6e6f302..51ef0c3 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -63,6 +63,8 @@
 
     <!-- thickness (height) of the navigation bar on phones that require it -->
     <dimen name="navigation_bar_size">@*android:dimen/navigation_bar_height</dimen>
+    <!-- Minimum swipe distance to catch the swipe gestures to invoke assist or switch tasks. -->
+    <dimen name="navigation_bar_min_swipe_distance">48dp</dimen>
 
     <!-- thickness (height) of the dead zone at the top of the navigation bar,
          reducing false presses on navbar buttons; approx 2mm -->
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index 76e8181..be7d322 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -54,7 +54,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /** A proxy implementation for the recents component */
-public class AlternateRecentsComponent {
+public class AlternateRecentsComponent implements ActivityOptions.OnAnimationStartedListener {
 
     final public static String EXTRA_FROM_HOME = "recents.triggeredOverHome";
     final public static String EXTRA_FROM_SEARCH_HOME = "recents.triggeredOverSearchHome";
@@ -62,7 +62,9 @@
     final public static String EXTRA_FROM_TASK_ID = "recents.activeTaskId";
     final public static String EXTRA_TRIGGERED_FROM_ALT_TAB = "recents.triggeredFromAltTab";
     final public static String EXTRA_TRIGGERED_FROM_HOME_KEY = "recents.triggeredFromHomeKey";
+    final public static String EXTRA_REUSE_TASK_STACK_VIEWS = "recents.reuseTaskStackViews";
 
+    final public static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation";
     final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity";
     final public static String ACTION_HIDE_RECENTS_ACTIVITY = "action_hide_recents_activity";
 
@@ -77,7 +79,10 @@
     Context mContext;
     LayoutInflater mInflater;
     SystemServicesProxy mSystemServicesProxy;
+    Handler mHandler;
     boolean mBootCompleted;
+    boolean mStartAnimationTriggered;
+    boolean mCanReuseTaskStackViews = true;
 
     // Task launching
     RecentsConfiguration mConfig;
@@ -103,6 +108,7 @@
         mInflater = LayoutInflater.from(context);
         mContext = context;
         mSystemServicesProxy = new SystemServicesProxy(context);
+        mHandler = new Handler();
         mTaskStackBounds = new Rect();
     }
 
@@ -128,7 +134,7 @@
         }
 
         // When we start, preload the metadata associated with the previous tasks
-        RecentsTaskLoader.getInstance().preload(mContext);
+        RecentsTaskLoader.getInstance().preload(mContext, RecentsTaskLoader.ALL_TASKS);
     }
 
     public void onBootCompleted() {
@@ -176,7 +182,9 @@
     }
 
     public void onPreloadRecents() {
-        // Do nothing
+        // When we start, preload the metadata associated with the previous tasks
+        RecentsTaskLoader.getInstance().preload(mContext,
+                Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount);
     }
 
     public void onCancelPreloadingRecents() {
@@ -186,7 +194,7 @@
     void showRelativeAffiliatedTask(boolean showNextTask) {
         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
         TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(),
-                -1, -1, false, true, null, null);
+                -1, -1, RecentsTaskLoader.ALL_TASKS, false, true, null, null);
         // Return early if there are no tasks
         if (stack.getTaskCount() == 0) return;
 
@@ -251,6 +259,8 @@
     }
 
     public void onConfigurationChanged(Configuration newConfig) {
+        // Don't reuse task stack views if the configuration changes
+        mCanReuseTaskStackViews = false;
         // Reload the header bar layout
         reloadHeaderBarLayout();
     }
@@ -364,23 +374,28 @@
      * Creates the activity options for a unknown state->recents transition.
      */
     ActivityOptions getUnknownTransitionActivityOptions() {
+        mStartAnimationTriggered = false;
         return ActivityOptions.makeCustomAnimation(mContext,
                 R.anim.recents_from_unknown_enter,
-                R.anim.recents_from_unknown_exit);
+                R.anim.recents_from_unknown_exit,
+                mHandler, this);
     }
 
     /**
      * Creates the activity options for a home->recents transition.
      */
     ActivityOptions getHomeTransitionActivityOptions(boolean fromSearchHome) {
+        mStartAnimationTriggered = false;
         if (fromSearchHome) {
             return ActivityOptions.makeCustomAnimation(mContext,
                     R.anim.recents_from_search_launcher_enter,
-                    R.anim.recents_from_search_launcher_exit);
+                    R.anim.recents_from_search_launcher_exit,
+                    mHandler, this);
         }
         return ActivityOptions.makeCustomAnimation(mContext,
                 R.anim.recents_from_launcher_enter,
-                R.anim.recents_from_launcher_exit);
+                R.anim.recents_from_launcher_exit,
+                mHandler, this);
     }
 
     /**
@@ -408,9 +423,10 @@
                 c.setBitmap(null);
             }
 
+            mStartAnimationTriggered = false;
             return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mStatusBarView,
                     thumbnail, toTaskRect.left, toTaskRect.top, toTaskRect.width(),
-                    toTaskRect.height(), null);
+                    toTaskRect.height(), this);
         }
 
         // If both the screenshot and thumbnail fails, then just fall back to the default transition
@@ -423,7 +439,7 @@
         // Get the stack of tasks that we are animating into
         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
         TaskStack stack = loader.getTaskStack(mSystemServicesProxy, mContext.getResources(),
-                runningTaskId, -1, false, isTopTaskHome, null, null);
+                runningTaskId, -1, RecentsTaskLoader.ALL_TASKS, false, isTopTaskHome, null, null);
         if (stack.getTaskCount() == 0) {
             return null;
         }
@@ -529,11 +545,13 @@
         }
         intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab);
         intent.putExtra(EXTRA_FROM_TASK_ID, (topTask != null) ? topTask.id : -1);
+        intent.putExtra(EXTRA_REUSE_TASK_STACK_VIEWS, mCanReuseTaskStackViews);
         if (opts != null) {
             mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT);
         } else {
             mContext.startActivityAsUser(intent, UserHandle.CURRENT);
         }
+        mCanReuseTaskStackViews = true;
     }
 
     /** Sets the RecentsComponent callbacks. */
@@ -547,4 +565,42 @@
             sRecentsComponentCallbacks.onVisibilityChanged(visible);
         }
     }
+
+    /**** OnAnimationStartedListener Implementation ****/
+
+    @Override
+    public void onAnimationStarted() {
+        // Notify recents to start the enter animation
+        if (!mStartAnimationTriggered) {
+            // There can be a race condition between the start animation callback and
+            // the start of the new activity (where we register the receiver that listens
+            // to this broadcast, so we add our own receiver and if that gets called, then
+            // we know the activity has not yet started and we can retry sending the broadcast.
+            BroadcastReceiver fallbackReceiver = new BroadcastReceiver() {
+                @Override
+                public void onReceive(Context context, Intent intent) {
+                    if (getResultCode() == Activity.RESULT_OK) {
+                        mStartAnimationTriggered = true;
+                        return;
+                    }
+
+                    // Schedule for the broadcast to be sent again after some time
+                    mHandler.postDelayed(new Runnable() {
+                        @Override
+                        public void run() {
+                            onAnimationStarted();
+                        }
+                    }, 25);
+                }
+            };
+
+            // Send the broadcast to notify Recents that the animation has started
+            Intent intent = new Intent(ACTION_START_ENTER_ANIMATION);
+            intent.setPackage(mContext.getPackageName());
+            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT |
+                    Intent.FLAG_RECEIVER_FOREGROUND);
+            mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, null,
+                    fallbackReceiver, null, Activity.RESULT_CANCELED, null, null);
+        }
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index d2c55f7..f8d981f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -27,6 +27,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
@@ -142,6 +143,12 @@
             } else if (action.equals(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY)) {
                 // If we are toggling Recents, then first unfilter any filtered stacks first
                 dismissRecentsToFocusedTaskOrHome(true);
+            } else if (action.equals(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION)) {
+                // Trigger the enter animation
+                onEnterAnimationTriggered();
+                // Notify the fallback receiver that we have successfully got the broadcast
+                // See AlternateRecentsComponent.onAnimationStarted()
+                setResultCode(Activity.RESULT_OK);
             }
         }
     };
@@ -157,7 +164,8 @@
                 // When the screen turns off, dismiss Recents to Home
                 dismissRecentsToHome(false);
                 // Start preloading some tasks in the background
-                RecentsTaskLoader.getInstance().preload(RecentsActivity.this);
+                RecentsTaskLoader.getInstance().preload(RecentsActivity.this,
+                        Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount);
             } else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) {
                 // When the search activity changes, update the Search widget
                 refreshSearchWidget();
@@ -188,6 +196,8 @@
                 AlternateRecentsComponent.EXTRA_FROM_TASK_ID, -1);
         mConfig.launchedWithAltTab = launchIntent.getBooleanExtra(
                 AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB, false);
+        mConfig.launchedReuseTaskStackViews = launchIntent.getBooleanExtra(
+                AlternateRecentsComponent.EXTRA_REUSE_TASK_STACK_VIEWS, false);
 
         // Load all the tasks
         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
@@ -397,8 +407,12 @@
 
         // Update if we are getting a configuration change
         if (savedInstanceState != null) {
+            // Update RecentsConfiguration
+            mConfig = RecentsConfiguration.reinitialize(this,
+                    RecentsTaskLoader.getInstance().getSystemServicesProxy());
             mConfig.updateOnConfigurationChange();
-            onConfigurationChange();
+            // Trigger the enter animation
+            onEnterAnimationTriggered();
         }
 
         // Start listening for widget package changes if there is one bound, post it since we don't
@@ -428,19 +442,6 @@
         }
     }
 
-    /** Called when the configuration changes. */
-    void onConfigurationChange() {
-        // Update RecentsConfiguration
-        mConfig = RecentsConfiguration.reinitialize(this,
-                RecentsTaskLoader.getInstance().getSystemServicesProxy());
-
-        // Try and start the enter animation (or restart it on configuration changed)
-        ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null);
-        mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
-        // Animate the SystemUI scrim views
-        mScrimViews.startEnterRecentsAnimation();
-    }
-
     /** Handles changes to the activity visibility. */
     void onRecentsActivityVisibilityChanged(boolean visible) {
         if (!visible) {
@@ -474,6 +475,7 @@
         IntentFilter filter = new IntentFilter();
         filter.addAction(AlternateRecentsComponent.ACTION_HIDE_RECENTS_ACTIVITY);
         filter.addAction(AlternateRecentsComponent.ACTION_TOGGLE_RECENTS_ACTIVITY);
+        filter.addAction(AlternateRecentsComponent.ACTION_START_ENTER_ANIMATION);
         registerReceiver(mServiceBroadcastReceiver, filter);
 
         // Register any broadcast receivers for the task loader
@@ -492,8 +494,8 @@
     protected void onStop() {
         super.onStop();
 
-        // Remove all the views
-        mRecentsView.removeAllTaskStacks();
+        // Notify the views that we are no longer visible
+        mRecentsView.onRecentsHidden();
 
         // Unregister the RecentsService receiver
         unregisterReceiver(mServiceBroadcastReceiver);
@@ -515,8 +517,7 @@
         }
     }
 
-    @Override
-    public void onEnterAnimationComplete() {
+    public void onEnterAnimationTriggered() {
         // Try and start the enter animation (or restart it on configuration changed)
         ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null);
         mRecentsView.startEnterRecentsAnimation(new ViewAnimation.TaskViewEnterContext(t));
@@ -584,7 +585,6 @@
 
     /** Called when debug mode is triggered */
     public void onDebugModeTriggered() {
-
         if (mConfig.developerOptionsEnabled) {
             SharedPreferences settings = getSharedPreferences(getPackageName(), 0);
             if (settings.getBoolean(Constants.Values.App.Key_DebugModeEnabled, false)) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index bfea3f7..e0c76b1 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -115,8 +115,8 @@
     public boolean launchedWithAltTab;
     public boolean launchedWithNoRecentTasks;
     public boolean launchedFromAppWithThumbnail;
-    public boolean launchedFromAppWithScreenshot;
     public boolean launchedFromHome;
+    public boolean launchedReuseTaskStackViews;
     public int launchedToTaskId;
 
     /** Misc **/
@@ -308,6 +308,7 @@
         launchedWithNoRecentTasks = false;
         launchedFromAppWithThumbnail = false;
         launchedFromHome = false;
+        launchedReuseTaskStackViews = false;
         launchedToTaskId = -1;
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java b/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java
index 4456066..735f79f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/DozeTrigger.java
@@ -82,4 +82,9 @@
     public boolean hasTriggered() {
         return mHasTriggered;
     }
+
+    /** Resets the doze trigger state. */
+    public void resetTrigger() {
+        mHasTriggered = false;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
index b4f62d5..390507f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoader.java
@@ -260,6 +260,7 @@
     private static final String TAG = "RecentsTaskLoader";
 
     static RecentsTaskLoader sInstance;
+    public static final int ALL_TASKS = -1;
 
     SystemServicesProxy mSystemServicesProxy;
     DrawableLruCache mApplicationIconCache;
@@ -326,10 +327,9 @@
 
     /** Gets the list of recent tasks, ordered from back to front. */
     private static List<ActivityManager.RecentTaskInfo> getRecentTasks(SystemServicesProxy ssp,
-            boolean isTopTaskHome) {
-        RecentsConfiguration config = RecentsConfiguration.getInstance();
+            int numTasksToLoad, boolean isTopTaskHome) {
         List<ActivityManager.RecentTaskInfo> tasks =
-                ssp.getRecentTasks(config.maxNumTasksToLoad, UserHandle.CURRENT.getIdentifier(),
+                ssp.getRecentTasks(numTasksToLoad, UserHandle.CURRENT.getIdentifier(),
                         isTopTaskHome);
         Collections.reverse(tasks);
         return tasks;
@@ -416,7 +416,8 @@
         ArrayList<Task.TaskKey> taskKeys = new ArrayList<Task.TaskKey>();
         ArrayList<Task> tasksToLoad = new ArrayList<Task>();
         TaskStack stack = getTaskStack(mSystemServicesProxy, context.getResources(),
-                -1, preloadCount, true, isTopTaskHome, taskKeys, tasksToLoad);
+                -1, preloadCount, RecentsTaskLoader.ALL_TASKS, true, isTopTaskHome, taskKeys,
+                tasksToLoad);
         SpaceNode root = new SpaceNode();
         root.setStack(stack);
 
@@ -428,10 +429,10 @@
     }
 
     /** Preloads the set of recent tasks (not including thumbnails). */
-    public void preload(Context context) {
+    public void preload(Context context, int numTasksToPreload) {
         ArrayList<Task> tasksToLoad = new ArrayList<Task>();
         getTaskStack(mSystemServicesProxy, context.getResources(),
-                -1, -1, true, true, null, tasksToLoad);
+                -1, -1, numTasksToPreload, true, true, null, tasksToLoad);
 
         // Start the task loader and add all the tasks we need to load
         mLoadQueue.addTasks(tasksToLoad);
@@ -440,11 +441,13 @@
 
     /** Creates a lightweight stack of the current recent tasks, without thumbnails and icons. */
     public synchronized TaskStack getTaskStack(SystemServicesProxy ssp, Resources res,
-            int preloadTaskId, int preloadTaskCount,
+            int preloadTaskId, int preloadTaskCount, int loadTaskCount,
             boolean loadTaskThumbnails, boolean isTopTaskHome,
             List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) {
         RecentsConfiguration config = RecentsConfiguration.getInstance();
-        List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp, isTopTaskHome);
+        List<ActivityManager.RecentTaskInfo> tasks = getRecentTasks(ssp,
+                (loadTaskCount == ALL_TASKS ? config.maxNumTasksToLoad : loadTaskCount),
+                isTopTaskHome);
         HashMap<Task.ComponentNameKey, ActivityInfoHandle> activityInfoCache =
                 new HashMap<Task.ComponentNameKey, ActivityInfoHandle>();
         ArrayList<Task> tasksToAdd = new ArrayList<Task>();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index ff0330d..81ee839 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -95,42 +95,57 @@
 
     /** Set/get the bsp root node */
     public void setTaskStacks(ArrayList<TaskStack> stacks) {
-        // Remove all TaskStackViews (but leave the search bar)
+        int numStacks = stacks.size();
+
+        // Make a list of the stack view children only
+        ArrayList<TaskStackView> stackViews = new ArrayList<TaskStackView>();
         int childCount = getChildCount();
-        for (int i = childCount - 1; i >= 0; i--) {
-            View v = getChildAt(i);
-            if (v != mSearchBar) {
-                removeViewAt(i);
+        for (int i = 0; i < childCount; i++) {
+            View child = getChildAt(i);
+            if (child != mSearchBar) {
+                stackViews.add((TaskStackView) child);
             }
         }
 
-        // Create and add all the stacks for this partition of space.
+        // Remove all/extra stack views
+        int numTaskStacksToKeep = 0; // Keep no tasks if we are recreating the layout
+        if (mConfig.launchedReuseTaskStackViews) {
+            numTaskStacksToKeep = Math.min(childCount, numStacks);
+        }
+        for (int i = stackViews.size() - 1; i >= numTaskStacksToKeep; i--) {
+            removeView(stackViews.get(i));
+            stackViews.remove(i);
+        }
+
+        // Update the stack views that we are keeping
+        for (int i = 0; i < numTaskStacksToKeep; i++) {
+            stackViews.get(i).setStack(stacks.get(i));
+        }
+
+        // Add remaining/recreate stack views
         mStacks = stacks;
-        int numStacks = mStacks.size();
-        for (int i = 0; i < numStacks; i++) {
-            TaskStack stack = mStacks.get(i);
+        for (int i = stackViews.size(); i < numStacks; i++) {
+            TaskStack stack = stacks.get(i);
             TaskStackView stackView = new TaskStackView(getContext(), stack);
             stackView.setCallbacks(this);
-            // Enable debug mode drawing
-            if (mConfig.debugModeEnabled) {
-                stackView.setDebugOverlay(mDebugOverlay);
-            }
             addView(stackView);
         }
 
+        // Enable debug mode drawing on all the stacks if necessary
+        if (mConfig.debugModeEnabled) {
+            for (int i = childCount - 1; i >= 0; i--) {
+                View v = getChildAt(i);
+                if (v != mSearchBar) {
+                    TaskStackView stackView = (TaskStackView) v;
+                    stackView.setDebugOverlay(mDebugOverlay);
+                }
+            }
+        }
+
         // Reset the launched state
         mAlreadyLaunchingTask = false;
-    }
-
-    /** Removes all the task stack views from this recents view. */
-    public void removeAllTaskStacks() {
-        int childCount = getChildCount();
-        for (int i = childCount - 1; i >= 0; i--) {
-            View child = getChildAt(i);
-            if (child != mSearchBar) {
-                removeViewAt(i);
-            }
-        }
+        // Trigger a new layout
+        requestLayout();
     }
 
     /** Launches the focused task from the first stack if possible */
@@ -529,6 +544,19 @@
         mCb.onAllTaskViewsDismissed();
     }
 
+    /** Final callback after Recents is finally hidden. */
+    public void onRecentsHidden() {
+        // Notify each task stack view
+        int childCount = getChildCount();
+        for (int i = 0; i < childCount; i++) {
+            View child = getChildAt(i);
+            if (child != mSearchBar) {
+                TaskStackView stackView = (TaskStackView) child;
+                stackView.onRecentsHidden();
+            }
+        }
+    }
+
     @Override
     public void onTaskStackFilterTriggered() {
         // Hide the search bar
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index dee26e6..9df0db6 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -40,6 +40,7 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 
 
 /* The visual representation of a task stack view */
@@ -99,25 +100,11 @@
         }
     };
 
-    // A convenience runnable to return all views to the pool
-    Runnable mReturnAllViewsToPoolRunnable = new Runnable() {
-        @Override
-        public void run() {
-            int childCount = getChildCount();
-            for (int i = childCount - 1; i >= 0; i--) {
-                TaskView tv = (TaskView) getChildAt(i);
-                mViewPool.returnViewToPool(tv);
-                // Also hide the view since we don't need it anymore
-                tv.setVisibility(View.INVISIBLE);
-            }
-        }
-    };
-
     public TaskStackView(Context context, TaskStack stack) {
         super(context);
+        // Set the stack first
+        setStack(stack);
         mConfig = RecentsConfiguration.getInstance();
-        mStack = stack;
-        mStack.setCallbacks(this);
         mViewPool = new ViewPool<TaskView, Task>(context, this);
         mInflater = LayoutInflater.from(context);
         mLayoutAlgorithm = new TaskStackViewLayoutAlgorithm(mConfig);
@@ -143,11 +130,62 @@
         mCb = cb;
     }
 
+    /** Sets the task stack */
+    void setStack(TaskStack stack) {
+        // Unset the old stack
+        if (mStack != null) {
+            mStack.setCallbacks(null);
+
+            // Return all existing views to the pool
+            reset();
+            // Layout again with the new stack
+            requestLayout();
+        }
+
+        // Set the new stack
+        mStack = stack;
+        if (mStack != null) {
+            mStack.setCallbacks(this);
+        }
+    }
+
     /** Sets the debug overlay */
     public void setDebugOverlay(DebugOverlayView overlay) {
         mDebugOverlay = overlay;
     }
 
+    /** Resets this TaskStackView for reuse. */
+    void reset() {
+        // Return all the views to the pool
+        int childCount = getChildCount();
+        for (int i = childCount - 1; i >= 0; i--) {
+            TaskView tv = (TaskView) getChildAt(i);
+            mViewPool.returnViewToPool(tv);
+        }
+
+        // Mark each task view for relayout
+        if (mViewPool != null) {
+            Iterator<TaskView> iter = mViewPool.poolViewIterator();
+            if (iter != null) {
+                while (iter.hasNext()) {
+                    TaskView tv = iter.next();
+                    tv.reset();
+                }
+            }
+        }
+
+        // Reset the stack state
+        resetFocusedTask();
+        mStackViewsDirty = true;
+        mStackViewsClipDirty = true;
+        mAwaitingFirstLayout = true;
+        mPrevAccessibilityFocusedIndex = -1;
+        if (mUIDozeTrigger != null) {
+            mUIDozeTrigger.stopDozing();
+            mUIDozeTrigger.resetTrigger();
+        }
+    }
+
     /** Requests that the views be synchronized with the model */
     void requestSynchronizeStackViewsWithModel() {
         requestSynchronizeStackViewsWithModel(0);
@@ -510,6 +548,16 @@
         tv.dismissTask();
     }
 
+    /** Resets the focused task. */
+    void resetFocusedTask() {
+        if (mFocusedTaskIndex > -1) {
+            Task t = mStack.getTasks().get(mFocusedTaskIndex);
+            TaskView tv = getChildViewForTask(t);
+            tv.unsetFocusedTask();
+        }
+        mFocusedTaskIndex = -1;
+    }
+
     @Override
     public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
         super.onInitializeAccessibilityEvent(event);
@@ -543,6 +591,8 @@
 
     @Override
     public void computeScroll() {
+        if (mStack == null) return;
+
         mStackScroller.computeScroll();
         // Synchronize the views
         synchronizeStackViewsWithModel();
@@ -758,9 +808,6 @@
             TaskView tv = (TaskView) getChildAt(i);
             tv.startExitToHomeAnimation(ctx);
         }
-
-        // Add a runnable to the post animation ref counter to clear all the views
-        ctx.postAnimationTrigger.addLastDecrementRunnable(mReturnAllViewsToPoolRunnable);
     }
 
     /** Animates a task view in this stack as it launches. */
@@ -780,6 +827,12 @@
         }
     }
 
+    /** Final callback after Recents is finally hidden. */
+    void onRecentsHidden() {
+        reset();
+        setStack(null);
+    }
+
     public boolean isTransformedTouchPointInView(float x, float y, View child) {
         return isTransformedTouchPointInView(x, y, child, null);
     }
@@ -944,20 +997,23 @@
 
         // Reset the view properties
         tv.resetViewProperties();
+
+        // Reset the clip state of the task view
+        tv.setClipViewInStack(false);
     }
 
     @Override
     public void prepareViewToLeavePool(TaskView tv, Task task, boolean isNewView) {
+        // It is possible for a view to be returned to the view pool before it is laid out,
+        // which means that we will need to relayout the view when it is first used next.
+        boolean requiresRelayout = tv.getWidth() <= 0 && !isNewView;
+
         // Rebind the task and request that this task's data be filled into the TaskView
         tv.onTaskBound(task);
 
         // Load the task data
         RecentsTaskLoader.getInstance().loadTaskData(task);
 
-        // Sanity check, the task view should always be clipping against the stack at this point,
-        // but just in case, re-enable it here
-        tv.setClipViewInStack(true);
-
         // If the doze trigger has already fired, then update the state for this task view
         if (mUIDozeTrigger.hasTriggered()) {
             tv.setNoUserInteractionState();
@@ -985,13 +1041,17 @@
         // Add/attach the view to the hierarchy
         if (isNewView) {
             addView(tv, insertIndex);
-
-            // Set the callbacks and listeners for this new view
-            tv.setTouchEnabled(true);
-            tv.setCallbacks(this);
         } else {
             attachViewToParent(tv, insertIndex, tv.getLayoutParams());
+            if (requiresRelayout) {
+                tv.requestLayout();
+            }
         }
+
+        // Set the new state for this view, including the callbacks and view clipping
+        tv.setCallbacks(this);
+        tv.setTouchEnabled(true);
+        tv.setClipViewInStack(true);
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index 7b4e10a..790130a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -112,6 +112,14 @@
         mCb = cb;
     }
 
+    /** Resets this TaskView for reuse. */
+    void reset() {
+        resetViewProperties();
+        resetNoUserInteractionState();
+        setClipViewInStack(false);
+        setCallbacks(null);
+    }
+
     /** Gets the task */
     Task getTask() {
         return mTask;
@@ -191,6 +199,7 @@
     /** Resets this view's properties */
     void resetViewProperties() {
         setDim(0);
+        setLayerType(View.LAYER_TYPE_NONE, null);
         TaskViewTransform.reset(this);
     }
 
@@ -448,6 +457,11 @@
         mHeaderView.setNoUserInteractionState();
     }
 
+    /** Resets the state tracking that the user has not interacted with the stack after a certain time. */
+    void resetNoUserInteractionState() {
+        mHeaderView.resetNoUserInteractionState();
+    }
+
     /** Dismisses this task. */
     void dismissTask() {
         // Animate out the view and call the callback
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
index ba868f5..5de84bd 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewHeader.java
@@ -263,6 +263,11 @@
         }
     }
 
+    /** Resets the state tracking that the user has not interacted with the stack after a certain time. */
+    void resetNoUserInteractionState() {
+        mDismissButton.setVisibility(View.INVISIBLE);
+    }
+
     @Override
     protected int[] onCreateDrawableState(int extraSpace) {
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java b/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java
index af0094e..12b91af 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/ViewPool.java
@@ -75,4 +75,12 @@
         mViewCreator.prepareViewToLeavePool(v, prepareData, isNewView);
         return v;
     }
+
+    /** Returns an iterator to the list of the views in the pool. */
+    Iterator<V> poolViewIterator() {
+        if (mPool != null) {
+            return mPool.iterator();
+        }
+        return null;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 7bbf9e2..725a1a8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -59,7 +59,6 @@
 import android.service.notification.StatusBarNotification;
 import android.text.TextUtils;
 import android.util.Log;
-import android.util.Slog;
 import android.util.SparseArray;
 import android.util.SparseBooleanArray;
 import android.view.Display;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
index 628aab8..7ae6764 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/DelegateViewHelper.java
@@ -17,10 +17,11 @@
 package com.android.systemui.statusbar;
 
 import android.app.StatusBarManager;
+import android.content.res.Resources;
 import android.graphics.RectF;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.ViewConfiguration;
+import com.android.systemui.R;
 
 public class DelegateViewHelper {
     private View mDelegateView;
@@ -106,8 +107,8 @@
     public void setSourceView(View view) {
         mSourceView = view;
         if (mSourceView != null) {
-            mTriggerThreshhold =
-                    ViewConfiguration.get(mSourceView.getContext()).getScaledPagingTouchSlop();
+            Resources r = mSourceView.getContext().getResources();
+            mTriggerThreshhold = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
         }
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index a4e5e74..f8332ea 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -22,6 +22,7 @@
 import android.graphics.drawable.Drawable;
 import android.service.notification.StatusBarNotification;
 import android.util.AttributeSet;
+import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewStub;
 import android.view.accessibility.AccessibilityEvent;
@@ -68,6 +69,7 @@
     private NotificationGuts mGuts;
 
     private StatusBarNotification mStatusBarNotification;
+    private boolean mIsHeadsUp;
 
     public void setIconAnimationRunning(boolean running) {
         setIconAnimationRunning(running, mPublicLayout);
@@ -122,6 +124,10 @@
         return mStatusBarNotification;
     }
 
+    public void setHeadsUp(boolean isHeadsUp) {
+        mIsHeadsUp = isHeadsUp;
+    }
+
     public interface ExpansionLogger {
         public void logNotificationExpansion(String key, boolean userAction, boolean expanded);
     }
@@ -147,14 +153,16 @@
         mShowingPublicInitialized = false;
         mIsSystemExpanded = false;
         mExpansionDisabled = false;
-        mPublicLayout.reset();
-        mPrivateLayout.reset();
+        mPublicLayout.reset(mIsHeadsUp);
+        mPrivateLayout.reset(mIsHeadsUp);
         resetHeight();
         logExpansionEvent(false, wasExpanded);
     }
 
     public void resetHeight() {
-        super.resetHeight();
+        if (mIsHeadsUp) {
+            resetActualHeight();
+        }
         mMaxExpandHeight = 0;
         mWasReset = true;
         onHeightReset();
@@ -162,6 +170,11 @@
     }
 
     @Override
+    protected boolean filterMotionEvent(MotionEvent event) {
+        return mIsHeadsUp || super.filterMotionEvent(event);
+    }
+
+    @Override
     protected void onFinishInflate() {
         super.onFinishInflate();
         mPublicLayout = (NotificationContentView) findViewById(R.id.expandedPublic);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index edfbe86..bf1e78e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -103,9 +103,13 @@
         }
     }
 
-    protected void resetHeight() {
+    /**
+     * Resets the height of the view on the next layout pass
+     */
+    protected void resetActualHeight() {
         mActualHeight = 0;
         mActualHeightInitialized = false;
+        requestLayout();
     }
 
     protected int getInitialHeight() {
@@ -120,7 +124,7 @@
         return false;
     }
 
-    private boolean filterMotionEvent(MotionEvent event) {
+    protected boolean filterMotionEvent(MotionEvent event) {
         return event.getActionMasked() != MotionEvent.ACTION_DOWN
                 || event.getY() > mClipTopAmount && event.getY() < mActualHeight;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 992aa9f..58067c3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -146,8 +146,8 @@
         try {
             long chargingTimeRemaining = mBatteryInfo.computeChargeTimeRemaining();
             if (chargingTimeRemaining > 0) {
-                String chargingTimeFormatted =
-                        Formatter.formatShortElapsedTime(mContext, chargingTimeRemaining);
+                String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes(
+                        mContext, chargingTimeRemaining);
                 return mContext.getResources().getString(
                         R.string.keyguard_indication_charging_time, chargingTimeFormatted);
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 9b11f9b..99214a0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -74,7 +74,7 @@
     public NotificationContentView(Context context, AttributeSet attrs) {
         super(context, attrs);
         mFadePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
-        reset();
+        reset(true);
     }
 
     @Override
@@ -89,7 +89,7 @@
         updateVisibility();
     }
 
-    public void reset() {
+    public void reset(boolean resetActualHeight) {
         if (mContractedChild != null) {
             mContractedChild.animate().cancel();
         }
@@ -100,8 +100,10 @@
         mContractedChild = null;
         mExpandedChild = null;
         mSmallHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
-        mActualHeight = mSmallHeight;
         mContractedVisible = true;
+        if (resetActualHeight) {
+            mActualHeight = mSmallHeight;
+        }
     }
 
     public View getContractedChild() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index 9bb52e7..1e4dfb4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -21,6 +21,7 @@
 import android.animation.ObjectAnimator;
 import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
+import android.app.ActivityManagerNative;
 import android.app.StatusBarManager;
 import android.content.Context;
 import android.content.res.Configuration;
@@ -30,6 +31,7 @@
 import android.graphics.drawable.Drawable;
 import android.os.Handler;
 import android.os.Message;
+import android.os.RemoteException;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.Display;
@@ -43,6 +45,7 @@
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+
 import com.android.systemui.R;
 import com.android.systemui.statusbar.BaseStatusBar;
 import com.android.systemui.statusbar.DelegateViewHelper;
@@ -332,7 +335,7 @@
         mDisabledFlags = disabledFlags;
 
         final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
-        final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
+        boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
         final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)
                 && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
         final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);
@@ -357,6 +360,11 @@
                 }
             }
         }
+        if (inLockTask() && disableRecent && !disableHome) {
+            // Don't hide recents when in lock task, it is used for exiting.
+            // Unless home is hidden, then in DPM locked mode and no exit available.
+            disableRecent = false;
+        }
 
         getBackButton()   .setVisibility(disableBack       ? View.INVISIBLE : View.VISIBLE);
         getHomeButton()   .setVisibility(disableHome       ? View.INVISIBLE : View.VISIBLE);
@@ -365,6 +373,14 @@
         mBarTransitions.applyBackButtonQuiescentAlpha(mBarTransitions.getMode(), true /*animate*/);
     }
 
+    private boolean inLockTask() {
+        try {
+            return ActivityManagerNative.getDefault().isInLockTaskMode();
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+
     private void setVisibleOrGone(View view, boolean visible) {
         if (view != null) {
             view.setVisibility(visible ? VISIBLE : GONE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper.java
index c253e19..fdfcdfb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarViewTaskSwitchHelper.java
@@ -17,9 +17,11 @@
 package com.android.systemui.statusbar.phone;
 
 import android.content.Context;
+import android.content.res.Resources;
 import android.view.GestureDetector;
 import android.view.MotionEvent;
 import android.view.ViewConfiguration;
+import com.android.systemui.R;
 import com.android.systemui.statusbar.BaseStatusBar;
 
 public class NavigationBarViewTaskSwitchHelper extends GestureDetector.SimpleOnGestureListener {
@@ -36,7 +38,8 @@
 
     public NavigationBarViewTaskSwitchHelper(Context context) {
         ViewConfiguration configuration = ViewConfiguration.get(context);
-        mScrollTouchSlop = 4 * configuration.getScaledTouchSlop();
+        Resources r = context.getResources();
+        mScrollTouchSlop = r.getDimensionPixelSize(R.dimen.navigation_bar_min_swipe_distance);
         mMinFlingVelocity = configuration.getScaledMinimumFlingVelocity();
         mTaskSwitcherDetector = new GestureDetector(context, this);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 84ebcdf..5928845 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3968,6 +3968,8 @@
                 // long-pressed 'together'
                 if ((time - mLastLockToAppLongPress) < LOCK_TO_APP_GESTURE_TOLERENCE) {
                     activityManager.stopLockTaskModeOnCurrent();
+                    // When exiting refresh disabled flags.
+                    mNavigationBarView.setDisabledFlags(mDisabled, true);
                 } else if ((v.getId() == R.id.back)
                         && !mNavigationBarView.getRecentsButton().isPressed()) {
                     // If we aren't pressing recents right now then they presses
@@ -3983,6 +3985,8 @@
                     // When in accessibility mode a long press that is recents (not back)
                     // should stop lock task.
                     activityManager.stopLockTaskModeOnCurrent();
+                    // When exiting refresh disabled flags.
+                    mNavigationBarView.setDisabledFlags(mDisabled, true);
                 }
             }
             if (sendBackLongPress) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
index 84216a4..11ff272 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpNotificationView.java
@@ -54,7 +54,6 @@
     private EdgeSwipeHelper mEdgeSwipeHelper;
 
     private PhoneStatusBar mBar;
-    private ExpandHelper mExpandHelper;
 
     private long mStartTouchTime;
     private ViewGroup mContentHolder;
@@ -102,6 +101,7 @@
         if (mHeadsUp != null) {
             mHeadsUp.row.setSystemExpanded(true);
             mHeadsUp.row.setSensitive(false);
+            mHeadsUp.row.setHeadsUp(true);
             mHeadsUp.row.setHideSensitive(
                     false, false /* animated */, 0 /* delay */, 0 /* duration */);
             if (mContentHolder == null) {
@@ -205,7 +205,6 @@
 
         int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_min_height);
         int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_max_height);
-        mExpandHelper = new ExpandHelper(getContext(), this, minHeight, maxHeight);
 
         mContentHolder = (ViewGroup) findViewById(R.id.content_holder);
         mContentHolder.setOutlineProvider(CONTENT_HOLDER_OUTLINE_PROVIDER);
@@ -226,7 +225,6 @@
         }
         return mEdgeSwipeHelper.onInterceptTouchEvent(ev)
                 || mSwipeHelper.onInterceptTouchEvent(ev)
-                || mExpandHelper.onInterceptTouchEvent(ev)
                 || super.onInterceptTouchEvent(ev);
     }
 
@@ -254,7 +252,6 @@
         mBar.resetHeadsUpDecayTimer();
         return mEdgeSwipeHelper.onTouchEvent(ev)
                 || mSwipeHelper.onTouchEvent(ev)
-                || mExpandHelper.onTouchEvent(ev)
                 || super.onTouchEvent(ev);
     }
 
@@ -399,15 +396,12 @@
                     final float dY = ev.getY() - mFirstY;
                     final float daX = Math.abs(ev.getX() - mFirstX);
                     final float daY = Math.abs(dY);
-                    if (!mConsuming && (4f * daX) < daY && daY > mTouchSlop) {
+                    if (!mConsuming && daX < daY && daY > mTouchSlop) {
+                        releaseAndClose();
                         if (dY > 0) {
                             if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found an open");
                             mBar.animateExpandNotificationsPanel();
                         }
-                        if (dY < 0) {
-                            if (DEBUG_EDGE_SWIPE) Log.d(TAG, "found a close");
-                            mBar.onHeadsUpDismissed();
-                        }
                         mConsuming = true;
                     }
                     break;
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index a2d246d..1d4d671 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -184,7 +184,8 @@
 /**
  * @hide
  */
-public class ConnectivityService extends IConnectivityManager.Stub {
+public class ConnectivityService extends IConnectivityManager.Stub
+        implements PendingIntent.OnFinished {
     private static final String TAG = "ConnectivityService";
 
     private static final boolean DBG = true;
@@ -382,6 +383,19 @@
      */
     private static final int EVENT_SYSTEM_READY = 25;
 
+    /**
+     * used to add a network request with a pending intent
+     * includes a NetworkRequestInfo
+     */
+    private static final int EVENT_REGISTER_NETWORK_REQUEST_WITH_INTENT = 26;
+
+    /**
+     * used to remove a pending intent and its associated network request.
+     * arg1 = UID of caller
+     * obj  = PendingIntent
+     */
+    private static final int EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT = 27;
+
 
     /** Handler used for internal events. */
     final private InternalHandler mHandler;
@@ -395,6 +409,7 @@
     private String mNetTransitionWakeLockCausedBy = "";
     private int mNetTransitionWakeLockSerialNumber;
     private int mNetTransitionWakeLockTimeout;
+    private final PowerManager.WakeLock mPendingIntentWakeLock;
 
     private InetAddress mDefaultDns;
 
@@ -649,6 +664,7 @@
         mNetTransitionWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
         mNetTransitionWakeLockTimeout = mContext.getResources().getInteger(
                 com.android.internal.R.integer.config_networkTransitionTimeout);
+        mPendingIntentWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
 
         mNetTrackers = new NetworkStateTracker[
                 ConnectivityManager.MAX_NETWORK_TYPE+1];
@@ -2131,11 +2147,40 @@
         }
     }
 
+    // If this method proves to be too slow then we can maintain a separate
+    // pendingIntent => NetworkRequestInfo map.
+    // This method assumes that every non-null PendingIntent maps to exactly 1 NetworkRequestInfo.
+    private NetworkRequestInfo findExistingNetworkRequestInfo(PendingIntent pendingIntent) {
+        Intent intent = pendingIntent.getIntent();
+        for (Map.Entry<NetworkRequest, NetworkRequestInfo> entry : mNetworkRequests.entrySet()) {
+            PendingIntent existingPendingIntent = entry.getValue().mPendingIntent;
+            if (existingPendingIntent != null &&
+                    existingPendingIntent.getIntent().filterEquals(intent)) {
+                return entry.getValue();
+            }
+        }
+        return null;
+    }
+
+    private void handleRegisterNetworkRequestWithIntent(Message msg) {
+        final NetworkRequestInfo nri = (NetworkRequestInfo) (msg.obj);
+
+        NetworkRequestInfo existingRequest = findExistingNetworkRequestInfo(nri.mPendingIntent);
+        if (existingRequest != null) { // remove the existing request.
+            if (DBG) log("Replacing " + existingRequest.request + " with "
+                    + nri.request + " because their intents matched.");
+            handleReleaseNetworkRequest(existingRequest.request, getCallingUid());
+        }
+        handleRegisterNetworkRequest(msg);
+    }
+
     private void handleRegisterNetworkRequest(Message msg) {
         final NetworkRequestInfo nri = (NetworkRequestInfo) (msg.obj);
         final NetworkCapabilities newCap = nri.request.networkCapabilities;
         int score = 0;
 
+        mNetworkRequests.put(nri.request, nri);
+
         // Check for the best currently alive network that satisfies this request
         NetworkAgentInfo bestNetwork = null;
         for (NetworkAgentInfo network : mNetworkAgentInfos.values()) {
@@ -2173,7 +2218,7 @@
                 mLegacyTypeTracker.add(nri.request.legacyType, bestNetwork);
             }
         }
-        mNetworkRequests.put(nri.request, nri);
+
         if (nri.isRequest) {
             if (DBG) log("sending new NetworkRequest to factories");
             for (NetworkFactoryInfo nfi : mNetworkFactoryInfos.values()) {
@@ -2183,6 +2228,14 @@
         }
     }
 
+    private void handleReleaseNetworkRequestWithIntent(PendingIntent pendingIntent,
+            int callingUid) {
+        NetworkRequestInfo nri = findExistingNetworkRequestInfo(pendingIntent);
+        if (nri != null) {
+            handleReleaseNetworkRequest(nri.request, callingUid);
+        }
+    }
+
     private void handleReleaseNetworkRequest(NetworkRequest request, int callingUid) {
         NetworkRequestInfo nri = mNetworkRequests.get(request);
         if (nri != null) {
@@ -2218,11 +2271,11 @@
                     }
                 }
 
-                // Maintain the illusion.  When this request arrived, we might have preteneded
+                // Maintain the illusion.  When this request arrived, we might have pretended
                 // that a network connected to serve it, even though the network was already
                 // connected.  Now that this request has gone away, we might have to pretend
                 // that the network disconnected.  LegacyTypeTracker will generate that
-                // phatom disconnect for this type.
+                // phantom disconnect for this type.
                 NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
                 if (nai != null) {
                     mNetworkForRequestId.remove(nri.request.requestId);
@@ -2253,7 +2306,6 @@
 
         @Override
         public void handleMessage(Message msg) {
-            NetworkInfo info;
             switch (msg.what) {
                 case EVENT_EXPIRE_NET_TRANSITION_WAKELOCK:
                 case EVENT_CLEAR_NET_TRANSITION_WAKELOCK: {
@@ -2334,6 +2386,14 @@
                     handleRegisterNetworkRequest(msg);
                     break;
                 }
+                case EVENT_REGISTER_NETWORK_REQUEST_WITH_INTENT: {
+                    handleRegisterNetworkRequestWithIntent(msg);
+                    break;
+                }
+                case EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT: {
+                    handleReleaseNetworkRequestWithIntent((PendingIntent) msg.obj, msg.arg1);
+                    break;
+                }
                 case EVENT_RELEASE_NETWORK_REQUEST: {
                     handleReleaseNetworkRequest((NetworkRequest) msg.obj, msg.arg1);
                     break;
@@ -3347,12 +3407,23 @@
         static final boolean LISTEN = false;
 
         final NetworkRequest request;
-        IBinder mBinder;
+        final PendingIntent mPendingIntent;
+        private final IBinder mBinder;
         final int mPid;
         final int mUid;
         final Messenger messenger;
         final boolean isRequest;
 
+        NetworkRequestInfo(NetworkRequest r, PendingIntent pi, boolean isRequest) {
+            request = r;
+            mPendingIntent = pi;
+            messenger = null;
+            mBinder = null;
+            mPid = getCallingPid();
+            mUid = getCallingUid();
+            this.isRequest = isRequest;
+        }
+
         NetworkRequestInfo(Messenger m, NetworkRequest r, IBinder binder, boolean isRequest) {
             super();
             messenger = m;
@@ -3361,6 +3432,7 @@
             mPid = getCallingPid();
             mUid = getCallingUid();
             this.isRequest = isRequest;
+            mPendingIntent = null;
 
             try {
                 mBinder.linkToDeath(this, 0);
@@ -3370,7 +3442,9 @@
         }
 
         void unlinkDeathRecipient() {
-            mBinder.unlinkToDeath(this, 0);
+            if (mBinder != null) {
+                mBinder.unlinkToDeath(this, 0);
+            }
         }
 
         public void binderDied() {
@@ -3381,40 +3455,22 @@
 
         public String toString() {
             return (isRequest ? "Request" : "Listen") + " from uid/pid:" + mUid + "/" +
-                    mPid + " for " + request;
+                    mPid + " for " + request +
+                    (mPendingIntent == null ? "" : " to trigger " + mPendingIntent);
         }
     }
 
     @Override
     public NetworkRequest requestNetwork(NetworkCapabilities networkCapabilities,
             Messenger messenger, int timeoutMs, IBinder binder, int legacyType) {
-        if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
-                == false) {
-            enforceConnectivityInternalPermission();
-        } else {
-            enforceChangePermission();
-        }
-
         networkCapabilities = new NetworkCapabilities(networkCapabilities);
-
-        // if UID is restricted, don't allow them to bring up metered APNs
-        if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)
-                == false) {
-            final int uidRules;
-            final int uid = Binder.getCallingUid();
-            synchronized(mRulesLock) {
-                uidRules = mUidRules.get(uid, RULE_ALLOW_ALL);
-            }
-            if ((uidRules & RULE_REJECT_METERED) != 0) {
-                // we could silently fail or we can filter the available nets to only give
-                // them those they have access to.  Chose the more useful
-                networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
-            }
-        }
+        enforceNetworkRequestPermissions(networkCapabilities);
+        enforceMeteredApnPolicy(networkCapabilities);
 
         if (timeoutMs < 0 || timeoutMs > ConnectivityManager.MAX_NETWORK_REQUEST_TIMEOUT_MS) {
             throw new IllegalArgumentException("Bad timeout specified");
         }
+
         NetworkRequest networkRequest = new NetworkRequest(networkCapabilities, legacyType,
                 nextNetworkRequestId());
         if (DBG) log("requestNetwork for " + networkRequest);
@@ -3429,11 +3485,54 @@
         return networkRequest;
     }
 
+    private void enforceNetworkRequestPermissions(NetworkCapabilities networkCapabilities) {
+        if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
+                == false) {
+            enforceConnectivityInternalPermission();
+        } else {
+            enforceChangePermission();
+        }
+    }
+
+    private void enforceMeteredApnPolicy(NetworkCapabilities networkCapabilities) {
+        // if UID is restricted, don't allow them to bring up metered APNs
+        if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)
+                == false) {
+            final int uidRules;
+            final int uid = Binder.getCallingUid();
+            synchronized(mRulesLock) {
+                uidRules = mUidRules.get(uid, RULE_ALLOW_ALL);
+            }
+            if ((uidRules & RULE_REJECT_METERED) != 0) {
+                // we could silently fail or we can filter the available nets to only give
+                // them those they have access to.  Chose the more useful
+                networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
+            }
+        }
+    }
+
     @Override
     public NetworkRequest pendingRequestForNetwork(NetworkCapabilities networkCapabilities,
             PendingIntent operation) {
-        // TODO
-        return null;
+        checkNotNull(operation, "PendingIntent cannot be null.");
+        networkCapabilities = new NetworkCapabilities(networkCapabilities);
+        enforceNetworkRequestPermissions(networkCapabilities);
+        enforceMeteredApnPolicy(networkCapabilities);
+
+        NetworkRequest networkRequest = new NetworkRequest(networkCapabilities, TYPE_NONE,
+                nextNetworkRequestId());
+        if (DBG) log("pendingRequest for " + networkRequest + " to trigger " + operation);
+        NetworkRequestInfo nri = new NetworkRequestInfo(networkRequest, operation,
+                NetworkRequestInfo.REQUEST);
+        mHandler.sendMessage(mHandler.obtainMessage(EVENT_REGISTER_NETWORK_REQUEST_WITH_INTENT,
+                nri));
+        return networkRequest;
+    }
+
+    @Override
+    public void releasePendingNetworkRequest(PendingIntent operation) {
+        mHandler.sendMessage(mHandler.obtainMessage(EVENT_RELEASE_NETWORK_REQUEST_WITH_INTENT,
+                getCallingUid(), 0, operation));
     }
 
     @Override
@@ -3727,6 +3826,39 @@
         }
     }
 
+    private void sendPendingIntentForRequest(NetworkRequestInfo nri, NetworkAgentInfo networkAgent,
+            int notificationType) {
+        if (notificationType == ConnectivityManager.CALLBACK_AVAILABLE) {
+            Intent intent = new Intent();
+            intent.putExtra(ConnectivityManager.EXTRA_NETWORK_REQUEST_NETWORK, nri.request);
+            intent.putExtra(ConnectivityManager.EXTRA_NETWORK_REQUEST_NETWORK_REQUEST,
+                    networkAgent.network);
+            sendIntent(nri.mPendingIntent, intent);
+        }
+        // else not handled
+    }
+
+    private void sendIntent(PendingIntent pendingIntent, Intent intent) {
+        mPendingIntentWakeLock.acquire();
+        try {
+            if (DBG) log("Sending " + pendingIntent);
+            pendingIntent.send(mContext, 0, intent, this /* onFinished */, null /* Handler */);
+        } catch (PendingIntent.CanceledException e) {
+            if (DBG) log(pendingIntent + " was not sent, it had been canceled.");
+            mPendingIntentWakeLock.release();
+            releasePendingNetworkRequest(pendingIntent);
+        }
+        // ...otherwise, mPendingIntentWakeLock.release() gets called by onSendFinished()
+    }
+
+    @Override
+    public void onSendFinished(PendingIntent pendingIntent, Intent intent, int resultCode,
+            String resultData, Bundle resultExtras) {
+        if (DBG) log("Finished sending " + pendingIntent);
+        mPendingIntentWakeLock.release();
+        releasePendingNetworkRequest(pendingIntent);
+    }
+
     private void callCallbackForRequest(NetworkRequestInfo nri,
             NetworkAgentInfo networkAgent, int notificationType) {
         if (nri.messenger == null) return;  // Default request has no msgr
@@ -4137,7 +4269,11 @@
 //        } else if (nai.networkMonitor.isEvaluating()) {
 //            notifyType = NetworkCallbacks.callCallbackForRequest(request, nai, notifyType);
 //        }
-        callCallbackForRequest(nri, nai, notifyType);
+        if (nri.mPendingIntent == null) {
+            callCallbackForRequest(nri, nai, notifyType);
+        } else {
+            sendPendingIntentForRequest(nri, nai, notifyType);
+        }
     }
 
     private void sendLegacyNetworkBroadcast(NetworkAgentInfo nai, boolean connected, int type) {
@@ -4196,7 +4332,11 @@
             NetworkRequest nr = networkAgent.networkRequests.valueAt(i);
             NetworkRequestInfo nri = mNetworkRequests.get(nr);
             if (VDBG) log(" sending notification for " + nr);
-            callCallbackForRequest(nri, networkAgent, notifyType);
+            if (nri.mPendingIntent == null) {
+                callCallbackForRequest(nri, networkAgent, notifyType);
+            } else {
+                sendPendingIntentForRequest(nri, networkAgent, notifyType);
+            }
         }
     }
 
diff --git a/services/core/java/com/android/server/NativeDaemonConnector.java b/services/core/java/com/android/server/NativeDaemonConnector.java
index 96f9ab0..8c3b020 100644
--- a/services/core/java/com/android/server/NativeDaemonConnector.java
+++ b/services/core/java/com/android/server/NativeDaemonConnector.java
@@ -176,7 +176,6 @@
                     if (buffer[i] == 0) {
                         final String rawEvent = new String(
                                 buffer, start, i - start, StandardCharsets.UTF_8);
-                        log("RCV <- {" + rawEvent + "}");
 
                         boolean releaseWl = false;
                         try {
@@ -197,7 +196,6 @@
                                 mResponseQueue.add(event.getCmdNumber(), event);
                             }
                         } catch (IllegalArgumentException e) {
-                            log("Problem parsing message: " + rawEvent + " - " + e);
                         } finally {
                             if (releaseWl) {
                                 mWakeLock.acquire();
@@ -209,7 +207,6 @@
                 }
                 if (start == 0) {
                     final String rawEvent = new String(buffer, start, count, StandardCharsets.UTF_8);
-                    log("RCV incomplete <- {" + rawEvent + "}");
                 }
 
                 // We should end at the amount we read. If not, compact then
diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java
index bb91a14..738917f 100644
--- a/services/core/java/com/android/server/NetworkScoreService.java
+++ b/services/core/java/com/android/server/NetworkScoreService.java
@@ -130,7 +130,16 @@
 
     @Override
     public boolean setActiveScorer(String packageName) {
-        mContext.enforceCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED, TAG);
+        // TODO: For now, since SCORE_NETWORKS requires an app to be privileged, we allow such apps
+        // to directly set the scorer app rather than having to use the consent dialog. The
+        // assumption is that anyone bundling a scorer app with the system is trusted by the OEM to
+        // do the right thing and not enable this feature without explaining it to the user.
+        // In the future, should this API be opened to 3p apps, we will need to lock this down and
+        // figure out another way to streamline the UX.
+
+        // mContext.enforceCallingOrSelfPermission(permission.BROADCAST_NETWORK_PRIVILEGED, TAG);
+        mContext.enforceCallingOrSelfPermission(permission.SCORE_NETWORKS, TAG);
+
         return setScorerInternal(packageName);
     }
 
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index fcc5339..ba93213 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -596,7 +596,7 @@
                                 + " phoneId=" + phoneId + " state=" + state);
                     }
                     if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             if (DBG) {
                                 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
@@ -641,7 +641,7 @@
                                 + " phoneId=" + phoneId + " ss=" + signalStrength);
                     }
                     if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             if (DBG) {
                                 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
@@ -654,7 +654,7 @@
                         }
                     }
                     if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) &&
-                            subIdMatch(r.subId, subId)){
+                            idMatch(r.subId, subId, phoneId)){
                         try {
                             int gsmSignalStrength = signalStrength.getGsmSignalStrength();
                             int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
@@ -696,7 +696,7 @@
                 mCellInfo.set(phoneId, cellInfo);
                 for (Record r : mRecords) {
                     if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             if (DBG_LOC) {
                                 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
@@ -751,7 +751,7 @@
                 mMessageWaiting[phoneId] = mwi;
                 for (Record r : mRecords) {
                     if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             r.callback.onMessageWaitingIndicatorChanged(mwi);
                         } catch (RemoteException ex) {
@@ -782,7 +782,7 @@
                 mCallForwarding[phoneId] = cfi;
                 for (Record r : mRecords) {
                     if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             r.callback.onCallForwardingIndicatorChanged(cfi);
                         } catch (RemoteException ex) {
@@ -879,7 +879,7 @@
                 }
                 for (Record r : mRecords) {
                     if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             log("Notify data connection state changed on sub: " +
                                     subId);
@@ -965,7 +965,7 @@
                 mCellLocation[phoneId] = cellLocation;
                 for (Record r : mRecords) {
                     if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
-                            subIdMatch(r.subId, subId)) {
+                            idMatch(r.subId, subId, phoneId)) {
                         try {
                             if (DBG_LOC) {
                                 log("notifyCellLocation: cellLocation=" + cellLocation
@@ -1386,7 +1386,7 @@
 
         @Override
         public String toString() {
-            return mS + " " + mTime.toString() + " " + mSubId + " " + mPhoneId + " " + mState;
+            return mS + " Time " + mTime.toString() + " mSubId " + mSubId + " mPhoneId " + mPhoneId + "  mState " + mState;
         }
     }
 
@@ -1429,8 +1429,12 @@
         }
     }
 
-    boolean subIdMatch(int rSubId, int subId) {
+    boolean idMatch(int rSubId, int subId, int phoneId) {
         if(rSubId == SubscriptionManager.DEFAULT_SUB_ID) {
+            if(subId < 0) {
+                // Invalid case, we need compare phoneId with default one.
+                return (mDefaultPhoneId == phoneId);
+            }
             return (subId == mDefaultSubId);
         } else {
             return (rSubId == subId);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 91e2df0..97847b5 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -952,10 +952,13 @@
      */
     private boolean mWentToSleep = false;
 
+    static final int LOCK_SCREEN_HIDDEN = 0;
+    static final int LOCK_SCREEN_LEAVING = 1;
+    static final int LOCK_SCREEN_SHOWN = 2;
     /**
      * State of external call telling us if the lock screen is shown.
      */
-    private boolean mLockScreenShown = false;
+    int mLockScreenShown = LOCK_SCREEN_HIDDEN;
 
     /**
      * Set if we are shutting down the system, similar to sleeping.
@@ -6118,9 +6121,8 @@
             synchronized (this) {
                 if (DEBUG_LOCKSCREEN) logLockScreen("");
                 mWindowManager.keyguardWaitingForActivityDrawn();
-                if (mLockScreenShown) {
-                    mLockScreenShown = false;
-                    comeOutOfSleepIfNeededLocked();
+                if (mLockScreenShown == LOCK_SCREEN_SHOWN) {
+                    mLockScreenShown = LOCK_SCREEN_LEAVING;
                 }
             }
         } finally {
@@ -9957,14 +9959,23 @@
         Binder.restoreCallingIdentity(origId);
     }
 
+    private String lockScreenShownToString() {
+        switch (mLockScreenShown) {
+            case LOCK_SCREEN_HIDDEN: return "LOCK_SCREEN_HIDDEN";
+            case LOCK_SCREEN_LEAVING: return "LOCK_SCREEN_LEAVING";
+            case LOCK_SCREEN_SHOWN: return "LOCK_SCREEN_SHOWN";
+            default: return "Unknown=" + mLockScreenShown;
+        }
+    }
+
     void logLockScreen(String msg) {
         if (DEBUG_LOCKSCREEN) Slog.d(TAG, Debug.getCallers(2) + ":" + msg +
-                " mLockScreenShown=" + mLockScreenShown + " mWentToSleep=" +
+                " mLockScreenShown=" + lockScreenShownToString() + " mWentToSleep=" +
                 mWentToSleep + " mSleeping=" + mSleeping);
     }
 
-    private void comeOutOfSleepIfNeededLocked() {
-        if ((!mWentToSleep && !mLockScreenShown) || mRunningVoice) {
+    void comeOutOfSleepIfNeededLocked() {
+        if ((!mWentToSleep && mLockScreenShown == LOCK_SCREEN_HIDDEN) || mRunningVoice) {
             if (mSleeping) {
                 mSleeping = false;
                 mStackSupervisor.comeOutOfSleepIfNeededLocked();
@@ -10001,7 +10012,7 @@
             long ident = Binder.clearCallingIdentity();
             try {
                 if (DEBUG_LOCKSCREEN) logLockScreen(" shown=" + shown);
-                mLockScreenShown = shown;
+                mLockScreenShown = shown ? LOCK_SCREEN_SHOWN : LOCK_SCREEN_HIDDEN;
                 comeOutOfSleepIfNeededLocked();
             } finally {
                 Binder.restoreCallingIdentity(ident);
@@ -12767,9 +12778,9 @@
             }
         }
         if (dumpPackage == null) {
-            if (mSleeping || mWentToSleep || mLockScreenShown) {
+            if (mSleeping || mWentToSleep || mLockScreenShown != LOCK_SCREEN_HIDDEN) {
                 pw.println("  mSleeping=" + mSleeping + " mWentToSleep=" + mWentToSleep
-                        + " mLockScreenShown " + mLockScreenShown);
+                        + " mLockScreenShown " + lockScreenShownToString());
             }
             if (mShuttingDown || mRunningVoice) {
                 pw.print("  mShuttingDown=" + mShuttingDown + " mRunningVoice=" + mRunningVoice);
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index b61bd8a..b955011 100755
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -241,9 +241,6 @@
     /** Run all ActivityStacks through this */
     final ActivityStackSupervisor mStackSupervisor;
 
-    /** Used to keep resumeTopActivityLocked() from being entered recursively */
-    private boolean inResumeTopActivity;
-
     static final int PAUSE_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 1;
     static final int DESTROY_TIMEOUT_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 2;
     static final int LAUNCH_TICK_MSG = ActivityManagerService.FIRST_ACTIVITY_STACK_MSG + 3;
@@ -1468,7 +1465,7 @@
     }
 
     final boolean resumeTopActivityLocked(ActivityRecord prev, Bundle options) {
-        if (inResumeTopActivity) {
+        if (mStackSupervisor.inResumeTopActivity) {
             // Don't even start recursing.
             return false;
         }
@@ -1476,10 +1473,14 @@
         boolean result = false;
         try {
             // Protect against recursion.
-            inResumeTopActivity = true;
+            mStackSupervisor.inResumeTopActivity = true;
+            if (mService.mLockScreenShown == ActivityManagerService.LOCK_SCREEN_LEAVING) {
+                mService.mLockScreenShown = ActivityManagerService.LOCK_SCREEN_HIDDEN;
+                mService.comeOutOfSleepIfNeededLocked();
+            }
             result = resumeTopActivityInnerLocked(prev, options);
         } finally {
-            inResumeTopActivity = false;
+            mStackSupervisor.inResumeTopActivity = false;
         }
         return result;
     }
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index cc7026a..079df7d 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -274,6 +274,9 @@
     final ArrayList<PendingActivityLaunch> mPendingActivityLaunches
             = new ArrayList<PendingActivityLaunch>();
 
+    /** Used to keep resumeTopActivityLocked() from being entered recursively */
+    boolean inResumeTopActivity;
+
     /**
      * Description of a request to start a new activity, which has been held
      * due to app switches being disabled.
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java b/services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java
index d703989..53740fe 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecMessageValidator.java
@@ -29,11 +29,16 @@
     static final int ERROR_SOURCE = 1;
     static final int ERROR_DESTINATION = 2;
     static final int ERROR_PARAMETER = 3;
+    static final int ERROR_PARAMETER_SHORT = 4;
 
     private final HdmiControlService mService;
 
     interface ParameterValidator {
-        boolean isValid(byte[] params);
+        /**
+         * @return errorCode errorCode can be {@link #OK}, {@link #ERROR_PARAMETER} or
+         *         {@link #ERROR_PARAMETER_SHORT}.
+         */
+        int isValid(byte[] params);
     }
 
     // Only the direct addressing is allowed.
@@ -74,7 +79,7 @@
         addValidationInfo(Constants.MESSAGE_SET_STREAM_PATH,
                 physicalAddressValidator, DEST_BROADCAST);
         addValidationInfo(Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST,
-                physicalAddressValidator, DEST_DIRECT);
+                new SystemAudioModeRequestValidator(), DEST_DIRECT);
 
         // Messages have no parameter.
         FixedLengthValidator noneValidator = new FixedLengthValidator(0);
@@ -213,9 +218,10 @@
         }
 
         // Check the parameter type.
-        if (!info.parameterValidator.isValid(message.getParams())) {
+        int errorCode = info.parameterValidator.isValid(message.getParams());
+        if (errorCode != OK) {
             HdmiLogger.warning("Unexpected parameters: " + message);
-            return ERROR_PARAMETER;
+            return errorCode;
         }
         return OK;
     }
@@ -228,8 +234,10 @@
         }
 
         @Override
-        public boolean isValid(byte[] params) {
-            return params.length == mLength;
+        public int isValid(byte[] params) {
+            // If the length is longer than expected, we assume it's OK since the parameter can be
+            // extended in the future version.
+            return params.length < mLength ? ERROR_PARAMETER_SHORT : OK;
         }
     }
 
@@ -243,8 +251,8 @@
         }
 
         @Override
-        public boolean isValid(byte[] params) {
-            return params.length >= mMinLength && params.length <= mMaxLength;
+        public int isValid(byte[] params) {
+            return params.length < mMinLength ? ERROR_PARAMETER_SHORT : OK;
         }
     }
 
@@ -270,8 +278,7 @@
      * Check if the given type is valid. A valid type is one of the actual logical device types
      * defined in the standard ({@link HdmiDeviceInfo#DEVICE_TV},
      * {@link HdmiDeviceInfo#DEVICE_PLAYBACK}, {@link HdmiDeviceInfo#DEVICE_TUNER},
-     * {@link HdmiDeviceInfo#DEVICE_RECORDER}, and
-     * {@link HdmiDeviceInfo#DEVICE_AUDIO_SYSTEM}).
+     * {@link HdmiDeviceInfo#DEVICE_RECORDER}, and {@link HdmiDeviceInfo#DEVICE_AUDIO_SYSTEM}).
      *
      * @param type device type
      * @return true if the given type is valid
@@ -282,33 +289,49 @@
                 && type != HdmiDeviceInfo.DEVICE_RESERVED;
     }
 
+    private static int toErrorCode(boolean success) {
+        return success ? OK : ERROR_PARAMETER;
+    }
+
     private class PhysicalAddressValidator implements ParameterValidator {
         @Override
-        public boolean isValid(byte[] params) {
-            if (params.length != 2) {
-                return false;
+        public int isValid(byte[] params) {
+            if (params.length < 2) {
+                return ERROR_PARAMETER_SHORT;
             }
-            return isValidPhysicalAddress(params, 0);
+            return toErrorCode(isValidPhysicalAddress(params, 0));
+        }
+    }
+
+    private class SystemAudioModeRequestValidator extends PhysicalAddressValidator {
+        @Override
+        public int isValid(byte[] params) {
+            // TV can send <System Audio Mode Request> with no parameters to terminate system audio.
+            if (params.length == 0) {
+                return OK;
+            }
+            return super.isValid(params);
         }
     }
 
     private class ReportPhysicalAddressValidator implements ParameterValidator {
         @Override
-        public boolean isValid(byte[] params) {
-            if (params.length != 3) {
-                return false;
+        public int isValid(byte[] params) {
+            if (params.length < 3) {
+                return ERROR_PARAMETER_SHORT;
             }
-            return isValidPhysicalAddress(params, 0) && isValidType(params[2]);
+            return toErrorCode(isValidPhysicalAddress(params, 0) && isValidType(params[2]));
         }
     }
 
     private class RoutingChangeValidator implements ParameterValidator {
         @Override
-        public boolean isValid(byte[] params) {
-            if (params.length != 4) {
-                return false;
+        public int isValid(byte[] params) {
+            if (params.length < 4) {
+                return ERROR_PARAMETER_SHORT;
             }
-            return isValidPhysicalAddress(params, 0) && isValidPhysicalAddress(params, 2);
+            return toErrorCode(
+                    isValidPhysicalAddress(params, 0) && isValidPhysicalAddress(params, 2));
         }
     }
 }
diff --git a/services/core/java/com/android/server/hdmi/HdmiControlService.java b/services/core/java/com/android/server/hdmi/HdmiControlService.java
index d8d513e..907a49a 100644
--- a/services/core/java/com/android/server/hdmi/HdmiControlService.java
+++ b/services/core/java/com/android/server/hdmi/HdmiControlService.java
@@ -719,7 +719,8 @@
         assertRunOnServiceThread();
         int errorCode = mMessageValidator.isValid(message);
         if (errorCode != HdmiCecMessageValidator.OK) {
-            // We'll not response on the messages with the invalid source or destination.
+            // We'll not response on the messages with the invalid source or destination
+            // or with parameter length shorter than specified in the standard.
             if (errorCode == HdmiCecMessageValidator.ERROR_PARAMETER) {
                 maySendFeatureAbortCommand(message, Constants.ABORT_INVALID_OPERAND);
             }
diff --git a/services/core/java/com/android/server/notification/NextAlarmConditionProvider.java b/services/core/java/com/android/server/notification/NextAlarmConditionProvider.java
index dba203b..4a29573 100644
--- a/services/core/java/com/android/server/notification/NextAlarmConditionProvider.java
+++ b/services/core/java/com/android/server/notification/NextAlarmConditionProvider.java
@@ -45,7 +45,19 @@
 import java.io.PrintWriter;
 import java.util.Locale;
 
-/** Built-in zen condition provider for alarm clock conditions */
+/**
+ * Built-in zen condition provider for alarm-clock-based conditions.
+ *
+ * <p>If the user's next alarm is within a lookahead threshold (config, default 12hrs), advertise
+ * it as an exit condition for zen mode (unless the built-in downtime condition is also available).
+ *
+ * <p>When this next alarm is selected as the active exit condition, follow subsequent changes
+ * to the user's next alarm, assuming it remains within the 12-hr window.
+ *
+ * <p>The next alarm is defined as {@link AlarmManager#getNextAlarmClock(int)}, which does not
+ * survive a reboot.  Maintain the illusion of a consistent next alarm value by holding on to
+ * a persisted condition until we receive the first value after reboot, or timeout with no value.
+ */
 public class NextAlarmConditionProvider extends ConditionProviderService {
     private static final String TAG = "NextAlarmConditions";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -54,9 +66,12 @@
     private static final String EXTRA_TRIGGER = "trigger";
     private static final int REQUEST_CODE = 100;
     private static final long SECONDS = 1000;
-    private static final long HOURS = 60 * 60 * SECONDS;
+    private static final long MINUTES = 60 * SECONDS;
+    private static final long HOURS = 60 * MINUTES;
     private static final long NEXT_ALARM_UPDATE_DELAY = 1 * SECONDS;  // treat clear+set as update
     private static final long EARLY = 5 * SECONDS;  // fire early, ensure alarm stream is unmuted
+    private static final long WAIT_AFTER_CONNECT = 5 * MINUTES;// for initial alarm re-registration
+    private static final long WAIT_AFTER_BOOT = 20 * SECONDS;  // for initial alarm re-registration
     private static final String NEXT_ALARM_PATH = "next_alarm";
     public static final ComponentName COMPONENT =
             new ComponentName("android", NextAlarmConditionProvider.class.getName());
@@ -64,7 +79,7 @@
     private final Context mContext = this;
     private final H mHandler = new H();
 
-    private boolean mConnected;
+    private long mConnected;
     private boolean mRegistered;
     private AlarmManager mAlarmManager;
     private int mCurrentUserId;
@@ -73,6 +88,7 @@
     private Callback mCallback;
     private Uri mCurrentSubscription;
     private PowerManager.WakeLock mWakeLock;
+    private long mBootCompleted;
 
     public NextAlarmConditionProvider() {
         if (DEBUG) Slog.d(TAG, "new NextAlarmConditionProvider()");
@@ -81,6 +97,7 @@
     public void dump(PrintWriter pw, DumpFilter filter) {
         pw.println("    NextAlarmConditionProvider:");
         pw.print("      mConnected="); pw.println(mConnected);
+        pw.print("      mBootCompleted="); pw.println(mBootCompleted);
         pw.print("      mRegistered="); pw.println(mRegistered);
         pw.print("      mCurrentUserId="); pw.println(mCurrentUserId);
         pw.print("      mScheduledAlarmTime="); pw.println(formatAlarmDebug(mScheduledAlarmTime));
@@ -103,12 +120,12 @@
         mLookaheadThreshold = mContext.getResources()
                 .getInteger(R.integer.config_next_alarm_condition_lookahead_threshold_hrs) * HOURS;
         init();
-        mConnected = true;
+        mConnected = System.currentTimeMillis();
     }
 
     public void onUserSwitched() {
         if (DEBUG) Slog.d(TAG, "onUserSwitched");
-        if (mConnected) {
+        if (mConnected != 0) {
             init();
         }
     }
@@ -117,15 +134,16 @@
     public void onDestroy() {
         super.onDestroy();
         if (DEBUG) Slog.d(TAG, "onDestroy");
-        if (mConnected) {
+        if (mRegistered) {
             mContext.unregisterReceiver(mReceiver);
+            mRegistered = false;
         }
-        mConnected = false;
+        mConnected = 0;
     }
 
     @Override
     public void onRequestConditions(int relevance) {
-        if (!mConnected || (relevance & Condition.FLAG_RELEVANT_NOW) == 0) return;
+        if (mConnected == 0 || (relevance & Condition.FLAG_RELEVANT_NOW) == 0) return;
 
         final AlarmClockInfo nextAlarm = mAlarmManager.getNextAlarmClock(mCurrentUserId);
         if (nextAlarm == null) return;  // no next alarm
@@ -133,7 +151,7 @@
         if (!isWithinLookaheadThreshold(nextAlarm)) return;  // alarm not within window
 
         // next alarm exists, and is within the configured lookahead threshold
-        notifyCondition(newConditionId(), nextAlarm, true, "request");
+        notifyCondition(newConditionId(), nextAlarm, Condition.STATE_TRUE, "request");
     }
 
     private boolean isWithinLookaheadThreshold(AlarmClockInfo alarm) {
@@ -146,7 +164,7 @@
     public void onSubscribe(Uri conditionId) {
         if (DEBUG) Slog.d(TAG, "onSubscribe " + conditionId);
         if (!isNextAlarmCondition(conditionId)) {
-            notifyCondition(conditionId, null, false, "badCondition");
+            notifyCondition(conditionId, null, Condition.STATE_FALSE, "badCondition");
             return;
         }
         mCurrentSubscription = conditionId;
@@ -157,22 +175,38 @@
         return alarm != null ? (alarm.getTriggerTime() - EARLY) : 0;
     }
 
+    private boolean isDoneWaitingAfterBoot(long time) {
+        if (mBootCompleted > 0) return (time - mBootCompleted) > WAIT_AFTER_BOOT;
+        if (mConnected > 0) return (time - mConnected) > WAIT_AFTER_CONNECT;
+        return true;
+    }
+
     private void handleEvaluate() {
         final AlarmClockInfo nextAlarm = mAlarmManager.getNextAlarmClock(mCurrentUserId);
         final long triggerTime = getEarlyTriggerTime(nextAlarm);
         final boolean withinThreshold = isWithinLookaheadThreshold(nextAlarm);
+        final long now = System.currentTimeMillis();
+        final boolean booted = isDoneWaitingAfterBoot(now);
         if (DEBUG) Slog.d(TAG, "handleEvaluate mCurrentSubscription=" + mCurrentSubscription
                 + " nextAlarm=" + formatAlarmDebug(triggerTime)
-                + " withinThreshold=" + withinThreshold);
+                + " withinThreshold=" + withinThreshold
+                + " booted=" + booted);
         if (mCurrentSubscription == null) return;  // no one cares
+        if (!booted) {
+            // we don't know yet
+            notifyCondition(mCurrentSubscription, nextAlarm, Condition.STATE_UNKNOWN, "!booted");
+            final long recheckTime = (mBootCompleted > 0 ? mBootCompleted : now) + WAIT_AFTER_BOOT;
+            rescheduleAlarm(recheckTime);
+            return;
+        }
         if (!withinThreshold) {
             // triggertime invalid or in the past, condition = false
-            notifyCondition(mCurrentSubscription, nextAlarm, false, "!withinThreshold");
+            notifyCondition(mCurrentSubscription, nextAlarm, Condition.STATE_FALSE, "!within");
             mCurrentSubscription = null;
             return;
         }
         // triggertime in the future, condition = true, schedule alarm
-        notifyCondition(mCurrentSubscription, nextAlarm, true, "withinThreshold");
+        notifyCondition(mCurrentSubscription, nextAlarm, Condition.STATE_TRUE, "within");
         rescheduleAlarm(triggerTime);
     }
 
@@ -199,16 +233,14 @@
         }
     }
 
-    private void notifyCondition(Uri id, AlarmClockInfo alarm, boolean state, String reason) {
+    private void notifyCondition(Uri id, AlarmClockInfo alarm, int state, String reason) {
         final String formattedAlarm = alarm == null ? "" : formatAlarm(alarm.getTriggerTime());
-        if (DEBUG) Slog.d(TAG, "notifyCondition " + state + " alarm=" + formattedAlarm + " reason="
-                + reason);
+        if (DEBUG) Slog.d(TAG, "notifyCondition " + Condition.stateToString(state)
+                + " alarm=" + formattedAlarm + " reason=" + reason);
         notifyCondition(new Condition(id,
                 mContext.getString(R.string.zen_mode_next_alarm_summary, formattedAlarm),
                 mContext.getString(R.string.zen_mode_next_alarm_line_one),
-                formattedAlarm, 0,
-                state ? Condition.STATE_TRUE : Condition.STATE_FALSE,
-                Condition.FLAG_RELEVANT_NOW));
+                formattedAlarm, 0, state, Condition.FLAG_RELEVANT_NOW));
     }
 
     @Override
@@ -254,6 +286,7 @@
         filter.addAction(ACTION_TRIGGER);
         filter.addAction(Intent.ACTION_TIME_CHANGED);
         filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
+        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
         mContext.registerReceiverAsUser(mReceiver, new UserHandle(mCurrentUserId), filter, null,
                 null);
         mRegistered = true;
@@ -290,6 +323,8 @@
                 if (DEBUG) Slog.d(TAG, String.format("  next alarm for user %s: %s",
                         mCurrentUserId,
                         formatAlarmDebug(mAlarmManager.getNextAlarmClock(mCurrentUserId))));
+            } else if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
+                mBootCompleted = System.currentTimeMillis();
             }
             mHandler.postEvaluate(delay);
             mWakeLock.acquire(delay + 5000);  // stay awake during evaluate
diff --git a/services/core/java/com/android/server/pm/CrossProfileIntentFilter.java b/services/core/java/com/android/server/pm/CrossProfileIntentFilter.java
index 203d990..6d18531 100644
--- a/services/core/java/com/android/server/pm/CrossProfileIntentFilter.java
+++ b/services/core/java/com/android/server/pm/CrossProfileIntentFilter.java
@@ -141,4 +141,11 @@
         return "CrossProfileIntentFilter{0x" + Integer.toHexString(System.identityHashCode(this))
                 + " " + Integer.toString(mTargetUserId) + "}";
     }
+
+    boolean equalsIgnoreFilter(CrossProfileIntentFilter other) {
+        return mTargetUserId == other.mTargetUserId
+                && mOwnerUserId == other.mOwnerUserId
+                && mOwnerPackage.equals(other.mOwnerPackage)
+                && mFlags == other.mFlags;
+    }
 }
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index f9a85df..c75fb9a 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -11844,9 +11844,21 @@
             return;
         }
         synchronized (mPackages) {
-            CrossProfileIntentFilter filter = new CrossProfileIntentFilter(intentFilter,
+            CrossProfileIntentFilter newFilter = new CrossProfileIntentFilter(intentFilter,
                     ownerPackage, UserHandle.getUserId(callingUid), targetUserId, flags);
-            mSettings.editCrossProfileIntentResolverLPw(sourceUserId).addFilter(filter);
+            CrossProfileIntentResolver resolver =
+                    mSettings.editCrossProfileIntentResolverLPw(sourceUserId);
+            ArrayList<CrossProfileIntentFilter> existing = resolver.findFilters(intentFilter);
+            // We have all those whose filter is equal. Now checking if the rest is equal as well.
+            if (existing != null) {
+                int size = existing.size();
+                for (int i = 0; i < size; i++) {
+                    if (newFilter.equalsIgnoreFilter(existing.get(i))) {
+                        return;
+                    }
+                }
+            }
+            resolver.addFilter(newFilter);
             scheduleWritePackageRestrictionsLocked(sourceUserId);
         }
     }
diff --git a/services/core/java/com/android/server/trust/TrustAgentWrapper.java b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
index b1c918d..b2bcf75 100644
--- a/services/core/java/com/android/server/trust/TrustAgentWrapper.java
+++ b/services/core/java/com/android/server/trust/TrustAgentWrapper.java
@@ -27,11 +27,11 @@
 import android.content.ServiceConnection;
 import android.net.Uri;
 import android.os.Binder;
-import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
 import android.os.PatternMatcher;
+import android.os.PersistableBundle;
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.os.UserHandle;
@@ -218,7 +218,7 @@
         }
 
         @Override
-        public void onSetTrustAgentFeaturesEnabledCompleted(boolean result, IBinder token) {
+        public void onConfigureCompleted(boolean result, IBinder token) {
             if (DEBUG) Slog.v(TAG, "onSetTrustAgentFeaturesEnabledCompleted(result=" + result);
             mHandler.obtainMessage(MSG_SET_TRUST_AGENT_FEATURES_COMPLETED,
                     result ? 1 : 0, 0, token).sendToTarget();
@@ -318,23 +318,19 @@
                 DevicePolicyManager dpm =
                     (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
 
-                if ((dpm.getKeyguardDisabledFeatures(null)
+                if ((dpm.getKeyguardDisabledFeatures(null, mUserId)
                         & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0) {
-                    List<String> features = dpm.getTrustAgentFeaturesEnabled(null, mName);
+                    List<PersistableBundle> config = dpm.getTrustAgentConfiguration(
+                            null, mName, mUserId);
                     trustDisabled = true;
-                    if (DEBUG) Slog.v(TAG, "Detected trust agents disabled. Features = "
-                            + features);
-                    if (features != null && features.size() > 0) {
-                        Bundle bundle = new Bundle();
-                        bundle.putStringArrayList(TrustAgentService.KEY_FEATURES,
-                                (ArrayList<String>)features);
+                    if (DEBUG) Slog.v(TAG, "Detected trust agents disabled. Config = " + config);
+                    if (config != null && config.size() > 0) {
                         if (DEBUG) {
                             Slog.v(TAG, "TrustAgent " + mName.flattenToShortString()
-                                    + " disabled until it acknowledges "+ features);
+                                    + " disabled until it acknowledges "+ config);
                         }
                         mSetTrustAgentFeaturesToken = new Binder();
-                        mTrustAgentService.setTrustAgentFeaturesEnabled(bundle,
-                                mSetTrustAgentFeaturesToken);
+                        mTrustAgentService.onConfigure(config, mSetTrustAgentFeaturesToken);
                     }
                 }
                 final long maxTimeToLock = dpm.getMaximumTimeToLock(null);
diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java
index 4437e12..fe5cb33 100644
--- a/services/core/java/com/android/server/trust/TrustManagerService.java
+++ b/services/core/java/com/android/server/trust/TrustManagerService.java
@@ -48,6 +48,7 @@
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
+import android.os.PersistableBundle;
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.os.UserHandle;
@@ -228,10 +229,10 @@
 
                 if (!enabledAgents.contains(name)) continue;
                 if (disableTrustAgents) {
-                    List<String> features =
-                            dpm.getTrustAgentFeaturesEnabled(null /* admin */, name);
+                    List<PersistableBundle> config =
+                            dpm.getTrustAgentConfiguration(null /* admin */, name, userInfo.id);
                     // Disable agent if no features are enabled.
-                    if (features == null || features.isEmpty()) continue;
+                    if (config == null || config.isEmpty()) continue;
                 }
 
                 AgentInfo agentInfo = new AgentInfo();
diff --git a/services/core/java/com/android/server/wm/WindowAnimator.java b/services/core/java/com/android/server/wm/WindowAnimator.java
index 8d93141..c002ddf 100644
--- a/services/core/java/com/android/server/wm/WindowAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowAnimator.java
@@ -272,6 +272,7 @@
             if (winAnimator.mSurfaceControl != null) {
                 final boolean wasAnimating = winAnimator.mWasAnimating;
                 final boolean nowAnimating = winAnimator.stepAnimationLocked(mCurrentTime);
+                mAnimating |= nowAnimating;
 
                 if (WindowManagerService.DEBUG_WALLPAPER) {
                     Slog.v(TAG, win + ": wasAnimating=" + wasAnimating +
@@ -423,7 +424,8 @@
             if (mKeyguardGoingAwayDisableWindowAnimations) {
                 if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: skipping anim for windows");
             } else {
-                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim for windows");
+                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: created anim for windows="
+                        + unForceHiding);
                 mPostKeyguardExitAnimation = mPolicy.createForceHideEnterAnimation(
                         wallpaperInUnForceHiding, mKeyguardGoingAwayToNotificationShade);
             }
@@ -434,6 +436,17 @@
                     winAnimator.keyguardGoingAwayAnimation = true;
                 }
             }
+
+            // Wallpaper is going away in un-force-hide motion, animate it as well.
+            if (!wallpaperInUnForceHiding && wallpaper != null
+                    && !mKeyguardGoingAwayDisableWindowAnimations) {
+                if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
+                Animation a = mPolicy.createForceHideWallpaperExitAnimation(
+                        mKeyguardGoingAwayToNotificationShade);
+                if (a != null) {
+                    wallpaper.mWinAnimator.setAnimation(a);
+                }
+            }
         }
 
         if (mPostKeyguardExitAnimation != null) {
@@ -448,17 +461,6 @@
                 mPostKeyguardExitAnimation = null;
             }
         }
-
-        // Wallpaper is going away in un-force-hide motion, animate it as well.
-        if (!wallpaperInUnForceHiding && wallpaper != null
-                && !mKeyguardGoingAwayDisableWindowAnimations) {
-            if (DEBUG_KEYGUARD) Slog.d(TAG, "updateWindowsLocked: wallpaper animating away");
-            Animation a = mPolicy.createForceHideWallpaperExitAnimation(
-                    mKeyguardGoingAwayToNotificationShade);
-            if (a != null) {
-                wallpaper.mWinAnimator.setAnimation(a);
-            }
-        }
     }
 
     private void updateWallpaperLocked(int displayId) {
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 1dadb17..819ca50 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -486,8 +486,9 @@
     }
 
     boolean finishDrawingLocked() {
-        if (DEBUG_STARTING_WINDOW &&
-                mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
+        final boolean startingWindow =
+                mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
+        if (DEBUG_STARTING_WINDOW && startingWindow) {
             Slog.v(TAG, "Finishing drawing window " + mWin + ": mDrawState="
                     + drawStateToString());
         }
@@ -495,11 +496,13 @@
             if (DEBUG_SURFACE_TRACE || DEBUG_ANIM || SHOW_TRANSACTIONS || DEBUG_ORIENTATION)
                 Slog.v(TAG, "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING " + this + " in "
                         + mSurfaceControl);
-            if (DEBUG_STARTING_WINDOW &&
-                    mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING) {
+            if (DEBUG_STARTING_WINDOW && startingWindow) {
                 Slog.v(TAG, "Draw state now committed in " + mWin);
             }
             mDrawState = COMMIT_DRAW_PENDING;
+            if (startingWindow) {
+                mService.notifyActivityDrawnForKeyguard();
+            }
             return true;
         }
         return false;
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 308fcd8..2c6a222 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -60,6 +60,7 @@
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.IPowerManager;
+import android.os.PersistableBundle;
 import android.os.PowerManager;
 import android.os.Process;
 import android.os.RecoverySystem;
@@ -96,6 +97,7 @@
 import com.android.org.conscrypt.TrustedCertificateStore;
 import com.android.server.LocalServices;
 import com.android.server.SystemService;
+import com.android.server.devicepolicy.DevicePolicyManagerService.ActiveAdmin.TrustAgentInfo;
 
 import org.xmlpull.v1.XmlPullParser;
 
@@ -322,7 +324,7 @@
                 = "permitted-accessiblity-services";
         private static final String TAG_ENCRYPTION_REQUESTED = "encryption-requested";
         private static final String TAG_MANAGE_TRUST_AGENT_FEATURES = "manage-trust-agent-features";
-        private static final String TAG_TRUST_AGENT_FEATURE = "feature";
+        private static final String TAG_TRUST_AGENT_COMPONENT_OPTIONS = "trust-agent-component-options";
         private static final String TAG_TRUST_AGENT_COMPONENT = "component";
         private static final String TAG_PASSWORD_EXPIRATION_DATE = "password-expiration-date";
         private static final String TAG_PASSWORD_EXPIRATION_TIMEOUT = "password-expiration-timeout";
@@ -389,6 +391,7 @@
         long passwordExpirationDate = DEF_PASSWORD_EXPIRATION_DATE;
 
         static final int DEF_KEYGUARD_FEATURES_DISABLED = 0; // none
+
         int disabledKeyguardFeatures = DEF_KEYGUARD_FEATURES_DISABLED;
 
         boolean encryptionRequested = false;
@@ -397,6 +400,13 @@
         boolean disableScreenCapture = false; // Can only be set by a device/profile owner.
         boolean requireAutoTime = false; // Can only be set by a device owner.
 
+        static class TrustAgentInfo {
+            public PersistableBundle options;
+            TrustAgentInfo(PersistableBundle bundle) {
+                options = bundle;
+            }
+        }
+
         Set<String> accountTypesWithManagementDisabled = new HashSet<String>();
 
         // The list of permitted accessibility services package namesas set by a profile
@@ -413,7 +423,8 @@
         boolean specifiesGlobalProxy = false;
         String globalProxySpec = null;
         String globalProxyExclusionList = null;
-        HashMap<String, List<String>> trustAgentFeatures = new HashMap<String, List<String>>();
+
+        HashMap<String, TrustAgentInfo> trustAgentInfos = new HashMap<String, TrustAgentInfo>();
 
         List<String> crossProfileWidgetProviders;
 
@@ -551,16 +562,21 @@
                 }
                 out.endTag(null,  TAG_DISABLE_ACCOUNT_MANAGEMENT);
             }
-            if (!trustAgentFeatures.isEmpty()) {
-                Set<Entry<String, List<String>>> set = trustAgentFeatures.entrySet();
+            if (!trustAgentInfos.isEmpty()) {
+                Set<Entry<String, TrustAgentInfo>> set = trustAgentInfos.entrySet();
                 out.startTag(null, TAG_MANAGE_TRUST_AGENT_FEATURES);
-                for (Entry<String, List<String>> component : set) {
+                for (Entry<String, TrustAgentInfo> entry : set) {
+                    TrustAgentInfo trustAgentInfo = entry.getValue();
                     out.startTag(null, TAG_TRUST_AGENT_COMPONENT);
-                    out.attribute(null, ATTR_VALUE, component.getKey());
-                    for (String feature : component.getValue()) {
-                        out.startTag(null, TAG_TRUST_AGENT_FEATURE);
-                        out.attribute(null, ATTR_VALUE, feature);
-                        out.endTag(null, TAG_TRUST_AGENT_FEATURE);
+                    out.attribute(null, ATTR_VALUE, entry.getKey());
+                    if (trustAgentInfo.options != null) {
+                        out.startTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
+                        try {
+                            trustAgentInfo.options.saveToXml(out);
+                        } catch (XmlPullParserException e) {
+                            Log.e(LOG_TAG, "Failed to save TrustAgent options", e);
+                        }
+                        out.endTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
                     }
                     out.endTag(null, TAG_TRUST_AGENT_COMPONENT);
                 }
@@ -679,7 +695,7 @@
                 } else if (TAG_DISABLE_ACCOUNT_MANAGEMENT.equals(tag)) {
                     accountTypesWithManagementDisabled = readDisableAccountInfo(parser, tag);
                 } else if (TAG_MANAGE_TRUST_AGENT_FEATURES.equals(tag)) {
-                    trustAgentFeatures = getAllTrustAgentFeatures(parser, tag);
+                    trustAgentInfos = getAllTrustAgentInfos(parser, tag);
                 } else if (TAG_CROSS_PROFILE_WIDGET_PROVIDERS.equals(tag)) {
                     crossProfileWidgetProviders = getCrossProfileWidgetProviders(parser, tag);
                 } else if (TAG_PERMITTED_ACCESSIBILITY_SERVICES.equals(tag)) {
@@ -738,11 +754,11 @@
             return result;
         }
 
-        private HashMap<String, List<String>> getAllTrustAgentFeatures(XmlPullParser parser,
-                String tag) throws XmlPullParserException, IOException {
+        private HashMap<String, TrustAgentInfo> getAllTrustAgentInfos(
+                XmlPullParser parser, String tag) throws XmlPullParserException, IOException {
             int outerDepthDAM = parser.getDepth();
             int typeDAM;
-            HashMap<String, List<String>> result = new HashMap<String, List<String>>();
+            HashMap<String, TrustAgentInfo> result = new HashMap<String, TrustAgentInfo>();
             while ((typeDAM=parser.next()) != END_DOCUMENT
                     && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
                 if (typeDAM == END_TAG || typeDAM == TEXT) {
@@ -751,7 +767,8 @@
                 String tagDAM = parser.getName();
                 if (TAG_TRUST_AGENT_COMPONENT.equals(tagDAM)) {
                     final String component = parser.getAttributeValue(null, ATTR_VALUE);
-                    result.put(component, getTrustAgentFeatures(parser, tag));
+                    final TrustAgentInfo trustAgentInfo = getTrustAgentInfo(parser, tag);
+                    result.put(component, trustAgentInfo);
                 } else {
                     Slog.w(LOG_TAG, "Unknown tag under " + tag +  ": " + tagDAM);
                 }
@@ -759,20 +776,21 @@
             return result;
         }
 
-        private List<String> getTrustAgentFeatures(XmlPullParser parser, String tag)
+        private TrustAgentInfo getTrustAgentInfo(XmlPullParser parser, String tag)
                 throws XmlPullParserException, IOException  {
             int outerDepthDAM = parser.getDepth();
             int typeDAM;
-            ArrayList<String> result = new ArrayList<String>();
+            TrustAgentInfo result = new TrustAgentInfo(null);
             while ((typeDAM=parser.next()) != END_DOCUMENT
                     && (typeDAM != END_TAG || parser.getDepth() > outerDepthDAM)) {
                 if (typeDAM == END_TAG || typeDAM == TEXT) {
                     continue;
                 }
                 String tagDAM = parser.getName();
-                if (TAG_TRUST_AGENT_FEATURE.equals(tagDAM)) {
-                    final String feature = parser.getAttributeValue(null, ATTR_VALUE);
-                    result.add(feature);
+                if (TAG_TRUST_AGENT_COMPONENT_OPTIONS.equals(tagDAM)) {
+                    PersistableBundle bundle = new PersistableBundle();
+                    bundle.restoreFromXml(parser);
+                    result.options = bundle;
                 } else {
                     Slog.w(LOG_TAG, "Unknown tag under " + tag +  ": " + tagDAM);
                 }
@@ -1174,7 +1192,7 @@
             int userHandle) {
         List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
         for (UserInfo ui : profiles) {
-            int id = ui.getUserHandle().getIdentifier();
+            int id = ui.id;
             sendAdminCommandLocked(action, reqPolicy, id);
         }
     }
@@ -1591,7 +1609,7 @@
 
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo ui : profiles) {
-                int profileUserHandle = ui.getUserHandle().getIdentifier();
+                int profileUserHandle = ui.id;
                 final DevicePolicyData policy = getUserData(profileUserHandle);
                 final int count = policy.mAdminList.size();
                 if (count > 0) {
@@ -1878,7 +1896,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -1925,7 +1943,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -1972,7 +1990,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i = 0; i < N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2033,7 +2051,7 @@
 
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i = 0; i < N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2131,7 +2149,7 @@
 
         List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
         for (UserInfo userInfo : profiles) {
-            DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+            DevicePolicyData policy = getUserData(userInfo.id);
             final int N = policy.mAdminList.size();
             for (int i = 0; i < N; i++) {
                 ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2188,7 +2206,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2232,7 +2250,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2279,7 +2297,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2326,7 +2344,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i = 0; i < N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2373,7 +2391,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2420,7 +2438,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -2526,7 +2544,7 @@
         int count = 0;
         ActiveAdmin strictestAdmin = null;
         for (UserInfo userInfo : mUserManager.getProfiles(userHandle)) {
-            DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+            DevicePolicyData policy = getUserData(userInfo.id);
             for (ActiveAdmin admin : policy.mAdminList) {
                 if (admin.maximumFailedPasswordsForWipe ==
                         ActiveAdmin.DEF_MAXIMUM_FAILED_PASSWORDS_FOR_WIPE) {
@@ -2738,7 +2756,7 @@
             // Return strictest policy for this user and profiles that are visible from this user.
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
                 for (int i=0; i<N; i++) {
                     ActiveAdmin admin = policy.mAdminList.get(i);
@@ -3055,7 +3073,7 @@
     private void updatePasswordExpirationsLocked(int userHandle) {
             List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
             for (UserInfo userInfo : profiles) {
-                int profileId = userInfo.getUserHandle().getIdentifier();
+                int profileId = userInfo.id;
                 DevicePolicyData policy = getUserData(profileId);
                 final int N = policy.mAdminList.size();
                 if (N > 0) {
@@ -4106,13 +4124,13 @@
         }
     }
 
-    public void setTrustAgentFeaturesEnabled(ComponentName admin, ComponentName agent,
-            List<String>features, int userHandle) {
+    public void setTrustAgentConfiguration(ComponentName admin, ComponentName agent,
+            PersistableBundle args, int userHandle) {
         if (!mHasFeature) {
             return;
         }
         enforceCrossUserPermission(userHandle);
-        enforceNotManagedProfile(userHandle, "manage trust agent features");
+        enforceNotManagedProfile(userHandle, "set trust agent configuration");
         synchronized (this) {
             if (admin == null) {
                 throw new NullPointerException("admin is null");
@@ -4122,57 +4140,68 @@
             }
             ActiveAdmin ap = getActiveAdminForCallerLocked(admin,
                     DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_FEATURES);
-            ap.trustAgentFeatures.put(agent.flattenToString(), features);
+            ap.trustAgentInfos.put(agent.flattenToString(), new TrustAgentInfo(args));
             saveSettingsLocked(userHandle);
             syncDeviceCapabilitiesLocked(getUserData(userHandle));
         }
     }
 
-    public List<String> getTrustAgentFeaturesEnabled(ComponentName admin, ComponentName agent,
-            int userHandle) {
+    public List<PersistableBundle> getTrustAgentConfiguration(ComponentName admin,
+            ComponentName agent, int userHandle) {
         if (!mHasFeature) {
             return null;
         }
         enforceCrossUserPermission(userHandle);
+        if (agent == null) {
+            throw new NullPointerException("agent is null");
+        }
+
         synchronized (this) {
-            if (agent == null) {
-                throw new NullPointerException("agent is null");
-            }
             final String componentName = agent.flattenToString();
             if (admin != null) {
                 final ActiveAdmin ap = getActiveAdminUncheckedLocked(admin, userHandle);
-                return (ap != null) ? ap.trustAgentFeatures.get(componentName) : null;
+                if (ap == null) return null;
+                TrustAgentInfo trustAgentInfo = ap.trustAgentInfos.get(componentName);
+                if (trustAgentInfo == null || trustAgentInfo.options == null) return null;
+                List<PersistableBundle> result = new ArrayList<PersistableBundle>();
+                result.add(trustAgentInfo.options);
+                return result;
             }
 
             // Return strictest policy for this user and profiles that are visible from this user.
-            List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
-            List<String> result = null;
+            final List<UserInfo> profiles = mUserManager.getProfiles(userHandle);
+            List<PersistableBundle> result = null;
+
+            // Search through all admins that use KEYGUARD_DISABLE_TRUST_AGENTS and keep track
+            // of the options. If any admin doesn't have options, discard options for the rest
+            // and return null.
+            boolean allAdminsHaveOptions = true;
             for (UserInfo userInfo : profiles) {
-                DevicePolicyData policy = getUserData(userInfo.getUserHandle().getIdentifier());
+                DevicePolicyData policy = getUserData(userInfo.id);
                 final int N = policy.mAdminList.size();
-                for (int i=0; i<N; i++) {
-                    ActiveAdmin ap = policy.mAdminList.get(i);
-                    // Compute the intersection of all features for active admins that disable
-                    // trust agents:
-                    if ((ap.disabledKeyguardFeatures
-                            & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0) {
-                        final List<String> features = ap.trustAgentFeatures.get(componentName);
-                        if (result == null) {
-                            if (features == null || features.size() == 0) {
-                                result = new ArrayList<String>();
-                                Slog.w(LOG_TAG, "admin " + ap.info.getPackageName()
-                                    + " has null trust agent feature set; all will be disabled");
-                            } else {
-                                result = new ArrayList<String>(features.size());
-                                result.addAll(features);
+                for (int i=0; i < N; i++) {
+                    final ActiveAdmin active = policy.mAdminList.get(i);
+                    final boolean disablesTrust = (active.disabledKeyguardFeatures
+                            & DevicePolicyManager.KEYGUARD_DISABLE_TRUST_AGENTS) != 0;
+                    final TrustAgentInfo info = active.trustAgentInfos.get(componentName);
+                    if (info != null && info.options != null && !info.options.isEmpty()) {
+                        if (disablesTrust) {
+                            if (result == null) {
+                                result = new ArrayList<PersistableBundle>();
                             }
+                            result.add(info.options);
                         } else {
-                            result.retainAll(features);
+                            Log.w(LOG_TAG, "Ignoring admin " + active.info
+                                    + " because it has trust options but doesn't declare "
+                                    + "KEYGUARD_DISABLE_TRUST_AGENTS");
                         }
+                    } else if (disablesTrust) {
+                        allAdminsHaveOptions = false;
+                        break;
                     }
                 }
             }
-            return result;
+            return allAdminsHaveOptions ? result : null;
         }
     }
 
diff --git a/telecomm/java/android/telecom/Conference.java b/telecomm/java/android/telecom/Conference.java
index 003d5cd..6480a8a 100644
--- a/telecomm/java/android/telecom/Conference.java
+++ b/telecomm/java/android/telecom/Conference.java
@@ -207,6 +207,13 @@
     }
 
     /**
+     * @return The {@link DisconnectCause} for this connection.
+     */
+    public final DisconnectCause getDisconnectCause() {
+        return mDisconnectCause;
+    }
+
+    /**
      * Sets the capabilities of a conference. See {@link PhoneCapabilities} for valid values.
      *
      * @param capabilities A bitmask of the {@code PhoneCapabilities} of the conference call.
diff --git a/telecomm/java/android/telecom/DisconnectCause.java b/telecomm/java/android/telecom/DisconnectCause.java
index 206046d..73bcd0c 100644
--- a/telecomm/java/android/telecom/DisconnectCause.java
+++ b/telecomm/java/android/telecom/DisconnectCause.java
@@ -58,6 +58,11 @@
     public static final int RESTRICTED = 8;
     /** Disconnected for reason not described by other disconnect codes. */
     public static final int OTHER = 9;
+    /**
+     * Disconnected because the connection manager did not support the call. The call will be tried
+     * again without a connection manager. See {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}.
+     */
+    public static final int CONNECTION_MANAGER_NOT_SUPPORTED = 10;
 
     private int mDisconnectCode;
     private CharSequence mDisconnectLabel;
@@ -220,7 +225,10 @@
     @Override
     public String toString() {
         String code = "";
-        switch (getCode()) {
+        switch (mDisconnectCode) {
+            case UNKNOWN:
+                code = "UNKNOWN";
+                break;
             case ERROR:
                 code = "ERROR";
                 break;
@@ -230,6 +238,9 @@
             case REMOTE:
                 code = "REMOTE";
                 break;
+            case CANCELED:
+                code = "CANCELED";
+                break;
             case MISSED:
                 code = "MISSED";
                 break;
@@ -245,9 +256,12 @@
             case OTHER:
                 code = "OTHER";
                 break;
-            case UNKNOWN:
+            case CONNECTION_MANAGER_NOT_SUPPORTED:
+                code = "CONNECTION_MANAGER_NOT_SUPPORTED";
+                break;
             default:
-                code = "UNKNOWN";
+                code = "invalid code: " + mDisconnectCode;
+                break;
         }
         String label = mDisconnectLabel == null ? "" : mDisconnectLabel.toString();
         String description = mDisconnectDescription == null
diff --git a/telephony/java/android/telephony/SubInfoRecord.java b/telephony/java/android/telephony/SubInfoRecord.java
index e08f255..8ab69cc 100644
--- a/telephony/java/android/telephony/SubInfoRecord.java
+++ b/telephony/java/android/telephony/SubInfoRecord.java
@@ -250,7 +250,7 @@
         dest.writeCharSequence(mDisplayName);
         dest.writeInt(mNameSource);
         dest.writeInt(mColor);
-        dest.writeString(mNumber.toString());
+        dest.writeString(mNumber);
         dest.writeInt(mDataRoaming);
         dest.writeIntArray(mSimIconRes);
         dest.writeInt(mMcc);
diff --git a/tests/VectorDrawableTest/res/anim/ic_open_animation_ball_start.xml b/tests/VectorDrawableTest/res/anim/ic_open_animation_ball_start.xml
deleted file mode 100644
index c26c8ed..0000000
--- a/tests/VectorDrawableTest/res/anim/ic_open_animation_ball_start.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<set xmlns:android="http://schemas.android.com/apk/res/android" >
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="833"
-            android:propertyName="translateX"
-            android:valueFrom="144"
-            android:valueTo="144"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="100"
-            android:propertyName="translateX"
-            android:valueFrom="144"
-            android:valueTo="147.411817411"
-            android:interpolator="@interpolator/ic_open_ball_start_translatex_interpolator" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="167"
-            android:propertyName="translateY"
-            android:valueFrom="144.58457376"
-            android:valueTo="144.58457376"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="333"
-            android:propertyName="translateY"
-            android:valueFrom="144.58457376"
-            android:valueTo="196.11111456"
-            android:interpolator="@interpolator/ic_open_ball_start_translatey_interpolator_1" />
-        <objectAnimator
-            android:duration="333"
-            android:propertyName="translateY"
-            android:valueFrom="196.11111456"
-            android:valueTo="196.11111456"
-            android:interpolator="@interpolator/ic_open_ball_start_translatey_interpolator_2" />
-        <objectAnimator
-            android:duration="100"
-            android:propertyName="translateY"
-            android:valueFrom="196.11111456"
-            android:valueTo="129.468428513"
-            android:interpolator="@interpolator/ic_open_ball_start_translatey_interpolator_3" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="167"
-            android:propertyName="scaleX"
-            android:valueFrom="0"
-            android:valueTo="0.71187984"
-            android:interpolator="@interpolator/ic_open_ball_start_scalex_interpolator_1" />
-        <objectAnimator
-            android:duration="667"
-            android:propertyName="scaleX"
-            android:valueFrom="0.71187984"
-            android:valueTo="0.71187984"
-            android:interpolator="@interpolator/ic_open_ball_start_scalex_interpolator_2" />
-        <objectAnimator
-            android:duration="100"
-            android:propertyName="scaleX"
-            android:valueFrom="0.71187984"
-            android:valueTo="0.586201598553"
-            android:interpolator="@interpolator/ic_open_ball_start_scalex_interpolator_3" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="167"
-            android:propertyName="scaleY"
-            android:valueFrom="0"
-            android:valueTo="0.71187984"
-            android:interpolator="@interpolator/ic_open_ball_start_scaley_interpolator_1" />
-        <objectAnimator
-            android:duration="667"
-            android:propertyName="scaleY"
-            android:valueFrom="0.71187984"
-            android:valueTo="0.71187984"
-            android:interpolator="@interpolator/ic_open_ball_start_scaley_interpolator_2" />
-        <objectAnimator
-            android:duration="100"
-            android:propertyName="scaleY"
-            android:valueFrom="0.71187984"
-            android:valueTo="0.586201598553"
-            android:interpolator="@interpolator/ic_open_ball_start_scaley_interpolator_3" />
-    </set>
-</set>
diff --git a/tests/VectorDrawableTest/res/anim/ic_open_animation_ball_swoop.xml b/tests/VectorDrawableTest/res/anim/ic_open_animation_ball_swoop.xml
deleted file mode 100644
index 5096514..0000000
--- a/tests/VectorDrawableTest/res/anim/ic_open_animation_ball_swoop.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<set xmlns:android="http://schemas.android.com/apk/res/android" >
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="933"
-            android:propertyName="rotation"
-            android:valueFrom="-90"
-            android:valueTo="-90"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="1367"
-            android:propertyName="rotation"
-            android:valueFrom="-90"
-            android:valueTo="-87"
-            android:interpolator="@android:interpolator/linear" />
-    </set>
-</set>
diff --git a/tests/VectorDrawableTest/res/anim/ic_open_animation_path_1.xml b/tests/VectorDrawableTest/res/anim/ic_open_animation_path_1.xml
deleted file mode 100644
index ef8496e..0000000
--- a/tests/VectorDrawableTest/res/anim/ic_open_animation_path_1.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<set xmlns:android="http://schemas.android.com/apk/res/android" >
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="500"
-            android:propertyName="pathData"
-            android:valueFrom="M 0,-17.3838043213 c -9.625,0.0 -17.0795440674,8.28025817871 -17.0795440674,17.4052734375 c 0.0,9.75645446777 7.51704406738,17.6295623779 17.0795440674,17.353515625 c 11.5579986572,-0.333648681641 17.2784118652,-8.72853088379 17.2784118652,-17.353515625 c 0.0,-8.62501525879 -7.65341186523,-17.4052734375 -17.2784118652,-17.4052734375 Z"
-            android:valueTo="M 0,-17.3838043213 c -9.625,0.0 -17.0795440674,8.28025817871 -17.0795440674,17.4052734375 c 0.0,9.75645446777 7.51704406738,17.6295623779 17.0795440674,17.353515625 c 11.5579986572,-0.333648681641 17.2784118652,-8.72853088379 17.2784118652,-17.353515625 c 0.0,-8.62501525879 -7.65341186523,-17.4052734375 -17.2784118652,-17.4052734375 Z"
-            android:valueType="pathType"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="267"
-            android:propertyName="pathData"
-            android:valueFrom="M 0,-17.3838043213 c -9.625,0.0 -17.0795440674,8.28025817871 -17.0795440674,17.4052734375 c 0.0,9.75645446777 7.51704406738,17.6295623779 17.0795440674,17.353515625 c 11.5579986572,-0.333648681641 17.2784118652,-8.72853088379 17.2784118652,-17.353515625 c 0.0,-8.62501525879 -7.65341186523,-17.4052734375 -17.2784118652,-17.4052734375 Z"
-            android:valueTo="M 0,-6 c -9.625,0 -23.5648803711,6.97859191895 -23.5648803711,16.1035919189 c 0.0,8.875 6.62738037109,8.39640808105 23.5648803711,8.39640808105 c 17.0625,0.0 23.8825073242,0.375 23.8825073242,-8.25 c 0.0,-8.625 -14.2574920654,-16.25 -23.8825073242,-16.25 Z"
-            android:valueType="pathType"
-            android:interpolator="@interpolator/ic_open_path_1_pathdata_interpolator_1" />
-        <objectAnimator
-            android:duration="33"
-            android:propertyName="pathData"
-            android:valueFrom="M 0,-6 c -9.625,0 -23.5648803711,6.97859191895 -23.5648803711,16.1035919189 c 0.0,8.875 6.62738037109,8.39640808105 23.5648803711,8.39640808105 c 17.0625,0.0 23.8825073242,0.375 23.8825073242,-8.25 c 0.0,-8.625 -14.2574920654,-16.25 -23.8825073242,-16.25 Z"
-            android:valueTo="M 0,-6 c -9.625,0 -23.5648803711,6.97859191895 -23.5648803711,16.1035919189 c 0.0,8.875 6.62738037109,8.39640808105 23.5648803711,8.39640808105 c 17.0625,0.0 23.8825073242,0.375 23.8825073242,-8.25 c 0.0,-8.625 -14.2574920654,-16.25 -23.8825073242,-16.25 Z"
-            android:valueType="pathType"
-            android:interpolator="@interpolator/ic_open_path_1_pathdata_interpolator_2" />
-        <objectAnimator
-            android:duration="67"
-            android:propertyName="pathData"
-            android:valueFrom="M 0,-6 c -9.625,0 -23.5648803711,6.97859191895 -23.5648803711,16.1035919189 c 0.0,8.875 6.62738037109,8.39640808105 23.5648803711,8.39640808105 c 17.0625,0.0 23.8825073242,0.375 23.8825073242,-8.25 c 0.0,-8.625 -14.2574920654,-16.25 -23.8825073242,-16.25 Z"
-            android:valueTo="M 0,-17.3838043213 c -9.625,0.0 -17.0795440674,8.28025817871 -17.0795440674,17.4052734375 c 0.0,9.75645446777 7.51704406738,17.6295623779 17.0795440674,17.353515625 c 11.5579986572,-0.333648681641 17.2784118652,-8.72853088379 17.2784118652,-17.353515625 c 0.0,-8.62501525879 -7.65341186523,-17.4052734375 -17.2784118652,-17.4052734375 Z"
-            android:valueType="pathType"
-            android:interpolator="@interpolator/ic_open_path_1_pathdata_interpolator_3" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="933"
-            android:propertyName="fillAlpha"
-            android:valueFrom="1"
-            android:valueTo="1"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="17"
-            android:propertyName="fillAlpha"
-            android:valueFrom="1"
-            android:valueTo="0"
-            android:interpolator="@android:interpolator/linear" />
-    </set>
-</set>
diff --git a/tests/VectorDrawableTest/res/anim/ic_open_animation_path_1_1.xml b/tests/VectorDrawableTest/res/anim/ic_open_animation_path_1_1.xml
deleted file mode 100644
index 4961204..0000000
--- a/tests/VectorDrawableTest/res/anim/ic_open_animation_path_1_1.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<set xmlns:android="http://schemas.android.com/apk/res/android" >
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="917"
-            android:propertyName="strokeAlpha"
-            android:valueFrom="0"
-            android:valueTo="0"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="17"
-            android:propertyName="strokeAlpha"
-            android:valueFrom="0"
-            android:valueTo="1"
-            android:interpolator="@android:interpolator/linear" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="917"
-            android:propertyName="strokeWidth"
-            android:valueFrom="0"
-            android:valueTo="0"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="17"
-            android:propertyName="strokeWidth"
-            android:valueFrom="0"
-            android:valueTo="20"
-            android:interpolator="@android:interpolator/linear" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="933"
-            android:propertyName="trimPathStart"
-            android:valueFrom="0.06"
-            android:valueTo="0.06"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="383"
-            android:propertyName="trimPathStart"
-            android:valueFrom="0.06"
-            android:valueTo="0.19231"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="983"
-            android:propertyName="trimPathStart"
-            android:valueFrom="0.19231"
-            android:valueTo="0.999"
-            android:interpolator="@interpolator/ic_open_path_1_1_trimpathstart_interpolator_2" />
-    </set>
-    <set
-        android:ordering="sequentially" >
-        <objectAnimator
-            android:duration="933"
-            android:propertyName="trimPathEnd"
-            android:valueFrom="0.061"
-            android:valueTo="0.061"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="300"
-            android:propertyName="trimPathEnd"
-            android:valueFrom="0.061"
-            android:valueTo="0.19231"
-            android:interpolator="@android:interpolator/linear" />
-        <objectAnimator
-            android:duration="1067"
-            android:propertyName="trimPathEnd"
-            android:valueFrom="0.19231"
-            android:valueTo="1"
-            android:interpolator="@interpolator/ic_open_path_1_1_trimpathend_interpolator_2" />
-    </set>
-</set>
diff --git a/tests/VectorDrawableTest/res/drawable/ic_open.xml b/tests/VectorDrawableTest/res/drawable/ic_open.xml
deleted file mode 100644
index ad96094..0000000
--- a/tests/VectorDrawableTest/res/drawable/ic_open.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:height="288dp"
-    android:width="288dp"
-    android:viewportHeight="288"
-    android:viewportWidth="288" >
-    <group
-        android:name="ball_start"
-        android:translateX="147.411817411"
-        android:translateY="129.468428513"
-        android:scaleX="0.586201598553"
-        android:scaleY="0.586201598553" >
-        <group
-            android:name="shape_1"
-            android:scaleX="0.76"
-            android:scaleY="0.748114397321" >
-            <path
-                android:name="path_1"
-                android:pathData="M 0,-17.3838043213 c -9.625,0.0 -17.0795440674,8.28025817871 -17.0795440674,17.4052734375 c 0.0,9.75645446777 7.51704406738,17.6295623779 17.0795440674,17.353515625 c 11.5579986572,-0.333648681641 17.2784118652,-8.72853088379 17.2784118652,-17.353515625 c 0.0,-8.62501525879 -7.65341186523,-17.4052734375 -17.2784118652,-17.4052734375 Z"
-                android:fillColor="#FFFF9000"
-                android:fillAlpha="0" />
-        </group>
-    </group>
-    <group
-        android:name="ball_swoop"
-        android:translateX="144"
-        android:translateY="144"
-        android:scaleX="0.752248"
-        android:scaleY="0.752248"
-        android:rotation="-87.6585365854" >
-        <path
-            android:name="path_1_1"
-            android:pathData="M -56.7679443359,1.03857421875 c 0.0,0.0 191.916503906,-13.9097290039 191.916503906,88.0704345703 c 0.0,58.4487304688 -83.6709594727,90.1372070312 -137.004882812,90.1372070312 c -82.1782226562,0.0 -177.867431641,-63.5512695312 -177.867431641,-178.207641602 c 0.0,-115.985717773 98.7650146484,-178.160949707 177.986938477,-178.160949707 c 76.2376251221,0.0 178.1640625,60.6796875 178.1640625,178.185058594 "
-            android:strokeColor="#FFFF9000"
-            android:strokeAlpha="1"
-            android:strokeWidth="20"
-            android:strokeLineCap="round"
-            android:trimPathStart="0.93025"
-            android:trimPathEnd="0.96248"
-            android:trimPathOffset="0"
-            android:fillColor="#00000000" />
-    </group>
-</vector>
diff --git a/tests/VectorDrawableTest/res/drawable/ic_open_animation.xml b/tests/VectorDrawableTest/res/drawable/ic_open_animation.xml
deleted file mode 100644
index 83ee90b..0000000
--- a/tests/VectorDrawableTest/res/drawable/ic_open_animation.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:drawable="@drawable/ic_open" >
-    <target
-        android:name="ball_start"
-        android:animation="@anim/ic_open_animation_ball_start" />
-    <target
-        android:name="path_1"
-        android:animation="@anim/ic_open_animation_path_1" />
-    <target
-        android:name="ball_swoop"
-        android:animation="@anim/ic_open_animation_ball_swoop" />
-    <target
-        android:name="path_1_1"
-        android:animation="@anim/ic_open_animation_path_1_1" />
-</animated-vector>
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_1.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_1.xml
deleted file mode 100644
index 601cfc6..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_1.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.33333333,0.0 0.202777547991,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_2.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_2.xml
deleted file mode 100644
index 5011ef9..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.0103034467173,0.0 0.701918866569,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_3.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_3.xml
deleted file mode 100644
index 7b0af97..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scalex_interpolator_3.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.649706648701,0.0 0.884285938423,1.92358061843 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_1.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_1.xml
deleted file mode 100644
index 601cfc6..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_1.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.33333333,0.0 0.202777547991,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_2.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_2.xml
deleted file mode 100644
index 5011ef9..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.0103034467173,0.0 0.701918866569,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_3.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_3.xml
deleted file mode 100644
index 7b0af97..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_scaley_interpolator_3.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.649706648701,0.0 0.884285938423,1.92358061843 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatex_interpolator.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatex_interpolator.xml
deleted file mode 100644
index ea11d1f..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatex_interpolator.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.353876322169,0.0 0.686452288267,-1.02094740172 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_1.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_1.xml
deleted file mode 100644
index 7bd5c49..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_1.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.754478769148,0.0 0.97,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_2.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_2.xml
deleted file mode 100644
index b0ab6e8..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.33333333,0.0 0.83333333333,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_3.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_3.xml
deleted file mode 100644
index 61060a6..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_ball_start_translatey_interpolator_3.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.324310863613,0.0 0.735625629425,-0.0161527278292 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_1_trimpathend_interpolator_2.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_1_trimpathend_interpolator_2.xml
deleted file mode 100644
index 7e19ef6..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_1_trimpathend_interpolator_2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.744517024668,0.120263649138 0.135947812437,0.994319475209 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_1_trimpathstart_interpolator_2.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_1_trimpathstart_interpolator_2.xml
deleted file mode 100644
index 1280715..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_1_trimpathstart_interpolator_2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.781904890372,0.126303002187 0.188007240906,0.953418294755 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_1.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_1.xml
deleted file mode 100644
index ddf966e..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_1.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.000100000000012,0.0 0.0,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_2.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_2.xml
deleted file mode 100644
index 624e304..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_2.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 9.99999999007e-05,0.0 0.0,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_3.xml b/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_3.xml
deleted file mode 100644
index 3ebee0b..0000000
--- a/tests/VectorDrawableTest/res/interpolator/ic_open_path_1_pathdata_interpolator_3.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!-- Copyright (C) 2014 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.
--->
-<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
-    android:pathData="M 0 0 c 0.000100000000051,0.0 0.83333333333,1.0 1.0,1.0" />
diff --git a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
index 3045839..c4dfb84 100644
--- a/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
+++ b/tests/VectorDrawableTest/src/com/android/test/dynamic/AnimatedVectorDrawableTest.java
@@ -26,7 +26,6 @@
     private static final String LOGCAT = "AnimatedVectorDrawableTest";
 
     protected int[] icon = {
-            R.drawable.ic_open_animation,
             R.drawable.ic_rotate_2_portrait_v2_animation,
             R.drawable.ic_signal_airplane_v2_animation,
             R.drawable.ic_hourglass_animation,
diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java
index 5bf3470..75198e5 100644
--- a/wifi/java/android/net/wifi/WifiInfo.java
+++ b/wifi/java/android/net/wifi/WifiInfo.java
@@ -286,7 +286,7 @@
      * Returns the service set identifier (SSID) of the current 802.11 network.
      * If the SSID can be decoded as UTF-8, it will be returned surrounded by double
      * quotation marks. Otherwise, it is returned as a string of hex digits. The
-     * SSID may be {@code null} if there is no network currently connected.
+     * SSID may be &lt;unknown ssid&gt; if there is no network currently connected.
      * @return the SSID
      */
     public String getSSID() {