Merge "Don't need to link to libsqlite from media JNI library."
diff --git a/api/current.txt b/api/current.txt
index ab2ef54..7c05ed6 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7981,8 +7981,8 @@
     method public void drawPoint(float, float, android.graphics.Paint);
     method public void drawPoints(float[], int, int, android.graphics.Paint);
     method public void drawPoints(float[], android.graphics.Paint);
-    method public void drawPosText(char[], int, int, float[], android.graphics.Paint);
-    method public void drawPosText(java.lang.String, float[], android.graphics.Paint);
+    method public deprecated void drawPosText(char[], int, int, float[], android.graphics.Paint);
+    method public deprecated void drawPosText(java.lang.String, float[], android.graphics.Paint);
     method public void drawRGB(int, int, int);
     method public void drawRect(android.graphics.RectF, android.graphics.Paint);
     method public void drawRect(android.graphics.Rect, android.graphics.Paint);
@@ -8000,8 +8000,8 @@
     method public int getDensity();
     method public android.graphics.DrawFilter getDrawFilter();
     method public int getHeight();
-    method public void getMatrix(android.graphics.Matrix);
-    method public final android.graphics.Matrix getMatrix();
+    method public deprecated void getMatrix(android.graphics.Matrix);
+    method public final deprecated android.graphics.Matrix getMatrix();
     method public int getMaximumBitmapHeight();
     method public int getMaximumBitmapWidth();
     method public int getSaveCount();
@@ -8331,7 +8331,7 @@
     method public final boolean isDither();
     method public final boolean isFakeBoldText();
     method public final boolean isFilterBitmap();
-    method public final boolean isLinearText();
+    method public final deprecated boolean isLinearText();
     method public final boolean isStrikeThruText();
     method public final boolean isSubpixelText();
     method public final boolean isUnderlineText();
@@ -8351,7 +8351,7 @@
     method public void setFilterBitmap(boolean);
     method public void setFlags(int);
     method public void setHinting(int);
-    method public void setLinearText(boolean);
+    method public deprecated void setLinearText(boolean);
     method public android.graphics.MaskFilter setMaskFilter(android.graphics.MaskFilter);
     method public android.graphics.PathEffect setPathEffect(android.graphics.PathEffect);
     method public android.graphics.Rasterizer setRasterizer(android.graphics.Rasterizer);
diff --git a/core/java/android/inputmethodservice/ExtractEditText.java b/core/java/android/inputmethodservice/ExtractEditText.java
index 10c1195..23ae21b 100644
--- a/core/java/android/inputmethodservice/ExtractEditText.java
+++ b/core/java/android/inputmethodservice/ExtractEditText.java
@@ -100,6 +100,9 @@
     
     @Override public boolean onTextContextMenuItem(int id) {
         if (mIME != null && mIME.onExtractTextContextMenuItem(id)) {
+            // Mode was started on Extracted, needs to be stopped here.
+            // Cut and paste will change the text, which stops selection mode.
+            if (id == android.R.id.copy) stopSelectionActionMode();
             return true;
         }
         return super.onTextContextMenuItem(id);
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index 5a436c4..e06d661 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -908,12 +908,20 @@
 
     @Override
     public void drawPicture(Picture picture) {
+        if (picture.createdFromStream) {
+            return;
+        }
+
         picture.endRecording();
         // TODO: Implement rendering
     }
 
     @Override
     public void drawPicture(Picture picture, Rect dst) {
+        if (picture.createdFromStream) {
+            return;
+        }
+
         save();
         translate(dst.left, dst.top);
         if (picture.getWidth() > 0 && picture.getHeight() > 0) {
@@ -925,6 +933,10 @@
 
     @Override
     public void drawPicture(Picture picture, RectF dst) {
+        if (picture.createdFromStream) {
+            return;
+        }
+
         save();
         translate(dst.left, dst.top);
         if (picture.getWidth() > 0 && picture.getHeight() > 0) {
diff --git a/core/java/android/webkit/HTML5VideoFullScreen.java b/core/java/android/webkit/HTML5VideoFullScreen.java
index 21364c1a..bc0557e 100644
--- a/core/java/android/webkit/HTML5VideoFullScreen.java
+++ b/core/java/android/webkit/HTML5VideoFullScreen.java
@@ -198,6 +198,10 @@
         // Call into the native to ask for the state, if still in play mode,
         // this will trigger the video to play.
         mProxy.dispatchOnRestoreState();
+
+        if (getStartWhenPrepared()) {
+            mPlayer.start();
+        }
     }
 
     public boolean fullScreenExited() {
diff --git a/core/java/android/webkit/HTML5VideoView.java b/core/java/android/webkit/HTML5VideoView.java
index 1d8bda7..73166cb 100644
--- a/core/java/android/webkit/HTML5VideoView.java
+++ b/core/java/android/webkit/HTML5VideoView.java
@@ -194,6 +194,25 @@
         mPlayer.setOnInfoListener(proxy);
     }
 
+    public void prepareDataCommon(HTML5VideoViewProxy proxy) {
+        try {
+            mPlayer.setDataSource(proxy.getContext(), mUri, mHeaders);
+            mPlayer.prepareAsync();
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+        } catch (IllegalStateException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        mCurrentState = STATE_NOTPREPARED;
+    }
+
+    public void reprepareData(HTML5VideoViewProxy proxy) {
+        mPlayer.reset();
+        prepareDataCommon(proxy);
+    }
+
     // Normally called immediately after setVideoURI. But for full screen,
     // this should be after surface holder created
     public void prepareDataAndDisplayMode(HTML5VideoViewProxy proxy) {
@@ -204,19 +223,8 @@
         setOnPreparedListener(proxy);
         setOnErrorListener(proxy);
         setOnInfoListener(proxy);
-        // When there is exception, we could just bail out silently.
-        // No Video will be played though. Write the stack for debug
-        try {
-            mPlayer.setDataSource(mProxy.getContext(), mUri, mHeaders);
-            mPlayer.prepareAsync();
-        } catch (IllegalArgumentException e) {
-            e.printStackTrace();
-        } catch (IllegalStateException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        mCurrentState = STATE_NOTPREPARED;
+
+        prepareDataCommon(proxy);
     }
 
 
@@ -324,4 +332,14 @@
         return false;
     }
 
+    private boolean m_startWhenPrepared = false;
+
+    public void setStartWhenPrepared(boolean willPlay) {
+        m_startWhenPrepared  = willPlay;
+    }
+
+    public boolean getStartWhenPrepared() {
+        return m_startWhenPrepared;
+    }
+
 }
diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java
index 1c09bb9..d306c86 100644
--- a/core/java/android/webkit/HTML5VideoViewProxy.java
+++ b/core/java/android/webkit/HTML5VideoViewProxy.java
@@ -182,6 +182,21 @@
             if (mHTML5VideoView != null) {
                 currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
                 backFromFullScreenMode = mHTML5VideoView.fullScreenExited();
+
+                // When playing video back to back in full screen mode,
+                // javascript will switch the src and call play.
+                // In this case, we can just reuse the same full screen view,
+                // and play the video after prepared.
+                if (mHTML5VideoView.isFullScreenMode()
+                    && !backFromFullScreenMode
+                    && currentVideoLayerId != videoLayerId
+                    && mCurrentProxy != proxy) {
+                    mCurrentProxy = proxy;
+                    mHTML5VideoView.setStartWhenPrepared(true);
+                    mHTML5VideoView.setVideoURI(url, proxy);
+                    mHTML5VideoView.reprepareData(proxy);
+                    return;
+                }
             }
 
             if (backFromFullScreenMode
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 02144a8..e508e9a 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -357,7 +357,6 @@
     private float mLastDownPositionX, mLastDownPositionY;
     private Callback mCustomSelectionActionModeCallback;
 
-    private final int mSquaredTouchSlopDistance;
     // Set when this TextView gained focus with some text selected. Will start selection mode.
     private boolean mCreatedWithASelection = false;
 
@@ -443,15 +442,12 @@
         this(context, null);
     }
 
-    public TextView(Context context,
-                    AttributeSet attrs) {
+    public TextView(Context context, AttributeSet attrs) {
         this(context, attrs, com.android.internal.R.attr.textViewStyle);
     }
 
     @SuppressWarnings("deprecation")
-    public TextView(Context context,
-                    AttributeSet attrs,
-                    int defStyle) {
+    public TextView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
         mText = "";
 
@@ -1134,10 +1130,6 @@
         setLongClickable(longClickable);
 
         prepareCursorControllers();
-
-        final ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
-        final int touchSlop = viewConfiguration.getScaledTouchSlop();
-        mSquaredTouchSlopDistance = touchSlop * touchSlop;
     }
 
     private void setTypefaceByIndex(int typefaceIndex, int styleIndex) {
@@ -3202,8 +3194,7 @@
 
         int n = mFilters.length;
         for (int i = 0; i < n; i++) {
-            CharSequence out = mFilters[i].filter(text, 0, text.length(),
-                                                  EMPTY_SPANNED, 0, 0);
+            CharSequence out = mFilters[i].filter(text, 0, text.length(), EMPTY_SPANNED, 0, 0);
             if (out != null) {
                 text = out;
             }
@@ -5273,10 +5264,8 @@
                         state.handleUpEvent(event);
                     }
                     if (event.isTracking() && !event.isCanceled()) {
-                        if (isInSelectionMode) {
-                            stopSelectionActionMode();
-                            return true;
-                        }
+                        stopSelectionActionMode();
+                        return true;
                     }
                 }
             }
@@ -5621,11 +5610,13 @@
         return super.onKeyUp(keyCode, event);
     }
 
-    @Override public boolean onCheckIsTextEditor() {
+    @Override
+    public boolean onCheckIsTextEditor() {
         return mInputType != EditorInfo.TYPE_NULL;
     }
 
-    @Override public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
+    @Override
+    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
         if (onCheckIsTextEditor() && isEnabled()) {
             if (mInputMethodState == null) {
                 mInputMethodState = new InputMethodState();
@@ -9248,7 +9239,6 @@
         boolean vibrate = true;
 
         if (super.performLongClick()) {
-            mDiscardNextActionUp = true;
             handled = true;
         }
 
@@ -10184,7 +10174,10 @@
         return false;
     }
 
-    private void stopSelectionActionMode() {
+    /**
+     * @hide
+     */
+    protected void stopSelectionActionMode() {
         if (mSelectionActionMode != null) {
             // This will hide the mSelectionModifierCursorController
             mSelectionActionMode.finish();
@@ -10798,7 +10791,12 @@
                         final float deltaX = mDownPositionX - ev.getRawX();
                         final float deltaY = mDownPositionY - ev.getRawY();
                         final float distanceSquared = deltaX * deltaX + deltaY * deltaY;
-                        if (distanceSquared < mSquaredTouchSlopDistance) {
+
+                        final ViewConfiguration viewConfiguration = ViewConfiguration.get(
+                                TextView.this.getContext());
+                        final int touchSlop = viewConfiguration.getScaledTouchSlop();
+
+                        if (distanceSquared < touchSlop * touchSlop) {
                             if (mActionPopupWindow != null && mActionPopupWindow.isShowing()) {
                                 // Tapping on the handle dismisses the displayed action popup
                                 mActionPopupWindow.hide();
@@ -11012,7 +11010,8 @@
 
         // Double tap detection
         private long mPreviousTapUpTime = 0;
-        private float mPreviousTapPositionX, mPreviousTapPositionY;
+        private float mDownPositionX, mDownPositionY;
+        private boolean mGestureStayedInTapRegion;
 
         SelectionModifierCursorController() {
             resetTouchOffsets();
@@ -11075,20 +11074,28 @@
                     mMinTouchOffset = mMaxTouchOffset = getOffsetForPosition(x, y);
 
                     // Double tap detection
-                    long duration = SystemClock.uptimeMillis() - mPreviousTapUpTime;
-                    if (duration <= ViewConfiguration.getDoubleTapTimeout() &&
-                            isPositionOnText(x, y)) {
-                        final float deltaX = x - mPreviousTapPositionX;
-                        final float deltaY = y - mPreviousTapPositionY;
-                        final float distanceSquared = deltaX * deltaX + deltaY * deltaY;
-                        if (distanceSquared < mSquaredTouchSlopDistance) {
-                            startSelectionActionMode();
-                            mDiscardNextActionUp = true;
+                    if (mGestureStayedInTapRegion) {
+                        long duration = SystemClock.uptimeMillis() - mPreviousTapUpTime;
+                        if (duration <= ViewConfiguration.getDoubleTapTimeout()) {
+                            final float deltaX = x - mDownPositionX;
+                            final float deltaY = y - mDownPositionY;
+                            final float distanceSquared = deltaX * deltaX + deltaY * deltaY;
+
+                            ViewConfiguration viewConfiguration = ViewConfiguration.get(
+                                    TextView.this.getContext());
+                            int doubleTapSlop = viewConfiguration.getScaledDoubleTapSlop();
+                            boolean stayedInArea = distanceSquared < doubleTapSlop * doubleTapSlop;
+
+                            if (stayedInArea && isPositionOnText(x, y)) {
+                                startSelectionActionMode();
+                                mDiscardNextActionUp = true;
+                            }
                         }
                     }
 
-                    mPreviousTapPositionX = x;
-                    mPreviousTapPositionY = y;
+                    mDownPositionX = x;
+                    mDownPositionY = y;
+                    mGestureStayedInTapRegion = true;
                     break;
 
                 case MotionEvent.ACTION_POINTER_DOWN:
@@ -11101,6 +11108,22 @@
                     }
                     break;
 
+                case MotionEvent.ACTION_MOVE:
+                    if (mGestureStayedInTapRegion) {
+                        final float deltaX = event.getX() - mDownPositionX;
+                        final float deltaY = event.getY() - mDownPositionY;
+                        final float distanceSquared = deltaX * deltaX + deltaY * deltaY;
+
+                        final ViewConfiguration viewConfiguration = ViewConfiguration.get(
+                                TextView.this.getContext());
+                        int doubleTapTouchSlop = viewConfiguration.getScaledDoubleTapTouchSlop();
+
+                        if (distanceSquared > doubleTapTouchSlop * doubleTapTouchSlop) {
+                            mGestureStayedInTapRegion = false;
+                        }
+                    }
+                    break;
+
                 case MotionEvent.ACTION_UP:
                     mPreviousTapUpTime = SystemClock.uptimeMillis();
                     break;
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 8341e4c..5f61e16 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -28,7 +28,6 @@
 #include "android_runtime/AndroidRuntime.h"
 
 #include <media/AudioSystem.h>
-#include <media/AudioTrack.h>
 
 #include <system/audio.h>
 #include <system/audio_policy.h>
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 4aa49f4..26c9435 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -49,14 +49,6 @@
     jmethodID postNativeEventInJava; //... event post callback method
     int       PCM16;                 //...  format constants
     int       PCM8;                  //...  format constants
-    int       STREAM_VOICE_CALL;     //...  stream type constants
-    int       STREAM_SYSTEM;         //...  stream type constants
-    int       STREAM_RING;           //...  stream type constants
-    int       STREAM_MUSIC;          //...  stream type constants
-    int       STREAM_ALARM;          //...  stream type constants
-    int       STREAM_NOTIFICATION;   //...  stream type constants
-    int       STREAM_BLUETOOTH_SCO;  //...  stream type constants
-    int       STREAM_DTMF;           //...  stream type constants
     int       MODE_STREAM;           //...  memory mode
     int       MODE_STATIC;           //...  memory mode
     jfieldID  nativeTrackInJavaObj;  // stores in Java the native AudioTrack object
@@ -197,23 +189,18 @@
     
     // check the stream type
     audio_stream_type_t atStreamType;
-    if (streamType == javaAudioTrackFields.STREAM_VOICE_CALL) {
-        atStreamType = AUDIO_STREAM_VOICE_CALL;
-    } else if (streamType == javaAudioTrackFields.STREAM_SYSTEM) {
-        atStreamType = AUDIO_STREAM_SYSTEM;
-    } else if (streamType == javaAudioTrackFields.STREAM_RING) {
-        atStreamType = AUDIO_STREAM_RING;
-    } else if (streamType == javaAudioTrackFields.STREAM_MUSIC) {
-        atStreamType = AUDIO_STREAM_MUSIC;
-    } else if (streamType == javaAudioTrackFields.STREAM_ALARM) {
-        atStreamType = AUDIO_STREAM_ALARM;
-    } else if (streamType == javaAudioTrackFields.STREAM_NOTIFICATION) {
-        atStreamType = AUDIO_STREAM_NOTIFICATION;
-    } else if (streamType == javaAudioTrackFields.STREAM_BLUETOOTH_SCO) {
-        atStreamType = AUDIO_STREAM_BLUETOOTH_SCO;
-    } else if (streamType == javaAudioTrackFields.STREAM_DTMF) {
-        atStreamType = AUDIO_STREAM_DTMF;
-    } else {
+    switch (streamType) {
+    case AUDIO_STREAM_VOICE_CALL:
+    case AUDIO_STREAM_SYSTEM:
+    case AUDIO_STREAM_RING:
+    case AUDIO_STREAM_MUSIC:
+    case AUDIO_STREAM_ALARM:
+    case AUDIO_STREAM_NOTIFICATION:
+    case AUDIO_STREAM_BLUETOOTH_SCO:
+    case AUDIO_STREAM_DTMF:
+        atStreamType = (audio_stream_type_t) streamType;
+        break;
+    default:
         ALOGE("Error creating AudioTrack: unknown stream type.");
         return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
     }
@@ -227,7 +214,7 @@
 
     // for the moment 8bitPCM in MODE_STATIC is not supported natively in the AudioTrack C++ class
     // so we declare everything as 16bitPCM, the 8->16bit conversion for MODE_STATIC will be handled
-    // in android_media_AudioTrack_native_write()
+    // in android_media_AudioTrack_native_write_byte()
     if ((audioFormat == javaAudioTrackFields.PCM8) 
         && (memoryMode == javaAudioTrackFields.MODE_STATIC)) {
         ALOGV("android_media_AudioTrack_native_setup(): requesting MODE_STATIC for 8bit \
@@ -519,13 +506,13 @@
 }
 
 // ----------------------------------------------------------------------------
-static jint android_media_AudioTrack_native_write(JNIEnv *env,  jobject thiz,
+static jint android_media_AudioTrack_native_write_byte(JNIEnv *env,  jobject thiz,
                                                   jbyteArray javaAudioData,
                                                   jint offsetInBytes, jint sizeInBytes,
                                                   jint javaAudioFormat) {
     jbyte* cAudioData = NULL;
     AudioTrack *lpTrack = NULL;
-    //ALOGV("android_media_AudioTrack_native_write(offset=%d, sizeInBytes=%d) called",
+    //ALOGV("android_media_AudioTrack_native_write_byte(offset=%d, sizeInBytes=%d) called",
     //    offsetInBytes, sizeInBytes);
     
     // get the audio track to load with samples
@@ -567,7 +554,7 @@
                                                   jshortArray javaAudioData,
                                                   jint offsetInShorts, jint sizeInShorts,
                                                   jint javaAudioFormat) {
-    return (android_media_AudioTrack_native_write(env, thiz,
+    return (android_media_AudioTrack_native_write_byte(env, thiz,
                                                  (jbyteArray) javaAudioData,
                                                  offsetInShorts*2, sizeInShorts*2,
                                                  javaAudioFormat)
@@ -764,24 +751,20 @@
     // convert the stream type from Java to native value
     // FIXME: code duplication with android_media_AudioTrack_native_setup()
     audio_stream_type_t nativeStreamType;
-    if (javaStreamType == javaAudioTrackFields.STREAM_VOICE_CALL) {
-        nativeStreamType = AUDIO_STREAM_VOICE_CALL;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_SYSTEM) {
-        nativeStreamType = AUDIO_STREAM_SYSTEM;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_RING) {
-        nativeStreamType = AUDIO_STREAM_RING;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_MUSIC) {
-        nativeStreamType = AUDIO_STREAM_MUSIC;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_ALARM) {
-        nativeStreamType = AUDIO_STREAM_ALARM;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_NOTIFICATION) {
-        nativeStreamType = AUDIO_STREAM_NOTIFICATION;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_BLUETOOTH_SCO) {
-        nativeStreamType = AUDIO_STREAM_BLUETOOTH_SCO;
-    } else if (javaStreamType == javaAudioTrackFields.STREAM_DTMF) {
-        nativeStreamType = AUDIO_STREAM_DTMF;
-    } else {
+    switch (javaStreamType) {
+    case AUDIO_STREAM_VOICE_CALL:
+    case AUDIO_STREAM_SYSTEM:
+    case AUDIO_STREAM_RING:
+    case AUDIO_STREAM_MUSIC:
+    case AUDIO_STREAM_ALARM:
+    case AUDIO_STREAM_NOTIFICATION:
+    case AUDIO_STREAM_BLUETOOTH_SCO:
+    case AUDIO_STREAM_DTMF:
+        nativeStreamType = (audio_stream_type_t) javaStreamType;
+        break;
+    default:
         nativeStreamType = AUDIO_STREAM_DEFAULT;
+        break;
     }
 
     if (AudioSystem::getOutputSamplingRate(&afSamplingRate, nativeStreamType) != NO_ERROR) {
@@ -851,7 +834,7 @@
                                          (void *)android_media_AudioTrack_native_setup},
     {"native_finalize",      "()V",      (void *)android_media_AudioTrack_native_finalize},
     {"native_release",       "()V",      (void *)android_media_AudioTrack_native_release},
-    {"native_write_byte",    "([BIII)I", (void *)android_media_AudioTrack_native_write},
+    {"native_write_byte",    "([BIII)I", (void *)android_media_AudioTrack_native_write_byte},
     {"native_write_short",   "([SIII)I", (void *)android_media_AudioTrack_native_write_short},
     {"native_setVolume",     "(FF)V",    (void *)android_media_AudioTrack_set_volume},
     {"native_get_native_frame_count",
@@ -987,41 +970,6 @@
         return -1;
     }
  
-    // Get the stream types from the AudioManager class
-    jclass audioManagerClass = NULL;
-    audioManagerClass = env->FindClass(JAVA_AUDIOMANAGER_CLASS_NAME);
-    if (audioManagerClass == NULL) {
-       ALOGE("Can't find %s", JAVA_AUDIOMANAGER_CLASS_NAME);
-       return -1;
-    }
-    if ( !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_VOICE_CALL_NAME, &(javaAudioTrackFields.STREAM_VOICE_CALL))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_MUSIC_NAME, &(javaAudioTrackFields.STREAM_MUSIC))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_SYSTEM_NAME, &(javaAudioTrackFields.STREAM_SYSTEM))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_RING_NAME, &(javaAudioTrackFields.STREAM_RING))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_ALARM_NAME, &(javaAudioTrackFields.STREAM_ALARM))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_NOTIFICATION_NAME, &(javaAudioTrackFields.STREAM_NOTIFICATION))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_BLUETOOTH_SCO_NAME, &(javaAudioTrackFields.STREAM_BLUETOOTH_SCO))
-          || !android_media_getIntConstantFromClass(env, audioManagerClass,
-               JAVA_AUDIOMANAGER_CLASS_NAME,
-               JAVA_CONST_STREAM_DTMF_NAME, &(javaAudioTrackFields.STREAM_DTMF))) {
-       // error log performed in android_media_getIntConstantFromClass()
-       return -1;
-    }
-
     return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods));
 }
 
diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java
index 5cac42a..dcda67d 100644
--- a/graphics/java/android/graphics/Canvas.java
+++ b/graphics/java/android/graphics/Canvas.java
@@ -130,8 +130,7 @@
      */
     public Canvas(Bitmap bitmap) {
         if (!bitmap.isMutable()) {
-            throw new IllegalStateException(
-                            "Immutable bitmap passed to Canvas constructor");
+            throw new IllegalStateException("Immutable bitmap passed to Canvas constructor");
         }
         throwIfRecycled(bitmap);
         mNativeCanvas = initRaster(bitmap.ni());
@@ -361,8 +360,8 @@
     /**
      * Helper version of saveLayer() that takes 4 values rather than a RectF.
      */
-    public int saveLayer(float left, float top, float right, float bottom,
-                         Paint paint, int saveFlags) {
+    public int saveLayer(float left, float top, float right, float bottom, Paint paint,
+            int saveFlags) {
         return native_saveLayer(mNativeCanvas, left, top, right, bottom,
                                 paint != null ? paint.mNativePaint : 0,
                                 saveFlags);
@@ -392,8 +391,8 @@
     /**
      * Helper for saveLayerAlpha() that takes 4 values instead of a RectF.
      */
-    public int saveLayerAlpha(float left, float top, float right, float bottom,
-                              int alpha, int saveFlags) {
+    public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
+            int saveFlags) {
         return native_saveLayerAlpha(mNativeCanvas, left, top, right, bottom,
                                      alpha, saveFlags);
     }
@@ -496,9 +495,15 @@
     /**
      * Completely replace the current matrix with the specified matrix. If the
      * matrix parameter is null, then the current matrix is reset to identity.
+     * 
+     * <strong>Note:</strong> it is recommended to use {@link #concat(Matrix)},
+     * {@link #scale(float, float)}, {@link #translate(float, float)} and
+     * {@link #rotate(float)} instead of this method.
      *
      * @param matrix The matrix to replace the current matrix with. If it is
      *               null, set the current matrix to identity.
+     *               
+     * @see #concat(Matrix) 
      */
     public void setMatrix(Matrix matrix) {
         native_setMatrix(mNativeCanvas,
@@ -509,6 +514,7 @@
      * Return, in ctm, the current transformation matrix. This does not alter
      * the matrix in the canvas, but just returns a copy of it.
      */
+    @Deprecated
     public void getMatrix(Matrix ctm) {
         native_getCTM(mNativeCanvas, ctm.native_instance);
     }
@@ -517,8 +523,10 @@
      * Return a new matrix with a copy of the canvas' current transformation
      * matrix.
      */
+    @Deprecated
     public final Matrix getMatrix() {
         Matrix m = new Matrix();
+        //noinspection deprecation
         getMatrix(m);
         return m;
     }
@@ -531,9 +539,8 @@
      * @return true if the resulting clip is non-empty
      */
     public boolean clipRect(RectF rect, Region.Op op) {
-        return native_clipRect(mNativeCanvas,
-                               rect.left, rect.top, rect.right, rect.bottom,
-                               op.nativeInt);
+        return native_clipRect(mNativeCanvas, rect.left, rect.top, rect.right, rect.bottom,
+                op.nativeInt);
     }
 
     /**
@@ -545,9 +552,8 @@
      * @return true if the resulting clip is non-empty
      */
     public boolean clipRect(Rect rect, Region.Op op) {
-        return native_clipRect(mNativeCanvas,
-                               rect.left, rect.top, rect.right, rect.bottom,
-                               op.nativeInt);
+        return native_clipRect(mNativeCanvas, rect.left, rect.top, rect.right, rect.bottom,
+                op.nativeInt);
     }
 
     /**
@@ -583,10 +589,8 @@
      * @param op     How the clip is modified
      * @return       true if the resulting clip is non-empty
      */
-    public boolean clipRect(float left, float top, float right, float bottom,
-                            Region.Op op) {
-        return native_clipRect(mNativeCanvas, left, top, right, bottom,
-                               op.nativeInt);
+    public boolean clipRect(float left, float top, float right, float bottom, Region.Op op) {
+        return native_clipRect(mNativeCanvas, left, top, right, bottom, op.nativeInt);
     }
 
     /**
@@ -602,9 +606,8 @@
      *               clip
      * @return       true if the resulting clip is non-empty
      */
-    public native boolean clipRect(float left, float top,
-                                   float right, float bottom);
-    
+    public native boolean clipRect(float left, float top, float right, float bottom);
+
     /**
      * Intersect the current clip with the specified rectangle, which is
      * expressed in local coordinates.
@@ -618,9 +621,8 @@
      *               clip
      * @return       true if the resulting clip is non-empty
      */
-    public native boolean clipRect(int left, int top,
-                                   int right, int bottom);
-    
+    public native boolean clipRect(int left, int top, int right, int bottom);
+
     /**
         * Modify the current clip with the specified path.
      *
@@ -753,8 +755,7 @@
      * @return            true if the rect (transformed by the canvas' matrix)
      *                    does not intersect with the canvas' clip
      */
-    public boolean quickReject(float left, float top, float right, float bottom,
-                               EdgeType type) {
+    public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) {
         return native_quickReject(mNativeCanvas, left, top, right, bottom,
                                   type.nativeInt);
     }
@@ -854,8 +855,7 @@
      *                 "points" that are drawn is really (count >> 1).
      * @param paint    The paint used to draw the points
      */
-    public native void drawPoints(float[] pts, int offset, int count,
-                                  Paint paint);
+    public native void drawPoints(float[] pts, int offset, int count, Paint paint);
 
     /**
      * Helper for drawPoints() that assumes you want to draw the entire array
@@ -878,10 +878,8 @@
      * @param startY The y-coordinate of the start point of the line
      * @param paint  The paint used to draw the line
      */
-    public void drawLine(float startX, float startY, float stopX, float stopY,
-                         Paint paint) {
-        native_drawLine(mNativeCanvas, startX, startY, stopX, stopY,
-                        paint.mNativePaint);
+    public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
+        native_drawLine(mNativeCanvas, startX, startY, stopX, stopY, paint.mNativePaint);
     }
 
     /**
@@ -899,8 +897,7 @@
      *                 (count >> 2).
      * @param paint    The paint used to draw the points
      */
-    public native void drawLines(float[] pts, int offset, int count,
-                                 Paint paint);
+    public native void drawLines(float[] pts, int offset, int count, Paint paint);
 
     public void drawLines(float[] pts, Paint paint) {
         drawLines(pts, 0, pts.length, paint);
@@ -939,10 +936,8 @@
      * @param bottom The bottom side of the rectangle to be drawn
      * @param paint  The paint used to draw the rect
      */
-    public void drawRect(float left, float top, float right, float bottom,
-                         Paint paint) {
-        native_drawRect(mNativeCanvas, left, top, right, bottom,
-                        paint.mNativePaint);
+    public void drawRect(float left, float top, float right, float bottom, Paint paint) {
+        native_drawRect(mNativeCanvas, left, top, right, bottom, paint.mNativePaint);
     }
 
     /**
@@ -969,8 +964,7 @@
      * @param paint  The paint used to draw the circle
      */
     public void drawCircle(float cx, float cy, float radius, Paint paint) {
-        native_drawCircle(mNativeCanvas, cx, cy, radius,
-                          paint.mNativePaint);
+        native_drawCircle(mNativeCanvas, cx, cy, radius, paint.mNativePaint);
     }
 
     /**
@@ -996,8 +990,8 @@
                         close it if it is being stroked. This will draw a wedge
      * @param paint      The paint used to draw the arc
      */
-    public void drawArc(RectF oval, float startAngle, float sweepAngle,
-                        boolean useCenter, Paint paint) {
+    public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
+            Paint paint) {
         if (oval == null) {
             throw new NullPointerException();
         }
@@ -1035,8 +1029,7 @@
     
     private static void throwIfRecycled(Bitmap bitmap) {
         if (bitmap.isRecycled()) {
-            throw new RuntimeException(
-                        "Canvas: trying to use a recycled bitmap " + bitmap);
+            throw new RuntimeException("Canvas: trying to use a recycled bitmap " + bitmap);
         }
     }
 
@@ -1077,8 +1070,7 @@
     public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
         throwIfRecycled(bitmap);
         native_drawBitmap(mNativeCanvas, bitmap.ni(), left, top,
-                paint != null ? paint.mNativePaint : 0, mDensity, mScreenDensity,
-                bitmap.mDensity);
+                paint != null ? paint.mNativePaint : 0, mDensity, mScreenDensity, bitmap.mDensity);
     }
 
     /**
@@ -1109,8 +1101,7 @@
         }
         throwIfRecycled(bitmap);
         native_drawBitmap(mNativeCanvas, bitmap.ni(), src, dst,
-                          paint != null ? paint.mNativePaint : 0,
-                          mScreenDensity, bitmap.mDensity);
+                          paint != null ? paint.mNativePaint : 0, mScreenDensity, bitmap.mDensity);
     }
 
     /**
@@ -1141,8 +1132,7 @@
         }
         throwIfRecycled(bitmap);
         native_drawBitmap(mNativeCanvas, bitmap.ni(), src, dst,
-                          paint != null ? paint.mNativePaint : 0,
-                          mScreenDensity, bitmap.mDensity);
+                          paint != null ? paint.mNativePaint : 0, mScreenDensity, bitmap.mDensity);
     }
     
     /**
@@ -1164,9 +1154,8 @@
      *                 be 0xFF for every pixel).
      * @param paint  May be null. The paint used to draw the bitmap
      */
-    public void drawBitmap(int[] colors, int offset, int stride, float x,
-                           float y, int width, int height, boolean hasAlpha,
-                           Paint paint) {
+    public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
+            int width, int height, boolean hasAlpha, Paint paint) {
         // check for valid input
         if (width < 0) {
             throw new IllegalArgumentException("width must be >= 0");
@@ -1195,8 +1184,7 @@
     /** Legacy version of drawBitmap(int[] colors, ...) that took ints for x,y
      */
     public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
-                           int width, int height, boolean hasAlpha,
-                           Paint paint) {
+            int width, int height, boolean hasAlpha, Paint paint) {
         // call through to the common float version
         drawBitmap(colors, offset, stride, (float)x, (float)y, width, height,
                    hasAlpha, paint);
@@ -1250,8 +1238,7 @@
      * @param paint  May be null. The paint used to draw the bitmap
      */
     public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight,
-                               float[] verts, int vertOffset,
-                               int[] colors, int colorOffset, Paint paint) {
+            float[] verts, int vertOffset, int[] colors, int colorOffset, Paint paint) {
         if ((meshWidth | meshHeight | vertOffset | colorOffset) < 0) {
             throw new ArrayIndexOutOfBoundsException();
         }
@@ -1269,7 +1256,7 @@
                              verts, vertOffset, colors, colorOffset,
                              paint != null ? paint.mNativePaint : 0);
     }
-        
+
     public enum VertexMode {
         TRIANGLES(0),
         TRIANGLE_STRIP(1),
@@ -1315,12 +1302,9 @@
      * @param indexCount number of entries in the indices array (if not null).
      * @param paint Specifies the shader to use if the texs array is non-null. 
      */
-    public void drawVertices(VertexMode mode, int vertexCount,
-                             float[] verts, int vertOffset,
-                             float[] texs, int texOffset,
-                             int[] colors, int colorOffset,
-                             short[] indices, int indexOffset,
-                             int indexCount, Paint paint) {
+    public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
+            float[] texs, int texOffset, int[] colors, int colorOffset,
+            short[] indices, int indexOffset, int indexCount, Paint paint) {
         checkRange(verts.length, vertOffset, vertexCount);
         if (texs != null) {
             checkRange(texs.length, texOffset, vertexCount);
@@ -1345,8 +1329,7 @@
      * @param y     The y-coordinate of the origin of the text being drawn
      * @param paint The paint used for the text (e.g. color, size, style)
      */
-    public void drawText(char[] text, int index, int count, float x, float y,
-                         Paint paint) {
+    public void drawText(char[] text, int index, int count, float x, float y, Paint paint) {
         if ((index | count | (index + count) |
             (text.length - index - count)) < 0) {
             throw new IndexOutOfBoundsException();
@@ -1380,8 +1363,7 @@
      * @param y     The y-coordinate of the origin of the text being drawn
      * @param paint The paint used for the text (e.g. color, size, style)
      */
-    public void drawText(String text, int start, int end, float x, float y,
-                         Paint paint) {
+    public void drawText(String text, int start, int end, float x, float y, Paint paint) {
         if ((start | end | (end - start) | (text.length() - end)) < 0) {
             throw new IndexOutOfBoundsException();
         }
@@ -1402,8 +1384,7 @@
      * @param y        The y-coordinate of origin for where to draw the text
      * @param paint The paint used for the text (e.g. color, size, style)
      */
-    public void drawText(CharSequence text, int start, int end, float x,
-                         float y, Paint paint) {
+    public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
         if (text instanceof String || text instanceof SpannedString ||
             text instanceof SpannableString) {
             native_drawText(mNativeCanvas, text.toString(), start, end, x, y,
@@ -1441,9 +1422,8 @@
      * @param paint the paint
      * @hide
      */
-    public void drawTextRun(char[] text, int index, int count,
-            int contextIndex, int contextCount, float x, float y, int dir,
-            Paint paint) {
+    public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
+            float x, float y, int dir, Paint paint) {
 
         if (text == null) {
             throw new NullPointerException("text is null");
@@ -1479,9 +1459,8 @@
      * @param paint the paint
      * @hide
      */
-    public void drawTextRun(CharSequence text, int start, int end,
-            int contextStart, int contextEnd, float x, float y, int dir,
-            Paint paint) {
+    public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
+            float x, float y, int dir, Paint paint) {
 
         if (text == null) {
             throw new NullPointerException("text is null");
@@ -1527,8 +1506,8 @@
      *                 character
      * @param paint    The paint used for the text (e.g. color, size, style)
      */
-    public void drawPosText(char[] text, int index, int count, float[] pos,
-                            Paint paint) {
+    @Deprecated
+    public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) {
         if (index < 0 || index + count > text.length || count*2 > pos.length) {
             throw new IndexOutOfBoundsException();
         }
@@ -1547,6 +1526,7 @@
      * @param pos   Array of [x,y] positions, used to position each character
      * @param paint The paint used for the text (e.g. color, size, style)
      */
+    @Deprecated
     public void drawPosText(String text, float[] pos, Paint paint) {
         if (text.length()*2 > pos.length) {
             throw new ArrayIndexOutOfBoundsException();
@@ -1568,7 +1548,7 @@
      * @param paint    The paint used for the text (e.g. color, size, style)
      */
     public void drawTextOnPath(char[] text, int index, int count, Path path,
-                               float hOffset, float vOffset, Paint paint) {
+            float hOffset, float vOffset, Paint paint) {
         if (index < 0 || index + count > text.length) {
             throw new ArrayIndexOutOfBoundsException();
         }
@@ -1590,12 +1570,10 @@
      *                 the text
      * @param paint    The paint used for the text (e.g. color, size, style)
      */
-    public void drawTextOnPath(String text, Path path, float hOffset,
-                               float vOffset, Paint paint) {
+    public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
         if (text.length() > 0) {
-            native_drawTextOnPath(mNativeCanvas, text, path.ni(),
-                                  hOffset, vOffset, paint.mBidiFlags,
-                                  paint.mNativePaint);
+            native_drawTextOnPath(mNativeCanvas, text, path.ni(), hOffset, vOffset,
+                    paint.mBidiFlags, paint.mNativePaint);
         }
     }
 
@@ -1618,8 +1596,7 @@
         save();
         translate(dst.left, dst.top);
         if (picture.getWidth() > 0 && picture.getHeight() > 0) {
-            scale(dst.width() / picture.getWidth(),
-                  dst.height() / picture.getHeight());
+            scale(dst.width() / picture.getWidth(), dst.height() / picture.getHeight());
         }
         drawPicture(picture);
         restore();
@@ -1632,8 +1609,8 @@
         save();
         translate(dst.left, dst.top);
         if (picture.getWidth() > 0 && picture.getHeight() > 0) {
-            scale((float)dst.width() / picture.getWidth(),
-                  (float)dst.height() / picture.getHeight());
+            scale((float) dst.width() / picture.getWidth(),
+                    (float) dst.height() / picture.getHeight());
         }
         drawPicture(picture);
         restore();
diff --git a/graphics/java/android/graphics/DrawFilter.java b/graphics/java/android/graphics/DrawFilter.java
index 6b44ed7..1f64539 100644
--- a/graphics/java/android/graphics/DrawFilter.java
+++ b/graphics/java/android/graphics/DrawFilter.java
@@ -28,7 +28,11 @@
     /* package */ int mNativeInt;    // pointer to native object
 
     protected void finalize() throws Throwable {
-        nativeDestructor(mNativeInt);
+        try {
+            nativeDestructor(mNativeInt);
+        } finally {
+            super.finalize();
+        }
     }
     
     private static native void nativeDestructor(int nativeDrawFilter);
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index ce42612..c97785e 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -528,6 +528,7 @@
      *
      * @return true if the lineartext bit is set in the paint's flags
      */
+    @Deprecated
     public final boolean isLinearText() {
         return (getFlags() & LINEAR_TEXT_FLAG) != 0;
     }
@@ -538,6 +539,7 @@
      * @param linearText true to set the linearText bit in the paint's flags,
      *                   false to clear it.
      */
+    @Deprecated
     public native void setLinearText(boolean linearText);
 
     /**
@@ -2142,8 +2144,6 @@
     private static native void native_setTextAlign(int native_object,
                                                    int align);
 
-    private static native float native_getFontMetrics(int native_paint,
-                                                      FontMetrics metrics);
     private static native int native_getTextWidths(int native_object,
                             char[] text, int index, int count, float[] widths);
     private static native int native_getTextWidths(int native_object,
diff --git a/graphics/java/android/graphics/Picture.java b/graphics/java/android/graphics/Picture.java
index 9c06fed..997141d 100644
--- a/graphics/java/android/graphics/Picture.java
+++ b/graphics/java/android/graphics/Picture.java
@@ -32,10 +32,15 @@
     private Canvas mRecordingCanvas;
     private final int mNativePicture;
 
+    /**
+     * @hide
+     */
+    public final boolean createdFromStream;
+
     private static final int WORKING_STREAM_STORAGE = 16 * 1024;
 
     public Picture() {
-        this(nativeConstructor(0));
+        this(nativeConstructor(0), false);
     }
 
     /**
@@ -44,7 +49,7 @@
      * changes will not be reflected in this picture.
      */
     public Picture(Picture src) {
-        this(nativeConstructor(src != null ? src.mNativePicture : 0));
+        this(nativeConstructor(src != null ? src.mNativePicture : 0), false);
     }
     
     /**
@@ -101,15 +106,24 @@
     /**
      * Create a new picture (already recorded) from the data in the stream. This
      * data was generated by a previous call to writeToStream().
+     * 
+     * <strong>Note:</strong> a picture created from an input stream cannot be
+     * replayed on a hardware accelerated canvas.
+     * 
+     * @see #writeToStream(java.io.OutputStream) 
      */
     public static Picture createFromStream(InputStream stream) {
-        return new Picture(
-            nativeCreateFromStream(stream, new byte[WORKING_STREAM_STORAGE]));
+        return new Picture(nativeCreateFromStream(stream, new byte[WORKING_STREAM_STORAGE]), true);
     }
 
     /**
      * Write the picture contents to a stream. The data can be used to recreate
      * the picture in this or another process by calling createFromStream.
+     *
+     * <strong>Note:</strong> a picture created from an input stream cannot be
+     * replayed on a hardware accelerated canvas.
+     * 
+     * @see #createFromStream(java.io.InputStream) 
      */
     public void writeToStream(OutputStream stream) {
         // do explicit check before calling the native method
@@ -129,16 +143,17 @@
             super.finalize();
         }
     }
-    
-    /*package*/ final int ni() {
+
+    final int ni() {
         return mNativePicture;
     }
     
-    private Picture(int nativePicture) {
+    private Picture(int nativePicture, boolean fromStream) {
         if (nativePicture == 0) {
             throw new RuntimeException();
         }
         mNativePicture = nativePicture;
+        createdFromStream = fromStream;
     }
 
     // return empty picture if src is 0, or a copy of the native src
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 84a8f1c..44925f2 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -22,7 +22,6 @@
 
 #include <media/IAudioFlinger.h>
 #include <media/IAudioRecord.h>
-#include <media/AudioTrack.h>
 
 #include <utils/RefBase.h>
 #include <utils/Errors.h>
@@ -34,6 +33,8 @@
 
 namespace android {
 
+class audio_track_cblk_t;
+
 // ----------------------------------------------------------------------------
 
 class AudioRecord
diff --git a/libs/hwui/DisplayListRenderer.h b/libs/hwui/DisplayListRenderer.h
index dd7ec4f..422184e 100644
--- a/libs/hwui/DisplayListRenderer.h
+++ b/libs/hwui/DisplayListRenderer.h
@@ -422,7 +422,7 @@
             return;
         }
 
-        SkPaint* paintCopy =  mPaintMap.valueFor(paint);
+        SkPaint* paintCopy = mPaintMap.valueFor(paint);
         if (paintCopy == NULL || paintCopy->getGenerationID() != paint->getGenerationID()) {
             paintCopy = new SkPaint(*paint);
             mPaintMap.add(paint, paintCopy);
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index f532d35..7379d68 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -548,6 +548,7 @@
 
 status_t AudioSystem::setPhoneState(audio_mode_t state)
 {
+    if (uint32_t(state) >= AUDIO_MODE_CNT) return BAD_VALUE;
     const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
     if (aps == 0) return PERMISSION_DENIED;
 
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index acf97a6..f1c47dd 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -30,7 +30,7 @@
 #include <gui/SurfaceTextureClient.h>
 
 #include <media/mediaplayer.h>
-#include <media/AudioTrack.h>
+#include <media/AudioSystem.h>
 
 #include <surfaceflinger/Surface.h>
 
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 6b68b87..fa71d11 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -34,6 +34,7 @@
 
 namespace android {
 
+class AudioTrack;
 class IMediaRecorder;
 class IMediaMetadataRetriever;
 class IOMX;
diff --git a/media/libmediaplayerservice/MediaRecorderClient.cpp b/media/libmediaplayerservice/MediaRecorderClient.cpp
index d219fc2..beda945 100644
--- a/media/libmediaplayerservice/MediaRecorderClient.cpp
+++ b/media/libmediaplayerservice/MediaRecorderClient.cpp
@@ -33,8 +33,6 @@
 
 #include <utils/String16.h>
 
-#include <media/AudioTrack.h>
-
 #include <system/audio.h>
 
 #include "MediaRecorderClient.h"
diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h
index dfe4318..f6f8f7b 100644
--- a/media/libmediaplayerservice/MidiFile.h
+++ b/media/libmediaplayerservice/MidiFile.h
@@ -19,7 +19,6 @@
 #define ANDROID_MIDIFILE_H
 
 #include <media/MediaPlayerInterface.h>
-#include <media/AudioTrack.h>
 #include <libsonivox/eas.h>
 
 namespace android {
diff --git a/media/libstagefright/include/ThrottledSource.h b/media/libstagefright/include/ThrottledSource.h
index 8928a4a..7fe7c06 100644
--- a/media/libstagefright/include/ThrottledSource.h
+++ b/media/libstagefright/include/ThrottledSource.h
@@ -35,6 +35,11 @@
     virtual status_t getSize(off64_t *size);
     virtual uint32_t flags();
 
+    virtual String8 getMIMEType() const {
+        return mSource->getMIMEType();
+    }
+
+
 private:
     Mutex mLock;
 
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java
index 80a3bcd..7dfab7d 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java
@@ -82,7 +82,6 @@
     /**
      * To test thumbnail / frame extraction on H.263 QCIF.
      */
-    // TODO : TC_TN_001
     @LargeTest
     public void testThumbnailForH263QCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -104,7 +103,6 @@
     /**
      * To test thumbnail / frame extraction on MPEG4 VGA .
      */
-    // TODO : TC_TN_002
     @LargeTest
     public void testThumbnailForMPEG4VGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -124,7 +122,6 @@
     /**
      * To test thumbnail / frame extraction on MPEG4 NTSC.
      */
-    // TODO : TC_TN_003
     @LargeTest
     public void testThumbnailForMPEG4NTSC() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -144,7 +141,6 @@
     /**
      * To test thumbnail / frame extraction on MPEG4 WVGA.
      */
-    // TODO : TC_TN_004
     @LargeTest
     public void testThumbnailForMPEG4WVGA() throws Exception {
 
@@ -165,7 +161,6 @@
     /**
      * To test thumbnail / frame extraction on MPEG4 QCIF.
      */
-    // TODO : TC_TN_005
     @LargeTest
     public void testThumbnailForMPEG4QCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -186,7 +181,6 @@
     /**
      * To test thumbnail / frame extraction on H264 QCIF.
      */
-    // TODO : TC_TN_006
     @LargeTest
     public void testThumbnailForH264QCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -207,7 +201,6 @@
     /**
      * To test thumbnail / frame extraction on H264 VGA.
      */
-    // TODO : TC_TN_007
     @LargeTest
     public void testThumbnailForH264VGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -228,7 +221,6 @@
     /**
      * To test thumbnail / frame extraction on H264 WVGA.
      */
-    // TODO : TC_TN_008
     @LargeTest
     public void testThumbnailForH264WVGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -248,7 +240,6 @@
     /**
      * To test thumbnail / frame extraction on H264 854x480.
      */
-    // TODO : TC_TN_009
     @LargeTest
     public void testThumbnailForH264854_480() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -269,7 +260,6 @@
     /**
      * To test thumbnail / frame extraction on H264 960x720.
      */
-    // TODO : TC_TN_010
     @LargeTest
     public void testThumbnailForH264HD960() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -290,7 +280,6 @@
     /**
      * To test thumbnail / frame extraction on H264 1080x720 .
      */
-    // TODO : TC_TN_011
     @LargeTest
     public void testThumbnailForH264HD1080() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -310,7 +299,6 @@
     /**
      * Check the thumbnail / frame extraction precision at 0,100 and 200 ms
      */
-    // TODO : TC_TN_012
     @LargeTest
     public void testThumbnailForH264VGADifferentDuration() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -345,7 +333,6 @@
      *Check the thumbnail / frame extraction precision at
      * FileDuration,FileDuration/2 + 100 andFileDuration/2 + 200 ms
      */
-    // TODO : TC_TN_013
     @LargeTest
     public void testThumbnailForMP4VGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -379,7 +366,6 @@
     /**
      * Check the thumbnail / frame extraction on JPEG file
      */
-    // TODO : TC_TN_014
     @LargeTest
     public void testThumbnailForImage() throws Exception {
         final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -402,7 +388,6 @@
     /**
      *To test ThumbnailList for H263 QCIF
      */
-    // TODO : TC_TN_015
     @LargeTest
     public void testThumbnailListH263QCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -432,7 +417,6 @@
     /**
      *To test ThumbnailList for MPEG4 QCIF
      */
-    // TODO : TC_TN_016
     @LargeTest
     public void testThumbnailListMPEG4QCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -463,7 +447,6 @@
     /**
      *To test ThumbnailList for H264 VGA
      */
-    // TODO : TC_TN_017
     @LargeTest
     public void testThumbnailListH264VGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -492,7 +475,6 @@
     /**
      *To test ThumbnailList for H264 WVGA
      */
-    // TODO : TC_TN_018
     @LargeTest
     public void testThumbnailListH264WVGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -521,7 +503,6 @@
     /**
      *To test ThumbnailList for H264 VGA ,Time exceeding file duration
      */
-    // TODO : TC_TN_019
     @LargeTest
     public void testThumbnailH264VGAExceedingFileDuration() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -547,7 +528,6 @@
     /**
      *To test ThumbnailList for VGA Image
      */
-    // TODO : TC_TN_020
     @LargeTest
     public void testThumbnailListVGAImage() throws Exception {
         final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -576,7 +556,6 @@
     /**
      *To test ThumbnailList for Invalid file path
      */
-    // TODO : TC_TN_021
     @LargeTest
     public void testThumbnailForInvalidFilePath() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "/sdcard/abc.jpg";
@@ -596,7 +575,6 @@
     /**
      * To test thumbnail / frame extraction with setBoundaries
      */
-    // TODO : TC_TN_022
     @LargeTest
     public void testThumbnailForMPEG4WVGAWithSetBoundaries() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -620,7 +598,6 @@
     /**
      *To test ThumbnailList for H264 WVGA with setExtractboundaries
      */
-    // TODO : TC_TN_023
     @LargeTest
     public void testThumbnailListForH264WVGAWithSetBoundaries() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -652,7 +629,6 @@
     /**
      *To test ThumbnailList for H264 WVGA with count > frame available
      */
-    // TODO : TC_TN_024
     @LargeTest
     public void testThumbnailListForH264WVGAWithCount() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -684,7 +660,6 @@
     /**
      *To test ThumbnailList for H264 WVGA with startTime > End Time
      */
-    // TODO : TC_TN_025
     @LargeTest
     public void testThumbnailListH264WVGAWithStartGreaterEnd() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -710,9 +685,8 @@
     }
 
     /**
-     *To test ThumbnailList TC_TN_026 for H264 WVGA with startTime = End Time
+     *To test ThumbnailList for H264 WVGA with startTime = End Time
      */
-    // TODO : TC_TN_026
     @LargeTest
     public void testThumbnailListH264WVGAWithStartEqualEnd() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -738,10 +712,9 @@
     }
 
     /**
-     *To test ThumbnailList TC_TN_027 for file where video duration is less
+     *To test ThumbnailList for file where video duration is less
      * than file duration.
      */
-    // TODO : TC_TN_027
     @LargeTest
     public void testThumbnailForVideoDurationLessFileDuration() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -760,9 +733,8 @@
     }
 
     /**
-     *To test ThumbnailList TC_TN_028 for file which has video part corrupted
+     *To test ThumbnailList for file which has video part corrupted
      */
-    // TODO : TC_TN_028
     @LargeTest
     public void testThumbnailWithCorruptedVideoPart() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -787,7 +759,6 @@
     /**
      * Check the thumbnail / frame list extraction for Height as Negative Value
      */
-    // TODO : TC_TN_029
     @LargeTest
     public void testThumbnailWithNegativeHeight() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -815,7 +786,6 @@
     /**
      * Check the thumbnail for Height as Zero
      */
-    // TODO : TC_TN_030
     @LargeTest
     public void testThumbnailWithHeightAsZero() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -839,7 +809,6 @@
     /**
      * Check the thumbnail for Height = 10
      */
-    // TODO : TC_TN_031
     @LargeTest
     public void testThumbnailWithHeight() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -859,7 +828,6 @@
     /**
      * Check the thumbnail / frame list extraction for Width as Negative Value
      */
-    // TODO : TC_TN_032
     @LargeTest
     public void testThumbnailWithNegativeWidth() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -887,7 +855,6 @@
     /**
      * Check the thumbnail / frame list extraction for Width zero
      */
-    // TODO : TC_TN_033
     @LargeTest
     public void testThumbnailWithWidthAsZero() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -911,7 +878,6 @@
     /**
      * Check the thumbnail for Width = 10
      */
-    // TODO : TC_TN_034
     @LargeTest
     public void testThumbnailWithWidth() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -931,7 +897,6 @@
     /**
      * To test thumbnail / frame extraction on MPEG4 (time beyond file duration).
      */
-    // TODO : TC_TN_035
     @LargeTest
     public void testThumbnailMPEG4withMorethanFileDuration() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java
index e2f6863..34cf9f0 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java
@@ -130,7 +130,6 @@
     /**
      *To test Media Properties for file MPEG4 854 x 480
      */
-    // TODO : Remove TC_MP_001
     @LargeTest
     public void testPropertiesMPEG4854_480() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -163,7 +162,6 @@
     /**
      *To test Media Properties for file MPEG4 WVGA
      */
-    // TODO : Remove TC_MP_002
     @LargeTest
     public void testPropertiesMPEGWVGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -195,7 +193,6 @@
     /**
      *To test media properties for MPEG4 720x480 (NTSC) + AAC file.
      */
-    // TODO : Remove TC_MP_003
     @LargeTest
     public void testPropertiesMPEGNTSC() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -227,7 +224,6 @@
     /**
      *To test Media Properties for file MPEG4 VGA
      */
-    // TODO : Remove TC_MP_004
     @LargeTest
     public void testPropertiesMPEGVGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -259,7 +255,6 @@
     /**
      *To test Media Properties for file MPEG4 QCIF
      */
-    // TODO : Remove TC_MP_005
     @LargeTest
     public void testPropertiesMPEGQCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -291,7 +286,6 @@
     /**
      *To To test media properties for H263 176x144 (QCIF) + AAC (mono) file.
      */
-    // TODO : Remove TC_MP_006
     @LargeTest
     public void testPropertiesH263QCIF() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -322,7 +316,6 @@
     /**
      *To test Media Properties for file H264 VGA
      */
-    // TODO : Remove TC_MP_007
     @LargeTest
     public void testPropertiesH264VGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -353,7 +346,6 @@
     /**
      *To test Media Properties for file H264 NTSC
      */
-    // TODO : Remove TC_MP_008
     @LargeTest
     public void testPropertiesH264NTSC() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -385,7 +377,6 @@
     /**
      *To test media properties for H264 800x480 (WVGA) + AAC file.
      */
-    // TODO : Remove TC_MP_009
     @LargeTest
     public void testPropertiesH264WVGA() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -417,7 +408,6 @@
     /**
      *To test Media Properties for file H264 HD1280
      */
-    // TODO : Remove TC_MP_010
     @LargeTest
     public void testPropertiesH264HD1280() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -449,7 +439,6 @@
     /**
      *To test media properties for H264 1080x720 + AAC file
      */
-    // TODO : Remove TC_MP_011
     @LargeTest
     public void testPropertiesH264HD1080WithAudio() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -481,7 +470,6 @@
     /**
      *To test Media Properties for file WMV - Unsupported type
      */
-    // TODO : Remove TC_MP_012
     @LargeTest
     public void testPropertiesWMVFile() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -506,7 +494,6 @@
     /**
      *To test media properties for H.264 Main/Advanced profile.
      */
-    // TODO : Remove TC_MP_013
     @LargeTest
     public void testPropertiesH264MainLineProfile() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH
@@ -539,7 +526,6 @@
     /**
      *To test Media Properties for non existing file.
      */
-    // TODO : Remove TC_MP_014
     @LargeTest
     public void testPropertiesForNonExsitingFile() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH + "abc.3gp";
@@ -559,7 +545,6 @@
     /**
      *To test Media Properties for file H264 HD1080
      */
-    // TODO : Remove TC_MP_015
     @LargeTest
     public void testPropertiesH264HD1080WithoutAudio() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -591,7 +576,6 @@
     /**
      *To test Media Properties for Image file of JPEG Type
      */
-    // TODO : Remove TC_MP_016
     @LargeTest
     public void testPropertiesVGAImage() throws Exception {
         final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -611,7 +595,6 @@
     /**
      *To test Media Properties for Image file of PNG Type
      */
-    // TODO : Remove TC_MP_017
     @LargeTest
     public void testPropertiesPNG() throws Exception {
         final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png";
@@ -630,7 +613,6 @@
     /**
      *To test Media Properties for file GIF - Unsupported type
      */
-    // TODO : Remove TC_MP_018
     @LargeTest
     public void testPropertiesGIFFile() throws Exception {
 
@@ -651,7 +633,6 @@
     /**
      *To test Media Properties for file Text file named as 3GP
      */
-    // TODO : Remove TC_MP_019
     @LargeTest
     public void testPropertiesofDirtyFile() throws Exception {
 
@@ -672,7 +653,6 @@
     /**
      *To test Media Properties for file name as NULL
      */
-    // TODO : Remove TC_MP_020
     @LargeTest
     public void testPropertieNULLFile() throws Exception {
         final String videoItemFilename = null;
@@ -691,7 +671,6 @@
     /**
      *To test Media Properties for file which is of type MPEG2
      */
-    // TODO : Remove TC_MP_021
     @LargeTest
     public void testPropertiesMPEG2File() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -709,9 +688,8 @@
     }
 
     /**
-     *To test Media Properties TC_MP_023 for file without Video only Audio
+     *To test Media Properties for file without Video only Audio
      */
-    // TODO : Remove TC_MP_023
     @LargeTest
     public void testProperties3GPWithoutVideoMediaItem() throws Exception {
         final String audioFilename = INPUT_FILE_PATH +
@@ -731,7 +709,6 @@
     /**
      *To test media properties for Audio Track file. (No Video, AAC Audio)
      */
-    // TODO : Remove TC_MP_024
     @LargeTest
     public void testProperties3GPWithoutVideoAudioTrack() throws Exception {
 
@@ -753,7 +730,6 @@
         /**
      *To test media properties for Audio Track file. MP3 file
      */
-    // TODO : Remove TC_MP_025
     @LargeTest
     public void testPropertiesMP3AudioTrack() throws Exception {
 
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorAPITest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorAPITest.java
index b32d865..6e520c3 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorAPITest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorAPITest.java
@@ -88,7 +88,6 @@
     /**
      * To Test Creation of Media Video Item.
      */
-    // TODO : remove TC_API_001
     @LargeTest
     public void testMediaVideoItem() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -130,7 +129,6 @@
      * To test creation of Media Video Item with Set Extract Boundaries With Get
      * the Begin and End Time.
      */
-    // TODO : remove TC_API_002
     @LargeTest
     public void testMediaVideoItemExtractBoundaries() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -199,7 +197,6 @@
     /**
      * To test creation of Media Video Item with Set and Get rendering Mode
      */
-    // TODO : remove TC_API_003
     @LargeTest
     public void testMediaVideoItemRenderingModes() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -238,12 +235,10 @@
             mediaVideoItem1.getRenderingMode());
     }
 
-    /** Test Case  TC_API_004 is removed */
 
     /**
      * To Test the Media Video API : Set Audio Volume, Get Audio Volume and Mute
      */
-    // TODO : remove TC_API_005
     @LargeTest
     public void testMediaVideoItemAudioFeatures() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -301,7 +296,6 @@
      * extractAudioWaveFormData
      */
 
-    // TODO : remove TC_API_006
     @LargeTest
     public void testMediaVideoItemGetWaveformData() throws Exception {
 
@@ -343,7 +337,6 @@
      * To Test the Media Video API : Get Effect, GetAllEffects, remove Effect
      */
 
-    // TODO : remove TC_API_007
     @LargeTest
     public void testMediaVideoItemEffect() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -384,7 +377,6 @@
      * To Test the Media Video API : Get Before and after transition
      */
 
-    // TODO : remove TC_API_008
     @LargeTest
     public void testMediaVideoItemTransitions() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -431,7 +423,6 @@
      *
      */
 
-    // TODO : remove TC_API_009
     @LargeTest
     public void testMediaVideoItemOverlays() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -474,7 +465,6 @@
     /**
      * To Test Creation of Media Image Item.
      */
-    // TODO : remove TC_API_010
     @LargeTest
     public void testMediaImageItem() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
@@ -511,7 +501,6 @@
     /**
      * To Test the Media Image API : Get and Set rendering Mode
      */
-    // TODO : remove TC_API_011
     @LargeTest
     public void testMediaImageItemRenderingModes() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
@@ -554,7 +543,6 @@
     /**
      * To Test the Media Image API : GetHeight and GetWidth
      */
-    // TODO : remove TC_API_012
     @LargeTest
     public void testMediaImageItemHeightWidth() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -576,7 +564,6 @@
     /**
      * To Test the Media Image API : Scaled Height and Scaled GetWidth
      */
-    // TODO : remove TC_API_013
     @LargeTest
     public void testMediaImageItemScaledHeightWidth() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
@@ -597,7 +584,6 @@
      * To Test the Media Image API : Get Effect, GetAllEffects, remove Effect
      */
 
-    // TODO : remove TC_API_014
     @LargeTest
     public void testMediaImageItemEffect() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
@@ -637,7 +623,6 @@
      * To Test the Media Image API : Get Before and after transition
      */
 
-    // TODO : remove TC_API_015
     @LargeTest
     public void testMediaImageItemTransitions() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
@@ -685,7 +670,6 @@
      * Overlay
      */
 
-    // TODO : remove TC_API_016
     @LargeTest
     public void testMediaImageItemOverlays() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -729,7 +713,6 @@
      * To test creation of Audio Track
      */
 
-    // TODO : remove TC_API_017
     @LargeTest
     public void testAudioTrack() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -756,7 +739,6 @@
     /**
      * To test creation of Audio Track with set extract boundaries
      */
-    // TODO : remove TC_API_018
     @LargeTest
     public void testAudioTrackExtractBoundaries() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -824,7 +806,6 @@
     /**
      * To test creation of Audio Track with set Start Time and Get Time
      */
-    // TODO : remove TC_API_019
     @LargeTest
     public void testAudioTrackSetGetTime() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -840,7 +821,6 @@
     /**
      * To Test the Audio Track API: Enable Ducking
      */
-    // TODO : remove TC_API_020
     @LargeTest
     public void testAudioTrackEnableDucking() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -910,7 +890,6 @@
     /**
      * To Test the Audio Track API: Looping
      */
-    // TODO : remove TC_API_021
     @LargeTest
     public void testAudioTrackLooping() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -928,7 +907,6 @@
     /**
      * To Test the Audio Track API:Extract waveform data
      */
-    // TODO : remove TC_API_022
 
     @LargeTest
     public void testAudioTrackWaveFormData() throws Exception {
@@ -984,7 +962,6 @@
     /**
      * To Test the Audio Track API: Mute
      */
-    // TODO : remove TC_API_023
     @LargeTest
     public void testAudioTrackMute() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -1001,7 +978,6 @@
     /**
      * To Test the Audio Track API: Get Volume and Set Volume
      */
-    // TODO : remove TC_API_024
     @LargeTest
     public void testAudioTrackGetSetVolume() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -1042,7 +1018,6 @@
     /**
      * To test Effect Color.
      */
-    // TODO : remove TC_API_025
     @LargeTest
     public void testAllEffects() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -1206,7 +1181,6 @@
     /**
      * To test Effect Color : Set duration and Get Duration
      */
-    // TODO : remove TC_API_026
     @LargeTest
     public void testEffectSetgetDuration() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -1246,7 +1220,6 @@
     /**
      * To test Effect Color : UNDEFINED color param value
      */
-    // TODO : remove TC_API_027
     @LargeTest
     public void testEffectUndefinedColorParam() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -1269,7 +1242,6 @@
     /**
      * To test Effect Color : with Invalid StartTime and Duration
      */
-    // TODO : remove TC_API_028
     @LargeTest
     public void testEffectInvalidStartTimeAndDuration() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -1315,7 +1287,6 @@
     /**
      * To test Effect : with NULL Media Item
      */
-    // TODO : remove TC_API_034
     @LargeTest
     public void testEffectNullMediaItem() throws Exception {
         boolean flagForException = false;
@@ -1331,7 +1302,6 @@
     /**
      * To test Effect : KenBurn Effect
      */
-    // TODO : remove TC_API_035
     @LargeTest
     public void testEffectKenBurn() throws Exception {
         // Test ken burn effect using a JPEG file.
@@ -1375,7 +1345,6 @@
      * To test KenBurnEffect : Set StartRect and EndRect
      */
 
-    // TODO : remove TC_API_036
     @LargeTest
     public void testEffectKenBurnSet() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -1443,7 +1412,6 @@
      * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
      */
 
-    // TODO : remove TC_API_037
     @LargeTest
     public void testTransitionFadeBlack() throws Exception {
 
@@ -1591,7 +1559,6 @@
      * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
      */
 
-    // TODO : remove TC_API_038
     @LargeTest
     public void testTransitionCrossFade() throws Exception {
 
@@ -1742,7 +1709,6 @@
      * ,DIRECTION_BOTTOM_OUT_TOP_IN
      */
 
-    // TODO : remove TC_API_039
     @LargeTest
     public void testTransitionSliding() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH +
@@ -1932,7 +1898,6 @@
      * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST
      */
 
-    // TODO : remove TC_API_040
     @LargeTest
     public void testTransitionAlpha() throws Exception {
 
@@ -2111,7 +2076,6 @@
      * To test Frame Overlay for Media Video Item
      */
 
-    // TODO : remove TC_API_041
     @LargeTest
     public void testFrameOverlayVideoItem() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH +
@@ -2147,7 +2111,6 @@
      * Duration
      */
 
-    // TODO : remove TC_API_042
     @LargeTest
     public void testFrameOverlaySetAndGet() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH +
@@ -2193,7 +2156,6 @@
      * Duration
      */
 
-    // TODO : remove TC_API_043
     @LargeTest
     public void testFrameOverlayInvalidTime() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH +
@@ -2242,7 +2204,6 @@
     /**
      * To test Frame Overlay for Media Image Item
      */
-    // TODO : remove TC_API_045
     @LargeTest
     public void testFrameOverlayImageItem() throws Exception {
         final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -2278,7 +2239,6 @@
      * Duration
      */
 
-    // TODO : remove TC_API_046
     @LargeTest
     public void testFrameOverlaySetAndGetImage() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -2321,7 +2281,6 @@
      * Duration
      */
 
-    // TODO : remove TC_API_047
     @LargeTest
     public void testFrameOverlayInvalidTimeImage() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -2370,7 +2329,6 @@
      * To Test Frame Overlay Media Image Item :JPG File
      */
 
-    // TODO : remove TC_API_048
     @LargeTest
     public void testFrameOverlayJPGImage() throws Exception {
 
@@ -2392,7 +2350,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_049
     @LargeTest
     public void testVideoEditorAPI() throws Exception {
 
@@ -2555,7 +2512,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_050
     @LargeTest
     public void testVideoLessThanAudio() throws Exception {
         final String videoItemFileName1 = INPUT_FILE_PATH
@@ -2583,7 +2539,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_051
     @LargeTest
     public void testVideoContentHD() throws Exception {
         final String videoItemFileName1 = INPUT_FILE_PATH
@@ -2609,7 +2564,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_052
     @LargeTest
     public void testRemoveAudioTrack() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -2638,7 +2592,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_053
     @LargeTest
     public void testAudioDuckingDisable() throws Exception {
         final String audioFileName = INPUT_FILE_PATH +
@@ -2653,8 +2606,6 @@
     }
 
 
-    // TODO : remove TC_API_054
-    /** This test case is added with Test case ID TC_API_010 */
 
       /**
      * To test: Need a basic test case for the get value for TransitionAlpha
@@ -2662,7 +2613,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_055
     @LargeTest
     public void testTransitionAlphaBasic() throws Exception {
 
@@ -2700,7 +2650,6 @@
      *
      * @throws Exception
      */
-    // TODO : remove TC_API_056
     @LargeTest
     public void testNullAPIs() throws Exception {
 
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java
index 57a1c75..69ecf0d 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java
@@ -91,7 +91,6 @@
     /**
      * To Test export : Merge and Trim different types of Video and Image files
      */
-    // TODO :remove TC_EXP_001
     @LargeTest
     public void testExportMergeTrim() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH
@@ -173,7 +172,6 @@
     /**
      *To Test export : With Effect and Overlays on Different Media Items
      */
-    // TODO :remove TC_EXP_002
     @LargeTest
     public void testExportEffectOverlay() throws Exception {
           final String videoItemFilename1 = INPUT_FILE_PATH
@@ -301,7 +299,6 @@
     /**
      * To test export : with Image with KenBurnEffect
      */
-    // TODO : remove TC_EXP_003
     @LargeTest
     public void testExportEffectKenBurn() throws Exception {
         final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
@@ -359,7 +356,6 @@
     /**
      * To Test Export : With Video and Image and An Audio BackGround Track
      */
-    // TODO : remove TC_EXP_004
     @LargeTest
     public void testExportAudio() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -420,7 +416,6 @@
     /**
      *To Test export : With Transition on Different Media Items
      */
-    // TODO :remove TC_EXP_005
     @LargeTest
     public void testExportTransition() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH
@@ -540,7 +535,6 @@
      *
      * @throws Exception
      */
-    // TODO :remove TC_EXP_006
     @LargeTest
     public void testExportWithoutMediaItems() throws Exception {
         boolean flagForException = false;
@@ -566,7 +560,6 @@
      *
      * @throws Exception
      */
-    // TODO :remove TC_EXP_007
     @LargeTest
     public void testExportWithoutMediaItemsAddRemove() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH +
@@ -621,7 +614,6 @@
      *
      * @throws Exception
      */
-    // TODO :remove TC_EXP_008
     @LargeTest
     public void testExportMMS() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java
index 4181903..7965b0a 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java
@@ -216,7 +216,6 @@
     /**
      *To test Preview : FULL Preview of current work (beginning till end)
      */
-    // TODO : remove TC_PRV_001
     @LargeTest
     public void testPreviewTheStoryBoard() throws Exception {
         final String videoItemFileName1 = INPUT_FILE_PATH
@@ -275,7 +274,6 @@
     /**
      * To test Preview : Preview of start + 10 sec till end of story board
      */
-    // TODO : remove TC_PRV_002
     @LargeTest
     public void testPreviewTheStoryBoardFromDuration() throws Exception {
         final String videoItemFileName1 = INPUT_FILE_PATH
@@ -336,7 +334,6 @@
     /**
      * To test Preview : Preview of current Effects applied
      */
-    // TODO : remove TC_PRV_003
     @LargeTest
     public void testPreviewOfEffects() throws Exception {
         final String videoItemFileName1 = INPUT_FILE_PATH +
@@ -394,7 +391,6 @@
      *To test Preview : Preview of current Transitions applied (with multiple
      * generatePreview)
      */
-    // TODO : remove TC_PRV_004
     @LargeTest
     public void testPreviewWithTransition() throws Exception {
 
@@ -547,7 +543,6 @@
     /**
      * To test Preview : Preview of current Overlay applied
      */
-    // TODO : remove TC_PRV_005
     @LargeTest
     public void testPreviewWithOverlay() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH
@@ -601,7 +596,6 @@
      * To test Preview : Preview of current Trim applied (with default aspect
      * ratio)
      */
-    // TODO : remove TC_PRV_006
     @LargeTest
     public void testPreviewWithTrim() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -625,7 +619,6 @@
      * applied
      */
 
-    // TODO : remove TC_PRV_007
     @LargeTest
     public void testPreviewWithOverlayEffectKenBurn() throws Exception {
 
@@ -684,7 +677,6 @@
     /**
      *To test Preview : Export during preview
      */
-    // TODO : remove TC_PRV_008
     @LargeTest
     public void testPreviewDuringExport() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -765,7 +757,6 @@
      * To test Preview : Preview of current Effects applied (with from time >
      * total duration)
      */
-    // TODO : remove TC_PRV_009
     @LargeTest
     public void testPreviewWithDurationGreaterThanMediaDuration()
         throws Exception {
@@ -826,7 +817,6 @@
      * To test Preview : Preview of current Effects applied (with Render Preview
      * Frame)
      */
-    // TODO : remove TC_PRV_010
     @LargeTest
     public void testPreviewWithRenderPreviewFrame() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
@@ -873,7 +863,6 @@
      * To test Preview : Preview of current work from selected jump location
      * till end with Audio Track
      */
-    // TODO : remove TC_PRV_011
     @LargeTest
     public void testPreviewWithEndAudioTrack() throws Exception {
         final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
@@ -917,7 +906,6 @@
     /**
      * To test render Preview Frame
      */
-    // TODO : remove TC_PRV_012
     @LargeTest
     public void testRenderPreviewFrame() throws Exception {
         final String videoItemFileName1 = INPUT_FILE_PATH
@@ -1031,7 +1019,6 @@
     /**
      * To Test Preview : Without any Media Items in the story Board
      */
-    // TODO : remove TC_PRV_013
     @LargeTest
     public void testStartPreviewWithoutMediaItems() throws Exception {
         boolean flagForException = false;
@@ -1064,7 +1051,6 @@
      * To Test Preview : Add Media and Remove Media Item (Without any Media
      * Items in the story Board)
      */
-    // TODO : remove TC_PRV_014
     @LargeTest
     public void testStartPreviewAddRemoveMediaItems() throws Exception {
         final String videoItemFilename1 = INPUT_FILE_PATH
@@ -1134,7 +1120,6 @@
      * To test Preview : Preview of current Effects applied (with Render Preview
      * Frame)
      */
-    // TODO : remove TC_PRV_015
     @LargeTest
     public void testPreviewWithRenderPreviewFrameWithoutGenerate() throws Exception {
         final String videoItemFileName = INPUT_FILE_PATH +
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
index 3d0be4f..6f1959c 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
@@ -931,7 +931,6 @@
     /**
      *To test ThumbnailList for H264
      */
-    // TODO : TC_PRF_12
     @LargeTest
     public void testThumbnailH264NonIFrame() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
@@ -962,7 +961,6 @@
     /**
      *To test ThumbnailList for H264
      */
-    // TODO : TC_PRF_13
     @LargeTest
     public void testThumbnailH264AnIFrame() throws Exception {
         final String videoItemFilename = INPUT_FILE_PATH +
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index fb2a072..e2e5214 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -331,7 +331,7 @@
 
 status_t AudioFlinger::dump(int fd, const Vector<String16>& args)
 {
-    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
+    if (!checkCallingPermission(String16("android.permission.DUMP"))) {
         dumpPermissionDenial(fd, args);
     } else {
         // get state of hardware lock
@@ -1849,7 +1849,7 @@
 
 AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
     :   PlaybackThread(audioFlinger, output, id, device),
-        mAudioMixer(NULL)
+        mAudioMixer(NULL), mPrevMixerStatus(MIXER_IDLE)
 {
     mType = ThreadBase::MIXER;
     mAudioMixer = new AudioMixer(mFrameCount, mSampleRate);
@@ -1962,7 +1962,8 @@
                     ALOGV("MixerThread %p TID %d waking up\n", this, gettid());
                     acquireWakeLock_l();
 
-                    if (mMasterMute == false) {
+                    mPrevMixerStatus = MIXER_IDLE;
+                    if (!mMasterMute) {
                         char value[PROPERTY_VALUE_MAX];
                         property_get("ro.audio.silent", value, "0");
                         if (atoi(value)) {
@@ -2121,11 +2122,11 @@
         // make sure that we have enough frames to mix one full buffer.
         // enforce this condition only once to enable draining the buffer in case the client
         // app does not call stop() and relies on underrun to stop:
-        // hence the test on (track->mRetryCount >= kMaxTrackRetries) meaning the track was mixed
+        // hence the test on (mPrevMixerStatus == MIXER_TRACKS_READY) meaning the track was mixed
         // during last round
         uint32_t minFrames = 1;
         if (!track->isStopped() && !track->isPausing() &&
-                (track->mRetryCount >= kMaxTrackRetries)) {
+                (mPrevMixerStatus == MIXER_TRACKS_READY)) {
             if (t->sampleRate() == (int)mSampleRate) {
                 minFrames = mFrameCount;
             } else {
@@ -2274,7 +2275,13 @@
 
             // reset retry count
             track->mRetryCount = kMaxTrackRetries;
-            mixerStatus = MIXER_TRACKS_READY;
+            // If one track is ready, set the mixer ready if:
+            //  - the mixer was not ready during previous round OR
+            //  - no other track is not ready
+            if (mPrevMixerStatus != MIXER_TRACKS_READY ||
+                    mixerStatus != MIXER_TRACKS_ENABLED) {
+                mixerStatus = MIXER_TRACKS_READY;
+            }
         } else {
             //ALOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", name, cblk->user, cblk->server, this);
             if (track->isStopped()) {
@@ -2292,7 +2299,11 @@
                     tracksToRemove->add(track);
                     // indicate to client process that the track was disabled because of underrun
                     android_atomic_or(CBLK_DISABLED_ON, &cblk->flags);
-                } else if (mixerStatus != MIXER_TRACKS_READY) {
+                // If one track is not ready, mark the mixer also not ready if:
+                //  - the mixer was ready during previous round OR
+                //  - no other track is ready
+                } else if (mPrevMixerStatus == MIXER_TRACKS_READY ||
+                                mixerStatus != MIXER_TRACKS_READY) {
                     mixerStatus = MIXER_TRACKS_ENABLED;
                 }
             }
@@ -2326,6 +2337,7 @@
         memset(mMixBuffer, 0, mFrameCount * mChannelCount * sizeof(int16_t));
     }
 
+    mPrevMixerStatus = mixerStatus;
     return mixerStatus;
 }
 
@@ -2659,7 +2671,7 @@
                     ALOGV("DirectOutputThread %p TID %d waking up in active mode\n", this, gettid());
                     acquireWakeLock_l();
 
-                    if (mMasterMute == false) {
+                    if (!mMasterMute) {
                         char value[PROPERTY_VALUE_MAX];
                         property_get("ro.audio.silent", value, "0");
                         if (atoi(value)) {
@@ -3054,7 +3066,8 @@
                     ALOGV("DuplicatingThread %p TID %d waking up\n", this, gettid());
                     acquireWakeLock_l();
 
-                    if (mMasterMute == false) {
+                    mPrevMixerStatus = MIXER_IDLE;
+                    if (!mMasterMute) {
                         char value[PROPERTY_VALUE_MAX];
                         property_get("ro.audio.silent", value, "0");
                         if (atoi(value)) {
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 275f40e..8a82bdb 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -830,7 +830,9 @@
         virtual     uint32_t    idleSleepTimeUs();
         virtual     uint32_t    suspendSleepTimeUs();
 
-        AudioMixer*                     mAudioMixer;
+                    AudioMixer* mAudioMixer;
+                    uint32_t    mPrevMixerStatus; // previous status (mixer_state) returned by
+                                                  // prepareTracks_l()
     };
 
     class DirectOutputThread : public PlaybackThread {
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index fcf014f..ba9f8b0 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -43,11 +43,11 @@
 
 namespace android {
 
-static const char *kDeadlockedString = "AudioPolicyService may be deadlocked\n";
-static const char *kCmdDeadlockedString = "AudioPolicyService command thread may be deadlocked\n";
+static const char kDeadlockedString[] = "AudioPolicyService may be deadlocked\n";
+static const char kCmdDeadlockedString[] = "AudioPolicyService command thread may be deadlocked\n";
 
 static const int kDumpLockRetries = 50;
-static const int kDumpLockSleep = 20000;
+static const int kDumpLockSleepUs = 20000;
 
 static bool checkPermission() {
     if (getpid() == IPCThreadState::self()->getCallingPid()) return true;
@@ -563,7 +563,7 @@
             locked = true;
             break;
         }
-        usleep(kDumpLockSleep);
+        usleep(kDumpLockSleepUs);
     }
     return locked;
 }
@@ -587,7 +587,7 @@
 
 status_t AudioPolicyService::dump(int fd, const Vector<String16>& args)
 {
-    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
+    if (!checkCallingPermission(String16("android.permission.DUMP"))) {
         dumpPermissionDenial(fd);
     } else {
         bool locked = tryLock(mLock);
@@ -1069,7 +1069,7 @@
 // Audio pre-processing configuration
 // ----------------------------------------------------------------------------
 
-const char *AudioPolicyService::kInputSourceNames[AUDIO_SOURCE_CNT -1] = {
+/*static*/ const char * const AudioPolicyService::kInputSourceNames[AUDIO_SOURCE_CNT -1] = {
     MIC_SRC_TAG,
     VOICE_UL_SRC_TAG,
     VOICE_DL_SRC_TAG,
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index 0715790..cb8c33f 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -254,7 +254,7 @@
         Vector< sp<AudioEffect> >mEffects;
     };
 
-    static const char *kInputSourceNames[AUDIO_SOURCE_CNT -1];
+    static const char * const kInputSourceNames[AUDIO_SOURCE_CNT -1];
 
     void setPreProcessorEnabled(InputDesc *inputDesc, bool enabled);
     status_t loadPreProcessorConfig(const char *path);
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp
index 68bbb570..1f8cf63 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -156,8 +156,6 @@
         mPendingEventCount(0), mPendingEventIndex(0), mPendingINotify(false) {
     acquire_wake_lock(PARTIAL_WAKE_LOCK, WAKE_LOCK_ID);
 
-    mNumCpus = sysconf(_SC_NPROCESSORS_ONLN);
-
     mEpollFd = epoll_create(EPOLL_SIZE_HINT);
     LOG_ALWAYS_FATAL_IF(mEpollFd < 0, "Could not create epoll instance.  errno=%d", errno);
 
@@ -648,8 +646,9 @@
                         sizeof(struct input_event) * capacity);
                 if (readSize == 0 || (readSize < 0 && errno == ENODEV)) {
                     // Device was removed before INotify noticed.
-                    ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d capacity: %d errno: %d)\n",
-                         device->fd, readSize, bufferSize, capacity, errno);
+                    ALOGW("could not get event, removed? (fd: %d size: %d bufferSize: %d "
+                            "capacity: %d errno: %d)\n",
+                            device->fd, readSize, bufferSize, capacity, errno);
                     deviceChanged = true;
                     closeDeviceLocked(device);
                 } else if (readSize < 0) {
@@ -774,19 +773,6 @@
         } else {
             // Some events occurred.
             mPendingEventCount = size_t(pollResult);
-
-            // On an SMP system, it is possible for the framework to read input events
-            // faster than the kernel input device driver can produce a complete packet.
-            // Because poll() wakes up as soon as the first input event becomes available,
-            // the framework will often end up reading one event at a time until the
-            // packet is complete.  Instead of one call to read() returning 71 events,
-            // it could take 71 calls to read() each returning 1 event.
-            //
-            // Sleep for a short period of time after waking up from the poll() to give
-            // the kernel time to finish writing the entire packet of input events.
-            if (mNumCpus > 1) {
-                usleep(250);
-            }
         }
     }
 
diff --git a/services/input/EventHub.h b/services/input/EventHub.h
index 9d8252e..8a2afd3 100644
--- a/services/input/EventHub.h
+++ b/services/input/EventHub.h
@@ -367,9 +367,6 @@
     size_t mPendingEventCount;
     size_t mPendingEventIndex;
     bool mPendingINotify;
-
-    // Set to the number of CPUs.
-    int32_t mNumCpus;
 };
 
 }; // namespace android
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 6f97ff0..112c606 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -38,6 +38,15 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+
+        <activity
+                android:name="MatrixActivity"
+                android:label="_Matrix">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
         
         <activity
                 android:name="TextFadeActivity"
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/MatrixActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/MatrixActivity.java
new file mode 100644
index 0000000..1906b9d
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/MatrixActivity.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2010 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.test.hwui;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class MatrixActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        setContentView(new MatrixView(this));
+    }
+
+    static class MatrixView extends View {
+        MatrixView(Context c) {
+            super(c);
+        }
+
+        @Override
+        protected void onDraw(Canvas canvas) {
+            super.onDraw(canvas);
+            canvas.drawRGB(255, 255, 255);
+
+            Log.d("Matrix", "m1=" + canvas.getMatrix());
+
+            canvas.save();
+            canvas.translate(10.0f, 10.0f);
+            Log.d("Matrix", "m2=" + canvas.getMatrix());
+            canvas.translate(20.0f, 20.0f);
+            Log.d("Matrix", "m3=" + canvas.getMatrix());
+            canvas.restore();
+        }
+    }
+}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index 8e3ed93..f797836 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -717,7 +717,7 @@
     /*package*/ static void native_drawCircle(int nativeCanvas,
             float cx, float cy, float radius, int paint) {
         native_drawOval(nativeCanvas,
-                new RectF(cx - radius, cy - radius, radius, radius),
+                new RectF(cx - radius, cy - radius, cx + radius, cy + radius),
                 paint);
     }
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
index 1523823..9ebec61 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint_Delegate.java
@@ -904,17 +904,6 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static float native_getFontMetrics(int native_paint, FontMetrics metrics) {
-        // get the delegate from the native int.
-        Paint_Delegate delegate = sManager.getDelegate(native_paint);
-        if (delegate == null) {
-            return 0.f;
-        }
-
-        return delegate.getFontMetrics(metrics);
-    }
-
-    @LayoutlibDelegate
     /*package*/ static int native_getTextWidths(int native_object, char[] text, int index,
             int count, float[] widths) {
         // get the delegate from the native int.