Merge "Use advertised h264 encoding parameters by default if the profile is not baseline"
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
index 38d0d2a..2666b41 100644
--- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
+++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
@@ -23,6 +23,8 @@
 import android.os.RemoteException;
 import android.os.ServiceManager;
 
+import java.util.HashSet;
+
 public final class Bmgr {
     IBackupManager mBmgr;
     IRestoreSession mRestore;
@@ -45,7 +47,6 @@
     }
 
     public void run(String[] args) {
-        boolean validCommand = false;
         if (args.length < 1) {
             showUsage();
             return;
@@ -329,7 +330,13 @@
         } else {
             try {
                 long token = Long.parseLong(arg, 16);
-                doRestoreAll(token);
+                HashSet<String> filter = null;
+                while ((arg = nextArg()) != null) {
+                    if (filter == null) filter = new HashSet<String>();
+                    filter.add(arg);
+                }
+
+                doRestoreAll(token, filter);
             } catch (NumberFormatException e) {
                 showUsage();
                 return;
@@ -364,7 +371,7 @@
         }
     }
 
-    private void doRestoreAll(long token) {
+    private void doRestoreAll(long token, HashSet<String> filter) {
         RestoreObserver observer = new RestoreObserver();
 
         try {
@@ -383,7 +390,13 @@
                     for (RestoreSet s : sets) {
                         if (s.token == token) {
                             System.out.println("Scheduling restore: " + s.name);
-                            didRestore = (mRestore.restoreAll(token, observer) == 0);
+                            if (filter == null) {
+                                didRestore = (mRestore.restoreAll(token, observer) == 0);
+                            } else {
+                                String[] names = new String[filter.size()];
+                                filter.toArray(names);
+                                didRestore = (mRestore.restoreSome(token, observer, names) == 0);
+                            }
                             break;
                         }
                     }
@@ -430,6 +443,7 @@
         System.err.println("       bmgr list sets");
         System.err.println("       bmgr transport WHICH");
         System.err.println("       bmgr restore TOKEN");
+        System.err.println("       bmgr restore TOKEN PACKAGE...");
         System.err.println("       bmgr restore PACKAGE");
         System.err.println("       bmgr run");
         System.err.println("       bmgr wipe PACKAGE");
@@ -457,12 +471,18 @@
         System.err.println("The 'transport' command designates the named transport as the currently");
         System.err.println("active one.  This setting is persistent across reboots.");
         System.err.println("");
-        System.err.println("The 'restore' command when given a restore token initiates a full-system");
+        System.err.println("The 'restore' command when given just a restore token initiates a full-system");
         System.err.println("restore operation from the currently active transport.  It will deliver");
         System.err.println("the restore set designated by the TOKEN argument to each application");
         System.err.println("that had contributed data to that restore set.");
         System.err.println("");
-        System.err.println("The 'restore' command when given a package name intiates a restore of");
+        System.err.println("The 'restore' command when given a token and one or more package names");
+        System.err.println("initiates a restore operation of just those given packages from the restore");
+        System.err.println("set designated by the TOKEN argument.  It is effectively the same as the");
+        System.err.println("'restore' operation supplying only a token, but applies a filter to the");
+        System.err.println("set of applications to be restored.");
+        System.err.println("");
+        System.err.println("The 'restore' command when given just a package name intiates a restore of");
         System.err.println("just that one package according to the restore set selection algorithm");
         System.err.println("used by the RestoreSession.restorePackage() method.");
         System.err.println("");
diff --git a/core/java/android/app/backup/IRestoreSession.aidl b/core/java/android/app/backup/IRestoreSession.aidl
index 1dddbb0..14731ee 100644
--- a/core/java/android/app/backup/IRestoreSession.aidl
+++ b/core/java/android/app/backup/IRestoreSession.aidl
@@ -52,6 +52,25 @@
     int restoreAll(long token, IRestoreObserver observer);
 
     /**
+     * Restore select packages from the given set onto the device, replacing the
+     * current data of any app contained in the set with the data previously
+     * backed up.
+     *
+     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
+     *
+     * @return Zero on success, nonzero on error. The observer will only receive
+     *   progress callbacks if this method returned zero.
+     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
+     *   the restore set that should be used.
+     * @param observer If non-null, this binder points to an object that will receive
+     *   progress callbacks during the restore operation.
+     * @param packages The set of packages for which to attempt a restore.  Regardless of
+     *   the contents of the actual back-end dataset named by {@code token}, only
+     *   applications mentioned in this list will have their data restored.
+     */
+    int restoreSome(long token, IRestoreObserver observer, in String[] packages);
+
+    /**
      * Restore a single application from backup.  The data will be restored from the
      * current backup dataset if the given package has stored data there, or from
      * the dataset used during the last full device setup operation if the current
diff --git a/core/java/android/app/backup/RestoreSession.java b/core/java/android/app/backup/RestoreSession.java
index 24ddb99..7181c61 100644
--- a/core/java/android/app/backup/RestoreSession.java
+++ b/core/java/android/app/backup/RestoreSession.java
@@ -87,6 +87,40 @@
     }
 
     /**
+     * Restore select packages from the given set onto the device, replacing the
+     * current data of any app contained in the set with the data previously
+     * backed up.
+     *
+     * <p>Callers must hold the android.permission.BACKUP permission to use this method.
+     *
+     * @return Zero on success, nonzero on error. The observer will only receive
+     *   progress callbacks if this method returned zero.
+     * @param token The token from {@link getAvailableRestoreSets()} corresponding to
+     *   the restore set that should be used.
+     * @param observer If non-null, this binder points to an object that will receive
+     *   progress callbacks during the restore operation.
+     * @param packages The set of packages for which to attempt a restore.  Regardless of
+     *   the contents of the actual back-end dataset named by {@code token}, only
+     *   applications mentioned in this list will have their data restored.
+     *
+     * @hide
+     */
+    public int restoreSome(long token, RestoreObserver observer, String[] packages) {
+        int err = -1;
+        if (mObserver != null) {
+            Log.d(TAG, "restoreAll() called during active restore");
+            return -1;
+        }
+        mObserver = new RestoreObserverWrapper(mContext, observer);
+        try {
+            err = mBinder.restoreSome(token, mObserver, packages);
+        } catch (RemoteException e) {
+            Log.d(TAG, "Can't contact server to restore packages");
+        }
+        return err;
+    }
+
+    /**
      * Restore a single application from backup.  The data will be restored from the
      * current backup dataset if the given package has stored data there, or from
      * the dataset used during the last full device setup operation if the current
diff --git a/core/java/android/provider/CalendarContract.java b/core/java/android/provider/CalendarContract.java
index b492615..f9dc257 100644
--- a/core/java/android/provider/CalendarContract.java
+++ b/core/java/android/provider/CalendarContract.java
@@ -687,7 +687,7 @@
     /**
      * Fields and helpers for interacting with Attendees. Each row of this table
      * represents a single attendee or guest of an event. Calling
-     * {@link #query(ContentResolver, long)} will return a list of attendees for
+     * {@link #query(ContentResolver, long, String[])} will return a list of attendees for
      * the event with the given eventId. Both apps and sync adapters may write
      * to this table. There are six writable fields and all of them except
      * {@link #ATTENDEE_NAME} must be included when inserting a new attendee.
@@ -708,24 +708,20 @@
          */
         @SuppressWarnings("hiding")
         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/attendees");
-        /**
-         * the projection used by the attendees query
-         */
-        public static final String[] PROJECTION = new String[] {
-                _ID, ATTENDEE_NAME, ATTENDEE_EMAIL, ATTENDEE_RELATIONSHIP, ATTENDEE_STATUS,};
         private static final String ATTENDEES_WHERE = Attendees.EVENT_ID + "=?";
 
         /**
          * Queries all attendees associated with the given event. This is a
          * blocking call and should not be done on the UI thread.
-         *
+         * 
          * @param cr The content resolver to use for the query
          * @param eventId The id of the event to retrieve attendees for
+         * @param projection the columns to return in the cursor
          * @return A Cursor containing all attendees for the event
          */
-        public static final Cursor query(ContentResolver cr, long eventId) {
+        public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
             String[] attArgs = {Long.toString(eventId)};
-            return cr.query(CONTENT_URI, PROJECTION, ATTENDEES_WHERE, attArgs /* selection args */,
+            return cr.query(CONTENT_URI, projection, ATTENDEES_WHERE, attArgs /* selection args */,
                     null /* sort order */);
         }
     }
@@ -1746,13 +1742,6 @@
     public static final class EventDays implements EventDaysColumns {
         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY
                 + "/instances/groupbyday");
-
-        /**
-         * The projection used by the EventDays query.
-         */
-        public static final String[] PROJECTION = {
-                STARTDAY, ENDDAY
-        };
         private static final String SELECTION = "selected=1";
 
         /**
@@ -1761,14 +1750,16 @@
          * endday representing the max range of days for all events beginning on
          * each startday.This is a blocking function and should not be done on
          * the UI thread.
-         *
+         * 
          * @param cr the ContentResolver
          * @param startDay the first Julian day in the range
          * @param numDays the number of days to load (must be at least 1)
+         * @param projection the columns to return in the cursor
          * @return a database cursor containing a list of start and end days for
          *         events
          */
-        public static final Cursor query(ContentResolver cr, int startDay, int numDays) {
+        public static final Cursor query(ContentResolver cr, int startDay, int numDays,
+                String[] projection) {
             if (numDays < 1) {
                 return null;
             }
@@ -1776,7 +1767,7 @@
             Uri.Builder builder = CONTENT_URI.buildUpon();
             ContentUris.appendId(builder, startDay);
             ContentUris.appendId(builder, endDay);
-            return cr.query(builder.build(), PROJECTION, SELECTION,
+            return cr.query(builder.build(), projection, SELECTION,
                     null /* selection args */, STARTDAY);
         }
     }
@@ -1821,7 +1812,7 @@
     /**
      * Fields and helpers for accessing reminders for an event. Each row of this
      * table represents a single reminder for an event. Calling
-     * {@link #query(ContentResolver, long)} will return a list of reminders for
+     * {@link #query(ContentResolver, long, String[])} will return a list of reminders for
      * the event with the given eventId. Both apps and sync adapters may write
      * to this table. There are three writable fields and all of them must be
      * included when inserting a new reminder. They are:
@@ -1833,25 +1824,21 @@
      */
     public static final class Reminders implements BaseColumns, RemindersColumns, EventsColumns {
         private static final String REMINDERS_WHERE = CalendarContract.Reminders.EVENT_ID + "=?";
-        /**
-         * The projection used by the reminders query.
-         */
-        public static final String[] PROJECTION = new String[] {
-                _ID, MINUTES, METHOD,};
         @SuppressWarnings("hiding")
         public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/reminders");
 
         /**
          * Queries all reminders associated with the given event. This is a
          * blocking call and should not be done on the UI thread.
-         *
+         * 
          * @param cr The content resolver to use for the query
          * @param eventId The id of the event to retrieve reminders for
+         * @param projection the columns to return in the cursor
          * @return A Cursor containing all reminders for the event
          */
-        public static final Cursor query(ContentResolver cr, long eventId) {
+        public static final Cursor query(ContentResolver cr, long eventId, String[] projection) {
             String[] remArgs = {Long.toString(eventId)};
-            return cr.query(CONTENT_URI, PROJECTION, REMINDERS_WHERE, remArgs /* selection args */,
+            return cr.query(CONTENT_URI, projection, REMINDERS_WHERE, remArgs /*selection args*/,
                     null /* sort order */);
         }
     }
@@ -2134,7 +2121,7 @@
          * given event id, begin time and alarm time. If one is found then this
          * alarm already exists and this method returns true. TODO Move to
          * provider
-         * 
+         *
          * @param cr the ContentResolver
          * @param eventId the event id to match
          * @param begin the start time of the event in UTC millis
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 41412de..e6fdb17 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -46,7 +46,6 @@
 
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Locale;
 
 /**
  * <p>
@@ -5019,7 +5018,7 @@
      */
     @Override
     protected void resolveTextDirection() {
-        int resolvedTextDirection = TEXT_DIRECTION_UNDEFINED;
+        int resolvedTextDirection;
         switch(mTextDirection) {
             default:
             case TEXT_DIRECTION_INHERIT:
diff --git a/core/java/android/webkit/L10nUtils.java b/core/java/android/webkit/L10nUtils.java
index 4c42cde..f9d0067d 100644
--- a/core/java/android/webkit/L10nUtils.java
+++ b/core/java/android/webkit/L10nUtils.java
@@ -74,7 +74,8 @@
         com.android.internal.R.string.autofill_country_code_re,             // IDS_AUTOFILL_COUNTRY_CODE_RE
         com.android.internal.R.string.autofill_area_code_notext_re,         // IDS_AUTOFILL_AREA_CODE_NOTEXT_RE
         com.android.internal.R.string.autofill_phone_prefix_separator_re,   // IDS_AUTOFILL_PHONE_PREFIX_SEPARATOR_RE
-        com.android.internal.R.string.autofill_phone_suffix_separator_re    // IDS_AUTOFILL_PHONE_SUFFIX_SEPARATOR_RE
+        com.android.internal.R.string.autofill_phone_suffix_separator_re,   // IDS_AUTOFILL_PHONE_SUFFIX_SEPARATOR_RE
+        com.android.internal.R.string.credit_card_number_preview_format     // IDS_CREDIT_CARD_NUMBER_PREVIEW_FORMAT
     };
 
     private static Context mApplicationContext;
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index 2145edd..c652e55 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2240,6 +2240,10 @@
     }
 
     private void setupViewport(boolean updateViewState) {
+        if (mWebView == null || mSettings == null) {
+            // We've been destroyed or are being destroyed, return early
+            return;
+        }
         // set the viewport settings from WebKit
         setViewportSettingsFromNative();
 
diff --git a/core/java/com/android/internal/util/Protocol.java b/core/java/com/android/internal/util/Protocol.java
index 2e7ec58..b754d94 100644
--- a/core/java/com/android/internal/util/Protocol.java
+++ b/core/java/com/android/internal/util/Protocol.java
@@ -26,6 +26,9 @@
  * codes with Message.what starting at Protocol.WIFI + 1 and less than or equal to Protocol.WIFI +
  * Protocol.MAX_MESSAGE
  *
+ * NOTE: After a value is created and source released a value shouldn't be changed to
+ * maintain backwards compatibility.
+ *
  * {@hide}
  */
 public class Protocol {
@@ -40,7 +43,7 @@
     public static final int BASE_DHCP                                               = 0x00030000;
     public static final int BASE_DATA_CONNECTION                                    = 0x00040000;
     public static final int BASE_DATA_CONNECTION_AC                                 = 0x00041000;
-    public static final int BASE_DATA_CONNECTION_TRACKER                            = 0x00050000;
+    public static final int BASE_DATA_CONNECTION_TRACKER                            = 0x00042000;
 
     //TODO: define all used protocols
 }
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 50f8df7..97a8c0b 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2085,6 +2085,10 @@
     <!-- Do not translate. Regex used by AutoFill. -->
     <string name="autofill_phone_suffix_separator_re">^-$</string>
 
+    <!-- Do not translate. Regex used by AutoFill. -->
+    <!-- Ex: ************1234 -->
+    <string name="credit_card_number_preview_format">$1</string>
+
     <!-- Title of an application permission, listed so the user can choose whether
         they want to allow the application to do this. -->
     <string name="permlab_readHistoryBookmarks">read Browser\'s history and bookmarks</string>
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 06e3b29..a349121 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -673,11 +673,11 @@
 
         float x = rect.left;
         float y = rect.top;
-        bool simpleTransform = mSnapshot->transform->isPureTranslate();
-
-        if (simpleTransform &&
+        bool simpleTransform = mSnapshot->transform->isPureTranslate() &&
                 layer->getWidth() == (uint32_t) rect.getWidth() &&
-                layer->getHeight() == (uint32_t) rect.getHeight()) {
+                layer->getHeight() == (uint32_t) rect.getHeight();
+
+        if (simpleTransform) {
             // When we're swapping, the layer is already in screen coordinates
             if (!swap) {
                 x = (int) floorf(rect.left + mSnapshot->transform->getTranslateX() + 0.5f);
diff --git a/packages/SystemUI/src/com/android/systemui/recent/Constants.java b/packages/SystemUI/src/com/android/systemui/recent/Constants.java
new file mode 100644
index 0000000..66f9292
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/recent/Constants.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.systemui.recent;
+
+public class Constants {
+    static final int MAX_ESCAPE_ANIMATION_DURATION = 500; // in ms
+    static final float FADE_CONSTANT = 0.5f; // unitless
+    static final int SNAP_BACK_DURATION = 250; // in ms
+    static final int ESCAPE_VELOCITY = 100; // speed of item required to "curate" it in dp/s
+}
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
index 3dbcc59..fb7a0a7 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsHorizontalScrollView.java
@@ -25,6 +25,7 @@
 import android.animation.ValueAnimator;
 import android.animation.ValueAnimator.AnimatorUpdateListener;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.database.DataSetObserver;
 import android.graphics.RectF;
 import android.util.AttributeSet;
@@ -33,6 +34,7 @@
 import android.view.MotionEvent;
 import android.view.VelocityTracker;
 import android.view.View;
+import android.view.ViewConfiguration;
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.LinearInterpolator;
 import android.widget.HorizontalScrollView;
@@ -42,12 +44,9 @@
 
 public class RecentsHorizontalScrollView extends HorizontalScrollView
         implements View.OnClickListener, View.OnTouchListener {
-    private static final float FADE_CONSTANT = 0.5f;
-    private static final int SNAP_BACK_DURATION = 250;
-    private static final int ESCAPE_VELOCITY = 100; // speed of item required to "curate" it
-    private static final String TAG = RecentsPanelView.TAG;
-    private static final float THRESHHOLD = 50;
     private static final boolean DEBUG_INVALIDATE = false;
+    private static final String TAG = RecentsPanelView.TAG;
+    private static final boolean DEBUG = RecentsPanelView.DEBUG;
     private LinearLayout mLinearLayout;
     private ActivityDescriptionAdapter mAdapter;
     private RecentsCallback mCallback;
@@ -56,6 +55,8 @@
     private float mLastY;
     private boolean mDragging;
     private VelocityTracker mVelocityTracker;
+    private float mDensityScale;
+    private float mPagingTouchSlop;
 
     public RecentsHorizontalScrollView(Context context) {
         this(context, null);
@@ -63,6 +64,8 @@
 
     public RecentsHorizontalScrollView(Context context, AttributeSet attrs) {
         super(context, attrs, 0);
+        mDensityScale = getResources().getDisplayMetrics().density;
+        mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
     }
 
     private int scrollPositionOfMostRecent() {
@@ -101,7 +104,8 @@
 
             case MotionEvent.ACTION_MOVE:
                 float delta = ev.getY() - mLastY;
-                if (Math.abs(delta) > THRESHHOLD) {
+                if (DEBUG) Log.v(TAG, "ACTION_MOVE : " + delta);
+                if (Math.abs(delta) > mPagingTouchSlop) {
                     mDragging = true;
                 }
                 break;
@@ -114,13 +118,14 @@
     }
 
     private float getAlphaForOffset(View view, float thumbHeight) {
-        final float fadeHeight = FADE_CONSTANT * thumbHeight;
+        final float fadeHeight = Constants.FADE_CONSTANT * thumbHeight;
         float result = 1.0f;
         if (view.getY() >= thumbHeight) {
             result = 1.0f - (view.getY() - thumbHeight) / fadeHeight;
         } else if (view.getY() < 0.0f) {
             result = 1.0f + (thumbHeight + view.getY()) / fadeHeight;
         }
+        if (DEBUG) Log.v(TAG, "FADE AMOUNT: " + result);
         return result;
     }
 
@@ -155,12 +160,13 @@
                     final float velocityY = velocityTracker.getYVelocity();
                     final float curY = animView.getY();
                     final float newY = (velocityY >= 0.0f ? 1 : -1) * animView.getHeight();
-
+                    final float maxVelocity = Constants.ESCAPE_VELOCITY * mDensityScale;
                     if (Math.abs(velocityY) > Math.abs(velocityX)
-                            && Math.abs(velocityY) > ESCAPE_VELOCITY
+                            && Math.abs(velocityY) > maxVelocity
                             && (velocityY >= 0.0f) == (animView.getY() >= 0)) {
-                        final long duration =
+                        long duration =
                             (long) (Math.abs(newY - curY) * 1000.0f / Math.abs(velocityY));
+                        duration = Math.min(duration, Constants.MAX_ESCAPE_ANIMATION_DURATION);
                         anim = ObjectAnimator.ofFloat(animView, "y", curY, newY);
                         anim.setInterpolator(new LinearInterpolator());
                         final int swipeDirection = animView.getY() >= 0.0f ?
@@ -181,9 +187,10 @@
                         });
                         anim.setDuration(duration);
                     } else { // Animate back to position
-                        final long duration = Math.abs(velocityY) > 0.0f ?
+                        long duration = Math.abs(velocityY) > 0.0f ?
                                 (long) (Math.abs(newY - curY) * 1000.0f / Math.abs(velocityY))
-                                : SNAP_BACK_DURATION;
+                                : Constants.SNAP_BACK_DURATION;
+                        duration = Math.min(duration, Constants.SNAP_BACK_DURATION);
                         anim = ObjectAnimator.ofFloat(animView, "y", animView.getY(), 0.0f);
                         anim.setInterpolator(new DecelerateInterpolator(2.0f));
                         anim.setDuration(duration);
@@ -241,8 +248,15 @@
         setOverScrollEffectPadding(leftPadding, 0);
     }
 
+    @Override
+    protected void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        mDensityScale = getResources().getDisplayMetrics().density;
+        mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
+    }
+
     private void setOverScrollEffectPadding(int leftPadding, int i) {
-        // TODO Add to RecentsHorizontalScrollView
+        // TODO Add to (Vertical)ScrollView
     }
 
     @Override
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 6190c9bb..a55fe9c 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -417,11 +417,11 @@
         mActivityDescriptions = getRecentTasks();
         mListAdapter.notifyDataSetInvalidated();
         if (mActivityDescriptions.size() > 0) {
-            Log.v(TAG, "Showing " + mActivityDescriptions.size() + " apps");
+            if (DEBUG) Log.v(TAG, "Showing " + mActivityDescriptions.size() + " apps");
             updateUiElements(getResources().getConfiguration());
         } else {
             // Immediately hide this panel
-            Log.v(TAG, "Nothing to show");
+            if (DEBUG) Log.v(TAG, "Nothing to show");
             hide(false);
         }
     }
@@ -436,7 +436,7 @@
             paint.setAlpha(255);
             final int srcWidth = thumbnail.getWidth();
             final int srcHeight = thumbnail.getHeight();
-            Log.v(TAG, "Source thumb: " + srcWidth + "x" + srcHeight);
+            if (DEBUG) Log.v(TAG, "Source thumb: " + srcWidth + "x" + srcHeight);
             canvas.drawBitmap(thumbnail,
                     new Rect(0, 0, srcWidth-1, srcHeight-1),
                     new RectF(mGlowBitmapPaddingLeftPx, mGlowBitmapPaddingTopPx,
@@ -486,7 +486,7 @@
 
     public void handleSwipe(View view, int direction) {
         ActivityDescription ad = ((ViewHolder) view.getTag()).activityDescription;
-        Log.v(TAG, "Jettison " + ad.label);
+        if (DEBUG) Log.v(TAG, "Jettison " + ad.label);
         mActivityDescriptions.remove(ad);
 
         // Handled by widget containers to enable LayoutTransitions properly
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
index 6a962cb..711ffa3 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsVerticalScrollView.java
@@ -25,6 +25,7 @@
 import android.animation.ValueAnimator;
 import android.animation.ValueAnimator.AnimatorUpdateListener;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.database.DataSetObserver;
 import android.graphics.RectF;
 import android.util.AttributeSet;
@@ -33,6 +34,7 @@
 import android.view.MotionEvent;
 import android.view.VelocityTracker;
 import android.view.View;
+import android.view.ViewConfiguration;
 import android.view.animation.DecelerateInterpolator;
 import android.view.animation.LinearInterpolator;
 import android.widget.LinearLayout;
@@ -42,12 +44,9 @@
 
 public class RecentsVerticalScrollView extends ScrollView
         implements View.OnClickListener, View.OnTouchListener {
-    private static final float FADE_CONSTANT = 0.5f;
-    private static final int SNAP_BACK_DURATION = 250;
-    private static final int ESCAPE_VELOCITY = 100; // speed of item required to "curate" it
     private static final String TAG = RecentsPanelView.TAG;
-    private static final float THRESHHOLD = 50;
     private static final boolean DEBUG_INVALIDATE = false;
+    private static final boolean DEBUG = RecentsPanelView.DEBUG;
     private LinearLayout mLinearLayout;
     private ActivityDescriptionAdapter mAdapter;
     private RecentsCallback mCallback;
@@ -56,6 +55,8 @@
     private float mLastX;
     private boolean mDragging;
     private VelocityTracker mVelocityTracker;
+    private float mDensityScale;
+    private float mPagingTouchSlop;
 
     public RecentsVerticalScrollView(Context context) {
         this(context, null);
@@ -63,6 +64,8 @@
 
     public RecentsVerticalScrollView(Context context, AttributeSet attrs) {
         super(context, attrs, 0);
+        mDensityScale = getResources().getDisplayMetrics().density;
+        mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
     }
 
     private int scrollPositionOfMostRecent() {
@@ -101,8 +104,8 @@
 
             case MotionEvent.ACTION_MOVE:
                 float delta = ev.getX() - mLastX;
-                Log.v(TAG, "ACTION_MOVE : " + delta);
-                if (Math.abs(delta) > THRESHHOLD) {
+                if (DEBUG) Log.v(TAG, "ACTION_MOVE : " + delta);
+                if (Math.abs(delta) > mPagingTouchSlop) {
                     mDragging = true;
                 }
                 break;
@@ -115,14 +118,14 @@
     }
 
     private float getAlphaForOffset(View view, float thumbWidth) {
-        final float fadeWidth = FADE_CONSTANT * thumbWidth;
+        final float fadeWidth = Constants.FADE_CONSTANT * thumbWidth;
         float result = 1.0f;
         if (view.getX() >= thumbWidth) {
             result = 1.0f - (view.getX() - thumbWidth) / fadeWidth;
         } else if (view.getX() < 0.0f) {
             result = 1.0f + (thumbWidth + view.getX()) / fadeWidth;
         }
-        Log.v(TAG, "FADE AMOUNT: " + result);
+        if (DEBUG) Log.v(TAG, "FADE AMOUNT: " + result);
         return result;
     }
 
@@ -157,12 +160,13 @@
                     final float velocityY = velocityTracker.getYVelocity();
                     final float curX = animView.getX();
                     final float newX = (velocityX >= 0.0f ? 1 : -1) * animView.getWidth();
-
+                    final float maxVelocity = Constants.ESCAPE_VELOCITY * mDensityScale;
                     if (Math.abs(velocityX) > Math.abs(velocityY)
-                            && Math.abs(velocityX) > ESCAPE_VELOCITY
+                            && Math.abs(velocityX) > maxVelocity
                             && (velocityX > 0.0f) == (animView.getX() >= 0)) {
-                        final long duration =
+                        long duration =
                             (long) (Math.abs(newX-curX) * 1000.0f / Math.abs(velocityX));
+                        duration = Math.min(duration, Constants.MAX_ESCAPE_ANIMATION_DURATION);
                         anim = ObjectAnimator.ofFloat(animView, "x", curX, newX);
                         anim.setInterpolator(new LinearInterpolator());
                         final int swipeDirection = animView.getX() >= 0.0f ?
@@ -183,9 +187,10 @@
                         });
                         anim.setDuration(duration);
                     } else { // Animate back to position
-                        final long duration = Math.abs(velocityX) > 0.0f ?
+                        long duration = Math.abs(velocityX) > 0.0f ?
                                 (long) (Math.abs(newX-curX) * 1000.0f / Math.abs(velocityX))
-                                : SNAP_BACK_DURATION;
+                                : Constants.SNAP_BACK_DURATION;
+                        duration = Math.min(duration, Constants.SNAP_BACK_DURATION);
                         anim = ObjectAnimator.ofFloat(animView, "x", animView.getX(), 0.0f);
                         anim.setInterpolator(new DecelerateInterpolator(4.0f));
                         anim.setDuration(duration);
@@ -243,6 +248,13 @@
         setOverScrollEffectPadding(leftPadding, 0);
     }
 
+    @Override
+    protected void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        mDensityScale = getResources().getDisplayMetrics().density;
+        mPagingTouchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop();
+    }
+
     private void setOverScrollEffectPadding(int leftPadding, int i) {
         // TODO Add to (Vertical)ScrollView
     }
diff --git a/services/audioflinger/AudioResamplerCubic.cpp b/services/audioflinger/AudioResamplerCubic.cpp
index 1d247bd..4d721f6 100644
--- a/services/audioflinger/AudioResamplerCubic.cpp
+++ b/services/audioflinger/AudioResamplerCubic.cpp
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+#define LOG_TAG "AudioSRC"
+
 #include <stdint.h>
 #include <string.h>
 #include <sys/types.h>
@@ -22,8 +24,6 @@
 #include "AudioResampler.h"
 #include "AudioResamplerCubic.h"
 
-#define LOG_TAG "AudioSRC"
-
 namespace android {
 // ----------------------------------------------------------------------------
 
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index 6afccec..786f2fa 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -224,6 +224,7 @@
         public PackageInfo pkgInfo;
         public int pmToken; // in post-install restore, the PM's token for this transaction
         public boolean needFullBackup;
+        public String[] filterSet;
 
         RestoreParams(IBackupTransport _transport, IRestoreObserver _obs,
                 long _token, PackageInfo _pkg, int _pmToken, boolean _needFullBackup) {
@@ -233,6 +234,7 @@
             pkgInfo = _pkg;
             pmToken = _pmToken;
             needFullBackup = _needFullBackup;
+            filterSet = null;
         }
 
         RestoreParams(IBackupTransport _transport, IRestoreObserver _obs, long _token,
@@ -243,6 +245,18 @@
             pkgInfo = null;
             pmToken = 0;
             needFullBackup = _needFullBackup;
+            filterSet = null;
+        }
+
+        RestoreParams(IBackupTransport _transport, IRestoreObserver _obs, long _token,
+                String[] _filterSet, boolean _needFullBackup) {
+            transport = _transport;
+            observer = _obs;
+            token = _token;
+            pkgInfo = null;
+            pmToken = 0;
+            needFullBackup = _needFullBackup;
+            filterSet = _filterSet;
         }
     }
 
@@ -404,7 +418,7 @@
                 Slog.d(TAG, "MSG_RUN_RESTORE observer=" + params.observer);
                 (new PerformRestoreTask(params.transport, params.observer,
                         params.token, params.pkgInfo, params.pmToken,
-                        params.needFullBackup)).run();
+                        params.needFullBackup, params.filterSet)).run();
                 break;
             }
 
@@ -3020,6 +3034,7 @@
         private File mStateDir;
         private int mPmToken;
         private boolean mNeedFullBackup;
+        private HashSet<String> mFilterSet;
 
         class RestoreRequest {
             public PackageInfo app;
@@ -3033,7 +3048,7 @@
 
         PerformRestoreTask(IBackupTransport transport, IRestoreObserver observer,
                 long restoreSetToken, PackageInfo targetPackage, int pmToken,
-                boolean needFullBackup) {
+                boolean needFullBackup, String[] filterSet) {
             mTransport = transport;
             mObserver = observer;
             mToken = restoreSetToken;
@@ -3041,6 +3056,15 @@
             mPmToken = pmToken;
             mNeedFullBackup = needFullBackup;
 
+            if (filterSet != null) {
+                mFilterSet = new HashSet<String>();
+                for (String pkg : filterSet) {
+                    mFilterSet.add(pkg);
+                }
+            } else {
+                mFilterSet = null;
+            }
+
             try {
                 mStateDir = new File(mBaseStateDir, transport.transportDirName());
             } catch (RemoteException e) {
@@ -3052,7 +3076,8 @@
             long startRealtime = SystemClock.elapsedRealtime();
             if (DEBUG) Slog.v(TAG, "Beginning restore process mTransport=" + mTransport
                     + " mObserver=" + mObserver + " mToken=" + Long.toHexString(mToken)
-                    + " mTargetPackage=" + mTargetPackage + " mPmToken=" + mPmToken);
+                    + " mTargetPackage=" + mTargetPackage + " mFilterSet=" + mFilterSet
+                    + " mPmToken=" + mPmToken);
 
             PackageManagerBackupAgent pmAgent = null;
             int error = -1; // assume error
@@ -3071,6 +3096,22 @@
 
                 List<PackageInfo> agentPackages = allAgentPackages();
                 if (mTargetPackage == null) {
+                    // if there's a filter set, strip out anything that isn't
+                    // present before proceeding
+                    if (mFilterSet != null) {
+                        for (int i = agentPackages.size() - 1; i >= 0; i--) {
+                            final PackageInfo pkg = agentPackages.get(i);
+                            if (! mFilterSet.contains(pkg.packageName)) {
+                                agentPackages.remove(i);
+                            }
+                        }
+                        if (DEBUG) {
+                            Slog.i(TAG, "Post-filter package set for restore:");
+                            for (PackageInfo p : agentPackages) {
+                                Slog.i(TAG, "    " + p);
+                            }
+                        }
+                    }
                     restorePackages.addAll(agentPackages);
                 } else {
                     // Just one package to attempt restore of
@@ -4266,6 +4307,67 @@
             return -1;
         }
 
+        public synchronized int restoreSome(long token, IRestoreObserver observer,
+                String[] packages) {
+            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BACKUP,
+                    "performRestore");
+
+            if (DEBUG) {
+                StringBuilder b = new StringBuilder(128);
+                b.append("restoreSome token=");
+                b.append(Long.toHexString(token));
+                b.append(" observer=");
+                b.append(observer.toString());
+                b.append(" packages=");
+                if (packages == null) {
+                    b.append("null");
+                } else {
+                    b.append('{');
+                    boolean first = true;
+                    for (String s : packages) {
+                        if (!first) {
+                            b.append(", ");
+                        } else first = false;
+                        b.append(s);
+                    }
+                    b.append('}');
+                }
+                Slog.d(TAG, b.toString());
+            }
+
+            if (mEnded) {
+                throw new IllegalStateException("Restore session already ended");
+            }
+
+            if (mRestoreTransport == null || mRestoreSets == null) {
+                Slog.e(TAG, "Ignoring restoreAll() with no restore set");
+                return -1;
+            }
+
+            if (mPackageName != null) {
+                Slog.e(TAG, "Ignoring restoreAll() on single-package session");
+                return -1;
+            }
+
+            synchronized (mQueueLock) {
+                for (int i = 0; i < mRestoreSets.length; i++) {
+                    if (token == mRestoreSets[i].token) {
+                        long oldId = Binder.clearCallingIdentity();
+                        mWakelock.acquire();
+                        Message msg = mBackupHandler.obtainMessage(MSG_RUN_RESTORE);
+                        msg.obj = new RestoreParams(mRestoreTransport, observer, token,
+                                packages, true);
+                        mBackupHandler.sendMessage(msg);
+                        Binder.restoreCallingIdentity(oldId);
+                        return 0;
+                    }
+                }
+            }
+
+            Slog.w(TAG, "Restore token " + Long.toHexString(token) + " not found");
+            return -1;
+        }
+
         public synchronized int restorePackage(String packageName, IRestoreObserver observer) {
             if (DEBUG) Slog.v(TAG, "restorePackage pkg=" + packageName + " obs=" + observer);
 
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
index 9695344..1f24b58 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnection.java
@@ -76,8 +76,6 @@
                 + "' APN: '" + mApn.apn
                 + "' proxy: '" + mApn.proxy + "' port: '" + mApn.port);
 
-        setHttpProxy (mApn.proxy, mApn.port);
-
         createTime = -1;
         lastFailTime = -1;
         lastFailCause = FailCause.NONE;
@@ -152,38 +150,6 @@
         Log.d(LOG_TAG, "[" + getName() + "] " + s);
     }
 
-    private void setHttpProxy(String httpProxy, String httpPort) {
-
-        if (DBG) log("set http proxy for"
-                + "' APN: '" + mActiveApnType
-                + "' proxy: '" + mApn.proxy + "' port: '" + mApn.port);
-        if(TextUtils.equals(mActiveApnType, Phone.APN_TYPE_DEFAULT)) {
-            if (httpProxy == null || httpProxy.length() == 0) {
-                phone.setSystemProperty("net.gprs.http-proxy", null);
-                return;
-            }
-
-            if (httpPort == null || httpPort.length() == 0) {
-                httpPort = "8080";     // Default to port 8080
-            }
-
-            phone.setSystemProperty("net.gprs.http-proxy",
-                    "http://" + httpProxy + ":" + httpPort + "/");
-        } else {
-            if (httpProxy == null || httpProxy.length() == 0) {
-                phone.setSystemProperty("net.gprs.http-proxy." + mActiveApnType, null);
-                return;
-            }
-
-            if (httpPort == null || httpPort.length() == 0) {
-                httpPort = "8080";  // Default to port 8080
-            }
-
-            phone.setSystemProperty("net.gprs.http-proxy." + mActiveApnType,
-                    "http://" + httpProxy + ":" + httpPort + "/");
-        }
-    }
-
     private boolean isIpAddress(String address) {
         if (address == null) return false;