Merge "Heterogeneous comment for convertView in getView documentation"
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index dde198e..e07dbb8 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -735,14 +735,24 @@
 
         final Pair<Long, Long> previousSettings =
                 mSyncStorageEngine.getBackoff(op.account, op.authority);
-        long newDelayInMs;
-        if (previousSettings == null || previousSettings.second <= 0) {
+        long newDelayInMs = -1;
+        if (previousSettings != null) {
+            // don't increase backoff before current backoff is expired. This will happen for op's
+            // with ignoreBackoff set.
+            if (now < previousSettings.first) {
+                if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                    Log.v(TAG, "Still in backoff, do not increase it. "
+                        + "Remaining: " + ((previousSettings.first - now) / 1000) + " seconds.");
+                }
+                return;
+            }
+            // Subsequent delays are the double of the previous delay
+            newDelayInMs = previousSettings.second * 2;
+        }
+        if (newDelayInMs <= 0) {
             // The initial delay is the jitterized INITIAL_SYNC_RETRY_TIME_IN_MS
             newDelayInMs = jitterize(INITIAL_SYNC_RETRY_TIME_IN_MS,
                     (long)(INITIAL_SYNC_RETRY_TIME_IN_MS * 1.1));
-        } else {
-            // Subsequent delays are the double of the previous delay
-            newDelayInMs = previousSettings.second * 2;
         }
 
         // Cap the delay
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index d21870c..7fc7e54 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -8465,13 +8465,6 @@
         public static final int CENTER = 1;
         public static final int RIGHT = 2;
 
-        class LongPressCallback implements Runnable {
-            public void run() {
-                mController.hide();
-                startSelectionActionMode();
-            }
-        }
-
         public HandleView(CursorController controller, int pos) {
             super(TextView.this.mContext);
             mController = controller;
diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java
index 0211a4a..507f41f 100644
--- a/graphics/java/android/renderscript/RSSurfaceView.java
+++ b/graphics/java/android/renderscript/RSSurfaceView.java
@@ -119,7 +119,7 @@
     }
 
     public RenderScriptGL createRenderScriptGL(RenderScriptGL.SurfaceConfig sc) {
-        RenderScriptGL rs = new RenderScriptGL(sc);
+      RenderScriptGL rs = new RenderScriptGL(this.getContext(), sc);
         setRenderScriptGL(rs);
         return rs;
     }
@@ -137,4 +137,3 @@
         return mRS;
     }
 }
-
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index c6dcff5..5f93f5b 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -18,6 +18,7 @@
 
 import java.lang.reflect.Field;
 
+import android.content.Context;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.util.Config;
@@ -42,9 +43,9 @@
     @SuppressWarnings({"UnusedDeclaration", "deprecation"})
     static final boolean LOG_ENABLED = DEBUG ? Config.LOGD : Config.LOGV;
 
+    private Context mApplicationContext;
 
-
-     /*
+    /*
      * We use a class initializer to allow the native code to cache some
      * field offsets.
      */
@@ -416,9 +417,9 @@
     synchronized void nScriptCSetScript(byte[] script, int offset, int length) {
         rsnScriptCSetScript(mContext, script, offset, length);
     }
-    native int  rsnScriptCCreate(int con, String val);
-    synchronized int nScriptCCreate(String val) {
-        return rsnScriptCCreate(mContext, val);
+    native int  rsnScriptCCreate(int con, String val, String cacheDir);
+    synchronized int nScriptCCreate(String resName, String cacheDir) {
+      return rsnScriptCCreate(mContext, resName, cacheDir);
     }
 
     native void rsnSamplerBegin(int con);
@@ -776,17 +777,27 @@
         }
     }
 
-    RenderScript() {
+    RenderScript(Context ctx) {
+        mApplicationContext = ctx.getApplicationContext();
+    }
+
+    /**
+     * Gets the application context associated with the RenderScript context.
+     *
+     * @return The application context.
+     */
+    public final Context getApplicationContext() {
+        return mApplicationContext;
     }
 
     /**
      * Create a basic RenderScript context.
      *
-     *
+     * @param ctx The context.
      * @return RenderScript
      */
-    public static RenderScript create() {
-        RenderScript rs = new RenderScript();
+    public static RenderScript create(Context ctx) {
+        RenderScript rs = new RenderScript(ctx);
 
         rs.mDev = rs.nDeviceCreate();
         rs.mContext = rs.nContextCreate(rs.mDev, 0);
diff --git a/graphics/java/android/renderscript/RenderScriptGL.java b/graphics/java/android/renderscript/RenderScriptGL.java
index 0886db4..5adb682 100644
--- a/graphics/java/android/renderscript/RenderScriptGL.java
+++ b/graphics/java/android/renderscript/RenderScriptGL.java
@@ -18,6 +18,7 @@
 
 import java.lang.reflect.Field;
 
+import android.content.Context;
 import android.graphics.PixelFormat;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
@@ -168,10 +169,11 @@
     /**
      * Construct a new RenderScriptGL context.
      *
-     *
+     * @param ctx The context.
      * @param sc The desired format of the primart rendering surface.
      */
-    public RenderScriptGL(SurfaceConfig sc) {
+    public RenderScriptGL(Context ctx, SurfaceConfig sc) {
+        super(ctx);
         mSurfaceConfig = new SurfaceConfig(sc);
 
         mSurface = null;
@@ -304,5 +306,3 @@
     }
 
 }
-
-
diff --git a/graphics/java/android/renderscript/ScriptC.java b/graphics/java/android/renderscript/ScriptC.java
index 64ed75b..b10247c 100644
--- a/graphics/java/android/renderscript/ScriptC.java
+++ b/graphics/java/android/renderscript/ScriptC.java
@@ -16,9 +16,11 @@
 
 package android.renderscript;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.util.Log;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Map.Entry;
@@ -76,6 +78,7 @@
         rs.nScriptCBegin();
         rs.nScriptCSetScript(pgm, 0, pgmLength);
         Log.v(TAG, "Create script for resource = " + resources.getResourceName(resourceID));
-        return rs.nScriptCCreate(resources.getResourceName(resourceID));
+        String cacheDir = rs.getApplicationContext().getCacheDir().toString();
+        return rs.nScriptCCreate(resources.getResourceName(resourceID), cacheDir);
     }
 }
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 04a7b41..a8343b3 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -902,11 +902,15 @@
 }
 
 static jint
-nScriptCCreate(JNIEnv *_env, jobject _this, RsContext con, jstring resName)
+nScriptCCreate(JNIEnv *_env, jobject _this, RsContext con, jstring resName, jstring cacheDir)
 {
     LOG_API("nScriptCCreate, con(%p)", con);
     const char* resNameUTF = _env->GetStringUTFChars(resName, NULL);
-    return (jint)rsScriptCCreate(con, resNameUTF);
+    const char* cacheDirUTF = _env->GetStringUTFChars(cacheDir, NULL);
+    jint i = (jint)rsScriptCCreate(con, resNameUTF, cacheDirUTF);
+    _env->ReleaseStringUTFChars(resName, resNameUTF);
+    _env->ReleaseStringUTFChars(cacheDir, cacheDirUTF);
+    return i;
 }
 
 // ---------------------------------------------------------------------------
@@ -1297,7 +1301,7 @@
 
 {"rsnScriptCBegin",                  "(I)V",                                  (void*)nScriptCBegin },
 {"rsnScriptCSetScript",              "(I[BII)V",                              (void*)nScriptCSetScript },
-{"rsnScriptCCreate",                 "(ILjava/lang/String;)I",                (void*)nScriptCCreate },
+{"rsnScriptCCreate",                 "(ILjava/lang/String;Ljava/lang/String;)I",  (void*)nScriptCCreate },
 
 {"rsnProgramStoreBegin",             "(III)V",                                (void*)nProgramStoreBegin },
 {"rsnProgramStoreDepthFunc",         "(II)V",                                 (void*)nProgramStoreDepthFunc },
@@ -1372,4 +1376,3 @@
 bail:
     return result;
 }
-
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index a8fe646..46fdc31 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -925,11 +925,17 @@
 }
 
 void OpenGLRenderer::setupDrawColorUniforms() {
-    if (mColorSet && mSetShaderColor) {
+    if (mColorSet || (mShader && mSetShaderColor)) {
         mCaches.currentProgram->setColor(mColorR, mColorG, mColorB, mColorA);
     }
 }
 
+void OpenGLRenderer::setupDrawColorAlphaUniforms() {
+    if (mSetShaderColor) {
+        mCaches.currentProgram->setColor(mColorA, mColorA, mColorA, mColorA);
+    }
+}
+
 void OpenGLRenderer::setupDrawShaderUniforms(bool ignoreTransform) {
     if (mShader) {
         if (ignoreTransform) {
@@ -1721,7 +1727,7 @@
     } else {
         setupDrawModelViewTranslate(left, top, right, bottom, ignoreTransform);
     }
-    setupDrawColorUniforms();
+    setupDrawColorAlphaUniforms();
     setupDrawColorFilterUniforms();
     setupDrawTexture(texture);
     setupDrawMesh(vertices, texCoords, vbo);
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 82b27b0..5d8653d 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -443,6 +443,7 @@
     void setupDrawModelViewTranslate(float left, float top, float right, float bottom,
             bool ignoreTransform = false);
     void setupDrawColorUniforms();
+    void setupDrawColorAlphaUniforms();
     void setupDrawShaderUniforms(bool ignoreTransform = false);
     void setupDrawColorFilterUniforms();
     void setupDrawSimpleMesh();
diff --git a/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index 09654ab..5de09f7 100644
--- a/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/libs/rs/java/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -362,7 +362,7 @@
     }
 
     private void createScript() {
-        mRS = RenderScript.create();
+        mRS = RenderScript.create(this);
         mRS.setMessageHandler(new FilterCallback());
 
         mInPixelsAllocation = Allocation.createFromBitmap(mRS, mBitmapIn,
diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java
index c1f652f..265e1d6 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestCore.java
@@ -16,6 +16,7 @@
 
 package com.android.rs.test;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.renderscript.*;
 import android.util.Log;
@@ -28,8 +29,10 @@
 public class RSTestCore {
     int mWidth;
     int mHeight;
+    Context mCtx;
 
-    public RSTestCore() {
+    public RSTestCore(Context ctx) {
+        mCtx = ctx;
     }
 
     private Resources mRes;
@@ -61,10 +64,10 @@
 
         unitTests = new ArrayList<UnitTest>();
 
-        unitTests.add(new UT_primitives(this, mRes));
-        unitTests.add(new UT_rsdebug(this, mRes));
-        unitTests.add(new UT_rstypes(this, mRes));
-        unitTests.add(new UT_fp_mad(this, mRes));
+        unitTests.add(new UT_primitives(this, mRes, mCtx));
+        unitTests.add(new UT_rsdebug(this, mRes, mCtx));
+        unitTests.add(new UT_rstypes(this, mRes, mCtx));
+        unitTests.add(new UT_fp_mad(this, mRes, mCtx));
         /*
         unitTests.add(new UnitTest(null, "<Pass>", 1));
         unitTests.add(new UnitTest());
diff --git a/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java b/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java
index 2f7542d..368f286 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/RSTestView.java
@@ -41,8 +41,11 @@
 
 public class RSTestView extends RSSurfaceView {
 
+    private Context mCtx;
+
     public RSTestView(Context context) {
         super(context);
+        mCtx = context;
         //setFocusable(true);
     }
 
@@ -55,7 +58,7 @@
             RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
             mRS = createRenderScriptGL(sc);
             mRS.setSurface(holder, w, h);
-            mRender = new RSTestCore();
+            mRender = new RSTestCore(mCtx);
             mRender.init(mRS, getResources(), w, h);
         }
     }
@@ -92,5 +95,3 @@
         return ret;
     }
 }
-
-
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java b/libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java
index 409192b..f2c91af 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UT_fp_mad.java
@@ -16,19 +16,20 @@
 
 package com.android.rs.test;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.renderscript.*;
 
 public class UT_fp_mad extends UnitTest {
     private Resources mRes;
 
-    protected UT_fp_mad(RSTestCore rstc, Resources res) {
-        super(rstc, "Fp_Mad");
+    protected UT_fp_mad(RSTestCore rstc, Resources res, Context ctx) {
+        super(rstc, "Fp_Mad", ctx);
         mRes = res;
     }
 
     public void run() {
-        RenderScript pRS = RenderScript.create();
+        RenderScript pRS = RenderScript.create(mCtx);
         ScriptC_fp_mad s = new ScriptC_fp_mad(pRS, mRes, R.raw.fp_mad);
         pRS.setMessageHandler(mRsMessage);
         s.invoke_fp_mad_test(0, 0);
@@ -37,4 +38,3 @@
         pRS.destroy();
     }
 }
-
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java b/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java
index 6e0859a..b7a65a5 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java
@@ -16,14 +16,15 @@
 
 package com.android.rs.test;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.renderscript.*;
 
 public class UT_primitives extends UnitTest {
     private Resources mRes;
 
-    protected UT_primitives(RSTestCore rstc, Resources res) {
-        super(rstc, "Primitives");
+    protected UT_primitives(RSTestCore rstc, Resources res, Context ctx) {
+        super(rstc, "Primitives", ctx);
         mRes = res;
     }
 
@@ -87,7 +88,7 @@
     }
 
     public void run() {
-        RenderScript pRS = RenderScript.create();
+        RenderScript pRS = RenderScript.create(mCtx);
         ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives);
         pRS.setMessageHandler(mRsMessage);
         if (!initializeGlobals(s)) {
@@ -101,4 +102,3 @@
         pRS.destroy();
     }
 }
-
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_rsdebug.java b/libs/rs/java/tests/src/com/android/rs/test/UT_rsdebug.java
index df31f98..0614b1a 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UT_rsdebug.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UT_rsdebug.java
@@ -16,19 +16,20 @@
 
 package com.android.rs.test;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.renderscript.*;
 
 public class UT_rsdebug extends UnitTest {
     private Resources mRes;
 
-    protected UT_rsdebug(RSTestCore rstc, Resources res) {
-        super(rstc, "rsDebug");
+    protected UT_rsdebug(RSTestCore rstc, Resources res, Context ctx) {
+        super(rstc, "rsDebug", ctx);
         mRes = res;
     }
 
     public void run() {
-        RenderScript pRS = RenderScript.create();
+        RenderScript pRS = RenderScript.create(mCtx);
         ScriptC_rsdebug s = new ScriptC_rsdebug(pRS, mRes, R.raw.rsdebug);
         pRS.setMessageHandler(mRsMessage);
         s.invoke_test_rsdebug(0, 0);
@@ -37,4 +38,3 @@
         pRS.destroy();
     }
 }
-
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java b/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java
index d1232ce..74211c8 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UT_rstypes.java
@@ -16,19 +16,20 @@
 
 package com.android.rs.test;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.renderscript.*;
 
 public class UT_rstypes extends UnitTest {
     private Resources mRes;
 
-    protected UT_rstypes(RSTestCore rstc, Resources res) {
-        super(rstc, "rsTypes");
+    protected UT_rstypes(RSTestCore rstc, Resources res, Context ctx) {
+        super(rstc, "rsTypes", ctx);
         mRes = res;
     }
 
     public void run() {
-        RenderScript pRS = RenderScript.create();
+        RenderScript pRS = RenderScript.create(mCtx);
         ScriptC_rstypes s = new ScriptC_rstypes(pRS, mRes, R.raw.rstypes);
         pRS.setMessageHandler(mRsMessage);
         s.invoke_test_rstypes(0, 0);
@@ -37,4 +38,3 @@
         pRS.destroy();
     }
 }
-
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java
index 8923a19..a7722c7 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java
@@ -15,6 +15,7 @@
  */
 
 package com.android.rs.test;
+import android.content.Context;
 import android.renderscript.RenderScript.RSMessageHandler;
 import android.util.Log;
 
@@ -24,6 +25,7 @@
     private ScriptField_ListAllocs_s.Item mItem;
     private RSTestCore mRSTC;
     private boolean msgHandled;
+    protected Context mCtx;
 
     /* These constants must match those in shared.rsh */
     public static final int RS_MSG_TEST_PASSED = 100;
@@ -32,25 +34,26 @@
     private static int numTests = 0;
     public int testID;
 
-    protected UnitTest(RSTestCore rstc, String n, int initResult) {
+    protected UnitTest(RSTestCore rstc, String n, int initResult, Context ctx) {
         super();
         mRSTC = rstc;
         name = n;
         msgHandled = false;
+        mCtx = ctx;
         result = initResult;
         testID = numTests++;
     }
 
-    protected UnitTest(RSTestCore rstc, String n) {
-        this(rstc, n, 0);
+    protected UnitTest(RSTestCore rstc, String n, Context ctx) {
+        this(rstc, n, 0, ctx);
     }
 
-    protected UnitTest(RSTestCore rstc) {
-        this (rstc, "<Unknown>");
+    protected UnitTest(RSTestCore rstc, Context ctx) {
+        this (rstc, "<Unknown>", ctx);
     }
 
-    protected UnitTest() {
-        this (null);
+    protected UnitTest(Context ctx) {
+        this (null, ctx);
     }
 
     protected RSMessageHandler mRsMessage = new RSMessageHandler() {
@@ -101,4 +104,3 @@
         }
     }
 }
-
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index 9f817b6..5daba08 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -322,6 +322,7 @@
 
 ScriptCCreate {
         param const char * resName
+        param const char * cacheDir
 	ret RsScript
 	}
 
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index b3dbf11..507430d 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -402,7 +402,7 @@
 extern const char rs_runtime_lib_bc[];
 extern unsigned rs_runtime_lib_bc_size;
 
-void ScriptCState::runCompiler(Context *rsc, ScriptC *s, const char *resName) {
+void ScriptCState::runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir) {
     {
         s->mBccScript = bccCreateScript();
         s->mEnviroment.mIsThreadable = true;
@@ -413,7 +413,8 @@
         if (bccReadBC(s->mBccScript,
                       s->mEnviroment.mScriptText,
                       s->mEnviroment.mScriptTextLength,
-                      resName) >= 0) {
+                      resName,
+                      cacheDir) >= 0) {
           //bccLinkBC(s->mBccScript, rs_runtime_lib_bc, rs_runtime_lib_bc_size);
           bccCompileBC(s->mBccScript);
         } else {
@@ -534,7 +535,7 @@
     ss->mScript->mEnviroment.mScriptTextLength = len;
 }
 
-RsScript rsi_ScriptCCreate(Context * rsc, const char *resName)
+RsScript rsi_ScriptCCreate(Context * rsc, const char *resName, const char *cacheDir)
 {
     ScriptCState *ss = &rsc->mScriptC;
 
@@ -542,7 +543,7 @@
     ss->mScript.clear();
     s->incUserRef();
 
-    ss->runCompiler(rsc, s.get(), resName);
+    ss->runCompiler(rsc, s.get(), resName, cacheDir);
     ss->clear(rsc);
     return s.get();
 }
diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h
index ab2db5c8..a714132 100644
--- a/libs/rs/rsScriptC.h
+++ b/libs/rs/rsScriptC.h
@@ -83,7 +83,7 @@
     void init(Context *rsc);
 
     void clear(Context *rsc);
-    void runCompiler(Context *rsc, ScriptC *s, const char *resName);
+    void runCompiler(Context *rsc, ScriptC *s, const char *resName, const char *cacheDir);
 
     struct SymbolTable_t {
         const char * mName;
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index 446021c..9332120 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -318,7 +318,7 @@
     int64_t seekTimeUs;
     ReadOptions::SeekMode mode;
     if (options != NULL && options->getSeekTo(&seekTimeUs, &mode)) {
-        int64_t pos = (seekTimeUs * mSampleRate) / 1000000 * mNumChannels * 2;
+        int64_t pos = (seekTimeUs * mSampleRate) / 1000000 * mNumChannels * (mBitsPerSample >> 3);
         if (pos > mSize) {
             pos = mSize;
         }
diff --git a/packages/SettingsProvider/res/xml/bookmarks.xml b/packages/SettingsProvider/res/xml/bookmarks.xml
index dfaeeaf..83229f4 100644
--- a/packages/SettingsProvider/res/xml/bookmarks.xml
+++ b/packages/SettingsProvider/res/xml/bookmarks.xml
@@ -4,9 +4,9 @@
      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.
@@ -14,6 +14,22 @@
      limitations under the License.
 -->
 
+<!--
+     Default system bookmarks for AOSP.
+     Bookmarks for vendor apps should be added to a bookmarks resource overlay; not here.
+
+     Typical shortcuts (not necessarily defined here):
+       'b': Browser
+       'c': Contacts
+       'e': Email
+       'g': GMail
+       'l': Calendar
+       'm': Maps
+       'p': Music
+       's': SMS
+       't': Talk
+       'y': YouTube
+-->
 <bookmarks>
     <bookmark
         package="com.android.browser"
@@ -21,30 +37,16 @@
         shortcut="b" />
     <bookmark
         package="com.android.contacts"
-        class="com.android.contacts.DialtactsContactsEntryActivity"
+        class="com.android.contacts.activities.ContactsFrontDoor"
         shortcut="c" />
     <bookmark
-        package="com.android.email"
+        package="com.google.android.email"
         class="com.android.email.activity.Welcome"
         shortcut="e" />
     <bookmark
-        package="com.google.android.gm"
-        class="com.google.android.gm.ConversationListActivityGmail"
-        shortcut="g" />
-    <bookmark
-        package="com.android.im"
-        class="com.android.im.app.LandingPage"
-        shortcut="i" />
-    <bookmark
-        package="com.android.calendar"
+        package="com.google.android.calendar"
         class="com.android.calendar.LaunchActivity"
         shortcut="l" />
-<!--
-    <bookmark
-        package="com.google.android.apps.maps"
-        class="com.google.android.maps.MapsActivity"
-        shortcut="m" />
--->
     <bookmark
         package="com.android.music"
         class="com.android.music.MusicBrowserActivity"
diff --git a/packages/SystemUI/res/xml/bookmarks.xml b/packages/SystemUI/res/xml/bookmarks.xml
deleted file mode 100644
index dfaeeaf..0000000
--- a/packages/SystemUI/res/xml/bookmarks.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 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.
--->
-
-<bookmarks>
-    <bookmark
-        package="com.android.browser"
-        class="com.android.browser.BrowserActivity"
-        shortcut="b" />
-    <bookmark
-        package="com.android.contacts"
-        class="com.android.contacts.DialtactsContactsEntryActivity"
-        shortcut="c" />
-    <bookmark
-        package="com.android.email"
-        class="com.android.email.activity.Welcome"
-        shortcut="e" />
-    <bookmark
-        package="com.google.android.gm"
-        class="com.google.android.gm.ConversationListActivityGmail"
-        shortcut="g" />
-    <bookmark
-        package="com.android.im"
-        class="com.android.im.app.LandingPage"
-        shortcut="i" />
-    <bookmark
-        package="com.android.calendar"
-        class="com.android.calendar.LaunchActivity"
-        shortcut="l" />
-<!--
-    <bookmark
-        package="com.google.android.apps.maps"
-        class="com.google.android.maps.MapsActivity"
-        shortcut="m" />
--->
-    <bookmark
-        package="com.android.music"
-        class="com.android.music.MusicBrowserActivity"
-        shortcut="p" />
-    <bookmark
-        package="com.android.mms"
-        class="com.android.mms.ui.ConversationList"
-        shortcut="s" />
-</bookmarks>
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 79bf9d0..c6984a4 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1330,38 +1330,40 @@
                 }
             } else if (keyCode == mShortcutKeyPressed) {
                 mShortcutKeyPressed = -1;
-                
                 if (mConsumeShortcutKeyUp) {
-                    // Consume the up-event
                     mConsumeShortcutKeyUp = false;
                     return true;
                 }
             }
+            return false;
         } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) {
             if (!down) {
                 showRecentAppsDialog();
             }
             return true;
         }
-        
+
         // Shortcuts are invoked through Search+key, so intercept those here
-        if (mShortcutKeyPressed != -1 && !mConsumeShortcutKeyUp) {
-            if (down && repeatCount == 0 && !keyguardOn) {
-                final KeyCharacterMap kcm = event.getKeyCharacterMap();
-                Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState);
-                if (shortcutIntent != null) {
-                    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-                    mContext.startActivity(shortcutIntent);
-                    
-                    /*
-                     * We launched an app, so the up-event of the search key
-                     * should be consumed
-                     */
-                    if (mShortcutKeyPressed != -1) {
-                        mConsumeShortcutKeyUp = true;
+        // Any printing key that is chorded with Search should be consumed
+        // even if no shortcut was invoked.  This prevents text from being
+        // inadvertently inserted when using a keyboard that has built-in macro
+        // shortcut keys (that emit Search+x) and some of them are not registered.
+        if (mShortcutKeyPressed != -1) {
+            final KeyCharacterMap kcm = event.getKeyCharacterMap();
+            if (kcm.isPrintingKey(keyCode)) {
+                mConsumeShortcutKeyUp = true;
+                if (down && repeatCount == 0 && !keyguardOn) {
+                    Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState);
+                    if (shortcutIntent != null) {
+                        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                        mContext.startActivity(shortcutIntent);
+                    } else {
+                        Slog.i(TAG, "Dropping unregistered shortcut key combination: "
+                                + KeyEvent.keyCodeToString(mShortcutKeyPressed)
+                                + "+" + KeyEvent.keyCodeToString(keyCode));
                     }
-                    return true;
                 }
+                return true;
             }
         }
 
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 16fa95a..8ac7590 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -907,10 +907,10 @@
                                     error.string());
                                 goto bail;
                         }
-                    } else if (tag == "uses-gl-texture") {
+                    } else if (tag == "supports-gl-texture") {
                         String8 name = getAttribute(tree, NAME_ATTR, &error);
                         if (name != "" && error == "") {
-                            printf("uses-gl-texture:'%s'\n", name.string());
+                            printf("supports-gl-texture:'%s'\n", name.string());
                         } else {
                             fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n",
                                     error.string());
diff --git a/tools/layoutlib/bridge/.classpath b/tools/layoutlib/bridge/.classpath
index 7204ace..2102eb1 100644
--- a/tools/layoutlib/bridge/.classpath
+++ b/tools/layoutlib/bridge/.classpath
@@ -6,7 +6,7 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/layoutlib_api/layoutlib_api-prebuilt.jar"/>
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_PLAT_SRC/dalvik/libcore/xml/src/main/java"/>
-	<classpathentry kind="var" path="ANDROID_PLAT_OUT_FRAMEWORK/ninepatch.jar" sourcepath="/ANDROID_PLAT_SRC/development/tools/ninepatch/src"/>
 	<classpathentry kind="var" path="ANDROID_PLAT_SRC/out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar" sourcepath="/ANDROID_PLAT_SRC/frameworks/base"/>
+	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/ninepatch/ninepatch-prebuilt.jar"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/tools/layoutlib/bridge/Android.mk b/tools/layoutlib/bridge/Android.mk
index b7a602a..9b7bc5f 100644
--- a/tools/layoutlib/bridge/Android.mk
+++ b/tools/layoutlib/bridge/Android.mk
@@ -21,7 +21,7 @@
 LOCAL_JAVA_LIBRARIES := \
 	kxml2-2.3.0 \
 	layoutlib_api-prebuilt \
-	ninepatch
+	ninepatch-prebuilt
 
 LOCAL_STATIC_JAVA_LIBRARIES := temp_layoutlib
 
diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
index a6c6dfd..95663ec 100644
--- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -167,7 +167,7 @@
 
        try {
            chunkObject.draw(bitmap_delegate.getImage(), graphics,
-                   left, top, right - left, bottom - top);
+                   left, top, right - left, bottom - top, destDensity, srcDensity);
        } finally {
            if (paint_delegate != null) {
                graphics.dispose();
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
index 13f0f4a7..f03931f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/ResourceHelper.java
@@ -48,7 +48,7 @@
 import java.util.regex.Pattern;
 
 /**
- * Helper class to provide various convertion method used in handling android resources.
+ * Helper class to provide various conversion method used in handling android resources.
  */
 public final class ResourceHelper {
 
@@ -133,7 +133,8 @@
                 // if either chunk or bitmap is null, then we reload the 9-patch file.
                 if (chunk == null || bitmap == null) {
                     try {
-                        NinePatch ninePatch = NinePatch.load(file.toURL(), false /* convert */);
+                        NinePatch ninePatch = NinePatch.load(file.toURI().toURL(),
+                                false /* convert */);
                         if (ninePatch != null) {
                             if (chunk == null) {
                                 chunk = ninePatch.getChunk();
@@ -161,6 +162,7 @@
                         // URL is wrong, we'll return null below
                     } catch (IOException e) {
                         // failed to read the file, we'll return null below.
+                        Bridge.getLog().error(null, e);
                     }
                 }
 
@@ -176,7 +178,7 @@
 
             return null;
         } else if (lowerCaseValue.endsWith(".xml")) {
-            // create a blockparser for the file
+            // create a block parser for the file
             File f = new File(stringValue);
             if (f.isFile()) {
                 try {
@@ -220,7 +222,7 @@
                     return new BitmapDrawable(context.getResources(), bitmap);
                 } catch (IOException e) {
                     // we'll return null below
-                    // TODO: log the error.
+                    Bridge.getLog().error(null, e);
                 }
             } else {
                 // attempt to get a color from the value
@@ -229,7 +231,8 @@
                     return new ColorDrawable(color);
                 } catch (NumberFormatException e) {
                     // we'll return null below.
-                    // TODO: log the error
+                    Bridge.getLog().error(null,
+                            "failed to convert " + stringValue + " into a drawable");
                 }
             }
         }