Merge "Improving accessibility focus traversal." into jb-dev
diff --git a/Android.mk b/Android.mk
index eef900a..b0a3dac 100644
--- a/Android.mk
+++ b/Android.mk
@@ -61,7 +61,6 @@
 LOCAL_SRC_FILES += \
 	core/java/android/accessibilityservice/IAccessibilityServiceConnection.aidl \
 	core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl \
-	core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl \
 	core/java/android/accounts/IAccountManager.aidl \
 	core/java/android/accounts/IAccountManagerResponse.aidl \
 	core/java/android/accounts/IAccountAuthenticator.aidl \
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 939c117..539b84e 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -129,6 +129,9 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IEventListener.java)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IEventListener.P)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/view/accessibility/IAccessibilityManager.P)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.java)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.P)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClient.P)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index c0fb06f..1d5f207 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -55,6 +55,10 @@
 #define SYSTEM_BOOTANIMATION_FILE "/system/media/bootanimation.zip"
 #define SYSTEM_ENCRYPTED_BOOTANIMATION_FILE "/system/media/bootanimation-encrypted.zip"
 
+extern "C" int clock_nanosleep(clockid_t clock_id, int flags,
+                           const struct timespec *request,
+                           struct timespec *remain);
+
 namespace android {
 
 // ---------------------------------------------------------------------------
@@ -476,6 +480,7 @@
         for (int r=0 ; !part.count || r<part.count ; r++) {
             for (int j=0 ; j<fcount && !exitPending(); j++) {
                 const Animation::Frame& frame(part.frames[j]);
+                nsecs_t lastFrame = systemTime();
 
                 if (r > 0) {
                     glBindTexture(GL_TEXTURE_2D, frame.tid);
@@ -508,10 +513,18 @@
 
                 nsecs_t now = systemTime();
                 nsecs_t delay = frameDuration - (now - lastFrame);
+                //ALOGD("%lld, %lld", ns2ms(now - lastFrame), ns2ms(delay));
                 lastFrame = now;
-                long wait = ns2us(delay);
-                if (wait > 0)
-                    usleep(wait);
+
+                if (delay > 0) {
+                    struct timespec spec;
+                    spec.tv_sec  = (now + delay) / 1000000000;
+                    spec.tv_nsec = (now + delay) % 1000000000;
+                    int err;
+                    do {
+                        err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL);
+                    } while (err<0 && errno == EINTR);
+                }
             }
             usleep(part.pause * ns2us(frameDuration));
         }
diff --git a/core/java/android/accessibilityservice/AccessibilityService.java b/core/java/android/accessibilityservice/AccessibilityService.java
index 850fe48..044c0c2 100644
--- a/core/java/android/accessibilityservice/AccessibilityService.java
+++ b/core/java/android/accessibilityservice/AccessibilityService.java
@@ -371,7 +371,7 @@
      *
      * <strong>Note:</strong> To receive gestures an accessibility service must
      * request that the device is in touch exploration mode by setting the
-     * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_INCLUDE_NOT_IMPORTANT_VIEWS}
+     * {@link android.accessibilityservice.AccessibilityServiceInfo#FLAG_REQUEST_TOUCH_EXPLORATION_MODE}
      * flag.
      *
      * @param gestureId The unique id of the performed gesture.
@@ -565,10 +565,8 @@
             mCaller.sendMessage(message);
         }
 
-        public void onGesture(int gestureId, IAccessibilityServiceClientCallback callback,
-                int interactionId) {
-            Message message = mCaller.obtainMessageIIO(DO_ON_GESTURE, gestureId, interactionId,
-                    callback);
+        public void onGesture(int gestureId) {
+            Message message = mCaller.obtainMessageI(DO_ON_GESTURE, gestureId);
             mCaller.sendMessage(message);
         }
 
@@ -601,15 +599,7 @@
                     return;
                 case DO_ON_GESTURE :
                     final int gestureId = message.arg1;
-                    final int interactionId = message.arg2;
-                    IAccessibilityServiceClientCallback callback =
-                        (IAccessibilityServiceClientCallback) message.obj;
-                    final boolean handled = mCallback.onGesture(gestureId);
-                    try {
-                        callback.setGestureResult(gestureId, handled, interactionId);
-                    } catch (RemoteException re) {
-                        Log.e(LOG_TAG, "Error calling back with the gesture resut.", re);
-                    }
+                    mCallback.onGesture(gestureId);
                     return;
                 default :
                     Log.w(LOG_TAG, "Unknown message type " + message.what);
diff --git a/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl b/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl
index 0257aa4..d459fd5 100644
--- a/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl
+++ b/core/java/android/accessibilityservice/IAccessibilityServiceClient.aidl
@@ -16,7 +16,6 @@
 
 package android.accessibilityservice;
 
-import android.accessibilityservice.IAccessibilityServiceClientCallback;
 import android.accessibilityservice.IAccessibilityServiceConnection;
 import android.view.accessibility.AccessibilityEvent;
 
@@ -33,5 +32,5 @@
 
     void onInterrupt();
 
-    void onGesture(int gesture, in IAccessibilityServiceClientCallback callback, int interactionId);
+    void onGesture(int gesture);
 }
diff --git a/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl b/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl
deleted file mode 100644
index 9061398..0000000
--- a/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.aidl
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-** Copyright 2012, 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 android.accessibilityservice;
-
-import android.accessibilityservice.IAccessibilityServiceConnection;
-import android.view.accessibility.AccessibilityEvent;
-
-/**
- * Callback for IAccessibilityServiceClient.
- *
- * @hide
- */
- oneway interface IAccessibilityServiceClientCallback {
-
-    void setGestureResult(int gestureId, boolean handled, int interactionId);
-}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index e2ebeba..5085b1e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -275,7 +275,7 @@
         }
 
         public String toString() {
-            ComponentName componentName = intent.getComponent();
+            ComponentName componentName = intent != null ? intent.getComponent() : null;
             return "ActivityRecord{"
                 + Integer.toHexString(System.identityHashCode(this))
                 + " token=" + token + " " + (componentName == null
diff --git a/core/java/android/preference/VolumePreference.java b/core/java/android/preference/VolumePreference.java
index fe5e76c..caf55d7 100644
--- a/core/java/android/preference/VolumePreference.java
+++ b/core/java/android/preference/VolumePreference.java
@@ -239,9 +239,7 @@
             public void onChange(boolean selfChange) {
                 super.onChange(selfChange);
                 if (mSeekBar != null && mAudioManager != null) {
-                    int volume = mAudioManager.isStreamMute(mStreamType) ?
-                            mAudioManager.getLastAudibleStreamVolume(mStreamType)
-                            : mAudioManager.getStreamVolume(mStreamType);
+                    int volume = mAudioManager.getStreamVolume(mStreamType);
                     mSeekBar.setProgress(volume);
                 }
             }
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 9d36677..3e0942c 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -154,7 +154,6 @@
         int mCurWindowPrivateFlags = mWindowPrivateFlags;
         final Rect mVisibleInsets = new Rect();
         final Rect mWinFrame = new Rect();
-        final Rect mSystemInsets = new Rect();
         final Rect mContentInsets = new Rect();
         final Configuration mConfiguration = new Configuration();
         
@@ -254,7 +253,7 @@
 
         final BaseIWindow mWindow = new BaseIWindow() {
             @Override
-            public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
+            public void resized(int w, int h, Rect contentInsets,
                     Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
                 Message msg = mCaller.obtainMessageI(MSG_WINDOW_RESIZED,
                         reportDraw ? 1 : 0);
@@ -621,7 +620,7 @@
 
                     final int relayoutResult = mSession.relayout(
                         mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
-                            View.VISIBLE, 0, mWinFrame, mSystemInsets, mContentInsets,
+                            View.VISIBLE, 0, mWinFrame, mContentInsets,
                             mVisibleInsets, mConfiguration, mSurfaceHolder.mSurface);
 
                     if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl
index 555f306..b4caad3 100644
--- a/core/java/android/view/IWindow.aidl
+++ b/core/java/android/view/IWindow.aidl
@@ -45,7 +45,7 @@
      */
     void executeCommand(String command, String parameters, in ParcelFileDescriptor descriptor);
 
-    void resized(int w, int h, in Rect systemInsets, in Rect contentInsets,
+    void resized(int w, int h, in Rect contentInsets,
             in Rect visibleInsets, boolean reportDraw, in Configuration newConfig);
     void dispatchAppVisibility(boolean visible);
     void dispatchGetNewSurface();
diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl
index f26d5e1..d4a03ce 100644
--- a/core/java/android/view/IWindowSession.aidl
+++ b/core/java/android/view/IWindowSession.aidl
@@ -58,10 +58,6 @@
      * {@link WindowManagerImpl#RELAYOUT_DEFER_SURFACE_DESTROY}.
      * @param outFrame Rect in which is placed the new position/size on
      * screen.
-     * @param outSystemInsets Rect in which is placed the offsets from
-     * <var>outFrame</var> over which any core system UI elements are
-     * currently covering the window.  This is not generally used for
-     * layout, but just to know where the window is obscured.
      * @param outContentInsets Rect in which is placed the offsets from
      * <var>outFrame</var> in which the content of the window should be
      * placed.  This can be used to modify the window layout to ensure its
@@ -83,7 +79,7 @@
      */
     int relayout(IWindow window, int seq, in WindowManager.LayoutParams attrs,
             int requestedWidth, int requestedHeight, int viewVisibility,
-            int flags, out Rect outFrame, out Rect outSystemInsets,
+            int flags, out Rect outFrame,
             out Rect outContentInsets, out Rect outVisibleInsets,
             out Configuration outConfig, out Surface outSurface);
 
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index ee322f8..fd302dc 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -98,7 +98,6 @@
     MyWindow mWindow;
     final Rect mVisibleInsets = new Rect();
     final Rect mWinFrame = new Rect();
-    final Rect mSystemInsets = new Rect();
     final Rect mContentInsets = new Rect();
     final Configuration mConfiguration = new Configuration();
     
@@ -231,7 +230,17 @@
     public void setVisibility(int visibility) {
         super.setVisibility(visibility);
         mViewVisibility = visibility == VISIBLE;
-        mRequestedVisible = mWindowVisibility && mViewVisibility;
+        boolean newRequestedVisible = mWindowVisibility && mViewVisibility;
+        if (newRequestedVisible != mRequestedVisible) {
+            // our base class (View) invalidates the layout only when
+            // we go from/to the GONE state. However, SurfaceView needs
+            // to request a re-layout when the visibility changes at all.
+            // This is needed because the transparent region is computed
+            // as part of the layout phase, and it changes (obviously) when
+            // the visibility changes.
+            requestLayout();
+        }
+        mRequestedVisible = newRequestedVisible;
         updateWindow(false, false);
     }
 
@@ -472,7 +481,7 @@
                         mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                             visible ? VISIBLE : GONE,
                             WindowManagerImpl.RELAYOUT_DEFER_SURFACE_DESTROY,
-                            mWinFrame, mSystemInsets, mContentInsets,
+                            mWinFrame, mContentInsets,
                             mVisibleInsets, mConfiguration, mNewSurface);
                     if ((relayoutResult&WindowManagerImpl.RELAYOUT_RES_FIRST_TIME) != 0) {
                         mReportDrawNeeded = true;
@@ -606,7 +615,7 @@
             mSurfaceView = new WeakReference<SurfaceView>(surfaceView);
         }
 
-        public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
+        public void resized(int w, int h, Rect contentInsets,
                 Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
             SurfaceView surfaceView = mSurfaceView.get();
             if (surfaceView != null) {
diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java
index f703e34..f5870e1 100644
--- a/core/java/android/view/VelocityTracker.java
+++ b/core/java/android/view/VelocityTracker.java
@@ -60,8 +60,7 @@
     private static native void nativeComputeCurrentVelocity(int ptr, int units, float maxVelocity);
     private static native float nativeGetXVelocity(int ptr, int id);
     private static native float nativeGetYVelocity(int ptr, int id);
-    private static native boolean nativeGetEstimator(int ptr, int id,
-            int degree, int horizonMillis, Estimator outEstimator);
+    private static native boolean nativeGetEstimator(int ptr, int id, Estimator outEstimator);
 
     /**
      * Retrieve a new VelocityTracker object to watch the velocity of a
@@ -227,21 +226,17 @@
      * this method.
      *
      * @param id Which pointer's velocity to return.
-     * @param degree The desired polynomial degree.  The actual estimator may have
-     * a lower degree than what is requested here.  If -1, uses the default degree.
-     * @param horizonMillis The maximum age of the oldest sample to consider, in milliseconds.
-     * If -1, uses the default horizon.
      * @param outEstimator The estimator to populate.
      * @return True if an estimator was obtained, false if there is no information
      * available about the pointer.
      *
      * @hide For internal use only.  Not a final API.
      */
-    public boolean getEstimator(int id, int degree, int horizonMillis, Estimator outEstimator) {
+    public boolean getEstimator(int id, Estimator outEstimator) {
         if (outEstimator == null) {
             throw new IllegalArgumentException("outEstimator must not be null");
         }
-        return nativeGetEstimator(mPtr, id, degree, horizonMillis, outEstimator);
+        return nativeGetEstimator(mPtr, id, outEstimator);
     }
 
     /**
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 42fd63f..14523d3 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4737,11 +4737,9 @@
         getBoundsOnScreen(bounds);
         info.setBoundsInScreen(bounds);
 
-        if ((mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
-            ViewParent parent = getParentForAccessibility();
-            if (parent instanceof View) {
-                info.setParent((View) parent);
-            }
+        ViewParent parent = getParentForAccessibility();
+        if (parent instanceof View) {
+            info.setParent((View) parent);
         }
 
         info.setVisibleToUser(isVisibleToUser());
@@ -6519,6 +6517,9 @@
      *       that is interesting for accessilility purposes.
      */
     public void notifyAccessibilityStateChanged() {
+        if (!AccessibilityManager.getInstance(mContext).isEnabled()) {
+            return;
+        }
         if ((mPrivateFlags2 & ACCESSIBILITY_STATE_CHANGED) == 0) {
             mPrivateFlags2 |= ACCESSIBILITY_STATE_CHANGED;
             if (mParent != null) {
@@ -15282,10 +15283,12 @@
     /**
      * Sets the next animation to play for this view.
      * If you want the animation to play immediately, use
-     * startAnimation. This method provides allows fine-grained
+     * {@link #startAnimation(android.view.animation.Animation)} instead.
+     * This method provides allows fine-grained
      * control over the start time and invalidation, but you
      * must make sure that 1) the animation has a start time set, and
-     * 2) the view will be invalidated when the animation is supposed to
+     * 2) the view's parent (which controls animations on its children)
+     * will be invalidated when the animation is supposed to
      * start.
      *
      * @param animation The next animation, or null.
@@ -17163,12 +17166,6 @@
         boolean mUse32BitDrawingCache;
 
         /**
-         * Describes the parts of the window that are currently completely
-         * obscured by system UI elements.
-         */
-        final Rect mSystemInsets = new Rect();
-
-        /**
          * For windows that are full-screen but using insets to layout inside
          * of the screen decorations, these are the current insets for the
          * content of the window.
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index a4c0258..b95ca5e 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -1633,8 +1633,7 @@
             final int childrenCount = children.getChildCount();
             for (int i = 0; i < childrenCount; i++) {
                 View child = children.getChildAt(i);
-                if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE
-                        && (child.mPrivateFlags & IS_ROOT_NAMESPACE) == 0) {
+                if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
                     if (child.includeForAccessibility()) {
                         childrenForAccessibility.add(child);
                     } else {
diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java
index 2012db2..ce6f4c5 100644
--- a/core/java/android/view/ViewPropertyAnimator.java
+++ b/core/java/android/view/ViewPropertyAnimator.java
@@ -342,6 +342,7 @@
      * otherwise), then this method can be used.
      */
     public void start() {
+        mView.removeCallbacks(mAnimationStarter);
         startAnimation();
     }
 
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 0eee17d..f86e036 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -262,7 +262,6 @@
 
     final Rect mPendingVisibleInsets = new Rect();
     final Rect mPendingContentInsets = new Rect();
-    final Rect mPendingSystemInsets = new Rect();
     final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
             = new ViewTreeObserver.InternalInsetsInfo();
 
@@ -272,7 +271,6 @@
     final Configuration mPendingConfiguration = new Configuration();
 
     class ResizedInfo {
-        Rect systemInsets;
         Rect contentInsets;
         Rect visibleInsets;
         Configuration newConfig;
@@ -568,7 +566,6 @@
                 if (mTranslator != null) {
                     mTranslator.translateRectInScreenToAppWindow(mAttachInfo.mContentInsets);
                 }
-                mPendingSystemInsets.set(0, 0, 0, 0);
                 mPendingContentInsets.set(mAttachInfo.mContentInsets);
                 mPendingVisibleInsets.set(0, 0, 0, 0);
                 if (DEBUG_LAYOUT) Log.v(TAG, "Added window " + mWindow);
@@ -1235,7 +1232,6 @@
         getRunQueue().executeActions(attachInfo.mHandler);
 
         boolean insetsChanged = false;
-        boolean activeRectChanged = false;
 
         boolean layoutRequested = mLayoutRequested && !mStopped;
         if (layoutRequested) {
@@ -1247,12 +1243,7 @@
                 // to opposite of the added touch mode.
                 mAttachInfo.mInTouchMode = !mAddedTouchMode;
                 ensureTouchModeLocally(mAddedTouchMode);
-                activeRectChanged = true;
             } else {
-                if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) {
-                    mAttachInfo.mSystemInsets.set(mPendingSystemInsets);
-                    activeRectChanged = true;
-                }
                 if (!mPendingContentInsets.equals(mAttachInfo.mContentInsets)) {
                     insetsChanged = true;
                 }
@@ -1406,10 +1397,6 @@
                     mPendingConfiguration.seq = 0;
                 }
 
-                if (!mPendingSystemInsets.equals(mAttachInfo.mSystemInsets)) {
-                    activeRectChanged = true;
-                    mAttachInfo.mSystemInsets.set(mPendingSystemInsets);
-                }
                 contentInsetsChanged = !mPendingContentInsets.equals(
                         mAttachInfo.mContentInsets);
                 visibleInsetsChanged = !mPendingVisibleInsets.equals(
@@ -1512,7 +1499,6 @@
                         // before actually drawing them, so it can display then
                         // all at once.
                         newSurface = true;
-                        activeRectChanged = true;
                         mFullRedrawNeeded = true;
                         mPreviousTransparentRegion.setEmpty();
 
@@ -1578,7 +1564,6 @@
             // window size we asked for. We should avoid this by getting a maximum size from
             // the window session beforehand.
             if (mWidth != frame.width() || mHeight != frame.height()) {
-                activeRectChanged = true;
                 mWidth = frame.width();
                 mHeight = frame.height();
             }
@@ -2836,7 +2821,6 @@
                 ResizedInfo ri = (ResizedInfo)msg.obj;
 
                 if (mWinFrame.width() == msg.arg1 && mWinFrame.height() == msg.arg2
-                        && mPendingSystemInsets.equals(ri.systemInsets)
                         && mPendingContentInsets.equals(ri.contentInsets)
                         && mPendingVisibleInsets.equals(ri.visibleInsets)
                         && ((ResizedInfo)msg.obj).newConfig == null) {
@@ -2853,7 +2837,6 @@
                     mWinFrame.right = msg.arg1;
                     mWinFrame.top = 0;
                     mWinFrame.bottom = msg.arg2;
-                    mPendingSystemInsets.set(((ResizedInfo)msg.obj).systemInsets);
                     mPendingContentInsets.set(((ResizedInfo)msg.obj).contentInsets);
                     mPendingVisibleInsets.set(((ResizedInfo)msg.obj).visibleInsets);
                     if (msg.what == MSG_RESIZED_REPORT) {
@@ -3888,7 +3871,7 @@
                 (int) (mView.getMeasuredWidth() * appScale + 0.5f),
                 (int) (mView.getMeasuredHeight() * appScale + 0.5f),
                 viewVisibility, insetsPending ? WindowManagerImpl.RELAYOUT_INSETS_PENDING : 0,
-                mWinFrame, mPendingSystemInsets, mPendingContentInsets, mPendingVisibleInsets,
+                mWinFrame, mPendingContentInsets, mPendingVisibleInsets,
                 mPendingConfiguration, mSurface);
         //Log.d(TAG, "<<<<<< BACK FROM relayout");
         if (restore) {
@@ -4084,11 +4067,10 @@
         mHandler.sendMessage(msg);
     }
 
-    public void dispatchResized(int w, int h, Rect systemInsets, Rect contentInsets,
+    public void dispatchResized(int w, int h, Rect contentInsets,
             Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
         if (DEBUG_LAYOUT) Log.v(TAG, "Resizing " + this + ": w=" + w
-                + " h=" + h + " systemInsets=" + systemInsets.toShortString()
-                + " contentInsets=" + contentInsets.toShortString()
+                + " h=" + h + " contentInsets=" + contentInsets.toShortString()
                 + " visibleInsets=" + visibleInsets.toShortString()
                 + " reportDraw=" + reportDraw);
         Message msg = mHandler.obtainMessage(reportDraw ? MSG_RESIZED_REPORT :MSG_RESIZED);
@@ -4101,7 +4083,6 @@
         msg.arg1 = w;
         msg.arg2 = h;
         ResizedInfo ri = new ResizedInfo();
-        ri.systemInsets = new Rect(systemInsets);
         ri.contentInsets = new Rect(contentInsets);
         ri.visibleInsets = new Rect(visibleInsets);
         ri.newConfig = newConfig;
@@ -4757,11 +4738,11 @@
             mViewAncestor = new WeakReference<ViewRootImpl>(viewAncestor);
         }
 
-        public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
+        public void resized(int w, int h, Rect contentInsets,
                 Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
             final ViewRootImpl viewAncestor = mViewAncestor.get();
             if (viewAncestor != null) {
-                viewAncestor.dispatchResized(w, h, systemInsets, contentInsets,
+                viewAncestor.dispatchResized(w, h, contentInsets,
                         visibleInsets, reportDraw, newConfig);
             }
         }
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index 110c239..78984e0 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -296,41 +296,33 @@
 
     private boolean isMuted(int streamType) {
         if (streamType == STREAM_MASTER) {
-            return mAudioService.isMasterMute();
+            return mAudioManager.isMasterMute();
         } else {
-            return mAudioService.isStreamMute(streamType);
+            return mAudioManager.isStreamMute(streamType);
         }
     }
 
     private int getStreamMaxVolume(int streamType) {
         if (streamType == STREAM_MASTER) {
-            return mAudioService.getMasterMaxVolume();
+            return mAudioManager.getMasterMaxVolume();
         } else {
-            return mAudioService.getStreamMaxVolume(streamType);
+            return mAudioManager.getStreamMaxVolume(streamType);
         }
     }
 
     private int getStreamVolume(int streamType) {
         if (streamType == STREAM_MASTER) {
-            return mAudioService.getMasterVolume();
+            return mAudioManager.getMasterVolume();
         } else {
-            return mAudioService.getStreamVolume(streamType);
+            return mAudioManager.getStreamVolume(streamType);
         }
     }
 
     private void setStreamVolume(int streamType, int index, int flags) {
         if (streamType == STREAM_MASTER) {
-            mAudioService.setMasterVolume(index, flags);
+            mAudioManager.setMasterVolume(index, flags);
         } else {
-            mAudioService.setStreamVolume(streamType, index, flags);
-        }
-    }
-
-    private int getLastAudibleStreamVolume(int streamType) {
-        if (streamType == STREAM_MASTER) {
-            return mAudioService.getLastAudibleMasterVolume();
-        } else {
-            return mAudioService.getLastAudibleStreamVolume(streamType);
+            mAudioManager.setStreamVolume(streamType, index, flags);
         }
     }
 
@@ -399,13 +391,18 @@
 
     /** Update the mute and progress state of a slider */
     private void updateSlider(StreamControl sc) {
-        sc.seekbarView.setProgress(getLastAudibleStreamVolume(sc.streamType));
+        sc.seekbarView.setProgress(getStreamVolume(sc.streamType));
         final boolean muted = isMuted(sc.streamType);
         sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
-        if (sc.streamType == AudioManager.STREAM_RING && muted
-                && mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
+        if (sc.streamType == AudioManager.STREAM_RING &&
+                mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
             sc.icon.setImageResource(R.drawable.ic_audio_ring_notif_vibrate);
         }
+        if (sc.streamType != mAudioManager.getMasterStreamType() && muted) {
+            sc.seekbarView.setEnabled(false);
+        } else {
+            sc.seekbarView.setEnabled(true);
+        }
     }
 
     private boolean isExpanded() {
@@ -510,9 +507,7 @@
     }
 
     protected void onShowVolumeChanged(int streamType, int flags) {
-        int index = isMuted(streamType) ?
-                getLastAudibleStreamVolume(streamType)
-                : getStreamVolume(streamType);
+        int index = getStreamVolume(streamType);
 
         mRingIsSilent = false;
 
@@ -592,6 +587,11 @@
                 sc.seekbarView.setMax(max);
             }
             sc.seekbarView.setProgress(index);
+            if (streamType != mAudioManager.getMasterStreamType() && isMuted(streamType)) {
+                sc.seekbarView.setEnabled(false);
+            } else {
+                sc.seekbarView.setEnabled(true);
+            }
         }
 
         if (!mDialog.isShowing()) {
@@ -607,8 +607,7 @@
         // Do a little vibrate if applicable (only when going into vibrate mode)
         if ((flags & AudioManager.FLAG_VIBRATE) != 0 &&
                 mAudioService.isStreamAffectedByRingerMode(streamType) &&
-                mAudioService.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE &&
-                mAudioService.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
+                mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_VIBRATE) {
             sendMessageDelayed(obtainMessage(MSG_VIBRATE), VIBRATE_DELAY);
         }
     }
@@ -646,7 +645,7 @@
     protected void onVibrate() {
 
         // Make sure we ended up in vibrate ringer mode
-        if (mAudioService.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE) {
+        if (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_VIBRATE) {
             return;
         }
 
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index bc38368..0c5d6ea 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -145,10 +145,6 @@
          * @param displayFrame The frame of the overall display in which this
          * window can appear, used for constraining the overall dimensions
          * of the window.
-         * @param systemFrame The frame within the display that any system
-         * elements are currently covering.  These indicate which parts of
-         * the window should be considered completely obscured by the screen
-         * decorations.
          * @param contentFrame The frame within the display in which we would
          * like active content to appear.  This will cause windows behind to
          * be resized to match the given content frame.
@@ -160,7 +156,7 @@
          * are visible.
          */
         public void computeFrameLw(Rect parentFrame, Rect displayFrame,
-                Rect systemFrame, Rect contentFrame, Rect visibleFrame);
+                Rect contentFrame, Rect visibleFrame);
 
         /**
          * Retrieve the current frame of the window that has been assigned by
@@ -188,14 +184,6 @@
         public Rect getDisplayFrameLw();
 
         /**
-         * Retrieve the frame of the system elements that last covered the window.
-         * Must be called with the window manager lock held.
-         *
-         * @return Rect The rectangle holding the system frame.
-         */
-        public Rect getSystemFrameLw();
-
-        /**
          * Retrieve the frame of the content area that this window was last
          * laid out in.  This is the area in which the content of the window
          * should be placed.  It will be smaller than the display frame to
@@ -773,6 +761,21 @@
     public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotation);
 
     /**
+     * Return the rectangle of the screen currently covered by system decorations.
+     * This will be called immediately after {@link #layoutWindowLw}.  It can
+     * fill in the rectangle to indicate any part of the screen that it knows
+     * for sure is covered by system decor such as the status bar.  The rectangle
+     * is initially set to the actual size of the screen, indicating nothing is
+     * covered.
+     *
+     * @param systemRect The rectangle of the screen that is not covered by
+     * system decoration.
+     * @return Returns the layer above which the system rectangle should
+     * not be applied.
+     */
+    public int getSystemDecorRectLw(Rect systemRect);
+
+    /**
      * Called for each window attached to the window manager as layout is
      * proceeding.  The implementation of this function must take care of
      * setting the window's frame, either here or in finishLayout().
@@ -797,7 +800,7 @@
      * 
      */
     public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
-    
+
     /**
      * Called when layout of the windows is finished.  After this function has
      * returned, all windows given to layoutWindow() <em>must</em> have had a
diff --git a/core/java/android/view/accessibility/AccessibilityInteractionClient.java b/core/java/android/view/accessibility/AccessibilityInteractionClient.java
index 24e90fd..bd341d0 100644
--- a/core/java/android/view/accessibility/AccessibilityInteractionClient.java
+++ b/core/java/android/view/accessibility/AccessibilityInteractionClient.java
@@ -441,10 +441,6 @@
         sAccessibilityNodeInfoCache.clear();
     }
 
-    public void removeCachedNode(long accessibilityNodeId) {
-        sAccessibilityNodeInfoCache.remove(accessibilityNodeId);
-    }
-
     public void onAccessibilityEvent(AccessibilityEvent event) {
         sAccessibilityNodeInfoCache.onAccessibilityEvent(event);
     }
@@ -630,7 +626,7 @@
             applyCompatibilityScaleIfNeeded(info, windowScale);
             info.setConnectionId(connectionId);
             info.setSealed(true);
-            sAccessibilityNodeInfoCache.put(info.getSourceNodeId(), info);
+            sAccessibilityNodeInfoCache.add(info);
         }
     }
 
diff --git a/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java b/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java
index d2609bb..52b7772 100644
--- a/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java
+++ b/core/java/android/view/accessibility/AccessibilityNodeInfoCache.java
@@ -16,10 +16,15 @@
 
 package android.view.accessibility;
 
+import android.os.Build;
 import android.util.Log;
 import android.util.LongSparseArray;
 import android.util.SparseLongArray;
 
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Queue;
+
 /**
  * Simple cache for AccessibilityNodeInfos. The cache is mapping an
  * accessibility id to an info. The cache allows storing of
@@ -36,10 +41,14 @@
 
     private static final boolean DEBUG = false;
 
+    private static final boolean CHECK_INTEGRITY = true;
+
     private final Object mLock = new Object();
 
     private final LongSparseArray<AccessibilityNodeInfo> mCacheImpl;
 
+    private int mWindowId;
+
     public AccessibilityNodeInfoCache() {
         if (ENABLED) {
             mCacheImpl = new LongSparseArray<AccessibilityNodeInfo>();
@@ -59,21 +68,49 @@
             final int eventType = event.getEventType();
             switch (eventType) {
                 case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED: {
+                    // New window so we clear the cache.
+                    mWindowId = event.getWindowId();
                     clear();
                 } break;
+                case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
+                case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: {
+                    final int windowId = event.getWindowId();
+                    if (mWindowId != windowId) {
+                        // New window so we clear the cache.
+                        mWindowId = windowId;
+                        clear();
+                    }
+                } break;
                 case AccessibilityEvent.TYPE_VIEW_FOCUSED:
+                case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED:
                 case AccessibilityEvent.TYPE_VIEW_SELECTED:
                 case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
                 case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: {
-                    final long accessibilityNodeId = event.getSourceNodeId();
-                    remove(accessibilityNodeId);
+                    // Since we prefetch the descendants of a node we
+                    // just remove the entire subtree since when the node
+                    // is fetched we will gets its descendant anyway.
+                    synchronized (mLock) {
+                        final long sourceId = event.getSourceNodeId();
+                        clearSubTreeLocked(sourceId);
+                        if (eventType == AccessibilityEvent.TYPE_VIEW_FOCUSED) {
+                            clearSubtreeWithOldInputFocusLocked(sourceId);
+                        }
+                        if (eventType == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) {
+                            clearSubtreeWithOldAccessibilityFocusLocked(sourceId);
+                        }
+                    }
                 } break;
                 case AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED:
                 case AccessibilityEvent.TYPE_VIEW_SCROLLED: {
-                    final long accessibilityNodeId = event.getSourceNodeId();
-                    clearSubTree(accessibilityNodeId);
+                    synchronized (mLock) {
+                        final long accessibilityNodeId = event.getSourceNodeId();
+                        clearSubTreeLocked(accessibilityNodeId);
+                    }
                 } break;
             }
+            if (Build.IS_DEBUGGABLE && CHECK_INTEGRITY) {
+                checkIntegrity();
+            }
         }
     }
 
@@ -105,51 +142,45 @@
     /**
      * Caches an {@link AccessibilityNodeInfo} given its accessibility node id.
      *
-     * @param accessibilityNodeId The info accessibility node id.
      * @param info The {@link AccessibilityNodeInfo} to cache.
      */
-    public void put(long accessibilityNodeId, AccessibilityNodeInfo info) {
+    public void add(AccessibilityNodeInfo info) {
         if (ENABLED) {
             synchronized(mLock) {
                 if (DEBUG) {
-                    Log.i(LOG_TAG, "put(" + accessibilityNodeId + ", " + info + ")");
+                    Log.i(LOG_TAG, "add(" + info + ")");
                 }
+
+                final long sourceId = info.getSourceNodeId();
+                AccessibilityNodeInfo oldInfo = mCacheImpl.get(sourceId);
+                if (oldInfo != null) {
+                    // If the added node is in the cache we have to be careful if
+                    // the new one represents a source state where some of the
+                    // children have been removed to avoid having disconnected
+                    // subtrees in the cache.
+                    SparseLongArray oldChildrenIds = oldInfo.getChildNodeIds();
+                    SparseLongArray newChildrenIds = info.getChildNodeIds();
+                    final int oldChildCount = oldChildrenIds.size();
+                    for (int i = 0; i < oldChildCount; i++) {
+                        final long oldChildId = oldChildrenIds.valueAt(i);
+                        if (newChildrenIds.indexOfValue(oldChildId) < 0) {
+                            clearSubTreeLocked(oldChildId);
+                        }
+                    }
+
+                    // Also be careful if the parent has changed since the new
+                    // parent may be a predecessor of the old parent which will
+                    // make the cached tree cyclic.
+                    final long oldParentId = oldInfo.getParentNodeId();
+                    if (info.getParentNodeId() != oldParentId) {
+                        clearSubTreeLocked(oldParentId);
+                    }
+                }
+
                 // Cache a copy since the client calls to AccessibilityNodeInfo#recycle()
                 // will wipe the data of the cached info.
                 AccessibilityNodeInfo clone = AccessibilityNodeInfo.obtain(info);
-                mCacheImpl.put(accessibilityNodeId, clone);
-            }
-        }
-    }
-
-    /**
-     * Returns whether the cache contains an accessibility node id key.
-     *
-     * @param accessibilityNodeId The key for which to check.
-     * @return True if the key is in the cache.
-     */
-    public boolean containsKey(long accessibilityNodeId) {
-        if (ENABLED) {
-            synchronized(mLock) {
-                return (mCacheImpl.indexOfKey(accessibilityNodeId) >= 0);
-            }
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Removes a cached {@link AccessibilityNodeInfo}.
-     *
-     * @param accessibilityNodeId The info accessibility node id.
-     */
-    public void remove(long accessibilityNodeId) {
-        if (ENABLED) {
-            synchronized(mLock) {
-                if (DEBUG) {
-                    Log.i(LOG_TAG, "remove(" + accessibilityNodeId + ")");
-                }
-                mCacheImpl.remove(accessibilityNodeId);
+                mCacheImpl.put(sourceId, clone);
             }
         }
     }
@@ -179,7 +210,7 @@
      *
      * @param rootNodeId The root id.
      */
-    private void clearSubTree(long rootNodeId) {
+    private void clearSubTreeLocked(long rootNodeId) {
         AccessibilityNodeInfo current = mCacheImpl.get(rootNodeId);
         if (current == null) {
             return;
@@ -189,7 +220,124 @@
         final int childCount = childNodeIds.size();
         for (int i = 0; i < childCount; i++) {
             final long childNodeId = childNodeIds.valueAt(i);
-            clearSubTree(childNodeId);
+            clearSubTreeLocked(childNodeId);
+        }
+    }
+
+    /**
+     * We are enforcing the invariant for a single input focus.
+     *
+     * @param currentInputFocusId The current input focused node.
+     */
+    private void clearSubtreeWithOldInputFocusLocked(long currentInputFocusId) {
+        final int cacheSize = mCacheImpl.size();
+        for (int i = 0; i < cacheSize; i++) {
+            AccessibilityNodeInfo info = mCacheImpl.valueAt(i);
+            final long infoSourceId = info.getSourceNodeId();
+            if (infoSourceId != currentInputFocusId && info.isFocused()) {
+                clearSubTreeLocked(infoSourceId);
+                return;
+            }
+        }
+    }
+
+    /**
+     * We are enforcing the invariant for a single accessibility focus.
+     *
+     * @param currentInputFocusId The current input focused node.
+     */
+    private void clearSubtreeWithOldAccessibilityFocusLocked(long currentAccessibilityFocusId) {
+        final int cacheSize = mCacheImpl.size();
+        for (int i = 0; i < cacheSize; i++) {
+            AccessibilityNodeInfo info = mCacheImpl.valueAt(i);
+            final long infoSourceId = info.getSourceNodeId();
+            if (infoSourceId != currentAccessibilityFocusId && info.isAccessibilityFocused()) {
+                clearSubTreeLocked(infoSourceId);
+                return;
+            }
+        }
+    }
+
+    /**
+     * Check the integrity of the cache which is it does not have nodes
+     * from more than one window, there are no duplicates, all nodes are
+     * connected, there is a single input focused node, and there is a
+     * single accessibility focused node.
+     */
+    private void checkIntegrity() {
+        synchronized (mLock) {
+            // Get the root.
+            if (mCacheImpl.size() <= 0) {
+                return;
+            }
+
+            // If the cache is a tree it does not matter from
+            // which node we start to search for the root.
+            AccessibilityNodeInfo root = mCacheImpl.valueAt(0);
+            AccessibilityNodeInfo parent = root;
+            while (parent != null) {
+                root = parent;
+                parent = mCacheImpl.get(parent.getParentNodeId());
+            }
+
+            // Traverse the tree and do some checks.
+            final int windowId = root.getWindowId();
+            AccessibilityNodeInfo accessFocus = null;
+            AccessibilityNodeInfo inputFocus = null;
+            HashSet<AccessibilityNodeInfo> seen = new HashSet<AccessibilityNodeInfo>();
+            Queue<AccessibilityNodeInfo> fringe = new LinkedList<AccessibilityNodeInfo>();
+            fringe.add(root);
+
+            while (!fringe.isEmpty()) {
+                AccessibilityNodeInfo current = fringe.poll();
+                // Check for duplicates
+                if (!seen.add(current)) {
+                    Log.e(LOG_TAG, "Duplicate node: " + current);
+                    return;
+                }
+
+                // Check for one accessibility focus.
+                if (current.isAccessibilityFocused()) {
+                    if (accessFocus != null) {
+                        Log.e(LOG_TAG, "Duplicate accessibility focus:" + current);
+                    } else {
+                        accessFocus = current;
+                    }
+                }
+
+                // Check for one input focus.
+                if (current.isFocused()) {
+                    if (inputFocus != null) {
+                        Log.e(LOG_TAG, "Duplicate input focus: " + current);
+                    } else {
+                        inputFocus = current;
+                    }
+                }
+
+                SparseLongArray childIds = current.getChildNodeIds();
+                final int childCount = childIds.size();
+                for (int i = 0; i < childCount; i++) {
+                    final long childId = childIds.valueAt(i);
+                    AccessibilityNodeInfo child = mCacheImpl.get(childId);
+                    if (child != null) {
+                        fringe.add(child);
+                    }
+                }
+            }
+
+            // Check for disconnected nodes or ones from another window.
+            final int cacheSize = mCacheImpl.size();
+            for (int i = 0; i < cacheSize; i++) {
+                AccessibilityNodeInfo info = mCacheImpl.valueAt(i);
+                if (!seen.contains(info)) {
+                    if (info.getWindowId() == windowId) {
+                        Log.e(LOG_TAG, "Disconneced node: ");
+                    } else {
+                        Log.e(LOG_TAG, "Node from: " + info.getWindowId() + " not from:"
+                                + windowId + " " + info);
+                    }
+                }
+            }
         }
     }
 }
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index eb6b7e3..f4796d5 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -88,7 +88,6 @@
 import android.view.ViewGroup;
 import android.view.ViewParent;
 import android.view.ViewRootImpl;
-import android.view.ViewTreeObserver;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityManager;
@@ -888,20 +887,18 @@
     private Point mSelectHandleLeftOffset;
     private Point mSelectHandleRightOffset;
     private Point mSelectHandleCenterOffset;
-    private Point mSelectCursorBase = new Point();
-    private int mSelectCursorBaseLayerId;
-    private QuadF mSelectCursorBaseTextQuad = new QuadF();
-    private Point mSelectCursorExtent = new Point();
-    private int mSelectCursorExtentLayerId;
-    private QuadF mSelectCursorExtentTextQuad = new QuadF();
+    private Point mSelectCursorLeft = new Point();
+    private int mSelectCursorLeftLayerId;
+    private QuadF mSelectCursorLeftTextQuad = new QuadF();
+    private Point mSelectCursorRight = new Point();
+    private int mSelectCursorRightLayerId;
+    private QuadF mSelectCursorRightTextQuad = new QuadF();
     private Point mSelectDraggingCursor;
     private Point mSelectDraggingOffset;
     private QuadF mSelectDraggingTextQuad;
     private boolean mIsCaretSelection;
-    static final int HANDLE_ID_START = 0;
-    static final int HANDLE_ID_END = 1;
-    static final int HANDLE_ID_BASE = 2;
-    static final int HANDLE_ID_EXTENT = 3;
+    static final int HANDLE_ID_LEFT = 0;
+    static final int HANDLE_ID_RIGHT = 1;
 
     // the color used to highlight the touch rectangles
     static final int HIGHLIGHT_COLOR = 0x6633b5e5;
@@ -3722,13 +3719,13 @@
             return;
         }
         if (mSelectingText) {
-            if (mSelectCursorBaseLayerId == mCurrentScrollingLayerId) {
-                mSelectCursorBase.offset(dx, dy);
-                mSelectCursorBaseTextQuad.offset(dx, dy);
+            if (mSelectCursorLeftLayerId == mCurrentScrollingLayerId) {
+                mSelectCursorLeft.offset(dx, dy);
+                mSelectCursorLeftTextQuad.offset(dx, dy);
             }
-            if (mSelectCursorExtentLayerId == mCurrentScrollingLayerId) {
-                mSelectCursorExtent.offset(dx, dy);
-                mSelectCursorExtentTextQuad.offset(dx, dy);
+            if (mSelectCursorRightLayerId == mCurrentScrollingLayerId) {
+                mSelectCursorRight.offset(dx, dy);
+                mSelectCursorRightTextQuad.offset(dx, dy);
             }
         } else if (mHandleAlpha.getAlpha() > 0) {
             // stop fading as we're not going to move with the layer.
@@ -3829,6 +3826,9 @@
         // reset the flag since we set to true in if need after
         // loading is see onPageFinished(Url)
         mAccessibilityScriptInjected = false;
+
+        // Don't start out editing.
+        mIsEditingText = false;
     }
 
     /**
@@ -4589,18 +4589,10 @@
      * startX, startY, endX, endY
      */
     private void getSelectionHandles(int[] handles) {
-        handles[0] = mSelectCursorBase.x;
-        handles[1] = mSelectCursorBase.y;
-        handles[2] = mSelectCursorExtent.x;
-        handles[3] = mSelectCursorExtent.y;
-        if (!nativeIsBaseFirst(mNativeClass)) {
-            int swap = handles[0];
-            handles[0] = handles[2];
-            handles[2] = swap;
-            swap = handles[1];
-            handles[1] = handles[3];
-            handles[3] = swap;
-        }
+        handles[0] = mSelectCursorLeft.x;
+        handles[1] = mSelectCursorLeft.y;
+        handles[2] = mSelectCursorRight.x;
+        handles[3] = mSelectCursorRight.y;
     }
 
     // draw history
@@ -5107,8 +5099,8 @@
         ClipboardManager cm = (ClipboardManager)(mContext
                 .getSystemService(Context.CLIPBOARD_SERVICE));
         if (cm.hasPrimaryClip()) {
-            Point cursorPoint = new Point(contentToViewX(mSelectCursorBase.x),
-                    contentToViewY(mSelectCursorBase.y));
+            Point cursorPoint = new Point(contentToViewX(mSelectCursorLeft.x),
+                    contentToViewY(mSelectCursorLeft.y));
             Point cursorTop = calculateCaretTop();
             cursorTop.set(contentToViewX(cursorTop.x),
                     contentToViewY(cursorTop.y));
@@ -5158,12 +5150,12 @@
      * calculates the top of a caret.
      */
     private Point calculateCaretTop() {
-        float scale = scaleAlongSegment(mSelectCursorBase.x, mSelectCursorBase.y,
-                mSelectCursorBaseTextQuad.p4, mSelectCursorBaseTextQuad.p3);
+        float scale = scaleAlongSegment(mSelectCursorLeft.x, mSelectCursorLeft.y,
+                mSelectCursorLeftTextQuad.p4, mSelectCursorLeftTextQuad.p3);
         int x = Math.round(scaleCoordinate(scale,
-                mSelectCursorBaseTextQuad.p1.x, mSelectCursorBaseTextQuad.p2.x));
+                mSelectCursorLeftTextQuad.p1.x, mSelectCursorLeftTextQuad.p2.x));
         int y = Math.round(scaleCoordinate(scale,
-                mSelectCursorBaseTextQuad.p1.y, mSelectCursorBaseTextQuad.p2.y));
+                mSelectCursorLeftTextQuad.p1.y, mSelectCursorLeftTextQuad.p2.y));
         return new Point(x, y);
     }
 
@@ -5174,46 +5166,40 @@
     }
 
     private void syncSelectionCursors() {
-        mSelectCursorBaseLayerId =
-                nativeGetHandleLayerId(mNativeClass, HANDLE_ID_BASE,
-                        mSelectCursorBase, mSelectCursorBaseTextQuad);
-        mSelectCursorExtentLayerId =
-                nativeGetHandleLayerId(mNativeClass, HANDLE_ID_EXTENT,
-                        mSelectCursorExtent, mSelectCursorExtentTextQuad);
+        mSelectCursorLeftLayerId =
+                nativeGetHandleLayerId(mNativeClass, HANDLE_ID_LEFT,
+                        mSelectCursorLeft, mSelectCursorLeftTextQuad);
+        mSelectCursorRightLayerId =
+                nativeGetHandleLayerId(mNativeClass, HANDLE_ID_RIGHT,
+                        mSelectCursorRight, mSelectCursorRightTextQuad);
     }
 
     private void adjustSelectionCursors() {
-        boolean wasDraggingStart = (mSelectDraggingCursor == mSelectCursorBase);
+        if (mIsCaretSelection) {
+            return; // no need to swap left and right handles.
+        }
+
+        boolean wasDraggingLeft = (mSelectDraggingCursor == mSelectCursorLeft);
         int oldX = mSelectDraggingCursor.x;
         int oldY = mSelectDraggingCursor.y;
-        int oldStartX = mSelectCursorBase.x;
-        int oldStartY = mSelectCursorBase.y;
-        int oldEndX = mSelectCursorExtent.x;
-        int oldEndY = mSelectCursorExtent.y;
-
+        int oldLeftX = mSelectCursorLeft.x;
+        int oldLeftY = mSelectCursorLeft.y;
+        int oldRightX = mSelectCursorRight.x;
+        int oldRightY = mSelectCursorRight.y;
         syncSelectionCursors();
-        boolean dragChanged = oldX != mSelectDraggingCursor.x ||
-                oldY != mSelectDraggingCursor.y;
-        if (dragChanged && !mIsCaretSelection) {
-            boolean draggingStart;
-            if (wasDraggingStart) {
-                float endStart = distanceSquared(oldEndX, oldEndY,
-                        mSelectCursorBase);
-                float endEnd = distanceSquared(oldEndX, oldEndY,
-                        mSelectCursorExtent);
-                draggingStart = endStart > endEnd;
-            } else {
-                float startStart = distanceSquared(oldStartX, oldStartY,
-                        mSelectCursorBase);
-                float startEnd = distanceSquared(oldStartX, oldStartY,
-                        mSelectCursorExtent);
-                draggingStart = startStart > startEnd;
-            }
-            mSelectDraggingCursor = (draggingStart
-                    ? mSelectCursorBase : mSelectCursorExtent);
-            mSelectDraggingTextQuad = (draggingStart
-                    ? mSelectCursorBaseTextQuad : mSelectCursorExtentTextQuad);
-            mSelectDraggingOffset = (draggingStart
+
+        boolean rightChanged = (oldRightX != mSelectCursorRight.x
+                || oldRightY != mSelectCursorRight.y);
+        boolean leftChanged = (oldLeftX != mSelectCursorLeft.x
+                || oldLeftY != mSelectCursorLeft.y);
+        if (leftChanged && rightChanged) {
+            // Left and right switched places, so swap dragging cursor
+            boolean draggingLeft = !wasDraggingLeft;
+            mSelectDraggingCursor = (draggingLeft
+                    ? mSelectCursorLeft : mSelectCursorRight);
+            mSelectDraggingTextQuad = (draggingLeft
+                    ? mSelectCursorLeftTextQuad : mSelectCursorRightTextQuad);
+            mSelectDraggingOffset = (draggingLeft
                     ? mSelectHandleLeftOffset : mSelectHandleRightOffset);
         }
         mSelectDraggingCursor.set(oldX, oldY);
@@ -5239,14 +5225,11 @@
     private void updateWebkitSelection() {
         int[] handles = null;
         if (mIsCaretSelection) {
-            mSelectCursorExtent.set(mSelectCursorBase.x, mSelectCursorBase.y);
+            mSelectCursorRight.set(mSelectCursorLeft.x, mSelectCursorLeft.y);
         }
         if (mSelectingText) {
             handles = new int[4];
-            handles[0] = mSelectCursorBase.x;
-            handles[1] = mSelectCursorBase.y;
-            handles[2] = mSelectCursorExtent.x;
-            handles[3] = mSelectCursorExtent.y;
+            getSelectionHandles(handles);
         } else {
             nativeSetTextSelection(mNativeClass, 0);
         }
@@ -5610,21 +5593,21 @@
         Point caretTop = calculateCaretTop();
         if (visibleRect.width() < mEditTextContentBounds.width()) {
             // The whole edit won't fit in the width, so use the caret rect
-            if (mSelectCursorBase.x < caretTop.x) {
-                showRect.left = Math.max(0, mSelectCursorBase.x - buffer);
+            if (mSelectCursorLeft.x < caretTop.x) {
+                showRect.left = Math.max(0, mSelectCursorLeft.x - buffer);
                 showRect.right = caretTop.x + buffer;
             } else {
                 showRect.left = Math.max(0, caretTop.x - buffer);
-                showRect.right = mSelectCursorBase.x + buffer;
+                showRect.right = mSelectCursorLeft.x + buffer;
             }
         }
         if (visibleRect.height() < mEditTextContentBounds.height()) {
             // The whole edit won't fit in the height, so use the caret rect
-            if (mSelectCursorBase.y > caretTop.y) {
+            if (mSelectCursorLeft.y > caretTop.y) {
                 showRect.top = Math.max(0, caretTop.y - buffer);
-                showRect.bottom = mSelectCursorBase.y + buffer;
+                showRect.bottom = mSelectCursorLeft.y + buffer;
             } else {
-                showRect.top = Math.max(0, mSelectCursorBase.y - buffer);
+                showRect.top = Math.max(0, mSelectCursorLeft.y - buffer);
                 showRect.bottom = caretTop.y + buffer;
             }
         }
@@ -5885,25 +5868,25 @@
                         if (mSelectHandleCenter != null && mSelectHandleCenter.getBounds()
                                 .contains(shiftedX, shiftedY)) {
                             mSelectionStarted = true;
-                            mSelectDraggingCursor = mSelectCursorBase;
+                            mSelectDraggingCursor = mSelectCursorLeft;
                             mSelectDraggingOffset = mSelectHandleCenterOffset;
-                            mSelectDraggingTextQuad = mSelectCursorBaseTextQuad;
+                            mSelectDraggingTextQuad = mSelectCursorLeftTextQuad;
                             mPrivateHandler.removeMessages(CLEAR_CARET_HANDLE);
                             hidePasteButton();
                         } else if (mSelectHandleLeft != null
                                 && mSelectHandleLeft.getBounds()
                                     .contains(shiftedX, shiftedY)) {
-                                mSelectionStarted = true;
-                                mSelectDraggingCursor = mSelectCursorBase;
-                                mSelectDraggingOffset = mSelectHandleLeftOffset;
-                                mSelectDraggingTextQuad = mSelectCursorBaseTextQuad;
+                            mSelectionStarted = true;
+                            mSelectDraggingOffset = mSelectHandleLeftOffset;
+                            mSelectDraggingCursor = mSelectCursorLeft;
+                            mSelectDraggingTextQuad = mSelectCursorLeftTextQuad;
                         } else if (mSelectHandleRight != null
                                 && mSelectHandleRight.getBounds()
                                 .contains(shiftedX, shiftedY)) {
                             mSelectionStarted = true;
-                            mSelectDraggingCursor = mSelectCursorExtent;
                             mSelectDraggingOffset = mSelectHandleRightOffset;
-                            mSelectDraggingTextQuad = mSelectCursorExtentTextQuad;
+                            mSelectDraggingCursor = mSelectCursorRight;
+                            mSelectDraggingTextQuad = mSelectCursorRightTextQuad;
                         } else if (mIsCaretSelection) {
                             selectionDone();
                         }
@@ -8648,7 +8631,6 @@
     private native void     nativeUpdateDrawGLFunction(int nativeInstance, Rect invScreenRect,
             Rect screenRect, RectF visibleContentRect, float scale);
     private native String   nativeGetSelection();
-    private native Rect     nativeLayerBounds(int layer);
     private native void     nativeSetHeightCanMeasure(boolean measure);
     private native boolean  nativeSetBaseLayer(int nativeInstance,
             int layer, boolean showVisualIndicator, boolean isPictureAfterFirstLayout);
@@ -8691,7 +8673,6 @@
     private static native void nativeSetTextSelection(int instance, int selection);
     private static native int nativeGetHandleLayerId(int instance, int handle,
             Point cursorLocation, QuadF textQuad);
-    private static native boolean nativeIsBaseFirst(int instance);
     private static native void nativeMapLayerRect(int instance, int layerId,
             Rect rect);
     // Returns 1 if a layer sync is needed, else 0
diff --git a/core/java/android/widget/CheckedTextView.java b/core/java/android/widget/CheckedTextView.java
index 278192c..61935c2 100644
--- a/core/java/android/widget/CheckedTextView.java
+++ b/core/java/android/widget/CheckedTextView.java
@@ -93,6 +93,7 @@
         if (mChecked != checked) {
             mChecked = checked;
             refreshDrawableState();
+            notifyAccessibilityStateChanged();
         }
     }
 
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 02c4c4f..0a71c5a 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -114,6 +114,7 @@
         if (mChecked != checked) {
             mChecked = checked;
             refreshDrawableState();
+            notifyAccessibilityStateChanged();
 
             // Avoid infinite recursions if setChecked() is called from a listener
             if (mBroadcasting) {
diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java
index cb10d0a..60a1d15 100644
--- a/core/java/android/widget/GridLayout.java
+++ b/core/java/android/widget/GridLayout.java
@@ -581,7 +581,7 @@
     }
 
     private int getDefaultMargin(View c, boolean isAtEdge, boolean horizontal, boolean leading) {
-        return /*isAtEdge ? DEFAULT_CONTAINER_MARGIN :*/ getDefaultMargin(c, horizontal, leading);
+        return isAtEdge ? DEFAULT_CONTAINER_MARGIN : getDefaultMargin(c, horizontal, leading);
     }
 
     private int getDefaultMargin(View c, LayoutParams p, boolean horizontal, boolean leading) {
@@ -733,6 +733,11 @@
     @Override
     protected void onSetLayoutParams(View child, ViewGroup.LayoutParams layoutParams) {
         super.onSetLayoutParams(child, layoutParams);
+
+        if (!checkLayoutParams(layoutParams)) {
+            handleInvalidParams("supplied LayoutParams are of the wrong type");
+        }
+
         invalidateStructure();
     }
 
@@ -740,6 +745,43 @@
         return (LayoutParams) c.getLayoutParams();
     }
 
+    private static void handleInvalidParams(String msg) {
+        throw new IllegalArgumentException(msg + ". ");
+    }
+
+    private void checkLayoutParams(LayoutParams lp, boolean horizontal) {
+        String groupName = horizontal ? "column" : "row";
+        Spec spec = horizontal ? lp.columnSpec : lp.rowSpec;
+        Interval span = spec.span;
+        if (span.min != UNDEFINED && span.min < 0) {
+            handleInvalidParams(groupName + " indices must be positive");
+        }
+        Axis axis = horizontal ? horizontalAxis : verticalAxis;
+        int count = axis.definedCount;
+        if (count != UNDEFINED) {
+            if (span.max > count) {
+                handleInvalidParams(groupName +
+                        " indices (start + span) mustn't exceed the " + groupName + " count");
+            }
+            if (span.size() > count) {
+                handleInvalidParams(groupName + " span mustn't exceed the " + groupName + " count");
+            }
+        }
+    }
+
+    @Override
+    protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
+        if (!(p instanceof LayoutParams)) {
+            return false;
+        }
+        LayoutParams lp = (LayoutParams) p;
+
+        checkLayoutParams(lp, true);
+        checkLayoutParams(lp, false);
+
+        return true;
+    }
+
     @Override
     protected LayoutParams generateDefaultLayoutParams() {
         return new LayoutParams();
@@ -1143,6 +1185,7 @@
                 Interval span = spec.span;
                 result = max(result, span.min);
                 result = max(result, span.max);
+                result = max(result, span.size());
             }
             return result == -1 ? UNDEFINED : result;
         }
@@ -1159,6 +1202,11 @@
         }
 
         public void setCount(int count) {
+            if (count != UNDEFINED && count < getMaxIndex()) {
+                handleInvalidParams((horizontal ? "column" : "row") +
+                        "Count must be greater than or equal to the maximum of all grid indices " +
+                        "(and spans) defined in the LayoutParams of each child");
+            }
             this.definedCount = count;
         }
 
@@ -1478,20 +1526,6 @@
         This is a special case of the Linear Programming problem that is, in turn,
         equivalent to the single-source shortest paths problem on a digraph, for
         which the O(n^2) Bellman-Ford algorithm the most commonly used general solution.
-
-        Other algorithms are faster in the case where no arcs have negative weights
-        but allowing negative weights turns out to be the same as accommodating maximum
-        size requirements as well as minimum ones.
-
-        Bellman-Ford works by iteratively 'relaxing' constraints over all nodes (an O(N)
-        process) and performing this step N times. Proof of correctness hinges on the
-        fact that there can be no negative weight chains of length > N - unless a
-        'negative weight loop' exists. The algorithm catches this case in a final
-        checking phase that reports failure.
-
-        By topologically sorting the nodes and checking this condition at each step
-        typical layout problems complete after the first iteration and the algorithm
-        completes in O(N) steps with very low constants.
         */
         private void solve(Arc[] arcs, int[] locations) {
             String axisName = horizontal ? "horizontal" : "vertical";
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 56eca01..abf2eb2 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -1472,6 +1472,10 @@
         }
 
         setText(mText);
+
+        if (hasPasswordTransformationMethod()) {
+            notifyAccessibilityStateChanged();
+        }
     }
 
     /**
diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java
index fbed4859..4c34d73 100644
--- a/core/java/com/android/internal/view/BaseIWindow.java
+++ b/core/java/com/android/internal/view/BaseIWindow.java
@@ -33,7 +33,7 @@
         mSession = session;
     }
     
-    public void resized(int w, int h, Rect systemInsets, Rect contentInsets,
+    public void resized(int w, int h, Rect contentInsets,
             Rect visibleInsets, boolean reportDraw, Configuration newConfig) {
         if (reportDraw) {
             try {
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index 9fbca82..458ea2f 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -873,15 +873,20 @@
 
         boolean invoked = itemImpl.invoke();
 
+        final ActionProvider provider = item.getActionProvider();
+        final boolean providerHasSubMenu = provider != null && provider.hasSubMenu();
         if (itemImpl.hasCollapsibleActionView()) {
             invoked |= itemImpl.expandActionView();
             if (invoked) close(true);
-        } else if (item.hasSubMenu()) {
+        } else if (itemImpl.hasSubMenu() || providerHasSubMenu) {
             close(false);
 
-            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
-            final ActionProvider provider = item.getActionProvider();
-            if (provider != null && provider.hasSubMenu()) {
+            if (!itemImpl.hasSubMenu()) {
+                itemImpl.setSubMenu(new SubMenuBuilder(getContext(), this, itemImpl));
+            }
+
+            final SubMenuBuilder subMenu = (SubMenuBuilder) itemImpl.getSubMenu();
+            if (providerHasSubMenu) {
                 provider.onPrepareSubMenu(subMenu);
             }
             invoked |= dispatchSubMenuSelected(subMenu);
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java
index 1d6af90..85e6c16 100644
--- a/core/java/com/android/internal/widget/PointerLocationView.java
+++ b/core/java/com/android/internal/widget/PointerLocationView.java
@@ -527,7 +527,7 @@
                 ps.addTrace(coords.x, coords.y);
                 ps.mXVelocity = mVelocity.getXVelocity(id);
                 ps.mYVelocity = mVelocity.getYVelocity(id);
-                mVelocity.getEstimator(id, -1, -1, ps.mEstimator);
+                mVelocity.getEstimator(id, ps.mEstimator);
                 ps.mToolType = event.getToolType(i);
             }
         }
diff --git a/core/jni/android_view_VelocityTracker.cpp b/core/jni/android_view_VelocityTracker.cpp
index 04d1056..0180e0a 100644
--- a/core/jni/android_view_VelocityTracker.cpp
+++ b/core/jni/android_view_VelocityTracker.cpp
@@ -48,8 +48,7 @@
     void addMovement(const MotionEvent* event);
     void computeCurrentVelocity(int32_t units, float maxVelocity);
     void getVelocity(int32_t id, float* outVx, float* outVy);
-    bool getEstimator(int32_t id, uint32_t degree, nsecs_t horizon,
-            VelocityTracker::Estimator* outEstimator);
+    bool getEstimator(int32_t id, VelocityTracker::Estimator* outEstimator);
 
 private:
     struct Velocity {
@@ -129,9 +128,8 @@
     }
 }
 
-bool VelocityTrackerState::getEstimator(int32_t id, uint32_t degree, nsecs_t horizon,
-        VelocityTracker::Estimator* outEstimator) {
-    return mVelocityTracker.getEstimator(id, degree, horizon, outEstimator);
+bool VelocityTrackerState::getEstimator(int32_t id, VelocityTracker::Estimator* outEstimator) {
+    return mVelocityTracker.getEstimator(id, outEstimator);
 }
 
 
@@ -186,14 +184,10 @@
 }
 
 static jboolean android_view_VelocityTracker_nativeGetEstimator(JNIEnv* env, jclass clazz,
-        jint ptr, jint id, jint degree, jint horizonMillis, jobject outEstimatorObj) {
+        jint ptr, jint id, jobject outEstimatorObj) {
     VelocityTrackerState* state = reinterpret_cast<VelocityTrackerState*>(ptr);
     VelocityTracker::Estimator estimator;
-    bool result = state->getEstimator(id,
-            degree < 0 ? VelocityTracker::DEFAULT_DEGREE : uint32_t(degree),
-            horizonMillis < 0 ? VelocityTracker::DEFAULT_HORIZON :
-                    nsecs_t(horizonMillis) * 1000000L,
-            &estimator);
+    bool result = state->getEstimator(id, &estimator);
 
     jfloatArray xCoeffObj = jfloatArray(env->GetObjectField(outEstimatorObj,
             gEstimatorClassInfo.xCoeff));
@@ -236,7 +230,7 @@
             "(II)F",
             (void*)android_view_VelocityTracker_nativeGetYVelocity },
     { "nativeGetEstimator",
-            "(IIIILandroid/view/VelocityTracker$Estimator;)Z",
+            "(IILandroid/view/VelocityTracker$Estimator;)Z",
             (void*)android_view_VelocityTracker_nativeGetEstimator },
 };
 
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_answer_active.png b/core/res/res/drawable-hdpi/ic_lockscreen_answer_active.png
deleted file mode 100644
index d201bfb7..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_answer_active.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_answer_focused.png b/core/res/res/drawable-hdpi/ic_lockscreen_answer_focused.png
deleted file mode 100644
index efb29f1..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_answer_focused.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_answer_normal.png b/core/res/res/drawable-hdpi/ic_lockscreen_answer_normal.png
deleted file mode 100644
index 176d448..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_answer_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_decline_activated.png b/core/res/res/drawable-hdpi/ic_lockscreen_decline_activated.png
deleted file mode 100644
index 9866769..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_decline_activated.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_decline_focused.png b/core/res/res/drawable-hdpi/ic_lockscreen_decline_focused.png
deleted file mode 100644
index f37b16a..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_decline_focused.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_decline_normal.png b/core/res/res/drawable-hdpi/ic_lockscreen_decline_normal.png
deleted file mode 100644
index d88087b..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_decline_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_text_activated.png b/core/res/res/drawable-hdpi/ic_lockscreen_text_activated.png
deleted file mode 100644
index 0ebff0b..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_text_activated.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_text_focusde.png b/core/res/res/drawable-hdpi/ic_lockscreen_text_focusde.png
deleted file mode 100644
index 5f1b881..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_text_focusde.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_text_normal.png b/core/res/res/drawable-hdpi/ic_lockscreen_text_normal.png
deleted file mode 100644
index bf73a26..0000000
--- a/core/res/res/drawable-hdpi/ic_lockscreen_text_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_answer_active.png b/core/res/res/drawable-mdpi/ic_lockscreen_answer_active.png
deleted file mode 100644
index 0ad03c0..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_answer_active.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_answer_focused.png b/core/res/res/drawable-mdpi/ic_lockscreen_answer_focused.png
deleted file mode 100644
index f46e8bd..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_answer_focused.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_answer_normal.png b/core/res/res/drawable-mdpi/ic_lockscreen_answer_normal.png
deleted file mode 100644
index ddeeb18..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_answer_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_decline_activated.png b/core/res/res/drawable-mdpi/ic_lockscreen_decline_activated.png
deleted file mode 100644
index d1aae18..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_decline_activated.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_decline_focused.png b/core/res/res/drawable-mdpi/ic_lockscreen_decline_focused.png
deleted file mode 100644
index b52c844..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_decline_focused.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_decline_normal.png b/core/res/res/drawable-mdpi/ic_lockscreen_decline_normal.png
deleted file mode 100644
index 722027e..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_decline_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_text_activated.png b/core/res/res/drawable-mdpi/ic_lockscreen_text_activated.png
deleted file mode 100644
index 878ff1f..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_text_activated.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_text_focusde.png b/core/res/res/drawable-mdpi/ic_lockscreen_text_focusde.png
deleted file mode 100644
index 1de7586..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_text_focusde.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_text_normal.png b/core/res/res/drawable-mdpi/ic_lockscreen_text_normal.png
deleted file mode 100644
index e007322..0000000
--- a/core/res/res/drawable-mdpi/ic_lockscreen_text_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_answer_active.png b/core/res/res/drawable-xhdpi/ic_lockscreen_answer_active.png
deleted file mode 100644
index 8edf62d..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_answer_active.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_answer_focused.png b/core/res/res/drawable-xhdpi/ic_lockscreen_answer_focused.png
deleted file mode 100644
index 2a47e9b..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_answer_focused.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_answer_normal.png b/core/res/res/drawable-xhdpi/ic_lockscreen_answer_normal.png
deleted file mode 100644
index f049dc9..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_answer_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_decline_activated.png b/core/res/res/drawable-xhdpi/ic_lockscreen_decline_activated.png
deleted file mode 100644
index 4244ca0..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_decline_activated.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_decline_focused.png b/core/res/res/drawable-xhdpi/ic_lockscreen_decline_focused.png
deleted file mode 100644
index a98a379..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_decline_focused.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_decline_normal.png b/core/res/res/drawable-xhdpi/ic_lockscreen_decline_normal.png
deleted file mode 100644
index fa2a0f4..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_decline_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_text_activated.png b/core/res/res/drawable-xhdpi/ic_lockscreen_text_activated.png
deleted file mode 100644
index ddebe3e..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_text_activated.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_text_focusde.png b/core/res/res/drawable-xhdpi/ic_lockscreen_text_focusde.png
deleted file mode 100644
index 42c8ad2..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_text_focusde.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_text_normal.png b/core/res/res/drawable-xhdpi/ic_lockscreen_text_normal.png
deleted file mode 100644
index ff65f20..0000000
--- a/core/res/res/drawable-xhdpi/ic_lockscreen_text_normal.png
+++ /dev/null
Binary files differ
diff --git a/core/res/res/drawable/ic_lockscreen_answer.xml b/core/res/res/drawable/ic_lockscreen_answer.xml
deleted file mode 100644
index dd50930..0000000
--- a/core/res/res/drawable/ic_lockscreen_answer.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item
-        android:state_enabled="true"
-        android:state_active="false"
-        android:state_focused="false"
-        android:drawable="@drawable/ic_lockscreen_answer_normal" />
-
-    <item
-        android:state_enabled="true"
-        android:state_active="true"
-        android:state_focused="false"
-        android:drawable="@drawable/ic_lockscreen_answer_active" />
-
-    <item
-        android:state_enabled="true"
-        android:state_active="false"
-        android:state_focused="true"
-        android:drawable="@drawable/ic_lockscreen_answer_active" />
-
-</selector>
diff --git a/core/res/res/drawable/ic_lockscreen_decline.xml b/core/res/res/drawable/ic_lockscreen_decline.xml
deleted file mode 100644
index 58e9d38..0000000
--- a/core/res/res/drawable/ic_lockscreen_decline.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item
-        android:state_enabled="true"
-        android:state_active="false"
-        android:state_focused="false"
-        android:drawable="@drawable/ic_lockscreen_decline_normal" />
-
-    <item
-        android:state_enabled="true"
-        android:state_active="true"
-        android:state_focused="false"
-        android:drawable="@drawable/ic_lockscreen_decline_activated" />
-
-    <item
-        android:state_enabled="true"
-        android:state_active="false"
-        android:state_focused="true"
-        android:drawable="@drawable/ic_lockscreen_decline_activated" />
-
-</selector>
diff --git a/core/res/res/drawable/ic_lockscreen_send_sms.xml b/core/res/res/drawable/ic_lockscreen_send_sms.xml
deleted file mode 100644
index 0d09297..0000000
--- a/core/res/res/drawable/ic_lockscreen_send_sms.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
-    <item
-        android:state_enabled="true"
-        android:state_active="false"
-        android:state_focused="false"
-        android:drawable="@drawable/ic_lockscreen_text_normal" />
-
-    <item
-        android:state_enabled="true"
-        android:state_active="true"
-        android:state_focused="false"
-        android:drawable="@drawable/ic_lockscreen_text_activated" />
-
-    <item
-        android:state_enabled="true"
-        android:state_active="false"
-        android:state_focused="true"
-        android:drawable="@drawable/ic_lockscreen_text_activated" />
-
-</selector>
diff --git a/core/res/res/layout-large/action_mode_close_item.xml b/core/res/res/layout-large/action_mode_close_item.xml
index 96aa451..f8b397a 100644
--- a/core/res/res/layout-large/action_mode_close_item.xml
+++ b/core/res/res/layout-large/action_mode_close_item.xml
@@ -34,6 +34,7 @@
               android:layout_marginLeft="4dip"
               android:layout_marginRight="16dip"
               android:textAppearance="?android:attr/textAppearanceSmall"
+              android:textColor="?android:attr/actionMenuTextColor"
               android:textSize="12sp"
               android:textAllCaps="true"
               android:text="@string/action_mode_done" />
diff --git a/core/res/res/values-da/strings.xml b/core/res/res/values-da/strings.xml
index d31afa1..25cfb7f 100644
--- a/core/res/res/values-da/strings.xml
+++ b/core/res/res/values-da/strings.xml
@@ -796,7 +796,7 @@
     <string name="js_dialog_title_default" msgid="6961903213729667573">"Javascript"</string>
     <string name="js_dialog_before_unload" msgid="730366588032430474">"Vil du gå væk fra denne side?"\n\n"<xliff:g id="MESSAGE">%s</xliff:g>"\n\n"Tryk på OK for at fortsætte eller Annuller for at blive på den aktuelle side."</string>
     <string name="save_password_label" msgid="6860261758665825069">"Bekræft"</string>
-    <string name="double_tap_toast" msgid="4595046515400268881">"Tip: Dobbeltklik for at zoome ind eller ud."</string>
+    <string name="double_tap_toast" msgid="4595046515400268881">"Tip! Dobbeltklik for at zoome ind eller ud."</string>
     <string name="autofill_this_form" msgid="4616758841157816676">"Autofyld"</string>
     <string name="setup_autofill" msgid="7103495070180590814">"Konfigurer Autofyld"</string>
     <string name="autofill_address_name_separator" msgid="6350145154779706772">" "</string>
@@ -997,7 +997,7 @@
     <string name="launch_warning_original" msgid="188102023021668683">"<xliff:g id="APP_NAME">%1$s</xliff:g> blev oprindeligt åbnet."</string>
     <string name="screen_compat_mode_scale" msgid="3202955667675944499">"Skaler"</string>
     <string name="screen_compat_mode_show" msgid="4013878876486655892">"Vis altid"</string>
-    <string name="screen_compat_mode_hint" msgid="1064524084543304459">"Aktiver dette igen i Systemindstillinger &gt; Apps &gt; Downloadet."</string>
+    <string name="screen_compat_mode_hint" msgid="1064524084543304459">"Aktivér dette igen i Systemindstillinger &gt; Apps &gt; Downloadet."</string>
     <string name="smv_application" msgid="3307209192155442829">"Appen <xliff:g id="APPLICATION">%1$s</xliff:g> (proces <xliff:g id="PROCESS">%2$s</xliff:g>) har overtrådt sin egen StrictMode-politik."</string>
     <string name="smv_process" msgid="5120397012047462446">"Processen <xliff:g id="PROCESS">%1$s</xliff:g> har overtrådt sin egen StrictMode-politik."</string>
     <string name="android_upgrading_title" msgid="1584192285441405746">"Android opgraderes..."</string>
diff --git a/core/res/res/values-de/strings.xml b/core/res/res/values-de/strings.xml
index 225f8e6..3d51570 100644
--- a/core/res/res/values-de/strings.xml
+++ b/core/res/res/values-de/strings.xml
@@ -1107,7 +1107,7 @@
     <string name="usb_ptp_notification_title" msgid="1960817192216064833">"Als Kamera angeschlossen"</string>
     <string name="usb_cd_installer_notification_title" msgid="6774712827892090754">"Als Installationsprogramm angeschlossen"</string>
     <string name="usb_accessory_notification_title" msgid="7848236974087653666">"Mit USB-Zubehör verbunden"</string>
-    <string name="usb_notification_message" msgid="2290859399983720271">"Zum Anzeigen weiterer USB-Optionen berühren"</string>
+    <string name="usb_notification_message" msgid="2290859399983720271">"Für mehr USB-Optionen berühren"</string>
     <string name="extmedia_format_title" product="nosdcard" msgid="9020092196061007262">"USB-Speicher formatieren?"</string>
     <string name="extmedia_format_title" product="default" msgid="3648415921526526069">"SD-Karte formatieren?"</string>
     <string name="extmedia_format_message" product="nosdcard" msgid="3934016853425761078">"Alle in Ihrem USB-Speicher abgelegten Dateien werden gelöscht. Diese Aktion kann nicht rückgängig gemacht werden!"</string>
diff --git a/core/res/res/values-ja/strings.xml b/core/res/res/values-ja/strings.xml
index 800f503..7e3e95b 100644
--- a/core/res/res/values-ja/strings.xml
+++ b/core/res/res/values-ja/strings.xml
@@ -175,28 +175,20 @@
     <string name="permgroupdesc_location" msgid="5704679763124170100">"現在地を追跡します。"</string>
     <string name="permgrouplab_network" msgid="5808983377727109831">"ネットワーク通信"</string>
     <string name="permgroupdesc_network" msgid="4478299413241861987">"さまざまなネットワーク機能にアクセスします。"</string>
-    <!-- no translation found for permgrouplab_bluetoothNetwork (1585403544162128109) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_bluetoothNetwork (5625288577164282391) -->
-    <skip />
-    <!-- no translation found for permgrouplab_shortrangeNetwork (130808676377486118) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_shortrangeNetwork (1884069062653436007) -->
-    <skip />
+    <string name="permgrouplab_bluetoothNetwork" msgid="1585403544162128109">"Bluetooth"</string>
+    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Bluetooth経由でデバイスやネットワークにアクセスします。"</string>
+    <string name="permgrouplab_shortrangeNetwork" msgid="130808676377486118">"短距離ネットワーク"</string>
+    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"NFCなどの近距離ネットワーク経由でデバイスにアクセスします。"</string>
     <string name="permgrouplab_audioSettings" msgid="8329261670151871235">"音声設定"</string>
     <string name="permgroupdesc_audioSettings" msgid="2641515403347568130">"音声設定を変更します。"</string>
     <string name="permgrouplab_affectsBattery" msgid="6209246653424798033">"電池への影響"</string>
     <string name="permgroupdesc_affectsBattery" msgid="6441275320638916947">"短時間で電池を消費する機能を使用します。"</string>
     <string name="permgrouplab_calendar" msgid="5863508437783683902">"カレンダー"</string>
     <string name="permgroupdesc_calendar" msgid="5777534316982184416">"カレンダーと予定に直接アクセスします。"</string>
-    <!-- no translation found for permgrouplab_dictionary (4148597128843641379) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_dictionary (7921166355964764490) -->
-    <skip />
-    <!-- no translation found for permgrouplab_writeDictionary (8090237702432576788) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_writeDictionary (2711561994497361646) -->
-    <skip />
+    <string name="permgrouplab_dictionary" msgid="4148597128843641379">"単語リストの読み取り"</string>
+    <string name="permgroupdesc_dictionary" msgid="7921166355964764490">"単語リストから語句を読み取ります。"</string>
+    <string name="permgrouplab_writeDictionary" msgid="8090237702432576788">"単語リストへの書き込み"</string>
+    <string name="permgroupdesc_writeDictionary" msgid="2711561994497361646">"単語リストに語句を追加します。"</string>
     <string name="permgrouplab_bookmarks" msgid="1949519673103968229">"ブックマークと履歴"</string>
     <string name="permgroupdesc_bookmarks" msgid="4169771606257963028">"ブックマークとブラウザの履歴に直接アクセスします。"</string>
     <string name="permgrouplab_deviceAlarms" msgid="6117704629728824101">"アラーム"</string>
@@ -569,8 +561,7 @@
     <string name="permdesc_sdcardRead" product="nosdcard" msgid="3530894470637667917">"USBストレージ(写真やメディアなど)の読み取りをアプリに許可します。"</string>
     <string name="permdesc_sdcardRead" product="default" msgid="2555811422562526606">"SDカードのコンテンツ(写真やメディアなど)の読み取りをアプリに許可します。"</string>
     <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"USBストレージのコンテンツの変更または削除"</string>
-    <!-- no translation found for permlab_sdcardWrite (8805693630050458763) -->
-    <skip />
+    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"SDカードのコンテンツの変更または削除"</string>
     <string name="permdesc_sdcardWrite" product="nosdcard" msgid="6175406299445710888">"USBストレージへの書き込みをアプリに許可します。"</string>
     <string name="permdesc_sdcardWrite" product="default" msgid="4337417790936632090">"SDカードへの書き込みをアプリに許可します。"</string>
     <string name="permlab_mediaStorageWrite" product="default" msgid="6859839199706879015">"内部メディアストレージの内容の変更/削除"</string>
@@ -1090,8 +1081,7 @@
     <string name="date_time_set" msgid="5777075614321087758">"設定"</string>
     <string name="date_time_done" msgid="2507683751759308828">"完了"</string>
     <string name="perms_new_perm_prefix" msgid="8257740710754301407"><font size="12" fgcolor="#ff900000">"NEW: "</font></string>
-    <!-- no translation found for perms_description_app (5139836143293299417) -->
-    <skip />
+    <string name="perms_description_app" msgid="5139836143293299417">"<xliff:g id="APP_NAME">%1$s</xliff:g>で提供されます。"</string>
     <string name="no_permissions" msgid="7283357728219338112">"権限の許可は必要ありません"</string>
     <string name="usb_storage_activity_title" msgid="4465055157209648641">"USBマスストレージ"</string>
     <string name="usb_storage_title" msgid="5901459041398751495">"USB接続"</string>
@@ -1322,6 +1312,5 @@
     <string name="launchBrowserDefault" msgid="2057951947297614725">"ブラウザを起動しますか?"</string>
     <string name="SetupCallDefault" msgid="5834948469253758575">"通話を受けますか?"</string>
     <string name="activity_resolver_use_always" msgid="8017770747801494933">"常時"</string>
-    <!-- no translation found for activity_resolver_use_once (405646673463328329) -->
-    <skip />
+    <string name="activity_resolver_use_once" msgid="405646673463328329">"今回のみ"</string>
 </resources>
diff --git a/core/res/res/values-nb/strings.xml b/core/res/res/values-nb/strings.xml
index d39c75c..a0e00eb 100644
--- a/core/res/res/values-nb/strings.xml
+++ b/core/res/res/values-nb/strings.xml
@@ -175,28 +175,20 @@
     <string name="permgroupdesc_location" msgid="5704679763124170100">"Overvåking av telefonens fysiske posisjon."</string>
     <string name="permgrouplab_network" msgid="5808983377727109831">"Nettverkstilgang"</string>
     <string name="permgroupdesc_network" msgid="4478299413241861987">"Tilgang til ulike nettverksfunksjoner."</string>
-    <!-- no translation found for permgrouplab_bluetoothNetwork (1585403544162128109) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_bluetoothNetwork (5625288577164282391) -->
-    <skip />
-    <!-- no translation found for permgrouplab_shortrangeNetwork (130808676377486118) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_shortrangeNetwork (1884069062653436007) -->
-    <skip />
+    <string name="permgrouplab_bluetoothNetwork" msgid="1585403544162128109">"Bluetooth"</string>
+    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Bruke enheter og nettverk gjennom Bluetooth"</string>
+    <string name="permgrouplab_shortrangeNetwork" msgid="130808676377486118">"Nettverk med kort rekkevidde"</string>
+    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"Bruke enheter via nettverk med kort rekkevidde, som NFC."</string>
     <string name="permgrouplab_audioSettings" msgid="8329261670151871235">"Lydinnstillingene"</string>
     <string name="permgroupdesc_audioSettings" msgid="2641515403347568130">"Endre lydinnstillingene."</string>
     <string name="permgrouplab_affectsBattery" msgid="6209246653424798033">"Påvirker batteriet"</string>
     <string name="permgroupdesc_affectsBattery" msgid="6441275320638916947">"Bruke funksjoner som kan tappe batteriet fortere."</string>
     <string name="permgrouplab_calendar" msgid="5863508437783683902">"Kalenderen"</string>
     <string name="permgroupdesc_calendar" msgid="5777534316982184416">"Direkte tilgang til kalenderen og aktiviteter."</string>
-    <!-- no translation found for permgrouplab_dictionary (4148597128843641379) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_dictionary (7921166355964764490) -->
-    <skip />
-    <!-- no translation found for permgrouplab_writeDictionary (8090237702432576788) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_writeDictionary (2711561994497361646) -->
-    <skip />
+    <string name="permgrouplab_dictionary" msgid="4148597128843641379">"Lese brukerordlisten"</string>
+    <string name="permgroupdesc_dictionary" msgid="7921166355964764490">"Lese ord i brukerordlisten."</string>
+    <string name="permgrouplab_writeDictionary" msgid="8090237702432576788">"Skrive i brukerordlisten"</string>
+    <string name="permgroupdesc_writeDictionary" msgid="2711561994497361646">"Legge til ord i brukerordlisten."</string>
     <string name="permgrouplab_bookmarks" msgid="1949519673103968229">"Bokmerkene og loggen"</string>
     <string name="permgroupdesc_bookmarks" msgid="4169771606257963028">"Direkte tilgang til bokmerker og nettleserloggen."</string>
     <string name="permgrouplab_deviceAlarms" msgid="6117704629728824101">"Alarmen"</string>
@@ -569,8 +561,7 @@
     <string name="permdesc_sdcardRead" product="nosdcard" msgid="3530894470637667917">"Tillater at appen leser innholdet i USB-lagring, som kan inneholde bilder og medier."</string>
     <string name="permdesc_sdcardRead" product="default" msgid="2555811422562526606">"Tillater at appen leser innholdet i SD-kort, som kan inneholde bilder og medier."</string>
     <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"endrer eller sletter innholdet i USB-lagringen"</string>
-    <!-- no translation found for permlab_sdcardWrite (8805693630050458763) -->
-    <skip />
+    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"endre eller slette innhold i SD-kortet"</string>
     <string name="permdesc_sdcardWrite" product="nosdcard" msgid="6175406299445710888">"Gir appen tillatelse til å skrive til USB-lagringen."</string>
     <string name="permdesc_sdcardWrite" product="default" msgid="4337417790936632090">"Lar appen skrive til SD-kortet."</string>
     <string name="permlab_mediaStorageWrite" product="default" msgid="6859839199706879015">"endre eller slette innhold på interne medier"</string>
@@ -1090,8 +1081,7 @@
     <string name="date_time_set" msgid="5777075614321087758">"Lagre"</string>
     <string name="date_time_done" msgid="2507683751759308828">"Ferdig"</string>
     <string name="perms_new_perm_prefix" msgid="8257740710754301407"><font size="12" fgcolor="#ff900000">"NYTT: "</font></string>
-    <!-- no translation found for perms_description_app (5139836143293299417) -->
-    <skip />
+    <string name="perms_description_app" msgid="5139836143293299417">"Levert av <xliff:g id="APP_NAME">%1$s</xliff:g>."</string>
     <string name="no_permissions" msgid="7283357728219338112">"Trenger ingen rettigheter"</string>
     <string name="usb_storage_activity_title" msgid="4465055157209648641">"USB-masselagring"</string>
     <string name="usb_storage_title" msgid="5901459041398751495">"USB koblet til"</string>
@@ -1322,6 +1312,5 @@
     <string name="launchBrowserDefault" msgid="2057951947297614725">"Vil du starte nettleseren?"</string>
     <string name="SetupCallDefault" msgid="5834948469253758575">"Vil du besvare anropet?"</string>
     <string name="activity_resolver_use_always" msgid="8017770747801494933">"Alltid"</string>
-    <!-- no translation found for activity_resolver_use_once (405646673463328329) -->
-    <skip />
+    <string name="activity_resolver_use_once" msgid="405646673463328329">"Bare én gang"</string>
 </resources>
diff --git a/core/res/res/values-pl/strings.xml b/core/res/res/values-pl/strings.xml
index 60ea8e8..10effa3 100644
--- a/core/res/res/values-pl/strings.xml
+++ b/core/res/res/values-pl/strings.xml
@@ -175,28 +175,20 @@
     <string name="permgroupdesc_location" msgid="5704679763124170100">"Monitorowanie fizycznej lokalizacji"</string>
     <string name="permgrouplab_network" msgid="5808983377727109831">"Połączenia sieciowe"</string>
     <string name="permgroupdesc_network" msgid="4478299413241861987">"Uzyskiwanie dostępu do różnych funkcji sieciowych"</string>
-    <!-- no translation found for permgrouplab_bluetoothNetwork (1585403544162128109) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_bluetoothNetwork (5625288577164282391) -->
-    <skip />
-    <!-- no translation found for permgrouplab_shortrangeNetwork (130808676377486118) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_shortrangeNetwork (1884069062653436007) -->
-    <skip />
+    <string name="permgrouplab_bluetoothNetwork" msgid="1585403544162128109">"Bluetooth"</string>
+    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Urządzenia dostępowe i sieci przez Bluetooth."</string>
+    <string name="permgrouplab_shortrangeNetwork" msgid="130808676377486118">"Sieci krótkiego zasięgu"</string>
+    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"Dostęp do urządzeń przez sieci krótkiego zasięgu, takie jak NFC."</string>
     <string name="permgrouplab_audioSettings" msgid="8329261670151871235">"Ustawienia dźwięku"</string>
     <string name="permgroupdesc_audioSettings" msgid="2641515403347568130">"Zmiana ustawień dźwięku."</string>
     <string name="permgrouplab_affectsBattery" msgid="6209246653424798033">"Użycie baterii"</string>
     <string name="permgroupdesc_affectsBattery" msgid="6441275320638916947">"Korzystanie z funkcji, które mogą szybko rozładować baterię."</string>
     <string name="permgrouplab_calendar" msgid="5863508437783683902">"Kalendarz"</string>
     <string name="permgroupdesc_calendar" msgid="5777534316982184416">"Bezpośredni dostęp do kalendarza i wydarzeń."</string>
-    <!-- no translation found for permgrouplab_dictionary (4148597128843641379) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_dictionary (7921166355964764490) -->
-    <skip />
-    <!-- no translation found for permgrouplab_writeDictionary (8090237702432576788) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_writeDictionary (2711561994497361646) -->
-    <skip />
+    <string name="permgrouplab_dictionary" msgid="4148597128843641379">"Czytanie słownika użytkownika"</string>
+    <string name="permgroupdesc_dictionary" msgid="7921166355964764490">"Czytanie wyrazów ze słownika użytkownika."</string>
+    <string name="permgrouplab_writeDictionary" msgid="8090237702432576788">"Zapisywanie w słowniku użytkownika"</string>
+    <string name="permgroupdesc_writeDictionary" msgid="2711561994497361646">"Dodawanie wyrazów do słownika użytkownika."</string>
     <string name="permgrouplab_bookmarks" msgid="1949519673103968229">"Zakładki i historia"</string>
     <string name="permgroupdesc_bookmarks" msgid="4169771606257963028">"Bezpośredni dostęp do zakładek i historii przeglądarki."</string>
     <string name="permgrouplab_deviceAlarms" msgid="6117704629728824101">"Alarm"</string>
@@ -569,8 +561,7 @@
     <string name="permdesc_sdcardRead" product="nosdcard" msgid="3530894470637667917">"Zezwala aplikacji na odczytywanie zawartości pamięci USB, która może obejmować zdjęcia i multimedia."</string>
     <string name="permdesc_sdcardRead" product="default" msgid="2555811422562526606">"Zezwala aplikacji na odczytywanie zawartości karty SD, która może obejmować zdjęcia i multimedia."</string>
     <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"modyfikowanie i usuwanie zawartości pamięci USB"</string>
-    <!-- no translation found for permlab_sdcardWrite (8805693630050458763) -->
-    <skip />
+    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"modyfikowanie i usuwanie zawartości karty SD"</string>
     <string name="permdesc_sdcardWrite" product="nosdcard" msgid="6175406299445710888">"Pozwala aplikacji na zapis w pamięci USB."</string>
     <string name="permdesc_sdcardWrite" product="default" msgid="4337417790936632090">"Pozwala aplikacji na zapis na karcie SD."</string>
     <string name="permlab_mediaStorageWrite" product="default" msgid="6859839199706879015">"modyfikowanie/usuwanie zawartości pamięci wew."</string>
@@ -1090,8 +1081,7 @@
     <string name="date_time_set" msgid="5777075614321087758">"Ustaw"</string>
     <string name="date_time_done" msgid="2507683751759308828">"Gotowe"</string>
     <string name="perms_new_perm_prefix" msgid="8257740710754301407"><font size="12" fgcolor="#ff900000">"NOWE: "</font></string>
-    <!-- no translation found for perms_description_app (5139836143293299417) -->
-    <skip />
+    <string name="perms_description_app" msgid="5139836143293299417">"Dostarczane przez <xliff:g id="APP_NAME">%1$s</xliff:g>."</string>
     <string name="no_permissions" msgid="7283357728219338112">"Nie są wymagane żadne uprawnienia"</string>
     <string name="usb_storage_activity_title" msgid="4465055157209648641">"Pamięć masowa USB"</string>
     <string name="usb_storage_title" msgid="5901459041398751495">"Połączenie przez USB"</string>
@@ -1322,6 +1312,5 @@
     <string name="launchBrowserDefault" msgid="2057951947297614725">"Uruchomić przeglądarkę?"</string>
     <string name="SetupCallDefault" msgid="5834948469253758575">"Odebrać połączenie?"</string>
     <string name="activity_resolver_use_always" msgid="8017770747801494933">"Zawsze"</string>
-    <!-- no translation found for activity_resolver_use_once (405646673463328329) -->
-    <skip />
+    <string name="activity_resolver_use_once" msgid="405646673463328329">"Tylko raz"</string>
 </resources>
diff --git a/core/res/res/values-pt/strings.xml b/core/res/res/values-pt/strings.xml
index ba10acd..4236d50 100644
--- a/core/res/res/values-pt/strings.xml
+++ b/core/res/res/values-pt/strings.xml
@@ -176,9 +176,9 @@
     <string name="permgrouplab_network" msgid="5808983377727109831">"Comunicação da rede"</string>
     <string name="permgroupdesc_network" msgid="4478299413241861987">"Acesse diversos recursos de rede."</string>
     <string name="permgrouplab_bluetoothNetwork" msgid="1585403544162128109">"Bluetooth"</string>
-    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Acessar dispositivos e redes através do Bluetooth."</string>
+    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Acessar dispositivos e redes por meio do Bluetooth."</string>
     <string name="permgrouplab_shortrangeNetwork" msgid="130808676377486118">"Redes de curto alcance"</string>
-    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"Acessar dispositivos através de redes de curto alcance de redes como a NFC."</string>
+    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"Acessar dispositivos por meio de redes de curto alcance de redes como a NFC."</string>
     <string name="permgrouplab_audioSettings" msgid="8329261670151871235">"Configurações de áudio"</string>
     <string name="permgroupdesc_audioSettings" msgid="2641515403347568130">"Alterar as configurações de áudio."</string>
     <string name="permgrouplab_affectsBattery" msgid="6209246653424798033">"Afeta a bateria"</string>
diff --git a/core/res/res/values-ro/strings.xml b/core/res/res/values-ro/strings.xml
index 45783d1..dd639858 100644
--- a/core/res/res/values-ro/strings.xml
+++ b/core/res/res/values-ro/strings.xml
@@ -175,28 +175,20 @@
     <string name="permgroupdesc_location" msgid="5704679763124170100">"Monitorizează locaţia dvs. fizică."</string>
     <string name="permgrouplab_network" msgid="5808983377727109831">"Comunicare în reţea"</string>
     <string name="permgroupdesc_network" msgid="4478299413241861987">"Accesează diferite funcţii ale reţelei."</string>
-    <!-- no translation found for permgrouplab_bluetoothNetwork (1585403544162128109) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_bluetoothNetwork (5625288577164282391) -->
-    <skip />
-    <!-- no translation found for permgrouplab_shortrangeNetwork (130808676377486118) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_shortrangeNetwork (1884069062653436007) -->
-    <skip />
+    <string name="permgrouplab_bluetoothNetwork" msgid="1585403544162128109">"Bluetooth"</string>
+    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Accesează dispozitive şi reţele prin intermediul Bluetooth."</string>
+    <string name="permgrouplab_shortrangeNetwork" msgid="130808676377486118">"Reţele cu distanţă scurtă"</string>
+    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"Accesează dispozitive prin intermediul reţelelor cu distanţă scurtă, cum ar fi NFC."</string>
     <string name="permgrouplab_audioSettings" msgid="8329261670151871235">"Setările audio"</string>
     <string name="permgroupdesc_audioSettings" msgid="2641515403347568130">"Modifică setările audio."</string>
     <string name="permgrouplab_affectsBattery" msgid="6209246653424798033">"Capacitatea de a afecta bateria"</string>
     <string name="permgroupdesc_affectsBattery" msgid="6441275320638916947">"Utilizează funcţii care pot consuma rapid bateria."</string>
     <string name="permgrouplab_calendar" msgid="5863508437783683902">"Calendarul"</string>
     <string name="permgroupdesc_calendar" msgid="5777534316982184416">"Acces direct la calendar şi la evenimente."</string>
-    <!-- no translation found for permgrouplab_dictionary (4148597128843641379) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_dictionary (7921166355964764490) -->
-    <skip />
-    <!-- no translation found for permgrouplab_writeDictionary (8090237702432576788) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_writeDictionary (2711561994497361646) -->
-    <skip />
+    <string name="permgrouplab_dictionary" msgid="4148597128843641379">"Citeşte dicţionarul utilizatorului"</string>
+    <string name="permgroupdesc_dictionary" msgid="7921166355964764490">"Citeşte cuvinte din dicţionarul utilizatorului."</string>
+    <string name="permgrouplab_writeDictionary" msgid="8090237702432576788">"Scrie în dicţionarul utilizatorului"</string>
+    <string name="permgroupdesc_writeDictionary" msgid="2711561994497361646">"Adaugă cuvinte în dicţionarul utilizatorului."</string>
     <string name="permgrouplab_bookmarks" msgid="1949519673103968229">"Marcajele şi Istoricul"</string>
     <string name="permgroupdesc_bookmarks" msgid="4169771606257963028">"Acces direct la marcaje şi la istoricul navigării."</string>
     <string name="permgrouplab_deviceAlarms" msgid="6117704629728824101">"Alarma"</string>
@@ -569,8 +561,7 @@
     <string name="permdesc_sdcardRead" product="nosdcard" msgid="3530894470637667917">"Permite aplic. să citească conţin. stoc. USB, care poate include fotogr. şi media."</string>
     <string name="permdesc_sdcardRead" product="default" msgid="2555811422562526606">"Permite aplicaţiei să citească conţinutul cardului SD, care poate include fotografii şi conţinut media."</string>
     <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"modifică sau şterge conţinutul stocării USB"</string>
-    <!-- no translation found for permlab_sdcardWrite (8805693630050458763) -->
-    <skip />
+    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"modifică sau şterge conţinutul cardului SD"</string>
     <string name="permdesc_sdcardWrite" product="nosdcard" msgid="6175406299445710888">"Permite scriere în stoc. USB."</string>
     <string name="permdesc_sdcardWrite" product="default" msgid="4337417790936632090">"Permite aplicaţiei să scrie pe cardul SD."</string>
     <string name="permlab_mediaStorageWrite" product="default" msgid="6859839199706879015">"modif./şterg. conţinutul media stocat intern"</string>
@@ -1090,8 +1081,7 @@
     <string name="date_time_set" msgid="5777075614321087758">"Setaţi"</string>
     <string name="date_time_done" msgid="2507683751759308828">"Terminat"</string>
     <string name="perms_new_perm_prefix" msgid="8257740710754301407"><font size="12" fgcolor="#ff900000">"NOU: "</font></string>
-    <!-- no translation found for perms_description_app (5139836143293299417) -->
-    <skip />
+    <string name="perms_description_app" msgid="5139836143293299417">"Furnizată de <xliff:g id="APP_NAME">%1$s</xliff:g>."</string>
     <string name="no_permissions" msgid="7283357728219338112">"Nu se solicită nicio permisiune"</string>
     <string name="usb_storage_activity_title" msgid="4465055157209648641">"Stocare masivă USB"</string>
     <string name="usb_storage_title" msgid="5901459041398751495">"USB conectat"</string>
@@ -1322,6 +1312,5 @@
     <string name="launchBrowserDefault" msgid="2057951947297614725">"Lansaţi browserul?"</string>
     <string name="SetupCallDefault" msgid="5834948469253758575">"Acceptaţi apelul?"</string>
     <string name="activity_resolver_use_always" msgid="8017770747801494933">"Întotdeauna"</string>
-    <!-- no translation found for activity_resolver_use_once (405646673463328329) -->
-    <skip />
+    <string name="activity_resolver_use_once" msgid="405646673463328329">"Doar o singură dată"</string>
 </resources>
diff --git a/core/res/res/values-sv/strings.xml b/core/res/res/values-sv/strings.xml
index 251d487..f91db69 100644
--- a/core/res/res/values-sv/strings.xml
+++ b/core/res/res/values-sv/strings.xml
@@ -175,28 +175,20 @@
     <string name="permgroupdesc_location" msgid="5704679763124170100">"Övervaka din fysiska plats."</string>
     <string name="permgrouplab_network" msgid="5808983377727109831">"Nätverkskommunikation"</string>
     <string name="permgroupdesc_network" msgid="4478299413241861987">"Åtkomst till olika nätverksfunktioner."</string>
-    <!-- no translation found for permgrouplab_bluetoothNetwork (1585403544162128109) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_bluetoothNetwork (5625288577164282391) -->
-    <skip />
-    <!-- no translation found for permgrouplab_shortrangeNetwork (130808676377486118) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_shortrangeNetwork (1884069062653436007) -->
-    <skip />
+    <string name="permgrouplab_bluetoothNetwork" msgid="1585403544162128109">"Bluetooth"</string>
+    <string name="permgroupdesc_bluetoothNetwork" msgid="5625288577164282391">"Få åtkomst till enheter och nätverk via Bluetooth."</string>
+    <string name="permgrouplab_shortrangeNetwork" msgid="130808676377486118">"Nätverk för kommunikation på nära håll"</string>
+    <string name="permgroupdesc_shortrangeNetwork" msgid="1884069062653436007">"Få åtkomst till enheter via nätverk för kommunikation på nära håll, som NFC."</string>
     <string name="permgrouplab_audioSettings" msgid="8329261670151871235">"Ljudinställningar"</string>
     <string name="permgroupdesc_audioSettings" msgid="2641515403347568130">"Ändra ljudinställningar."</string>
     <string name="permgrouplab_affectsBattery" msgid="6209246653424798033">"Påverkar batteriet"</string>
     <string name="permgroupdesc_affectsBattery" msgid="6441275320638916947">"Använda funktioner som gör att batteriet tar slut snabbt."</string>
     <string name="permgrouplab_calendar" msgid="5863508437783683902">"Kalender"</string>
     <string name="permgroupdesc_calendar" msgid="5777534316982184416">"Direktåtkomst till kalender och händelser."</string>
-    <!-- no translation found for permgrouplab_dictionary (4148597128843641379) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_dictionary (7921166355964764490) -->
-    <skip />
-    <!-- no translation found for permgrouplab_writeDictionary (8090237702432576788) -->
-    <skip />
-    <!-- no translation found for permgroupdesc_writeDictionary (2711561994497361646) -->
-    <skip />
+    <string name="permgrouplab_dictionary" msgid="4148597128843641379">"Läsa den egna ordlistan"</string>
+    <string name="permgroupdesc_dictionary" msgid="7921166355964764490">"Läsa ord i den egna ordlistan."</string>
+    <string name="permgrouplab_writeDictionary" msgid="8090237702432576788">"Skriva i den egna ordlistan"</string>
+    <string name="permgroupdesc_writeDictionary" msgid="2711561994497361646">"Lägga till ord i den egna ordlistan."</string>
     <string name="permgrouplab_bookmarks" msgid="1949519673103968229">"Bokmärken och historik"</string>
     <string name="permgroupdesc_bookmarks" msgid="4169771606257963028">"Direktåtkomst till bokmärken och webbläsarhistorik."</string>
     <string name="permgrouplab_deviceAlarms" msgid="6117704629728824101">"Larm"</string>
@@ -569,8 +561,7 @@
     <string name="permdesc_sdcardRead" product="nosdcard" msgid="3530894470637667917">"Tillåter att innehållet läses."</string>
     <string name="permdesc_sdcardRead" product="default" msgid="2555811422562526606">"Tillåter att appen läser SD-kortets innehåll, inklusive eventuella bilder och media."</string>
     <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"ändra eller ta bort innehållet"</string>
-    <!-- no translation found for permlab_sdcardWrite (8805693630050458763) -->
-    <skip />
+    <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"ändra eller ta bort innehåll på SD-kortet"</string>
     <string name="permdesc_sdcardWrite" product="nosdcard" msgid="6175406299445710888">"Gör att app skriver till USB."</string>
     <string name="permdesc_sdcardWrite" product="default" msgid="4337417790936632090">"Tillåter att appen skriver till SD-kortet."</string>
     <string name="permlab_mediaStorageWrite" product="default" msgid="6859839199706879015">"ändra/ta bort innehåll"</string>
@@ -1090,8 +1081,7 @@
     <string name="date_time_set" msgid="5777075614321087758">"Ställ in"</string>
     <string name="date_time_done" msgid="2507683751759308828">"Klar"</string>
     <string name="perms_new_perm_prefix" msgid="8257740710754301407"><font size="12" fgcolor="#ff900000">"NY: "</font></string>
-    <!-- no translation found for perms_description_app (5139836143293299417) -->
-    <skip />
+    <string name="perms_description_app" msgid="5139836143293299417">"Tillhandahålls av <xliff:g id="APP_NAME">%1$s</xliff:g>."</string>
     <string name="no_permissions" msgid="7283357728219338112">"Inga behörigheter krävs"</string>
     <string name="usb_storage_activity_title" msgid="4465055157209648641">"USB-masslagring"</string>
     <string name="usb_storage_title" msgid="5901459041398751495">"USB-ansluten"</string>
@@ -1322,6 +1312,5 @@
     <string name="launchBrowserDefault" msgid="2057951947297614725">"Vill du öppna webbläsaren?"</string>
     <string name="SetupCallDefault" msgid="5834948469253758575">"Vill du ta emot samtal?"</string>
     <string name="activity_resolver_use_always" msgid="8017770747801494933">"Alltid"</string>
-    <!-- no translation found for activity_resolver_use_once (405646673463328329) -->
-    <skip />
+    <string name="activity_resolver_use_once" msgid="405646673463328329">"Bara den här gången"</string>
 </resources>
diff --git a/data/fonts/fallback_fonts.xml b/data/fonts/fallback_fonts.xml
index 8517152..5f7017e 100644
--- a/data/fonts/fallback_fonts.xml
+++ b/data/fonts/fallback_fonts.xml
@@ -72,6 +72,7 @@
         <fileset>
             <file>DroidSansTamil-Regular.ttf</file>
             <file>DroidSansTamil-Bold.ttf</file>
+        </fileset>
     </family>
     <family>
         <fileset>
diff --git a/include/androidfw/VelocityTracker.h b/include/androidfw/VelocityTracker.h
index 6d17e1f..6964588 100644
--- a/include/androidfw/VelocityTracker.h
+++ b/include/androidfw/VelocityTracker.h
@@ -23,19 +23,13 @@
 
 namespace android {
 
+class VelocityTrackerStrategy;
+
 /*
  * Calculates the velocity of pointer movements over time.
  */
 class VelocityTracker {
 public:
-    // Default polynomial degree.  (used by getVelocity)
-    static const uint32_t DEFAULT_DEGREE = 2;
-
-    // Default sample horizon.  (used by getVelocity)
-    // We don't use too much history by default since we want to react to quick
-    // changes in direction.
-    static const nsecs_t DEFAULT_HORIZON = 100 * 1000000; // 100 ms
-
     struct Position {
         float x, y;
     };
@@ -64,6 +58,8 @@
     };
 
     VelocityTracker();
+    VelocityTracker(VelocityTrackerStrategy* strategy);
+    ~VelocityTracker();
 
     // Resets the velocity tracker state.
     void clear();
@@ -88,35 +84,80 @@
     // insufficient movement information for the pointer.
     bool getVelocity(uint32_t id, float* outVx, float* outVy) const;
 
-    // Gets a quadratic estimator for the movements of the specified pointer id.
+    // Gets an estimator for the recent movements of the specified pointer id.
     // Returns false and clears the estimator if there is no information available
     // about the pointer.
-    bool getEstimator(uint32_t id, uint32_t degree, nsecs_t horizon,
-            Estimator* outEstimator) const;
+    bool getEstimator(uint32_t id, Estimator* outEstimator) const;
 
     // Gets the active pointer id, or -1 if none.
     inline int32_t getActivePointerId() const { return mActivePointerId; }
 
     // Gets a bitset containing all pointer ids from the most recent movement.
-    inline BitSet32 getCurrentPointerIdBits() const { return mMovements[mIndex].idBits; }
+    inline BitSet32 getCurrentPointerIdBits() const { return mCurrentPointerIdBits; }
 
 private:
+    BitSet32 mCurrentPointerIdBits;
+    int32_t mActivePointerId;
+    VelocityTrackerStrategy* mStrategy;
+};
+
+
+/*
+ * Implements a particular velocity tracker algorithm.
+ */
+class VelocityTrackerStrategy {
+protected:
+    VelocityTrackerStrategy() { }
+
+public:
+    virtual ~VelocityTrackerStrategy() { }
+
+    virtual void clear() = 0;
+    virtual void clearPointers(BitSet32 idBits) = 0;
+    virtual void addMovement(nsecs_t eventTime, BitSet32 idBits,
+            const VelocityTracker::Position* positions) = 0;
+    virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const = 0;
+};
+
+
+/*
+ * Velocity tracker algorithm based on least-squares linear regression.
+ */
+class LeastSquaresVelocityTrackerStrategy : public VelocityTrackerStrategy {
+public:
+    LeastSquaresVelocityTrackerStrategy();
+    virtual ~LeastSquaresVelocityTrackerStrategy();
+
+    virtual void clear();
+    virtual void clearPointers(BitSet32 idBits);
+    virtual void addMovement(nsecs_t eventTime, BitSet32 idBits,
+            const VelocityTracker::Position* positions);
+    virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const;
+
+private:
+    // Polynomial degree.  Must be less than or equal to Estimator::MAX_DEGREE.
+    static const uint32_t DEGREE = 2;
+
+    // Sample horizon.
+    // We don't use too much history by default since we want to react to quick
+    // changes in direction.
+    static const nsecs_t HORIZON = 100 * 1000000; // 100 ms
+
     // Number of samples to keep.
     static const uint32_t HISTORY_SIZE = 20;
 
     struct Movement {
         nsecs_t eventTime;
         BitSet32 idBits;
-        Position positions[MAX_POINTERS];
+        VelocityTracker::Position positions[MAX_POINTERS];
 
-        inline const Position& getPosition(uint32_t id) const {
+        inline const VelocityTracker::Position& getPosition(uint32_t id) const {
             return positions[idBits.getIndexOfBit(id)];
         }
     };
 
     uint32_t mIndex;
     Movement mMovements[HISTORY_SIZE];
-    int32_t mActivePointerId;
 };
 
 } // namespace android
diff --git a/libs/androidfw/VelocityTracker.cpp b/libs/androidfw/VelocityTracker.cpp
index 2fb094e..de214f8f 100644
--- a/libs/androidfw/VelocityTracker.cpp
+++ b/libs/androidfw/VelocityTracker.cpp
@@ -33,13 +33,7 @@
 
 namespace android {
 
-// --- VelocityTracker ---
-
-const uint32_t VelocityTracker::DEFAULT_DEGREE;
-const nsecs_t VelocityTracker::DEFAULT_HORIZON;
-const uint32_t VelocityTracker::HISTORY_SIZE;
-
-static inline float vectorDot(const float* a, const float* b, uint32_t m) {
+static float vectorDot(const float* a, const float* b, uint32_t m) {
     float r = 0;
     while (m--) {
         r += *(a++) * *(b++);
@@ -47,7 +41,7 @@
     return r;
 }
 
-static inline float vectorNorm(const float* a, uint32_t m) {
+static float vectorNorm(const float* a, uint32_t m) {
     float r = 0;
     while (m--) {
         float t = *(a++);
@@ -91,45 +85,52 @@
 }
 #endif
 
-VelocityTracker::VelocityTracker() {
-    clear();
+
+// --- VelocityTracker ---
+
+VelocityTracker::VelocityTracker() :
+        mCurrentPointerIdBits(0), mActivePointerId(-1),
+        mStrategy(new LeastSquaresVelocityTrackerStrategy()) {
+}
+
+VelocityTracker::VelocityTracker(VelocityTrackerStrategy* strategy) :
+        mCurrentPointerIdBits(0), mActivePointerId(-1),
+        mStrategy(strategy) {
+}
+
+VelocityTracker::~VelocityTracker() {
+    delete mStrategy;
 }
 
 void VelocityTracker::clear() {
-    mIndex = 0;
-    mMovements[0].idBits.clear();
+    mCurrentPointerIdBits.clear();
     mActivePointerId = -1;
+
+    mStrategy->clear();
 }
 
 void VelocityTracker::clearPointers(BitSet32 idBits) {
-    BitSet32 remainingIdBits(mMovements[mIndex].idBits.value & ~idBits.value);
-    mMovements[mIndex].idBits = remainingIdBits;
+    BitSet32 remainingIdBits(mCurrentPointerIdBits.value & ~idBits.value);
+    mCurrentPointerIdBits = remainingIdBits;
 
     if (mActivePointerId >= 0 && idBits.hasBit(mActivePointerId)) {
         mActivePointerId = !remainingIdBits.isEmpty() ? remainingIdBits.firstMarkedBit() : -1;
     }
+
+    mStrategy->clearPointers(idBits);
 }
 
 void VelocityTracker::addMovement(nsecs_t eventTime, BitSet32 idBits, const Position* positions) {
-    if (++mIndex == HISTORY_SIZE) {
-        mIndex = 0;
-    }
-
     while (idBits.count() > MAX_POINTERS) {
         idBits.clearLastMarkedBit();
     }
 
-    Movement& movement = mMovements[mIndex];
-    movement.eventTime = eventTime;
-    movement.idBits = idBits;
-    uint32_t count = idBits.count();
-    for (uint32_t i = 0; i < count; i++) {
-        movement.positions[i] = positions[i];
+    mCurrentPointerIdBits = idBits;
+    if (mActivePointerId < 0 || !idBits.hasBit(mActivePointerId)) {
+        mActivePointerId = idBits.isEmpty() ? -1 : idBits.firstMarkedBit();
     }
 
-    if (mActivePointerId < 0 || !idBits.hasBit(mActivePointerId)) {
-        mActivePointerId = count != 0 ? idBits.firstMarkedBit() : -1;
-    }
+    mStrategy->addMovement(eventTime, idBits, positions);
 
 #if DEBUG_VELOCITY
     ALOGD("VelocityTracker: addMovement eventTime=%lld, idBits=0x%08x, activePointerId=%d",
@@ -139,7 +140,7 @@
         uint32_t index = idBits.getIndexOfBit(id);
         iterBits.clearBit(id);
         Estimator estimator;
-        getEstimator(id, DEFAULT_DEGREE, DEFAULT_HORIZON, &estimator);
+        getEstimator(id, &estimator);
         ALOGD("  %d: position (%0.3f, %0.3f), "
                 "estimator (degree=%d, xCoeff=%s, yCoeff=%s, confidence=%f)",
                 id, positions[index].x, positions[index].y,
@@ -215,6 +216,61 @@
     addMovement(eventTime, idBits, positions);
 }
 
+bool VelocityTracker::getVelocity(uint32_t id, float* outVx, float* outVy) const {
+    Estimator estimator;
+    if (getEstimator(id, &estimator) && estimator.degree >= 1) {
+        *outVx = estimator.xCoeff[1];
+        *outVy = estimator.yCoeff[1];
+        return true;
+    }
+    *outVx = 0;
+    *outVy = 0;
+    return false;
+}
+
+bool VelocityTracker::getEstimator(uint32_t id, Estimator* outEstimator) const {
+    return mStrategy->getEstimator(id, outEstimator);
+}
+
+
+// --- LeastSquaresVelocityTrackerStrategy ---
+
+const uint32_t LeastSquaresVelocityTrackerStrategy::DEGREE;
+const nsecs_t LeastSquaresVelocityTrackerStrategy::HORIZON;
+const uint32_t LeastSquaresVelocityTrackerStrategy::HISTORY_SIZE;
+
+LeastSquaresVelocityTrackerStrategy::LeastSquaresVelocityTrackerStrategy() {
+    clear();
+}
+
+LeastSquaresVelocityTrackerStrategy::~LeastSquaresVelocityTrackerStrategy() {
+}
+
+void LeastSquaresVelocityTrackerStrategy::clear() {
+    mIndex = 0;
+    mMovements[0].idBits.clear();
+}
+
+void LeastSquaresVelocityTrackerStrategy::clearPointers(BitSet32 idBits) {
+    BitSet32 remainingIdBits(mMovements[mIndex].idBits.value & ~idBits.value);
+    mMovements[mIndex].idBits = remainingIdBits;
+}
+
+void LeastSquaresVelocityTrackerStrategy::addMovement(nsecs_t eventTime, BitSet32 idBits,
+        const VelocityTracker::Position* positions) {
+    if (++mIndex == HISTORY_SIZE) {
+        mIndex = 0;
+    }
+
+    Movement& movement = mMovements[mIndex];
+    movement.eventTime = eventTime;
+    movement.idBits = idBits;
+    uint32_t count = idBits.count();
+    for (uint32_t i = 0; i < count; i++) {
+        movement.positions[i] = positions[i];
+    }
+}
+
 /**
  * Solves a linear least squares problem to obtain a N degree polynomial that fits
  * the specified input data as nearly as possible.
@@ -361,22 +417,8 @@
     return true;
 }
 
-bool VelocityTracker::getVelocity(uint32_t id, float* outVx, float* outVy) const {
-    Estimator estimator;
-    if (getEstimator(id, DEFAULT_DEGREE, DEFAULT_HORIZON, &estimator)) {
-        if (estimator.degree >= 1) {
-            *outVx = estimator.xCoeff[1];
-            *outVy = estimator.yCoeff[1];
-            return true;
-        }
-    }
-    *outVx = 0;
-    *outVy = 0;
-    return false;
-}
-
-bool VelocityTracker::getEstimator(uint32_t id, uint32_t degree, nsecs_t horizon,
-        Estimator* outEstimator) const {
+bool LeastSquaresVelocityTrackerStrategy::getEstimator(uint32_t id,
+        VelocityTracker::Estimator* outEstimator) const {
     outEstimator->clear();
 
     // Iterate over movement samples in reverse time order and collect samples.
@@ -393,11 +435,11 @@
         }
 
         nsecs_t age = newestMovement.eventTime - movement.eventTime;
-        if (age > horizon) {
+        if (age > HORIZON) {
             break;
         }
 
-        const Position& position = movement.getPosition(id);
+        const VelocityTracker::Position& position = movement.getPosition(id);
         x[m] = position.x;
         y[m] = position.y;
         time[m] = -age * 0.000000001f;
@@ -409,9 +451,7 @@
     }
 
     // Calculate a least squares polynomial fit.
-    if (degree > Estimator::MAX_DEGREE) {
-        degree = Estimator::MAX_DEGREE;
-    }
+    uint32_t degree = DEGREE;
     if (degree > m - 1) {
         degree = m - 1;
     }
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 9e7fbb5..a0bf8e3 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -540,9 +540,11 @@
         issueDrawCommand();
         mCurrentQuadIndex = 0;
     }
+
     for (uint32_t i = 0; i < mActiveFonts.size(); i++) {
         mActiveFonts[i]->invalidateTextureCache();
     }
+
     for (uint32_t i = 0; i < mCacheLines.size(); i++) {
         mCacheLines[i]->mCurrentCol = 0;
     }
@@ -551,8 +553,9 @@
 void FontRenderer::deallocateTextureMemory(CacheTexture *cacheTexture) {
     if (cacheTexture && cacheTexture->mTexture) {
         glDeleteTextures(1, &cacheTexture->mTextureId);
-        delete cacheTexture->mTexture;
+        delete[] cacheTexture->mTexture;
         cacheTexture->mTexture = NULL;
+        cacheTexture->mTextureId = 0;
     }
 }
 
@@ -582,11 +585,19 @@
     deallocateTextureMemory(mCacheTexture512);
 }
 
-void FontRenderer::allocateTextureMemory(CacheTexture *cacheTexture) {
+void FontRenderer::allocateTextureMemory(CacheTexture* cacheTexture) {
     int width = cacheTexture->mWidth;
     int height = cacheTexture->mHeight;
+
     cacheTexture->mTexture = new uint8_t[width * height];
+#if DEBUG_FONT_RENDERER
     memset(cacheTexture->mTexture, 0, width * height * sizeof(uint8_t));
+#endif
+
+    if (!cacheTexture->mTextureId) {
+        glGenTextures(1, &cacheTexture->mTextureId);
+    }
+
     glBindTexture(GL_TEXTURE_2D, cacheTexture->mTextureId);
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
     // Initialize texture dimensions
@@ -654,11 +665,12 @@
 
     uint32_t cacheWidth = cacheLine->mMaxWidth;
 
-    CacheTexture *cacheTexture = cacheLine->mCacheTexture;
-    if (cacheTexture->mTexture == NULL) {
+    CacheTexture* cacheTexture = cacheLine->mCacheTexture;
+    if (!cacheTexture->mTexture) {
         // Large-glyph texture memory is allocated only as needed
         allocateTextureMemory(cacheTexture);
     }
+
     uint8_t* cacheBuffer = cacheTexture->mTexture;
     uint8_t* bitmapBuffer = (uint8_t*) glyph.fImage;
     unsigned int stride = glyph.rowBytes();
@@ -675,34 +687,39 @@
 }
 
 CacheTexture* FontRenderer::createCacheTexture(int width, int height, bool allocate) {
-    GLuint textureId;
-    glGenTextures(1, &textureId);
     uint8_t* textureMemory = NULL;
+    CacheTexture* cacheTexture = new CacheTexture(textureMemory, width, height);
 
-    CacheTexture* cacheTexture = new CacheTexture(textureMemory, textureId, width, height);
     if (allocate) {
         allocateTextureMemory(cacheTexture);
     }
+
     return cacheTexture;
 }
 
 void FontRenderer::initTextTexture() {
+    for (uint32_t i = 0; i < mCacheLines.size(); i++) {
+        delete mCacheLines[i];
+    }
     mCacheLines.clear();
 
+    if (mCacheTextureSmall) {
+        delete mCacheTextureSmall;
+        delete mCacheTexture128;
+        delete mCacheTexture256;
+        delete mCacheTexture512;
+    }
+
     // Next, use other, separate caches for large glyphs.
     uint16_t maxWidth = 0;
     if (Caches::hasInstance()) {
         maxWidth = Caches::getInstance().maxTextureSize;
     }
+
     if (maxWidth > MAX_TEXT_CACHE_WIDTH || maxWidth == 0) {
         maxWidth = MAX_TEXT_CACHE_WIDTH;
     }
-    if (mCacheTextureSmall != NULL) {
-        delete mCacheTextureSmall;
-        delete mCacheTexture128;
-        delete mCacheTexture256;
-        delete mCacheTexture512;
-    }
+
     mCacheTextureSmall = createCacheTexture(mSmallCacheWidth, mSmallCacheHeight, true);
     mCacheTexture128 = createCacheTexture(maxWidth, 256, false);
     mCacheTexture256 = createCacheTexture(maxWidth, 256, false);
@@ -776,12 +793,6 @@
     initTextTexture();
     initVertexArrayBuffers();
 
-    // We store a string with letters in a rough frequency of occurrence
-    mLatinPrecache = String16("eisarntolcdugpmhbyfvkwzxjq ");
-    mLatinPrecache += String16("EISARNTOLCDUGPMHBYFVKWZXJQ");
-    mLatinPrecache += String16(",.?!()-+@;:'");
-    mLatinPrecache += String16("0123456789");
-
     mInitialized = true;
 }
 
@@ -944,11 +955,19 @@
 void FontRenderer::precacheLatin(SkPaint* paint) {
     // Remaining capacity is measured in %
     uint32_t remainingCapacity = getRemainingCacheCapacity();
-    uint32_t precacheIdx = 0;
-    while (remainingCapacity > 25 && precacheIdx < mLatinPrecache.size()) {
-        mCurrentFont->getCachedGlyph(paint, (int32_t) mLatinPrecache[precacheIdx]);
+    uint32_t precacheIndex = 0;
+
+    // We store a string with letters in a rough frequency of occurrence
+    String16 l("eisarntolcdugpmhbyfvkwzxjq EISARNTOLCDUGPMHBYFVKWZXJQ,.?!()-+@;:'0123456789");
+
+    size_t size = l.size();
+    uint16_t latin[size];
+    paint->utfToGlyphs(l.string(), SkPaint::kUTF16_TextEncoding, size * sizeof(char16_t), latin);
+
+    while (remainingCapacity > 25 && precacheIndex < size) {
+        mCurrentFont->getCachedGlyph(paint, TO_GLYPH(latin[precacheIndex]));
         remainingCapacity = getRemainingCacheCapacity();
-        precacheIdx ++;
+        precacheIndex++;
     }
 }
 
diff --git a/libs/hwui/FontRenderer.h b/libs/hwui/FontRenderer.h
index 4fc5862..2ab680e 100644
--- a/libs/hwui/FontRenderer.h
+++ b/libs/hwui/FontRenderer.h
@@ -41,11 +41,13 @@
 
 #if RENDER_TEXT_AS_GLYPHS
     typedef uint16_t glyph_t;
+    #define TO_GLYPH(g) g
     #define GET_METRICS(paint, glyph) paint->getGlyphMetrics(glyph)
     #define GET_GLYPH(text) nextGlyph((const uint16_t**) &text)
     #define IS_END_OF_STRING(glyph) false
 #else
     typedef SkUnichar glyph_t;
+    #define TO_GLYPH(g) ((SkUnichar) g)
     #define GET_METRICS(paint, glyph) paint->getUnicharMetrics(glyph)
     #define GET_GLYPH(text) SkUTF16_NextUnichar((const uint16_t**) &text)
     #define IS_END_OF_STRING(glyph) glyph < 0
@@ -59,15 +61,15 @@
 
 class CacheTexture {
 public:
-    CacheTexture(){}
-    CacheTexture(uint8_t* texture, GLuint textureId, uint16_t width, uint16_t height) :
-        mTexture(texture), mTextureId(textureId), mWidth(width), mHeight(height),
-        mLinearFiltering(false) {}
+    CacheTexture() { }
+    CacheTexture(uint8_t* texture, uint16_t width, uint16_t height) :
+            mTexture(texture), mTextureId(0), mWidth(width), mHeight(height),
+            mLinearFiltering(false) { }
     ~CacheTexture() {
-        if (mTexture != NULL) {
+        if (mTexture) {
             delete[] mTexture;
         }
-        if (mTextureId != 0) {
+        if (mTextureId) {
             glDeleteTextures(1, &mTextureId);
         }
     }
@@ -88,7 +90,7 @@
                 mCurrentRow(currentRow),
                 mCurrentCol(currentCol),
                 mDirty(false),
-                mCacheTexture(cacheTexture){
+                mCacheTexture(cacheTexture) {
     }
 
     bool fitBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY);
@@ -98,7 +100,7 @@
     uint32_t mCurrentRow;
     uint32_t mCurrentCol;
     bool mDirty;
-    CacheTexture *mCacheTexture;
+    CacheTexture* mCacheTexture;
 };
 
 struct CachedGlyphInfo {
@@ -236,8 +238,6 @@
     FontRenderer();
     ~FontRenderer();
 
-    void init();
-    void deinit();
     void flushLargeCaches();
 
     void setGammaTable(const uint8_t* gammaTable) {
@@ -278,6 +278,7 @@
 
     GLuint getTexture(bool linearFiltering = false) {
         checkInit();
+
         if (linearFiltering != mCurrentCacheTexture->mLinearFiltering) {
             mCurrentCacheTexture->mLinearFiltering = linearFiltering;
             mLinearFiltering = linearFiltering;
@@ -287,6 +288,7 @@
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
         }
+
         return mCurrentCacheTexture->mTextureId;
     }
 
@@ -326,7 +328,6 @@
     void initRender(const Rect* clip, Rect* bounds);
     void finishRender();
 
-    String16 mLatinPrecache;
     void precacheLatin(SkPaint* paint);
 
     void issueDrawCommand();
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 8015203..8da7d0f 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -701,6 +701,10 @@
             // Check if the ringer mode changes with this volume adjustment. If
             // it does, it will handle adjusting the volume, so we won't below
             adjustVolume = checkForRingerModeChange(aliasIndex, direction, step);
+            if ((streamTypeAlias == getMasterStreamType()) &&
+                    (mRingerMode == AudioManager.RINGER_MODE_SILENT)) {
+                streamState.setLastAudibleIndex(0, device);
+            }
         }
 
         // If stream is muted, adjust last audible index only
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index f51a24a..96f01db 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -401,7 +401,7 @@
             mChannels = AudioFormat.CHANNEL_OUT_STEREO;
             break;
         default:
-            if ((channelConfig & SUPPORTED_OUT_CHANNELS) != channelConfig) {
+            if (!isMultichannelConfigSupported(channelConfig)) {
                 // input channel configuration features unsupported channels
                 mChannelCount = 0;
                 mChannels = AudioFormat.CHANNEL_INVALID;
@@ -438,6 +438,37 @@
         }
     }
 
+    /**
+     * Convenience method to check that the channel configuration (a.k.a channel mask) is supported
+     * @param channelConfig the mask to validate
+     * @return false if the AudioTrack can't be used with such a mask
+     */
+    private static boolean isMultichannelConfigSupported(int channelConfig) {
+        // check for unsupported channels
+        if ((channelConfig & SUPPORTED_OUT_CHANNELS) != channelConfig) {
+            Log.e(TAG, "Channel configuration features unsupported channels");
+            return false;
+        }
+        // check for unsupported multichannel combinations:
+        // - FL/FR must be present
+        // - L/R channels must be paired (e.g. no single L channel)
+        final int frontPair =
+                AudioFormat.CHANNEL_OUT_FRONT_LEFT | AudioFormat.CHANNEL_OUT_FRONT_RIGHT;
+        if ((channelConfig & frontPair) != frontPair) {
+                Log.e(TAG, "Front channels must be present in multichannel configurations");
+                return false;
+        }
+        final int backPair =
+                AudioFormat.CHANNEL_OUT_BACK_LEFT | AudioFormat.CHANNEL_OUT_BACK_RIGHT;
+        if ((channelConfig & backPair) != 0) {
+            if ((channelConfig & backPair) != backPair) {
+                Log.e(TAG, "Rear channels can't be used independently");
+                return false;
+            }
+        }
+        return true;
+    }
+
 
     // Convenience method for the contructor's audio buffer size check.
     // preconditions:
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index 3b87b96..f09c010 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -223,6 +223,8 @@
 
         @Override
         public long calculateDirectorySize(String path) throws RemoteException {
+            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
+
             final File directory = new File(path);
             if (directory.exists() && directory.isDirectory()) {
                 return MeasurementUtils.measureDirectory(path);
@@ -233,6 +235,8 @@
 
         @Override
         public long[] getFileSystemStats(String path) {
+            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
+
             try {
                 final StructStatFs stat = Libcore.os.statfs(path);
                 final long totalSize = stat.f_blocks * stat.f_bsize;
diff --git a/packages/SystemUI/res/values-da/strings.xml b/packages/SystemUI/res/values-da/strings.xml
index 612ab6a..01068ec 100644
--- a/packages/SystemUI/res/values-da/strings.xml
+++ b/packages/SystemUI/res/values-da/strings.xml
@@ -138,7 +138,7 @@
     <string name="gps_notification_searching_text" msgid="8574247005642736060">"Søger efter GPS"</string>
     <string name="gps_notification_found_text" msgid="4619274244146446464">"Placeringen er angivet ved hjælp af GPS"</string>
     <string name="accessibility_clear_all" msgid="5235938559247164925">"Ryd alle meddelelser."</string>
-    <string name="dreams_dock_launcher" msgid="3541196417659166245">"Aktiver pauseskærm"</string>
+    <string name="dreams_dock_launcher" msgid="3541196417659166245">"Aktivér pauseskærm"</string>
     <string name="status_bar_notification_inspect_item_title" msgid="1163547729015390250">"Oplysninger om appen"</string>
     <string name="notifications_off_title" msgid="8936620513608443224">"Underretninger slået fra"</string>
     <string name="notifications_off_text" msgid="2529001315769385273">"Tryk her for at slå underretninger til igen."</string>
diff --git a/packages/SystemUI/res/values-de/strings.xml b/packages/SystemUI/res/values-de/strings.xml
index b7dcb14..c15a2fa 100644
--- a/packages/SystemUI/res/values-de/strings.xml
+++ b/packages/SystemUI/res/values-de/strings.xml
@@ -66,7 +66,7 @@
     <string name="screenshot_saving_title" msgid="8242282144535555697">"Screenshot wird gespeichert..."</string>
     <string name="screenshot_saving_text" msgid="2419718443411738818">"Screenshot wird gespeichert..."</string>
     <string name="screenshot_saved_title" msgid="6461865960961414961">"Screenshot aufgenommen"</string>
-    <string name="screenshot_saved_text" msgid="1152839647677558815">"Zum Anzeigen des Screenshots berühren"</string>
+    <string name="screenshot_saved_text" msgid="1152839647677558815">"Zum Ansehen berühren"</string>
     <string name="screenshot_failed_title" msgid="705781116746922771">"Screenshot konnte nicht aufgenommen werden."</string>
     <string name="screenshot_failed_text" msgid="8134011269572415402">"Screenshot konnte nicht gespeichert werden. Eventuell wird der Speicher gerade verwendet."</string>
     <string name="usb_preference_title" msgid="6551050377388882787">"USB-Dateiübertragungsoptionen"</string>
diff --git a/packages/SystemUI/res/values-ja/strings.xml b/packages/SystemUI/res/values-ja/strings.xml
index eb493b2..70ba034 100644
--- a/packages/SystemUI/res/values-ja/strings.xml
+++ b/packages/SystemUI/res/values-ja/strings.xml
@@ -142,10 +142,8 @@
     <string name="accessibility_clear_all" msgid="5235938559247164925">"通知をすべて消去。"</string>
     <string name="dreams_dock_launcher" msgid="3541196417659166245">"スクリーンセーバーを有効にする"</string>
     <string name="status_bar_notification_inspect_item_title" msgid="1163547729015390250">"アプリ情報"</string>
-    <!-- no translation found for notifications_off_title (8936620513608443224) -->
-    <skip />
-    <!-- no translation found for notifications_off_text (2529001315769385273) -->
-    <skip />
+    <string name="notifications_off_title" msgid="8936620513608443224">"通知OFF"</string>
+    <string name="notifications_off_text" msgid="2529001315769385273">"通知を再度ONにするにはここをタップします。"</string>
     <string name="accessibility_rotation_lock_off" msgid="4062780228931590069">"画面は自動的に回転します。"</string>
     <string name="accessibility_rotation_lock_on_landscape" msgid="6731197337665366273">"画面は横向きにロックされています。"</string>
     <string name="accessibility_rotation_lock_on_portrait" msgid="5809367521644012115">"画面は縦向きにロックされています。"</string>
diff --git a/packages/SystemUI/res/values-nb/strings.xml b/packages/SystemUI/res/values-nb/strings.xml
index 2a9c1c8..a1ee469 100644
--- a/packages/SystemUI/res/values-nb/strings.xml
+++ b/packages/SystemUI/res/values-nb/strings.xml
@@ -140,10 +140,8 @@
     <string name="accessibility_clear_all" msgid="5235938559247164925">"Fjern alle varslinger."</string>
     <string name="dreams_dock_launcher" msgid="3541196417659166245">"Aktiver skjermbeskytter"</string>
     <string name="status_bar_notification_inspect_item_title" msgid="1163547729015390250">"Info om app"</string>
-    <!-- no translation found for notifications_off_title (8936620513608443224) -->
-    <skip />
-    <!-- no translation found for notifications_off_text (2529001315769385273) -->
-    <skip />
+    <string name="notifications_off_title" msgid="8936620513608443224">"Varsler er deaktivert"</string>
+    <string name="notifications_off_text" msgid="2529001315769385273">"Trykk her for å aktivere varsler på nytt."</string>
     <string name="accessibility_rotation_lock_off" msgid="4062780228931590069">"Skjermen roterer automatisk."</string>
     <string name="accessibility_rotation_lock_on_landscape" msgid="6731197337665366273">"Skjermen er låst i liggende retning."</string>
     <string name="accessibility_rotation_lock_on_portrait" msgid="5809367521644012115">"Skjermen er låst i stående retning."</string>
diff --git a/packages/SystemUI/res/values-pl/strings.xml b/packages/SystemUI/res/values-pl/strings.xml
index b01345e..b4a77a2 100644
--- a/packages/SystemUI/res/values-pl/strings.xml
+++ b/packages/SystemUI/res/values-pl/strings.xml
@@ -140,10 +140,8 @@
     <string name="accessibility_clear_all" msgid="5235938559247164925">"Usuń wszystkie powiadomienia."</string>
     <string name="dreams_dock_launcher" msgid="3541196417659166245">"Włącz wygaszacz ekranu."</string>
     <string name="status_bar_notification_inspect_item_title" msgid="1163547729015390250">"O aplikacji"</string>
-    <!-- no translation found for notifications_off_title (8936620513608443224) -->
-    <skip />
-    <!-- no translation found for notifications_off_text (2529001315769385273) -->
-    <skip />
+    <string name="notifications_off_title" msgid="8936620513608443224">"Powiadomienia wyłączone"</string>
+    <string name="notifications_off_text" msgid="2529001315769385273">"Kliknij tutaj, by przywrócić powiadomienia."</string>
     <string name="accessibility_rotation_lock_off" msgid="4062780228931590069">"Ekran zostanie obrócony automatycznie."</string>
     <string name="accessibility_rotation_lock_on_landscape" msgid="6731197337665366273">"Ekran jest zablokowany w orientacji poziomej."</string>
     <string name="accessibility_rotation_lock_on_portrait" msgid="5809367521644012115">"Ekran jest zablokowany w orientacji pionowej."</string>
diff --git a/packages/SystemUI/res/values-pt/strings.xml b/packages/SystemUI/res/values-pt/strings.xml
index f074d22..596ceec 100644
--- a/packages/SystemUI/res/values-pt/strings.xml
+++ b/packages/SystemUI/res/values-pt/strings.xml
@@ -62,8 +62,8 @@
     <string name="compat_mode_off" msgid="4434467572461327898">"Ampliar p/ preencher tela"</string>
     <string name="compat_mode_help_header" msgid="7969493989397529910">"Zoom em modo de compatibilidade"</string>
     <string name="compat_mode_help_body" msgid="4946726776359270040">"Quando um aplicativo é desenvolvido para uma tela menor, um controle de zoom é exibido perto do relógio."</string>
-    <string name="screenshot_saving_ticker" msgid="7403652894056693515">"Salvar captura de tela..."</string>
-    <string name="screenshot_saving_title" msgid="8242282144535555697">"Salvar captura de tela..."</string>
+    <string name="screenshot_saving_ticker" msgid="7403652894056693515">"Salvando captura de tela..."</string>
+    <string name="screenshot_saving_title" msgid="8242282144535555697">"Salvando captura de tela..."</string>
     <string name="screenshot_saving_text" msgid="2419718443411738818">"A captura de tela está sendo salva."</string>
     <string name="screenshot_saved_title" msgid="6461865960961414961">"Captura de tela obtida."</string>
     <string name="screenshot_saved_text" msgid="1152839647677558815">"Toque para visualizar a captura de tela."</string>
diff --git a/packages/SystemUI/res/values-ro/strings.xml b/packages/SystemUI/res/values-ro/strings.xml
index 4750ac5..87eec9f 100644
--- a/packages/SystemUI/res/values-ro/strings.xml
+++ b/packages/SystemUI/res/values-ro/strings.xml
@@ -140,10 +140,8 @@
     <string name="accessibility_clear_all" msgid="5235938559247164925">"Ştergeţi toate notificările."</string>
     <string name="dreams_dock_launcher" msgid="3541196417659166245">"Activaţi screensaverul"</string>
     <string name="status_bar_notification_inspect_item_title" msgid="1163547729015390250">"Informaţii despre aplicaţie"</string>
-    <!-- no translation found for notifications_off_title (8936620513608443224) -->
-    <skip />
-    <!-- no translation found for notifications_off_text (2529001315769385273) -->
-    <skip />
+    <string name="notifications_off_title" msgid="8936620513608443224">"Notificările sunt dezactivate"</string>
+    <string name="notifications_off_text" msgid="2529001315769385273">"Apăsaţi aici pentru a reactiva notificările."</string>
     <string name="accessibility_rotation_lock_off" msgid="4062780228931590069">"Ecranul se va roti în mod automat."</string>
     <string name="accessibility_rotation_lock_on_landscape" msgid="6731197337665366273">"Ecranul este blocat în orientarea de tip peisaj."</string>
     <string name="accessibility_rotation_lock_on_portrait" msgid="5809367521644012115">"Ecranul este blocat în orientarea de tip portret."</string>
diff --git a/packages/SystemUI/res/values-ru/strings.xml b/packages/SystemUI/res/values-ru/strings.xml
index 7ca04e6..3277fb6 100644
--- a/packages/SystemUI/res/values-ru/strings.xml
+++ b/packages/SystemUI/res/values-ru/strings.xml
@@ -65,7 +65,7 @@
     <string name="screenshot_saving_ticker" msgid="7403652894056693515">"Сохранение..."</string>
     <string name="screenshot_saving_title" msgid="8242282144535555697">"Сохранение..."</string>
     <string name="screenshot_saving_text" msgid="2419718443411738818">"Сохранение..."</string>
-    <string name="screenshot_saved_title" msgid="6461865960961414961">"Скриншот сохранен."</string>
+    <string name="screenshot_saved_title" msgid="6461865960961414961">"Скриншот сохранен"</string>
     <string name="screenshot_saved_text" msgid="1152839647677558815">"Нажмите, чтобы просмотреть"</string>
     <string name="screenshot_failed_title" msgid="705781116746922771">"Не удалось сохранить скриншот."</string>
     <string name="screenshot_failed_text" msgid="8134011269572415402">"Не удалось сохранить скриншот. Возможно, накопители заняты."</string>
diff --git a/packages/SystemUI/res/values-sv/strings.xml b/packages/SystemUI/res/values-sv/strings.xml
index 36950dc..afbe0fb 100644
--- a/packages/SystemUI/res/values-sv/strings.xml
+++ b/packages/SystemUI/res/values-sv/strings.xml
@@ -140,10 +140,8 @@
     <string name="accessibility_clear_all" msgid="5235938559247164925">"Ta bort alla meddelanden."</string>
     <string name="dreams_dock_launcher" msgid="3541196417659166245">"Aktivera skärmsläckare"</string>
     <string name="status_bar_notification_inspect_item_title" msgid="1163547729015390250">"Info om appen"</string>
-    <!-- no translation found for notifications_off_title (8936620513608443224) -->
-    <skip />
-    <!-- no translation found for notifications_off_text (2529001315769385273) -->
-    <skip />
+    <string name="notifications_off_title" msgid="8936620513608443224">"Meddelanden inaktiverade"</string>
+    <string name="notifications_off_text" msgid="2529001315769385273">"Knacka lätt här om du vill aktivera meddelanden igen."</string>
     <string name="accessibility_rotation_lock_off" msgid="4062780228931590069">"Skärmen roteras automatiskt."</string>
     <string name="accessibility_rotation_lock_on_landscape" msgid="6731197337665366273">"Bildskärmens riktning är nu låst i liggande format."</string>
     <string name="accessibility_rotation_lock_on_portrait" msgid="5809367521644012115">"Bildskärmens riktning är nu låst i stående format."</string>
diff --git a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
index 6785c29..39d686f 100644
--- a/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/recent/RecentsPanelView.java
@@ -19,6 +19,7 @@
 import android.animation.Animator;
 import android.animation.LayoutTransition;
 import android.app.ActivityManager;
+import android.app.ActivityManagerNative;
 import android.app.ActivityOptions;
 import android.content.Context;
 import android.content.Intent;
@@ -26,13 +27,13 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Bitmap;
-import android.graphics.Canvas;
 import android.graphics.Matrix;
 import android.graphics.Rect;
 import android.graphics.Shader.TileMode;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
+import android.os.RemoteException;
 import android.provider.Settings;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -283,8 +284,19 @@
         }
     }
 
+    static void sendCloseSystemWindows(Context context, String reason) {
+        if (ActivityManagerNative.isSystemReady()) {
+            try {
+                ActivityManagerNative.getDefault().closeSystemDialogs(reason);
+            } catch (RemoteException e) {
+            }
+        }
+    }
+
     public void show(boolean show, boolean animate,
             ArrayList<TaskDescription> recentTaskDescriptions, boolean firstScreenful) {
+        sendCloseSystemWindows(mContext, BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
+
         // For now, disable animations. We may want to re-enable in the future
         if (show) {
             animate = false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index a44279a..464d4fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -85,6 +85,9 @@
 
     protected static final boolean ENABLE_INTRUDERS = false;
 
+    // Should match the value in PhoneWindowManager
+    public static final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
+
     public static final int EXPANDED_LEAVE_ALONE = -10000;
     public static final int EXPANDED_FULL_OPEN = -10001;
 
@@ -400,6 +403,15 @@
          return new H();
     }
 
+    static void sendCloseSystemWindows(Context context, String reason) {
+        if (ActivityManagerNative.isSystemReady()) {
+            try {
+                ActivityManagerNative.getDefault().closeSystemDialogs(reason);
+            } catch (RemoteException e) {
+            }
+        }
+    }
+
     protected class H extends Handler {
         public void handleMessage(Message m) {
             switch (m.what) {
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 6122390..a0d3eb4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1977,7 +1977,7 @@
                 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
                     String reason = intent.getStringExtra("reason");
                     if (reason != null) {
-                        excludeRecents = reason.equals("recentapps");
+                        excludeRecents = reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS);
                     }
                 }
                 animateCollapse(excludeRecents);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index a2c7637..5ab9919 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -1582,7 +1582,7 @@
                 if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
                     String reason = intent.getStringExtra("reason");
                     if (reason != null) {
-                        excludeRecents = reason.equals("recentapps");
+                        excludeRecents = reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS);
                     }
                 }
                 if (Intent.ACTION_SCREEN_OFF.equals(action)) {
diff --git a/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java b/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java
index a13ccc2..f476f82 100644
--- a/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java
+++ b/policy/src/com/android/internal/policy/impl/BiometricSensorUnlock.java
@@ -21,8 +21,7 @@
 interface BiometricSensorUnlock {
     /**
      * Initializes the view provided for the biometric unlock UI to work within.  The provided area
-     * completely covers the backup unlock mechanism.  The view is then displayed in the same manner
-     * as if {@link BiometricSensorUnlock#show(long)} was called with a timeout of 0.
+     * completely covers the backup unlock mechanism.
      * @param biometricUnlockView View provided for the biometric unlock UI.
      */
     public void initializeView(View biometricUnlockView);
diff --git a/policy/src/com/android/internal/policy/impl/FaceUnlock.java b/policy/src/com/android/internal/policy/impl/FaceUnlock.java
index ffdeeb1..c46b94a 100644
--- a/policy/src/com/android/internal/policy/impl/FaceUnlock.java
+++ b/policy/src/com/android/internal/policy/impl/FaceUnlock.java
@@ -101,7 +101,6 @@
     public void initializeView(View biometricUnlockView) {
         Log.d(TAG, "initializeView()");
         mFaceUnlockView = biometricUnlockView;
-        show(0);
     }
 
     /**
@@ -469,10 +468,8 @@
                     if (mLockPatternUtils == null) {
                         Log.d(TAG, "mLockPatternUtils is null");
                     }
-                    Log.d(TAG, "x,y,w,h,live: " + x + "," + y + "," + w + "," + h + "," +
-                            (mLockPatternUtils.isBiometricWeakLivelinessEnabled()?"yes":"no"));
-                    mService.startUi(windowToken, x, y, w, h,
-                            mLockPatternUtils.isBiometricWeakLivelinessEnabled());
+                    Log.d(TAG, "x,y,w,h,live: " + x + "," + y + "," + w + "," + h + ", no");
+                    mService.startUi(windowToken, x, y, w, h, false);
                     Log.d(TAG, "mService.startUi() called");
                 } catch (RemoteException e) {
                     Log.e(TAG, "Caught exception starting Face Unlock: " + e.toString());
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
index 7238fdf..18b8042 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
@@ -81,7 +81,7 @@
 
     private int mFailedAttempts = 0;
     private int mFailedBiometricUnlockAttempts = 0;
-    private static final int FAILED_BIOMETRIC_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 15;
+    private static final int FAILED_BIOMETRIC_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 5;
 
     private boolean mClockVisible;
 
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 8320b1d..049e6ac 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -414,12 +414,6 @@
         }
     };
 
-    // Indicates whether a biometric unlock method is in use
-    private boolean isBiometricUnlockInstalledAndSelected() {
-        return (mLockPatternUtils.usingBiometricWeak() &&
-                mLockPatternUtils.isBiometricWeakInstalled());
-    }
-
     /**
      * @param context Used to inflate, and create views.
      * @param callback Keyguard callback object for pokewakelock(), etc.
@@ -443,14 +437,6 @@
         sIsFirstAppearanceAfterBoot = false;
         mPluggedIn = mUpdateMonitor.isDevicePluggedIn();
         mScreenOn = ((PowerManager)context.getSystemService(Context.POWER_SERVICE)).isScreenOn();
-
-        // If the biometric unlock is not being used, we don't bother constructing it.  Then we can
-        // simply check if it is null when deciding whether we should make calls to it.
-        if (isBiometricUnlockInstalledAndSelected()) {
-            mBiometricUnlock = new FaceUnlock(context, updateMonitor, lockPatternUtils,
-                    mKeyguardScreenCallback);
-        }
-
         mUpdateMonitor.registerInfoCallback(mInfoCallback);
 
         /**
@@ -848,19 +834,11 @@
             }
         }
 
-        // Re-create the unlock screen if necessary. This is primarily required to properly handle
-        // SIM state changes. This typically happens when this method is called by reset()
+        // Re-create the unlock screen if necessary.
         final UnlockMode unlockMode = getUnlockMode();
         if (mode == Mode.UnlockScreen && unlockMode != UnlockMode.Unknown) {
             if (force || mUnlockScreen == null || unlockMode != mUnlockScreenMode) {
-                boolean restartBiometricUnlock = false;
-                if (mBiometricUnlock != null) {
-                    restartBiometricUnlock = mBiometricUnlock.stop();
-                }
                 recreateUnlockScreen(unlockMode);
-                if (mBiometricUnlock != null && restartBiometricUnlock) {
-                    maybeStartBiometricUnlock();
-                }
             }
         }
 
@@ -973,13 +951,7 @@
             throw new IllegalArgumentException("unknown unlock mode " + unlockMode);
         }
         initializeTransportControlView(unlockView);
-
-        if (mBiometricUnlock != null) {
-            // TODO: make faceLockAreaView a more general biometricUnlockView
-            // We will need to add our Face Unlock specific child views programmatically in
-            // initializeView rather than having them in the XML files.
-            mBiometricUnlock.initializeView(unlockView.findViewById(R.id.faceLockAreaView));
-        }
+        initializeBiometricUnlockView(unlockView);
 
         mUnlockScreenMode = unlockMode;
         return unlockView;
@@ -997,6 +969,55 @@
     }
 
     /**
+     * This returns false if there is any condition that indicates that the biometric unlock should
+     * not be used before the next time the unlock screen is recreated.  In other words, if this
+     * returns false there is no need to even construct the biometric unlock.
+     */
+    private boolean useBiometricUnlock() {
+        final UnlockMode unlockMode = getUnlockMode();
+        final boolean backupIsTimedOut = (mUpdateMonitor.getFailedAttempts() >=
+                LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT);
+        return (mLockPatternUtils.usingBiometricWeak() &&
+                mLockPatternUtils.isBiometricWeakInstalled() &&
+                !mUpdateMonitor.getMaxBiometricUnlockAttemptsReached() &&
+                !backupIsTimedOut &&
+                (unlockMode == UnlockMode.Pattern || unlockMode == UnlockMode.Password));
+    }
+
+    private void initializeBiometricUnlockView(View view) {
+        boolean restartBiometricUnlock = false;
+
+        if (mBiometricUnlock != null) {
+            restartBiometricUnlock = mBiometricUnlock.stop();
+        }
+
+        // If the biometric unlock is not being used, we don't bother constructing it.  Then we can
+        // simply check if it is null when deciding whether we should make calls to it.
+        mBiometricUnlock = null;
+        if (useBiometricUnlock()) {
+            // TODO: make faceLockAreaView a more general biometricUnlockView
+            // We will need to add our Face Unlock specific child views programmatically in
+            // initializeView rather than having them in the XML files.
+            View biometricUnlockView = view.findViewById(R.id.faceLockAreaView);
+            if (biometricUnlockView != null) {
+                mBiometricUnlock = new FaceUnlock(mContext, mUpdateMonitor, mLockPatternUtils,
+                        mKeyguardScreenCallback);
+                mBiometricUnlock.initializeView(biometricUnlockView);
+
+                // If this is being called because the screen turned off, we want to cover the
+                // backup lock so it is covered when the screen turns back on.
+                if (!mScreenOn) mBiometricUnlock.show(0);
+            } else {
+                Log.w(TAG, "Couldn't find biometric unlock view");
+            }
+        }
+
+        if (mBiometricUnlock != null && restartBiometricUnlock) {
+            maybeStartBiometricUnlock();
+        }
+    }
+
+    /**
      * Given the current state of things, what should be the initial mode of
      * the lock screen (lock or unlock).
      */
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 8e187cd..3147ba7 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -15,7 +15,6 @@
 
 package com.android.internal.policy.impl;
 
-import android.app.Activity;
 import android.app.ActivityManager;
 import android.app.ActivityManagerNative;
 import android.app.IUiModeManager;
@@ -37,8 +36,6 @@
 import android.database.ContentObserver;
 import android.graphics.PixelFormat;
 import android.graphics.Rect;
-import android.graphics.RectF;
-import android.hardware.input.InputManager;
 import android.media.AudioManager;
 import android.media.IAudioService;
 import android.os.BatteryManager;
@@ -148,7 +145,6 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.util.ArrayList;
 
 /**
  * WindowManagerPolicy implementation for the Android phone UI.  This
@@ -247,8 +243,6 @@
     static final int SYSTEM_UI_CHANGING_LAYOUT =
             View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
 
-    private static final int BTN_MOUSE = 0x110;
-
     /* Table of Application Launch keys.  Maps from key codes to intent categories.
      *
      * These are special keys that are used to launch particular kinds of applications,
@@ -447,7 +441,6 @@
 
     static final Rect mTmpParentFrame = new Rect();
     static final Rect mTmpDisplayFrame = new Rect();
-    static final Rect mTmpSystemFrame = new Rect();
     static final Rect mTmpContentFrame = new Rect();
     static final Rect mTmpVisibleFrame = new Rect();
     static final Rect mTmpNavigationFrame = new Rect();
@@ -2301,7 +2294,7 @@
             mStatusBarLayer = mNavigationBar.getSurfaceLayer();
             // And compute the final frame.
             mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
-                    mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame);
+                    mTmpNavigationFrame, mTmpNavigationFrame);
             if (DEBUG_LAYOUT) Log.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
         }
         if (DEBUG_LAYOUT) Log.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)",
@@ -2322,7 +2315,7 @@
             mStatusBarLayer = mStatusBar.getSurfaceLayer();
 
             // Let the status bar determine its size.
-            mStatusBar.computeFrameLw(pf, df, df, vf, vf);
+            mStatusBar.computeFrameLw(pf, df, vf, vf);
 
             // For layout, the status bar is always at the top with our fixed height.
             mStableTop = mUnrestrictedScreenTop + mStatusBarHeight;
@@ -2356,6 +2349,17 @@
         }
     }
 
+    /** {@inheritDoc} */
+    public int getSystemDecorRectLw(Rect systemRect) {
+        systemRect.left = mSystemLeft;
+        systemRect.top = mSystemTop;
+        systemRect.right = mSystemRight;
+        systemRect.bottom = mSystemBottom;
+        if (mStatusBar != null) return mStatusBar.getSurfaceLayer();
+        if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer();
+        return 0;
+    }
+
     void setAttachedWindowFrames(WindowState win, int fl, int adjust,
             WindowState attached, boolean insetDecors, Rect pf, Rect df, Rect cf, Rect vf) {
         if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) {
@@ -2426,7 +2430,6 @@
 
         final Rect pf = mTmpParentFrame;
         final Rect df = mTmpDisplayFrame;
-        final Rect sf = mTmpSystemFrame;
         final Rect cf = mTmpContentFrame;
         final Rect vf = mTmpVisibleFrame;
         
@@ -2670,20 +2673,6 @@
             df.right = df.bottom = cf.right = cf.bottom = vf.right = vf.bottom = 10000;
         }
 
-        // Compute the system frame.  This is easy: for things behind the
-        // status bar, it is any application windows; otherwise it is not set.
-        int parentType = attached != null ? attached.getAttrs().type : attrs.type;
-        if (win.getSurfaceLayer() < mStatusBarLayer
-                && parentType < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW) {
-            sf.left = mSystemLeft;
-            sf.top = mSystemTop;
-            sf.right = mSystemRight;
-            sf.bottom = mSystemBottom;
-        } else {
-            sf.left = sf.top = -10000;
-            sf.right = sf.bottom = 10000;
-        }
-
         if (DEBUG_LAYOUT) Log.v(TAG, "Compute frame " + attrs.getTitle()
                 + ": sim=#" + Integer.toHexString(sim)
                 + " attach=" + attached + " type=" + attrs.type 
@@ -2691,7 +2680,7 @@
                 + " pf=" + pf.toShortString() + " df=" + df.toShortString()
                 + " cf=" + cf.toShortString() + " vf=" + vf.toShortString());
         
-        win.computeFrameLw(pf, df, sf, cf, vf);
+        win.computeFrameLw(pf, df, cf, vf);
         
         // Dock windows carve out the bottom of the screen, so normal windows
         // can't appear underneath them.
diff --git a/services/java/com/android/server/CertBlacklister.java b/services/java/com/android/server/CertBlacklister.java
new file mode 100644
index 0000000..8b167d7
--- /dev/null
+++ b/services/java/com/android/server/CertBlacklister.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2012 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.server;
+
+import android.content.Context;
+import android.content.ContentResolver;
+import android.database.ContentObserver;
+import android.os.Binder;
+import android.os.FileUtils;
+import android.provider.Settings;
+import android.util.Slog;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import libcore.io.IoUtils;
+
+/**
+ * <p>CertBlacklister provides a simple mechanism for updating the platform blacklists for SSL
+ * certificate public keys and serial numbers.
+ */
+public class CertBlacklister extends Binder {
+
+    private static final String TAG = "CertBlacklister";
+
+    private static final String BLACKLIST_ROOT = System.getenv("ANDROID_DATA") + "/misc/keychain/";
+
+    public static final String PUBKEY_PATH = BLACKLIST_ROOT + "pubkey_blacklist.txt";
+    public static final String SERIAL_PATH = BLACKLIST_ROOT + "serial_blacklist.txt";
+
+    public static final String PUBKEY_BLACKLIST_KEY = "pubkey_blacklist";
+    public static final String SERIAL_BLACKLIST_KEY = "serial_blacklist";
+
+    private static class BlacklistObserver extends ContentObserver {
+
+        private final String mKey;
+        private final String mName;
+        private final String mPath;
+        private final File mTmpDir;
+        private final ContentResolver mContentResolver;
+
+        public BlacklistObserver(String key, String name, String path, ContentResolver cr) {
+            super(null);
+            mKey = key;
+            mName = name;
+            mPath = path;
+            mTmpDir = new File(mPath).getParentFile();
+            mContentResolver = cr;
+        }
+
+        @Override
+        public void onChange(boolean selfChange) {
+            super.onChange(selfChange);
+            writeBlacklist();
+        }
+
+        public String getValue() {
+            return Settings.Secure.getString(mContentResolver, mKey);
+        }
+
+        private void writeBlacklist() {
+            new Thread("BlacklistUpdater") {
+                public void run() {
+                    synchronized(mTmpDir) {
+                        String blacklist = getValue();
+                        if (blacklist != null) {
+                            Slog.i(TAG, "Certificate blacklist changed, updating...");
+                            FileOutputStream out = null;
+                            try {
+                                // create a temporary file
+                                File tmp = File.createTempFile("journal", "", mTmpDir);
+                                // mark it -rw-r--r--
+                                tmp.setReadable(true, false);
+                                // write to it
+                                out = new FileOutputStream(tmp);
+                                out.write(blacklist.getBytes());
+                                // sync to disk
+                                FileUtils.sync(out);
+                                // atomic rename
+                                tmp.renameTo(new File(mPath));
+                                Slog.i(TAG, "Certificate blacklist updated");
+                            } catch (IOException e) {
+                                Slog.e(TAG, "Failed to write blacklist", e);
+                            } finally {
+                                IoUtils.closeQuietly(out);
+                            }
+                        }
+                    }
+                }
+            }.start();
+        }
+    }
+
+    public CertBlacklister(Context context) {
+        registerObservers(context.getContentResolver());
+    }
+
+    private BlacklistObserver buildPubkeyObserver(ContentResolver cr) {
+        return new BlacklistObserver(PUBKEY_BLACKLIST_KEY,
+                    "pubkey",
+                    PUBKEY_PATH,
+                    cr);
+    }
+
+    private BlacklistObserver buildSerialObserver(ContentResolver cr) {
+        return new BlacklistObserver(SERIAL_BLACKLIST_KEY,
+                    "serial",
+                    SERIAL_PATH,
+                    cr);
+    }
+
+    private void registerObservers(ContentResolver cr) {
+        // set up the public key blacklist observer
+        cr.registerContentObserver(
+            Settings.Secure.getUriFor(PUBKEY_BLACKLIST_KEY),
+            true,
+            buildPubkeyObserver(cr)
+        );
+
+        // set up the serial number blacklist observer
+        cr.registerContentObserver(
+            Settings.Secure.getUriFor(SERIAL_BLACKLIST_KEY),
+            true,
+            buildSerialObserver(cr)
+        );
+    }
+}
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index d9833ab..bb103580 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -623,6 +623,13 @@
             } catch (Throwable e) {
                 reportWtf("starting CommonTimeManagementService service", e);
             }
+
+            try {
+                Slog.i(TAG, "CertBlacklister");
+                CertBlacklister blacklister = new CertBlacklister(context);
+            } catch (Throwable e) {
+                reportWtf("starting CertBlacklister", e);
+            }
             
             if (context.getResources().getBoolean(
                     com.android.internal.R.bool.config_enableDreams)) {
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index 0c6d85d..28ce1df 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -23,7 +23,6 @@
 import android.accessibilityservice.AccessibilityService;
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.accessibilityservice.IAccessibilityServiceClient;
-import android.accessibilityservice.IAccessibilityServiceClientCallback;
 import android.accessibilityservice.IAccessibilityServiceConnection;
 import android.app.PendingIntent;
 import android.content.BroadcastReceiver;
@@ -44,7 +43,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
-import android.os.Looper;
 import android.os.Message;
 import android.os.RemoteException;
 import android.os.ServiceManager;
@@ -58,9 +56,7 @@
 import android.view.InputDevice;
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
-import android.view.View;
 import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityInteractionClient;
 import android.view.accessibility.AccessibilityManager;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.view.accessibility.IAccessibilityInteractionConnection;
@@ -69,8 +65,6 @@
 import android.view.accessibility.IAccessibilityManagerClient;
 
 import com.android.internal.content.PackageMonitor;
-import com.android.internal.os.HandlerCaller;
-import com.android.internal.os.HandlerCaller.Callback;
 import com.android.server.accessibility.TouchExplorer.GestureListener;
 import com.android.server.wm.WindowManagerService;
 
@@ -85,7 +79,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * This class is instantiated by the system as a system level service and can be
@@ -107,8 +100,6 @@
 
     private static final int OWN_PROCESS_ID = android.os.Process.myPid();
 
-    private static final int UNDEFINED = -1;
-
     private static int sIdCounter = 0;
 
     private static int sNextWindowId;
@@ -155,10 +146,6 @@
 
     private Service mUiAutomationService;
 
-    private GestureHandler mGestureHandler;
-
-    private int mDefaultGestureHandlingHelperServiceId = UNDEFINED;
-
     /**
      * Handler for delayed event dispatch.
      */
@@ -416,7 +403,6 @@
             IAccessibilityInteractionConnection connection) throws RemoteException {
         synchronized (mLock) {
             final IWindow addedWindowToken = windowToken;
-            final IAccessibilityInteractionConnection addedConnection = connection;
             final int windowId = sNextWindowId++;
             AccessibilityConnectionWrapper wrapper = new AccessibilityConnectionWrapper(windowId,
                     connection);
@@ -486,44 +472,15 @@
 
     @Override
     public boolean onGesture(int gestureId) {
-        // Lazily instantiate the gesture handler.
-        if (mGestureHandler == null) {
-            mGestureHandler = new GestureHandler();
-        }
         synchronized (mLock) {
             boolean handled = notifyGestureLocked(gestureId, false);
             if (!handled) {
                 handled = notifyGestureLocked(gestureId, true);
             }
-            if (!handled) {
-                mGestureHandler.scheduleHandleGestureDefault(gestureId);
-            }
             return handled;
         }
     }
 
-    private Service getDefaultGestureHandlingHelperService() {
-        // Since querying of screen content is done through the
-        // AccessibilityInteractionClient which talks to an
-        // IAccessibilityServiceConnection implementation we create a proxy
-        // Service when necessary to enable interaction with the remote
-        // view tree. Note that this service is just a stateless proxy
-        // that does not get any events or interrupts.
-        if (mDefaultGestureHandlingHelperServiceId == UNDEFINED) {
-            ComponentName name = new ComponentName("android",
-                    "DefaultGestureHandlingHelperService");
-            AccessibilityServiceInfo info = new AccessibilityServiceInfo();
-            Service service = new Service(name, info, true);
-            mDefaultGestureHandlingHelperServiceId = service.mId;
-            AccessibilityInteractionClient.getInstance().addConnection(
-                    mDefaultGestureHandlingHelperServiceId, service);
-            return service;
-        } else {
-            return (Service) AccessibilityInteractionClient.getInstance()
-                .getConnection(mDefaultGestureHandlingHelperServiceId);
-        }
-    }
-
     private boolean notifyGestureLocked(int gestureId, boolean isDefault) {
         // TODO: Now we are giving the gestures to the last enabled
         //       service that can handle them which is the last one
@@ -537,7 +494,12 @@
         for (int i = mServices.size() - 1; i >= 0; i--) {
             Service service = mServices.get(i);
             if (service.mReqeustTouchExplorationMode && service.mIsDefault == isDefault) {
-                mGestureHandler.scheduleHandleGesture(gestureId, service.mServiceInterface);
+                try {
+                    service.mServiceInterface.onGesture(gestureId);
+                } catch (RemoteException re) {
+                    Slog.e(LOG_TAG, "Error during sending gesture " + gestureId
+                            + " to " + service.mService, re);
+                }
                 return true;
             }
         }
@@ -983,212 +945,6 @@
         }
     }
 
-    class GestureHandler extends IAccessibilityServiceClientCallback.Stub
-            implements Runnable, Callback {
-
-        private static final String THREAD_NAME = "AccessibilityGestureHandler";
-
-        private static final long TIMEOUT_INTERACTION_MILLIS = 5000;
-
-        private static final int MSG_HANDLE_GESTURE = 1;
-
-        private static final int MSG_HANDLE_GESTURE_DEFAULT = 2;
-
-        private final AtomicInteger mInteractionCounter = new AtomicInteger();
-
-        private final Object mGestureLock = new Object();
-
-        private HandlerCaller mHandlerCaller;
-
-        private volatile int mInteractionId = -1;
-
-        private volatile boolean mGestureResult;
-
-        public GestureHandler() {
-            synchronized (mGestureLock) {
-                Thread worker = new Thread(this, THREAD_NAME);
-                worker.start();
-                while (mHandlerCaller == null) {
-                    try {
-                        mGestureLock.wait();
-                    } catch (InterruptedException ie) {
-                        /*  ignore */
-                    }
-                }
-            }
-        }
-
-        @Override
-        public void run() {
-            Looper.prepare();
-            synchronized (mGestureLock) {
-                mHandlerCaller = new HandlerCaller(mContext, Looper.myLooper(), this);
-                mGestureLock.notifyAll();
-            }
-            Looper.loop();
-        }
-
-        @Override
-        public void setGestureResult(int gestureId, boolean handled, int interactionId) {
-            synchronized (mGestureLock) {
-                if (interactionId > mInteractionId) {
-                    mGestureResult = handled;
-                    mInteractionId = interactionId;
-                }
-                mGestureLock.notifyAll();
-            }
-        }
-
-        @Override
-        public void executeMessage(Message message) {
-            final int type = message.what;
-            switch (type) {
-                case MSG_HANDLE_GESTURE: {
-                    IAccessibilityServiceClient service =
-                        (IAccessibilityServiceClient) message.obj;
-                    final int gestureId = message.arg1;
-                    final int interactionId = message.arg2;
-
-                    try {
-                        service.onGesture(gestureId, this, interactionId);
-                    } catch (RemoteException re) {
-                        Slog.e(LOG_TAG, "Error dispatching a gesture to a client.", re);
-                        return;
-                    }
-
-                    long waitTimeMillis = 0;
-                    final long startTimeMillis = SystemClock.uptimeMillis();
-                    synchronized (mGestureLock) {
-                        while (true) {
-                            try {
-                                // Did we get the expected callback?
-                                if (mInteractionId == interactionId) {
-                                    break;
-                                }
-                                // Did we get an obsolete callback?
-                                if (mInteractionId > interactionId) {
-                                    break;
-                                }
-                                // Did we time out?
-                                final long elapsedTimeMillis =
-                                    SystemClock.uptimeMillis() - startTimeMillis;
-                                waitTimeMillis = TIMEOUT_INTERACTION_MILLIS - elapsedTimeMillis;
-                                if (waitTimeMillis <= 0) {
-                                    break;
-                                }
-                                mGestureLock.wait(waitTimeMillis);
-                            } catch (InterruptedException ie) {
-                                /* ignore */
-                            }
-                        }
-                        handleGestureIfNeededAndResetLocked(gestureId);
-                    }
-                } break;
-                case MSG_HANDLE_GESTURE_DEFAULT: {
-                    final int gestureId = message.arg1;
-                    handleGestureDefault(gestureId);
-                } break;
-                default: {
-                    throw new IllegalArgumentException("Unknown message type: " + type);
-                }
-            }
-        }
-
-        private void handleGestureIfNeededAndResetLocked(int gestureId) {
-            if (!mGestureResult) {
-                handleGestureDefault(gestureId);
-            }
-            mGestureResult = false;
-            mInteractionId = -1;
-        }
-
-        public void scheduleHandleGesture(int gestureId, IAccessibilityServiceClient service) {
-            final int interactionId = mInteractionCounter.incrementAndGet();
-            mHandlerCaller.obtainMessageIIO(MSG_HANDLE_GESTURE, gestureId, interactionId,
-                    service).sendToTarget();
-        }
-
-        public void scheduleHandleGestureDefault(int gestureId) {
-            final int interactionId = mInteractionCounter.incrementAndGet();
-            mHandlerCaller.obtainMessageI(MSG_HANDLE_GESTURE_DEFAULT, gestureId).sendToTarget();
-        }
-
-        private void handleGestureDefault(int gestureId) {
-            Service service = getDefaultGestureHandlingHelperService();
-
-            // Global actions.
-            switch (gestureId) {
-                case AccessibilityService.GESTURE_SWIPE_DOWN_AND_LEFT: {
-                    service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_BACK);
-                } return;
-                case AccessibilityService.GESTURE_SWIPE_DOWN_AND_RIGHT: {
-                    service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_HOME);
-                } return;
-                case AccessibilityService.GESTURE_SWIPE_UP_AND_LEFT: {
-                    service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_RECENTS);
-                } return;
-                case AccessibilityService.GESTURE_SWIPE_UP_AND_RIGHT: {
-                    service.performGlobalAction(AccessibilityService.GLOBAL_ACTION_NOTIFICATIONS);
-                } return;
-            }
-
-            AccessibilityInteractionClient client = AccessibilityInteractionClient.getInstance();
-
-            AccessibilityNodeInfo root = client.getRootInActiveWindow(service.mId);
-            if (root == null) {
-                return;
-            }
-
-            AccessibilityNodeInfo current = root.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY);
-            if (current == null) {
-                current = root;
-            }
-
-            // Local actions.
-            AccessibilityNodeInfo next = null;
-            switch (gestureId) {
-                case AccessibilityService.GESTURE_SWIPE_UP: {
-                    // TODO:
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_DOWN: {
-                    // TODO:
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_LEFT: {
-                    // TODO: Implement the RTL support.
-//                     if (mLayoutDirection == View.LAYOUT_DIRECTION_LTR) {
-                        next = current.focusSearch(View.ACCESSIBILITY_FOCUS_BACKWARD);
-//                     } else { // LAYOUT_DIRECTION_RTL
-//                        next = current.focusSearch(View.ACCESSIBILITY_FOCUS_FORWARD);
-//                     }
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_RIGHT: {
-                    // TODO: Implement the RTL support.
-//                    if (mLayoutDirection == View.LAYOUT_DIRECTION_LTR) {
-                        next = current.focusSearch(View.ACCESSIBILITY_FOCUS_FORWARD);
-//                    } else { // LAYOUT_DIRECTION_RTL
-//                        next = current.focusSearch(View.ACCESSIBILITY_FOCUS_BACKWARD);
-//                    }
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_UP_AND_DOWN: {
-                    next = current.focusSearch(View.ACCESSIBILITY_FOCUS_UP);
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_DOWN_AND_UP: {
-                    next = current.focusSearch(View.ACCESSIBILITY_FOCUS_DOWN);
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_LEFT_AND_RIGHT: {
-                    next = current.focusSearch(View.ACCESSIBILITY_FOCUS_LEFT);
-                } break;
-                case AccessibilityService.GESTURE_SWIPE_RIGHT_AND_LEFT: {
-                    next = current.focusSearch(View.ACCESSIBILITY_FOCUS_RIGHT);
-                } break;
-            }
-            if (next != null && !next.equals(current)) {
-                next.performAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS);
-            }
-        }
-    }
-
     /**
      * This class represents an accessibility service. It stores all per service
      * data required for the service management, provides API for starting/stopping the
@@ -1268,10 +1024,7 @@
             mIsDefault = (info.flags & DEFAULT) != 0;
 
             if (mIsAutomation || info.getResolveInfo().serviceInfo.applicationInfo.targetSdkVersion
-                    // TODO: Uncomment this line and remove the line below when JellyBean
-                    // SDK version is finalized.
-                    // >= Build.VERSION_CODES.JELLY_BEAN) {
-                    > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
+                    >= Build.VERSION_CODES.JELLY_BEAN) {
                 mIncludeNotImportantViews =
                     (info.flags & FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0;
             }
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index c300411..b9f63cf 100755
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -1036,6 +1036,11 @@
 
     final void activityStoppedLocked(ActivityRecord r, Bundle icicle, Bitmap thumbnail,
             CharSequence description) {
+        if (r.state != ActivityState.STOPPING) {
+            Slog.i(TAG, "Activity reported stop, but no longer stopping: " + r);
+            mHandler.removeMessages(STOP_TIMEOUT_MSG, r);
+            return;
+        }
         if (DEBUG_SAVED_STATE) Slog.i(TAG, "Saving icicle of " + r + ": " + icicle);
         if (icicle != null) {
             // If icicle is null, this is happening due to a timeout, so we
@@ -4394,14 +4399,14 @@
             r.forceNewConfig = false;
             if (r.app == null || r.app.thread == null) {
                 if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                        "Switch is destroying non-running " + r);
+                        "Config is destroying non-running " + r);
                 destroyActivityLocked(r, true, false, "config");
             } else if (r.state == ActivityState.PAUSING) {
                 // A little annoying: we are waiting for this activity to
                 // finish pausing.  Let's not do anything now, but just
                 // flag that it needs to be restarted when done pausing.
                 if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                        "Switch is skipping already pausing " + r);
+                        "Config is skipping already pausing " + r);
                 r.configDestroy = true;
                 return true;
             } else if (r.state == ActivityState.RESUMED) {
@@ -4410,12 +4415,12 @@
                 // Instead of doing the normal handshaking, just say
                 // "restart!".
                 if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                        "Switch is restarting resumed " + r);
+                        "Config is relaunching resumed " + r);
                 relaunchActivityLocked(r, r.configChangeFlags, true);
                 r.configChangeFlags = 0;
             } else {
                 if (DEBUG_SWITCH || DEBUG_CONFIGURATION) Slog.v(TAG,
-                        "Switch is restarting non-resumed " + r);
+                        "Config is relaunching non-resumed " + r);
                 relaunchActivityLocked(r, r.configChangeFlags, false);
                 r.configChangeFlags = 0;
             }
@@ -4461,7 +4466,9 @@
         r.startFreezingScreenLocked(r.app, 0);
         
         try {
-            if (DEBUG_SWITCH) Slog.i(TAG, "Switch is restarting resumed " + r);
+            if (DEBUG_SWITCH || DEBUG_STATES) Slog.i(TAG,
+                    (andResume ? "Relaunching to RESUMED " : "Relaunching to PAUSED ")
+                    + r);
             r.forceNewConfig = false;
             r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents,
                     changes, !andResume, new Configuration(mService.mConfiguration));
@@ -4469,7 +4476,7 @@
             // the caller will only pass in 'andResume' if this activity is
             // currently resumed, which implies we aren't sleeping.
         } catch (RemoteException e) {
-            return false;
+            if (DEBUG_SWITCH || DEBUG_STATES) Slog.i(TAG, "Relaunch failed", e);
         }
 
         if (andResume) {
@@ -4478,6 +4485,10 @@
             if (mMainStack) {
                 mService.reportResumedActivityLocked(r);
             }
+            r.state = ActivityState.RESUMED;
+        } else {
+            mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r);
+            r.state = ActivityState.PAUSED;
         }
 
         return true;
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index d7c5eea..497ee4b 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -5600,16 +5600,18 @@
 
         private final IPackageStatsObserver mObserver;
 
-        public MeasureParams(PackageStats stats, boolean success, IPackageStatsObserver observer) {
+        public MeasureParams(PackageStats stats, IPackageStatsObserver observer) {
             mObserver = observer;
             mStats = stats;
-            mSuccess = success;
         }
 
         @Override
         void handleStartCopy() throws RemoteException {
-            final boolean mounted;
+            synchronized (mInstallLock) {
+                mSuccess = getPackageSizeInfoLI(mStats.packageName, mStats);
+            }
 
+            final boolean mounted;
             if (Environment.isExternalStorageEmulated()) {
                 mounted = true;
             } else {
@@ -7781,22 +7783,16 @@
             final IPackageStatsObserver observer) {
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.GET_PACKAGE_SIZE, null);
-        // Queue up an async operation since the package deletion may take a little while.
-        mHandler.post(new Runnable() {
-            public void run() {
-                mHandler.removeCallbacks(this);
-                PackageStats stats = new PackageStats(packageName);
 
-                final boolean success;
-                synchronized (mInstallLock) {
-                    success = getPackageSizeInfoLI(packageName, stats);
-                }
+        PackageStats stats = new PackageStats(packageName);
 
-                Message msg = mHandler.obtainMessage(INIT_COPY);
-                msg.obj = new MeasureParams(stats, success, observer);
-                mHandler.sendMessage(msg);
-            } //end run
-        });
+        /*
+         * Queue up an async operation since the package measurement may take a
+         * little while.
+         */
+        Message msg = mHandler.obtainMessage(INIT_COPY);
+        msg.obj = new MeasureParams(stats, observer);
+        mHandler.sendMessage(msg);
     }
 
     private boolean getPackageSizeInfoLI(String packageName, PackageStats pStats) {
diff --git a/services/java/com/android/server/wm/Session.java b/services/java/com/android/server/wm/Session.java
index 53c0e07..61c0e9c 100644
--- a/services/java/com/android/server/wm/Session.java
+++ b/services/java/com/android/server/wm/Session.java
@@ -151,13 +151,13 @@
 
     public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs,
             int requestedWidth, int requestedHeight, int viewFlags,
-            int flags, Rect outFrame, Rect outSystemInsets, Rect outContentInsets,
+            int flags, Rect outFrame, Rect outContentInsets,
             Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
         if (false) Slog.d(WindowManagerService.TAG, ">>>>>> ENTERED relayout from "
                 + Binder.getCallingPid());
         int res = mService.relayoutWindow(this, window, seq, attrs,
                 requestedWidth, requestedHeight, viewFlags, flags,
-                outFrame, outSystemInsets, outContentInsets, outVisibleInsets,
+                outFrame, outContentInsets, outVisibleInsets,
                 outConfig, outSurface);
         if (false) Slog.d(WindowManagerService.TAG, "<<<<<< EXITING relayout to "
                 + Binder.getCallingPid());
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 8c917c1..b3ac6f1 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -479,6 +479,9 @@
             = new ArrayList<IRotationWatcher>();
     int mDeferredRotationPauseCount;
 
+    final Rect mSystemDecorRect = new Rect();
+    int mSystemDecorLayer = 0;
+
     int mPendingLayoutChanges = 0;
     boolean mLayoutNeeded = true;
     boolean mTraversalScheduled = false;
@@ -2646,7 +2649,7 @@
     public int relayoutWindow(Session session, IWindow client, int seq,
             WindowManager.LayoutParams attrs, int requestedWidth,
             int requestedHeight, int viewVisibility, int flags,
-            Rect outFrame, Rect outSystemInsets, Rect outContentInsets,
+            Rect outFrame, Rect outContentInsets,
             Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {
         boolean displayed = false;
         boolean inTouchMode;
@@ -2938,7 +2941,6 @@
                 win.mAppToken.updateReportedVisibilityLocked();
             }
             outFrame.set(win.mCompatFrame);
-            outSystemInsets.set(win.mSystemInsets);
             outContentInsets.set(win.mContentInsets);
             outVisibleInsets.set(win.mVisibleInsets);
             if (localLOGV) Slog.v(
@@ -7716,6 +7718,7 @@
         }
         
         mPolicy.beginLayoutLw(dw, dh, mRotation);
+        mSystemDecorLayer = mPolicy.getSystemDecorRectLw(mSystemDecorRect);
 
         int seq = mLayoutSeq+1;
         if (seq < 0) seq = 0;
@@ -8178,8 +8181,6 @@
     private void updateResizingWindows(final WindowState w) {
         final WindowStateAnimator winAnimator = w.mWinAnimator;
         if (w.mHasSurface && !w.mAppFreezing && w.mLayoutSeq == mLayoutSeq) {
-            w.mSystemInsetsChanged |=
-                    !w.mLastSystemInsets.equals(w.mSystemInsets);
             w.mContentInsetsChanged |=
                     !w.mLastContentInsets.equals(w.mContentInsets);
             w.mVisibleInsetsChanged |=
@@ -8196,8 +8197,7 @@
                     + ": configChanged=" + configChanged
                     + " last=" + w.mLastFrame + " frame=" + w.mFrame);
             w.mLastFrame.set(w.mFrame);
-            if (w.mSystemInsetsChanged
-                    || w.mContentInsetsChanged
+            if (w.mContentInsetsChanged
                     || w.mVisibleInsetsChanged
                     || winAnimator.mSurfaceResized
                     || configChanged) {
@@ -8209,7 +8209,6 @@
                             + " configChanged=" + configChanged);
                 }
 
-                w.mLastSystemInsets.set(w.mSystemInsets);
                 w.mLastContentInsets.set(w.mContentInsets);
                 w.mLastVisibleInsets.set(w.mVisibleInsets);
                 makeWindowFreezingScreenIfNeededLocked(w);
@@ -8593,11 +8592,10 @@
                             winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING) Slog.i(
                             TAG, "Resizing " + win + " WITH DRAW PENDING");
                     win.mClient.resized((int)winAnimator.mSurfaceW,
-                            (int)winAnimator.mSurfaceH, win.mLastSystemInsets,
+                            (int)winAnimator.mSurfaceH,
                             win.mLastContentInsets, win.mLastVisibleInsets,
                             winAnimator.mDrawState == WindowStateAnimator.DRAW_PENDING,
                             configChanged ? win.mConfiguration : null);
-                    win.mSystemInsetsChanged = false;
                     win.mContentInsetsChanged = false;
                     win.mVisibleInsetsChanged = false;
                     winAnimator.mSurfaceResized = false;
@@ -9588,6 +9586,8 @@
         pw.print("  mInTouchMode="); pw.print(mInTouchMode);
                 pw.print(" mLayoutSeq="); pw.println(mLayoutSeq);
         if (dumpAll) {
+            pw.print("  mSystemDecorRect="); pw.print(mSystemDecorRect.toShortString());
+                    pw.print(" mSystemDecorLayer="); pw.println(mSystemDecorLayer);
             if (mLastStatusBarVisibility != 0) {
                 pw.print("  mLastStatusBarVisibility=0x");
                         pw.println(Integer.toHexString(mLastStatusBarVisibility));
diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java
index 05e7d3a..1fd80c2 100644
--- a/services/java/com/android/server/wm/WindowState.java
+++ b/services/java/com/android/server/wm/WindowState.java
@@ -133,14 +133,6 @@
     boolean mContentInsetsChanged;
 
     /**
-     * Insets that are covered by system windows such as the status bar.  These
-     * are in the application's coordinate space (without compatibility scale applied).
-     */
-    final Rect mSystemInsets = new Rect();
-    final Rect mLastSystemInsets = new Rect();
-    boolean mSystemInsetsChanged;
-
-    /**
      * Set to true if we are waiting for this window to receive its
      * given internal insets before laying out other windows based on it.
      */
@@ -171,6 +163,13 @@
      */
     int mTouchableInsets = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME;
 
+    /**
+     * This is rectangle of the window's surface that is not covered by
+     * system decorations.
+     */
+    final Rect mSystemDecorRect = new Rect();
+    final Rect mLastSystemDecorRect = new Rect();
+
     // Current transformation being applied.
     float mGlobalScale=1;
     float mInvGlobalScale=1;
@@ -187,7 +186,6 @@
 
     final Rect mContainingFrame = new Rect();
     final Rect mDisplayFrame = new Rect();
-    final Rect mSystemFrame = new Rect();
     final Rect mContentFrame = new Rect();
     final Rect mParentFrame = new Rect();
     final Rect mVisibleFrame = new Rect();
@@ -356,7 +354,7 @@
     }
 
     @Override
-    public void computeFrameLw(Rect pf, Rect df, Rect sf, Rect cf, Rect vf) {
+    public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {
         mHaveFrame = true;
 
         final Rect container = mContainingFrame;
@@ -413,9 +411,6 @@
             mContentChanged = true;
         }
 
-        final Rect system = mSystemFrame;
-        system.set(sf);
-
         final Rect content = mContentFrame;
         content.set(cf);
 
@@ -449,10 +444,6 @@
 
         // Make sure the system, content and visible frames are inside of the
         // final window frame.
-        if (system.left < frame.left) system.left = frame.left;
-        if (system.top < frame.top) system.top = frame.top;
-        if (system.right > frame.right) system.right = frame.right;
-        if (system.bottom > frame.bottom) system.bottom = frame.bottom;
         if (content.left < frame.left) content.left = frame.left;
         if (content.top < frame.top) content.top = frame.top;
         if (content.right > frame.right) content.right = frame.right;
@@ -462,12 +453,6 @@
         if (visible.right > frame.right) visible.right = frame.right;
         if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;
 
-        final Rect systemInsets = mSystemInsets;
-        systemInsets.left = system.left-frame.left;
-        systemInsets.top = system.top-frame.top;
-        systemInsets.right = frame.right-system.right;
-        systemInsets.bottom = frame.bottom-system.bottom;
-
         final Rect contentInsets = mContentInsets;
         contentInsets.left = content.left-frame.left;
         contentInsets.top = content.top-frame.top;
@@ -485,7 +470,6 @@
             // If there is a size compatibility scale being applied to the
             // window, we need to apply this to its insets so that they are
             // reported to the app in its coordinate space.
-            systemInsets.scale(mInvGlobalScale);
             contentInsets.scale(mInvGlobalScale);
             visibleInsets.scale(mInvGlobalScale);
 
@@ -506,7 +490,6 @@
                         + mRequestedWidth + ", mRequestedheight="
                         + mRequestedHeight + ") to" + " (pw=" + pw + ", ph=" + ph
                         + "): frame=" + mFrame.toShortString()
-                        + " si=" + systemInsets.toShortString()
                         + " ci=" + contentInsets.toShortString()
                         + " vi=" + visibleInsets.toShortString());
             //}
@@ -529,11 +512,6 @@
     }
 
     @Override
-    public Rect getSystemFrameLw() {
-        return mSystemFrame;
-    }
-
-    @Override
     public Rect getContentFrameLw() {
         return mContentFrame;
     }
@@ -1067,6 +1045,9 @@
             pw.print(prefix); pw.print("mFrame="); mFrame.printShortString(pw);
                     pw.print(" last="); mLastFrame.printShortString(pw);
                     pw.println();
+            pw.print(prefix); pw.print("mSystemDecorRect="); mSystemDecorRect.printShortString(pw);
+                    pw.print(" last="); mLastSystemDecorRect.printShortString(pw);
+                    pw.println();
         }
         if (mEnforceSizeCompat) {
             pw.print(prefix); pw.print("mCompatFrame="); mCompatFrame.printShortString(pw);
@@ -1078,16 +1059,15 @@
                     pw.print(" parent="); mParentFrame.printShortString(pw);
                     pw.print(" display="); mDisplayFrame.printShortString(pw);
                     pw.println();
-            pw.print(prefix); pw.print("    system="); mSystemFrame.printShortString(pw);
-                    pw.print(" content="); mContentFrame.printShortString(pw);
+            pw.print(prefix); pw.print("    content="); mContentFrame.printShortString(pw);
                     pw.print(" visible="); mVisibleFrame.printShortString(pw);
                     pw.println();
-            pw.print(prefix); pw.print("Cur insets: system="); mSystemInsets.printShortString(pw);
-                    pw.print(" content="); mContentInsets.printShortString(pw);;
+            pw.print(prefix); pw.print("Cur insets: content=");
+                    mContentInsets.printShortString(pw);
                     pw.print(" visible="); mVisibleInsets.printShortString(pw);
                     pw.println();
-            pw.print(prefix); pw.print("Lst insets: system="); mLastSystemInsets.printShortString(pw);
-                    pw.print(" content="); mLastContentInsets.printShortString(pw);;
+            pw.print(prefix); pw.print("Lst insets: content=");
+                    mLastContentInsets.printShortString(pw);
                     pw.print(" visible="); mLastVisibleInsets.printShortString(pw);
                     pw.println();
         }
diff --git a/services/java/com/android/server/wm/WindowStateAnimator.java b/services/java/com/android/server/wm/WindowStateAnimator.java
index 293d3e8..cba92f3 100644
--- a/services/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/java/com/android/server/wm/WindowStateAnimator.java
@@ -436,8 +436,9 @@
 
         private float mSurfaceTraceAlpha = 0;
         private int mLayer;
-        private PointF mPosition = new PointF();
-        private Point mSize;
+        private final PointF mPosition = new PointF();
+        private final Point mSize = new Point();
+        private final Rect mWindowCrop = new Rect();
         private boolean mShown = false;
         private String mName = "Not named";
 
@@ -445,7 +446,7 @@
                        int pid, int display, int w, int h, int format, int flags) throws
                        OutOfResourcesException {
             super(s, pid, display, w, h, format, flags);
-            mSize = new Point(w, h);
+            mSize.set(w, h);
             Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
                     + Debug.getCallers(3));
         }
@@ -455,7 +456,7 @@
                    throws OutOfResourcesException {
             super(s, pid, name, display, w, h, format, flags);
             mName = name;
-            mSize = new Point(w, h);
+            mSize.set(w, h);
             Slog.v(SURFACE_TAG, "ctor: " + this + ". Called by "
                     + Debug.getCallers(3));
         }
@@ -489,7 +490,7 @@
         @Override
         public void setPosition(float x, float y) {
             super.setPosition(x, y);
-            mPosition = new PointF(x, y);
+            mPosition.set(x, y);
             Slog.v(SURFACE_TAG, "setPosition: " + this + ". Called by "
                     + Debug.getCallers(3));
         }
@@ -497,12 +498,20 @@
         @Override
         public void setSize(int w, int h) {
             super.setSize(w, h);
-            mSize = new Point(w, h);
+            mSize.set(w, h);
             Slog.v(SURFACE_TAG, "setSize: " + this + ". Called by "
                     + Debug.getCallers(3));
         }
 
         @Override
+        public void setWindowCrop(Rect crop) {
+            super.setWindowCrop(crop);
+            mWindowCrop.set(crop);
+            Slog.v(SURFACE_TAG, "setWindowCrop: " + this + ". Called by "
+                    + Debug.getCallers(3));
+        }
+
+        @Override
         public void hide() {
             super.hide();
             mShown = false;
@@ -545,7 +554,8 @@
             return "Surface " + Integer.toHexString(System.identityHashCode(this)) + " "
                     + mName + ": shown=" + mShown + " layer=" + mLayer
                     + " alpha=" + mSurfaceTraceAlpha + " " + mPosition.x + "," + mPosition.y
-                    + " " + mSize.x + "x" + mSize.y;
+                    + " " + mSize.x + "x" + mSize.y
+                    + " crop=" + mWindowCrop.toShortString();
         }
     }
 
@@ -596,6 +606,7 @@
             mSurfaceY = 0;
             mSurfaceW = w;
             mSurfaceH = h;
+            mWin.mLastSystemDecorRect.set(0, 0, 0, 0);
             try {
                 final boolean isHwAccelerated = (attrs.flags &
                         WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
@@ -991,6 +1002,55 @@
                 }
             }
         }
+
+        // Need to recompute a new system decor rect each time.
+        if ((w.mAttrs.flags & LayoutParams.FLAG_SCALED) != 0) {
+            // Currently can't do this cropping for scaled windows.  We'll
+            // just keep the crop rect the same as the source surface.
+            w.mSystemDecorRect.set(0, 0, w.mRequestedWidth, w.mRequestedHeight);
+        } else if (w.mLayer >= mService.mSystemDecorLayer) {
+            // Above the decor layer is easy, just use the entire window.
+            w.mSystemDecorRect.set(0, 0, w.mCompatFrame.width(),
+                    w.mCompatFrame.height());
+        } else {
+            final Rect decorRect = mService.mSystemDecorRect;
+            // Compute the offset of the window in relation to the decor rect.
+            final int offX = w.mXOffset + w.mFrame.left;
+            final int offY = w.mYOffset + w.mFrame.top;
+            // Initialize the decor rect to the entire frame.
+            w.mSystemDecorRect.set(0, 0, w.mFrame.width(), w.mFrame.height());
+            // Intersect with the decor rect, offsetted by window position.
+            w.mSystemDecorRect.intersect(decorRect.left-offX, decorRect.top-offY,
+                    decorRect.right-offX, decorRect.bottom-offY);
+            // If size compatibility is being applied to the window, the
+            // surface is scaled relative to the screen.  Also apply this
+            // scaling to the crop rect.  We aren't using the standard rect
+            // scale function because we want to round things to make the crop
+            // always round to a larger rect to ensure we don't crop too
+            // much and hide part of the window that should be seen.
+            if (w.mEnforceSizeCompat && w.mInvGlobalScale != 1.0f) {
+                final float scale = w.mInvGlobalScale;
+                w.mSystemDecorRect.left = (int) (w.mSystemDecorRect.left * scale - 0.5f);
+                w.mSystemDecorRect.top = (int) (w.mSystemDecorRect.top * scale - 0.5f);
+                w.mSystemDecorRect.right = (int) ((w.mSystemDecorRect.right+1) * scale - 0.5f);
+                w.mSystemDecorRect.bottom = (int) ((w.mSystemDecorRect.bottom+1) * scale - 0.5f);
+            }
+        }
+
+        if (!w.mSystemDecorRect.equals(w.mLastSystemDecorRect)) {
+            w.mLastSystemDecorRect.set(w.mSystemDecorRect);
+            try {
+                if (WindowManagerService.SHOW_TRANSACTIONS) WindowManagerService.logSurface(w,
+                        "CROP " + w.mSystemDecorRect.toShortString(), null);
+                mSurface.setWindowCrop(w.mSystemDecorRect);
+            } catch (RuntimeException e) {
+                Slog.w(TAG, "Error setting crop surface of " + w
+                        + " crop=" + w.mSystemDecorRect.toShortString(), e);
+                if (!recoveringMemory) {
+                    mService.reclaimSomeSurfaceMemoryLocked(this, "crop", true);
+                }
+            }
+        }
     }
 
     public void prepareSurfaceLocked(final boolean recoveringMemory) {
@@ -1126,6 +1186,7 @@
             mSurfaceX = left;
             mSurfaceY = top;
             mSurface.setPosition(left, top);
+            mSurface.setWindowCrop(null);
         } catch (RuntimeException e) {
             Slog.w(TAG, "Error positioning surface of " + mWin
                     + " pos=(" + left + "," + top + ")", e);
diff --git a/services/tests/servicestests/src/com/android/server/CertBlacklisterTest.java b/services/tests/servicestests/src/com/android/server/CertBlacklisterTest.java
new file mode 100644
index 0000000..10b9e7c
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/CertBlacklisterTest.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2012 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.server;
+
+import android.content.Context;
+import android.content.Intent;
+import android.test.AndroidTestCase;
+import android.provider.Settings;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashSet;
+
+import libcore.io.IoUtils;
+
+/**
+ * Tests for {@link com.android.server.CertBlacklister}
+ */
+public class CertBlacklisterTest extends AndroidTestCase {
+
+    private static final String BLACKLIST_ROOT = System.getenv("ANDROID_DATA") + "/misc/keychain/";
+
+    public static final String PUBKEY_PATH = BLACKLIST_ROOT + "pubkey_blacklist.txt";
+    public static final String SERIAL_PATH = BLACKLIST_ROOT + "serial_blacklist.txt";
+
+    public static final String PUBKEY_KEY = "pubkey_blacklist";
+    public static final String SERIAL_KEY = "serial_blacklist";
+
+    private void overrideSettings(String key, String value) throws Exception {
+        Settings.Secure.putString(mContext.getContentResolver(), key, value);
+        Thread.sleep(1000);
+    }
+
+    public void testClearBlacklistPubkey() throws Exception {
+        // clear the gservices setting for a clean slate
+        overrideSettings(PUBKEY_KEY, "");
+        // read the contents of the pubkey blacklist
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        // Verify that it's empty
+        assertEquals("", blacklist);
+    }
+
+    public void testSetBlacklistPubkey() throws Exception {
+        // build a new thing to blacklist
+        String badPubkey = "7ccabd7db47e94a5759901b6a7dfd45d1c091ccc";
+        // add the gservices override
+        overrideSettings(PUBKEY_KEY, badPubkey);
+        // check the contents again
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        // make sure that we're equal to the string we sent out
+        assertEquals(badPubkey, blacklist);
+    }
+
+    public void testChangeBlacklistPubkey() throws Exception {
+        String badPubkey = "6ccabd7db47e94a5759901b6a7dfd45d1c091ccc";
+        overrideSettings(PUBKEY_KEY, badPubkey);
+        badPubkey = "6ccabd7db47e94a5759901b6a7dfd45d1c091cce";
+        overrideSettings(PUBKEY_KEY, badPubkey);
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        assertEquals(badPubkey, blacklist);
+    }
+
+    public void testMultiBlacklistPubkey() throws Exception {
+        String badPubkey = "6ccabd7db47e94a5759901b6a7dfd45d1c091ccc,6ccabd7db47e94a5759901b6a7dfd45d1c091ccd";
+        overrideSettings(PUBKEY_KEY, badPubkey);
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        assertEquals(badPubkey, blacklist);
+    }
+
+    public void testInvalidMultiBlacklistPubkey() throws Exception {
+        String badPubkey = "6ccabd7db47e94a5759901b6a7dfd45d1c091ccc,ZZZZZ,6ccabd7db47e94a5759901b6a7dfd45d1c091ccd";
+        overrideSettings(PUBKEY_KEY, badPubkey);
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        assertEquals(badPubkey, blacklist);
+    }
+
+    public void testInvalidCharsBlacklistPubkey() throws Exception {
+        String badPubkey = "\n6ccabd7db47e94a5759901b6a7dfd45d1c091ccc,-ZZZZZ,+6ccabd7db47e94a5759901b6a7dfd45d1c091ccd";
+        overrideSettings(PUBKEY_KEY, badPubkey);
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        assertEquals(badPubkey, blacklist);
+    }
+
+    public void testLotsOfBlacklistedPubkeys() throws Exception {
+        StringBuilder bl = new StringBuilder();
+        for (int i=0; i < 1000; i++) {
+            bl.append("6ccabd7db47e94a5759901b6a7dfd45d1c091ccc,");
+        }
+        overrideSettings(PUBKEY_KEY, bl.toString());
+        String blacklist = IoUtils.readFileAsString(PUBKEY_PATH);
+        assertEquals(bl.toString(), blacklist);
+    }
+
+    public void testClearBlacklistSerial() throws Exception {
+        // clear the gservices setting for a clean slate
+        overrideSettings(SERIAL_KEY, "");
+        // read the contents of the pubkey blacklist
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        // Verify that it's empty
+        assertEquals("", blacklist);
+    }
+
+    public void testSetBlacklistSerial() throws Exception {
+        // build a new thing to blacklist
+        String badSerial = "22e514121e61c643b1e9b06bd4b9f7d0";
+        // add the gservices override
+        overrideSettings(SERIAL_KEY, badSerial);
+        // check the contents again
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        // make sure that we're equal to the string we sent out
+        assertEquals(badSerial, blacklist);
+    }
+
+    public void testChangeBlacklistSerial() throws Exception {
+        String badSerial = "22e514121e61c643b1e9b06bd4b9f7d0";
+        overrideSettings(SERIAL_KEY, badSerial);
+        badSerial = "22e514121e61c643b1e9b06bd4b9f7d1";
+        overrideSettings(SERIAL_KEY, badSerial);
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        assertEquals(badSerial, blacklist);
+    }
+
+    public void testMultiBlacklistSerial() throws Exception {
+        String badSerial = "22e514121e61c643b1e9b06bd4b9f7d0,22e514121e61c643b1e9b06bd4b9f7d1";
+        overrideSettings(SERIAL_KEY, badSerial);
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        assertEquals(badSerial, blacklist);
+    }
+
+    public void testInvalidMultiBlacklistSerial() throws Exception {
+        String badSerial = "22e514121e61c643b1e9b06bd4b9f7d0,ZZZZ,22e514121e61c643b1e9b06bd4b9f7d1";
+        overrideSettings(SERIAL_KEY, badSerial);
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        assertEquals(badSerial, blacklist);
+    }
+
+    public void testInvalidCharsBlacklistSerial() throws Exception {
+        String badSerial = "\n22e514121e61c643b1e9b06bd4b9f7d0,-ZZZZ,+22e514121e61c643b1e9b06bd4b9f7d1";
+        overrideSettings(SERIAL_KEY, badSerial);
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        assertEquals(badSerial, blacklist);
+    }
+
+    public void testLotsOfBlacklistedSerials() throws Exception {
+        StringBuilder bl = new StringBuilder();
+        for (int i=0; i < 1000; i++) {
+            bl.append("22e514121e61c643b1e9b06bd4b9f7d0,");
+        }
+        overrideSettings(SERIAL_KEY, bl.toString());
+        String blacklist = IoUtils.readFileAsString(SERIAL_PATH);
+        assertEquals(bl.toString(), blacklist);
+    }
+}
diff --git a/telephony/java/com/android/internal/telephony/IccSmsInterfaceManager.java b/telephony/java/com/android/internal/telephony/IccSmsInterfaceManager.java
index 9763265..5fef6de 100644
--- a/telephony/java/com/android/internal/telephony/IccSmsInterfaceManager.java
+++ b/telephony/java/com/android/internal/telephony/IccSmsInterfaceManager.java
@@ -112,7 +112,7 @@
      */
     public void sendText(String destAddr, String scAddr,
             String text, PendingIntent sentIntent, PendingIntent deliveryIntent) {
-        mPhone.getContext().enforceCallingOrSelfPermission(
+        mPhone.getContext().enforceCallingPermission(
                 "android.permission.SEND_SMS",
                 "Sending SMS message");
         if (Log.isLoggable("SMS", Log.VERBOSE)) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
index c44ddc6..379fb81 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java
@@ -47,7 +47,7 @@
     }
 
     @Override
-    public void resized(int arg0, int arg1, Rect argBlah, Rect arg2, Rect arg3,
+    public void resized(int arg0, int arg1, Rect arg2, Rect arg3,
             boolean arg4, Configuration arg5) throws RemoteException {
         // pass for now.
     }
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
index 3996d26..6fb599d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowSession.java
@@ -69,7 +69,7 @@
     }
     @Override
     public int relayout(IWindow arg0, int seq, LayoutParams arg1, int arg2, int arg3, int arg4,
-            int arg4_5, Rect arg4_6, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b,
+            int arg4_5, Rect arg5, Rect arg6, Rect arg7, Configuration arg7b,
             Surface arg8) throws RemoteException {
         // pass for now.
         return 0;
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index b099202..2903faa 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -182,6 +182,14 @@
     /* Tracks sequence number on a tether notification time out */
     private int mTetherToken = 0;
 
+    /**
+     * Driver start time out.
+     */
+    private static final int DRIVER_START_TIME_OUT_MSECS = 10000;
+
+    /* Tracks sequence number on a driver time out */
+    private int mDriverStartToken = 0;
+
     private LinkProperties mLinkProperties;
 
     /* Tracks sequence number on a periodic scan message */
@@ -250,7 +258,8 @@
     static final int CMD_STOP_SUPPLICANT_FAILED           = BASE + 17;
     /* Delayed stop to avoid shutting down driver too quick*/
     static final int CMD_DELAYED_STOP_DRIVER              = BASE + 18;
-
+    /* A delayed message sent to start driver when it fail to come up */
+    static final int CMD_DRIVER_START_TIMED_OUT           = BASE + 19;
 
     /* Start the soft access point */
     static final int CMD_START_AP                         = BASE + 21;
@@ -1837,6 +1846,7 @@
                 case CMD_START_DRIVER:
                 case CMD_STOP_DRIVER:
                 case CMD_DELAYED_STOP_DRIVER:
+                case CMD_DRIVER_START_TIMED_OUT:
                 case CMD_START_AP:
                 case CMD_START_AP_SUCCESS:
                 case CMD_START_AP_FAILURE:
@@ -2476,10 +2486,16 @@
     }
 
     class DriverStartingState extends State {
+        private int mTries;
         @Override
         public void enter() {
             if (DBG) log(getName() + "\n");
             EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
+
+            mTries = 1;
+            /* Send ourselves a delayed message to start driver a second time */
+            sendMessageDelayed(obtainMessage(CMD_DRIVER_START_TIMED_OUT,
+                        ++mDriverStartToken, 0), DRIVER_START_TIME_OUT_MSECS);
         }
         @Override
         public boolean processMessage(Message message) {
@@ -2495,6 +2511,24 @@
                         transitionTo(mDriverStartedState);
                     }
                     break;
+                case CMD_DRIVER_START_TIMED_OUT:
+                    if (message.arg1 == mDriverStartToken) {
+                        if (mTries >= 2) {
+                            loge("Failed to start driver after " + mTries);
+                            transitionTo(mDriverStoppedState);
+                        } else {
+                            loge("Driver start failed, retrying");
+                            mWakeLock.acquire();
+                            mWifiNative.startDriver();
+                            mWakeLock.release();
+
+                            ++mTries;
+                            /* Send ourselves a delayed message to start driver again */
+                            sendMessageDelayed(obtainMessage(CMD_DRIVER_START_TIMED_OUT,
+                                        ++mDriverStartToken, 0), DRIVER_START_TIME_OUT_MSECS);
+                        }
+                    }
+                    break;
                     /* Queue driver commands & connection events */
                 case CMD_START_DRIVER:
                 case CMD_STOP_DRIVER: