Merge "AudioManagerTest: modifications for fixed volume" into jb-mr2-dev
diff --git a/libs/testserver/src/android/webkit/cts/CtsTestServer.java b/libs/testserver/src/android/webkit/cts/CtsTestServer.java
index a18d329..0d1db19 100755
--- a/libs/testserver/src/android/webkit/cts/CtsTestServer.java
+++ b/libs/testserver/src/android/webkit/cts/CtsTestServer.java
@@ -67,7 +67,9 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Vector;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -129,9 +131,8 @@
     private Resources mResources;
     private boolean mSsl;
     private MimeTypeMap mMap;
-    private String mLastQuery;
+    private Vector<String> mQueries;
     private ArrayList<HttpEntity> mRequestEntities;
-    private int mRequestCount;
     private long mDocValidity;
     private long mDocAge;
 
@@ -168,6 +169,7 @@
         mSsl = ssl;
         mRequestEntities = new ArrayList<HttpEntity>();
         mMap = MimeTypeMap.getSingleton();
+        mQueries = new Vector<String>();
         mServerThread = new ServerThread(this, mSsl);
         if (mSsl) {
             mServerUri = "https://localhost:" + mServerThread.mSocket.getLocalPort();
@@ -379,8 +381,21 @@
                 .toString();
     }
 
-    public synchronized String getLastRequestUrl() {
-        return mLastQuery;
+    /**
+     * Returns true if the resource identified by url has been requested since
+     * the server was started or the last call to resetRequestState().
+     *
+     * @param url The relative url to check whether it has been requested.
+     */
+    public synchronized boolean wasResourceRequested(String url) {
+        Iterator<String> it = mQueries.iterator();
+        while (it.hasNext()) {
+            String request = it.next();
+            if (request.endsWith(url)) {
+                return true;
+            }
+        }
+        return false;
     }
 
     /**
@@ -391,7 +406,7 @@
     }
 
     public synchronized int getRequestCount() {
-        return mRequestCount;
+        return mQueries.size();
     }
 
     /**
@@ -417,8 +432,7 @@
      */
     public synchronized void resetRequestState() {
 
-        mRequestCount = 0;
-        mLastQuery = null;
+        mQueries.clear();
         mRequestEntities = new ArrayList<HttpEntity>();
     }
 
@@ -443,8 +457,7 @@
         Log.i(TAG, requestLine.getMethod() + ": " + uriString);
 
         synchronized (this) {
-            mRequestCount += 1;
-            mLastQuery = uriString;
+            mQueries.add(uriString);
             if (request instanceof HttpEntityEnclosingRequest) {
                 mRequestEntities.add(((HttpEntityEnclosingRequest)request).getEntity());
             }
diff --git a/suite/pts/deviceTests/opengl/jni/Android.mk b/suite/pts/deviceTests/opengl/jni/Android.mk
index 7ab7f89..be69522 100644
--- a/suite/pts/deviceTests/opengl/jni/Android.mk
+++ b/suite/pts/deviceTests/opengl/jni/Android.mk
@@ -26,6 +26,6 @@
 
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 
-LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libandroid libutils
+LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libandroid libutils libcutils
 
 include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
diff --git a/suite/pts/deviceTests/opengl/jni/GLUtils.cpp b/suite/pts/deviceTests/opengl/jni/graphics/GLUtils.cpp
similarity index 79%
rename from suite/pts/deviceTests/opengl/jni/GLUtils.cpp
rename to suite/pts/deviceTests/opengl/jni/graphics/GLUtils.cpp
index 9e75f2c..439e451 100644
--- a/suite/pts/deviceTests/opengl/jni/GLUtils.cpp
+++ b/suite/pts/deviceTests/opengl/jni/graphics/GLUtils.cpp
@@ -12,12 +12,12 @@
  * the License.
  */
 
-#include <GLUtils.h>
+#include "GLUtils.h"
 #include <stdlib.h>
 
 #define LOG_TAG "PTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include <utils/Log.h>
 
 // Loads the given source code as a shader of the given type.
 static GLuint loadShader(GLenum shaderType, const char** source) {
@@ -120,3 +120,28 @@
     delete[] m;
     return textureId;
 }
+
+bool GLUtils::createFBO(GLuint& fboId, GLuint& rboId, GLuint& cboId, int width, int height) {
+    glGenFramebuffers(1, &fboId);
+    glBindFramebuffer(GL_FRAMEBUFFER, fboId);
+
+    glGenRenderbuffers(1, &rboId);
+    glBindRenderbuffer(GL_RENDERBUFFER, rboId);
+    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
+    glBindRenderbuffer(GL_RENDERBUFFER, 0);
+    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboId);
+
+    glGenRenderbuffers(1, &cboId);
+    glBindRenderbuffer(GL_RENDERBUFFER, cboId);
+    glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB565, width, height);
+    glBindRenderbuffer(GL_RENDERBUFFER, 0);
+    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, cboId);
+
+    GLuint err = glGetError();
+    if (err != GL_NO_ERROR) {
+        ALOGV("GLError %d", err);
+        return false;
+    }
+
+    return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
+}
diff --git a/suite/pts/deviceTests/opengl/jni/GLUtils.h b/suite/pts/deviceTests/opengl/jni/graphics/GLUtils.h
similarity index 92%
rename from suite/pts/deviceTests/opengl/jni/GLUtils.h
rename to suite/pts/deviceTests/opengl/jni/graphics/GLUtils.h
index a0525bc..8708103 100644
--- a/suite/pts/deviceTests/opengl/jni/GLUtils.h
+++ b/suite/pts/deviceTests/opengl/jni/graphics/GLUtils.h
@@ -27,6 +27,7 @@
     static int roundUpToSmallestPowerOf2(int x);
     // Generates a random texture of the given dimensions.
     static GLuint genRandTex(int texWidth, int texHeight);
+    static bool createFBO(GLuint& fboId, GLuint& rboId, GLuint& cboId, int width, int height);
 };
 
 #endif
diff --git a/suite/pts/deviceTests/opengl/jni/GLNative.cpp b/suite/pts/deviceTests/opengl/jni/primitive/GLPrimitive.cpp
similarity index 100%
rename from suite/pts/deviceTests/opengl/jni/GLNative.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/GLPrimitive.cpp
diff --git a/suite/pts/deviceTests/opengl/jni/Renderer.cpp b/suite/pts/deviceTests/opengl/jni/primitive/Renderer.cpp
similarity index 78%
rename from suite/pts/deviceTests/opengl/jni/Renderer.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/Renderer.cpp
index 0f5c3ba..4bc0cda 100644
--- a/suite/pts/deviceTests/opengl/jni/Renderer.cpp
+++ b/suite/pts/deviceTests/opengl/jni/primitive/Renderer.cpp
@@ -12,11 +12,14 @@
  * the License.
  */
 #include "Renderer.h"
-#include <GLUtils.h>
+#include <graphics/GLUtils.h>
 
 #define LOG_TAG "PTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include <utils/Log.h>
+
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Trace.h>
 
 static const EGLint contextAttribs[] = {
         EGL_CONTEXT_CLIENT_VERSION, 2,
@@ -39,6 +42,7 @@
 }
 
 bool Renderer::setUp() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     mEglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     if (EGL_NO_DISPLAY == mEglDisplay || EGL_SUCCESS != eglGetError()) {
         return false;
@@ -85,7 +89,7 @@
     if (mOffscreen) {
         int w = GLUtils::roundUpToSmallestPowerOf2(width);
         int h = GLUtils::roundUpToSmallestPowerOf2(height);
-        if (!createFBO(mFboId, mRboId, mCboId, w, h)) {
+        if (!GLUtils::createFBO(mFboId, mRboId, mCboId, w, h)) {
             return false;
         }
     } else {
@@ -102,32 +106,8 @@
     return true;
 }
 
-bool Renderer::createFBO(GLuint& fboId, GLuint& rboId, GLuint& cboId, int width, int height) {
-    glGenFramebuffers(1, &fboId);
-    glBindFramebuffer(GL_FRAMEBUFFER, fboId);
-
-    glGenRenderbuffers(1, &rboId);
-    glBindRenderbuffer(GL_RENDERBUFFER, rboId);
-    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
-    glBindRenderbuffer(GL_RENDERBUFFER, 0);
-    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboId);
-
-    glGenRenderbuffers(1, &cboId);
-    glBindRenderbuffer(GL_RENDERBUFFER, cboId);
-    glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB565, width, height);
-    glBindRenderbuffer(GL_RENDERBUFFER, 0);
-    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, cboId);
-
-    GLuint err = glGetError();
-    if (err != GL_NO_ERROR) {
-        ALOGV("GLError %d", err);
-        return false;
-    }
-
-    return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
-}
-
 bool Renderer::tearDown() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mFboId != 0) {
         glDeleteFramebuffers(1, &mFboId);
         mFboId = 0;
diff --git a/suite/pts/deviceTests/opengl/jni/Renderer.h b/suite/pts/deviceTests/opengl/jni/primitive/Renderer.h
similarity index 93%
rename from suite/pts/deviceTests/opengl/jni/Renderer.h
rename to suite/pts/deviceTests/opengl/jni/primitive/Renderer.h
index a50d81c..49c7e98 100644
--- a/suite/pts/deviceTests/opengl/jni/Renderer.h
+++ b/suite/pts/deviceTests/opengl/jni/primitive/Renderer.h
@@ -28,7 +28,6 @@
     virtual bool draw() = 0;
     virtual ~Renderer() {};
 protected:
-    bool createFBO(GLuint& fboId, GLuint& rboId, GLuint& cboId, int width, int height);
     ANativeWindow* mWindow;
     EGLDisplay mEglDisplay;
     EGLSurface mEglSurface;
diff --git a/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp b/suite/pts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
similarity index 94%
rename from suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
index 0d85cae..cdfaaec 100644
--- a/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.cpp
+++ b/suite/pts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.cpp
@@ -21,11 +21,14 @@
 #include <GLES2/gl2ext.h>
 
 #include "ContextSwitchRenderer.h"
-#include <GLUtils.h>
+#include <graphics/GLUtils.h>
 
 #define LOG_TAG "PTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include <utils/Log.h>
+
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Trace.h>
 
 static const EGLint contextAttribs[] =
         { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
@@ -70,6 +73,7 @@
 }
 
 bool ContextSwitchRenderer::setUp() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (!Renderer::setUp()) {
         return false;
     }
@@ -105,7 +109,7 @@
 
         if (mOffscreen) {
             // Setup FBOs.
-            if (!Renderer::createFBO(mFboIds[i], mRboIds[i], mCboIds[i], w, h)) {
+            if (!GLUtils::createFBO(mFboIds[i], mRboIds[i], mCboIds[i], w, h)) {
                 return false;
             }
         }
@@ -137,6 +141,7 @@
 }
 
 bool ContextSwitchRenderer::tearDown() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mContexts) {
         for (int i = 0; i < mWorkload; i++) {
             eglDestroyContext(mEglDisplay, mContexts[i]);
@@ -168,6 +173,7 @@
 }
 
 bool ContextSwitchRenderer::draw() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     for (int i = 0; i < mWorkload; i++) {
         if (!eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mContexts[i])
                 || EGL_SUCCESS != eglGetError()) {
diff --git a/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.h b/suite/pts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h
similarity index 97%
rename from suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.h
rename to suite/pts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h
index 3dfe9f3..24d8df1 100644
--- a/suite/pts/deviceTests/opengl/jni/contextswitch/ContextSwitchRenderer.h
+++ b/suite/pts/deviceTests/opengl/jni/primitive/contextswitch/ContextSwitchRenderer.h
@@ -14,7 +14,7 @@
 #ifndef CONTEXTSWITCHRENDERER_H
 #define CONTEXTSWITCHRENDERER_H
 
-#include <Renderer.h>
+#include <primitive/Renderer.h>
 
 class ContextSwitchRenderer: public Renderer {
 public:
diff --git a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineMesh.cpp b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineMesh.cpp
similarity index 100%
rename from suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineMesh.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineMesh.cpp
diff --git a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineMesh.h b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineMesh.h
similarity index 100%
rename from suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineMesh.h
rename to suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineMesh.h
diff --git a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineProgram.cpp b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineProgram.cpp
similarity index 97%
rename from suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineProgram.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineProgram.cpp
index e3abc2c..b06cdd2 100644
--- a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineProgram.cpp
+++ b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineProgram.cpp
@@ -23,7 +23,7 @@
     mLightPosInModelSpace[0] = 0.0f;
     mLightPosInModelSpace[1] = 2.0f;
     mLightPosInModelSpace[2] = 2.0f;
-    mLightPosInModelSpace[3] = 1.0f;
+    mLightPosInModelSpace[3] = 2.0f;
     mMVMatrixHandle = glGetUniformLocation(programId, "u_MVMatrix");
     mMVPMatrixHandle = glGetUniformLocation(programId, "u_MVPMatrix");
     mLightPosHandle = glGetUniformLocation(programId, "u_LightPos");
diff --git a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineProgram.h b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineProgram.h
similarity index 100%
rename from suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineProgram.h
rename to suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineProgram.h
diff --git a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineRenderer.cpp b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp
similarity index 96%
rename from suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineRenderer.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp
index 4cab669..3db5eea 100644
--- a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineRenderer.cpp
+++ b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.cpp
@@ -21,11 +21,14 @@
 #include "FullPipelineRenderer.h"
 #include <graphics/Mesh.h>
 #include <graphics/TransformationNode.h>
-#include <GLUtils.h>
+#include <graphics/GLUtils.h>
 
 #define LOG_TAG "PTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include <utils/Log.h>
+
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Trace.h>
 
 static const int FP_NUM_VERTICES = 6;
 
@@ -101,6 +104,7 @@
 }
 
 bool FullPipelineRenderer::setUp() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (!Renderer::setUp()) {
         return false;
     }
@@ -169,6 +173,7 @@
 }
 
 bool FullPipelineRenderer::tearDown() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mTextureId != 0) {
         glDeleteTextures(1, &mTextureId);
         mTextureId = 0;
@@ -192,6 +197,7 @@
 }
 
 bool FullPipelineRenderer::draw() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mOffscreen) {
         glBindFramebuffer(GL_FRAMEBUFFER, mFboId);
     }
diff --git a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineRenderer.h b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h
similarity index 97%
rename from suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineRenderer.h
rename to suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h
index 0c5acae..14efcf6 100644
--- a/suite/pts/deviceTests/opengl/jni/fullpipeline/FullPipelineRenderer.h
+++ b/suite/pts/deviceTests/opengl/jni/primitive/fullpipeline/FullPipelineRenderer.h
@@ -16,7 +16,7 @@
 
 #include "FullPipelineProgram.h"
 
-#include <Renderer.h>
+#include <primitive/Renderer.h>
 #include <graphics/Matrix.h>
 #include <graphics/Mesh.h>
 #include <graphics/ProgramNode.h>
diff --git a/suite/pts/deviceTests/opengl/jni/pixeloutput/PixelOutputRenderer.cpp b/suite/pts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp
similarity index 93%
rename from suite/pts/deviceTests/opengl/jni/pixeloutput/PixelOutputRenderer.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp
index 95bf52b..d2fd762 100644
--- a/suite/pts/deviceTests/opengl/jni/pixeloutput/PixelOutputRenderer.cpp
+++ b/suite/pts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.cpp
@@ -12,11 +12,14 @@
  * the License.
  */
 #include "PixelOutputRenderer.h"
-#include <GLUtils.h>
+#include <graphics/GLUtils.h>
 
 #define LOG_TAG "PTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include <utils/Log.h>
+
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Trace.h>
 
 static const int PO_NUM_VERTICES = 6;
 
@@ -57,6 +60,7 @@
 }
 
 bool PixelOutputRenderer::setUp() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (!Renderer::setUp()) {
         return false;
     }
@@ -79,6 +83,7 @@
 }
 
 bool PixelOutputRenderer::tearDown() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mTextureId != 0) {
         glDeleteTextures(1, &mTextureId);
         mTextureId = 0;
@@ -90,6 +95,7 @@
 }
 
 bool PixelOutputRenderer::draw() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mOffscreen) {
         glBindFramebuffer(GL_FRAMEBUFFER, mFboId);
     }
diff --git a/suite/pts/deviceTests/opengl/jni/pixeloutput/PixelOutputRenderer.h b/suite/pts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h
similarity index 96%
rename from suite/pts/deviceTests/opengl/jni/pixeloutput/PixelOutputRenderer.h
rename to suite/pts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h
index 6422517..90b3f2a 100644
--- a/suite/pts/deviceTests/opengl/jni/pixeloutput/PixelOutputRenderer.h
+++ b/suite/pts/deviceTests/opengl/jni/primitive/pixeloutput/PixelOutputRenderer.h
@@ -14,7 +14,7 @@
 #ifndef PIXELOUTPUTRENDERER_H
 #define PIXELOUTPUTRENDERER_H
 
-#include <Renderer.h>
+#include <primitive/Renderer.h>
 
 class PixelOutputRenderer: public Renderer {
 public:
diff --git a/suite/pts/deviceTests/opengl/jni/shaderperf/ShaderPerfRenderer.cpp b/suite/pts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp
similarity index 96%
rename from suite/pts/deviceTests/opengl/jni/shaderperf/ShaderPerfRenderer.cpp
rename to suite/pts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp
index 6d98c9a..62fe1ac 100644
--- a/suite/pts/deviceTests/opengl/jni/shaderperf/ShaderPerfRenderer.cpp
+++ b/suite/pts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.cpp
@@ -12,13 +12,16 @@
  * the License.
  */
 #include "ShaderPerfRenderer.h"
-#include <GLUtils.h>
+#include <graphics/GLUtils.h>
 
 #include <math.h>
 
 #define LOG_TAG "PTS_OPENGL"
 #define LOG_NDEBUG 0
-#include "utils/Log.h"
+#include <utils/Log.h>
+
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Trace.h>
 
 static const float GOLDEN_RATIO = (1.0 + sqrt(5.0)) / 2.0;
 
@@ -98,6 +101,7 @@
 }
 
 bool ShaderPerfRenderer::setUp() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (!Renderer::setUp()) {
         return false;
     }
@@ -148,6 +152,7 @@
 }
 
 bool ShaderPerfRenderer::draw() {
+    android::ScopedTrace st(ATRACE_TAG, __func__);
     if (mOffscreen) {
         glBindFramebuffer(GL_FRAMEBUFFER, mFboId);
     }
diff --git a/suite/pts/deviceTests/opengl/jni/shaderperf/ShaderPerfRenderer.h b/suite/pts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h
similarity index 96%
rename from suite/pts/deviceTests/opengl/jni/shaderperf/ShaderPerfRenderer.h
rename to suite/pts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h
index 4460174..3537eba 100644
--- a/suite/pts/deviceTests/opengl/jni/shaderperf/ShaderPerfRenderer.h
+++ b/suite/pts/deviceTests/opengl/jni/primitive/shaderperf/ShaderPerfRenderer.h
@@ -14,7 +14,7 @@
 #ifndef SHADERPERFRENDERER_H
 #define SHADERPERFRENDERER_H
 
-#include <Renderer.h>
+#include <primitive/Renderer.h>
 
 class ShaderPerfRenderer: public Renderer {
 public:
diff --git a/suite/pts/utils/grapher.py b/suite/pts/utils/grapher.py
index 42b5f11..94bf25e 100755
--- a/suite/pts/utils/grapher.py
+++ b/suite/pts/utils/grapher.py
@@ -41,7 +41,7 @@
       # Create a new figure
       fig = plt.figure()
       # Set the title of the graph
-      plt.title(benchmark)
+      plt.title(benchmark[benchmark.index('#') + 1:])
       # For each result in the data set
       for r in results:
         score = r['result']
@@ -60,6 +60,9 @@
           ax.plot(x, y, 'o-', label=r['device'] + ' (%s)'%score)
           # Add a legend
           ax.legend(loc='upper right').get_frame().set_fill(False)
+      (ymin, ymax) = plt.ylim()
+      if ymax < 90:# So that on screen tests are easier to compare
+        plt.ylim(0, 90)
       plt.xlabel('Iteration')
       plt.ylabel('FPS')
       fig.autofmt_xdate()
diff --git a/tests/core/ctscore.mk b/tests/core/ctscore.mk
index 0961c96..1e4e017 100644
--- a/tests/core/ctscore.mk
+++ b/tests/core/ctscore.mk
@@ -23,7 +23,6 @@
 # Don't delete META-INF from the core-tests jar
 LOCAL_DONT_DELETE_JAR_META_INF := true
 
-LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 LOCAL_JNI_SHARED_LIBRARIES := libjavacoretests
 
 include $(BUILD_PACKAGE)
diff --git a/tests/core/libcore/com/Android.mk b/tests/core/libcore/com/Android.mk
index 6c68f9d..02dc3de 100644
--- a/tests/core/libcore/com/Android.mk
+++ b/tests/core/libcore/com/Android.mk
@@ -20,4 +20,5 @@
 
 include $(CLEAR_VARS)
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.com
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/dalvik/Android.mk b/tests/core/libcore/dalvik/Android.mk
index 5744fac..7b77a75 100644
--- a/tests/core/libcore/dalvik/Android.mk
+++ b/tests/core/libcore/dalvik/Android.mk
@@ -20,4 +20,5 @@
 
 include $(CLEAR_VARS)
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.dalvik
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/libcore/Android.mk b/tests/core/libcore/libcore/Android.mk
index 160b996..382b386 100644
--- a/tests/core/libcore/libcore/Android.mk
+++ b/tests/core/libcore/libcore/Android.mk
@@ -20,4 +20,5 @@
 
 include $(CLEAR_VARS)
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.libcore
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/org/Android.mk b/tests/core/libcore/org/Android.mk
index adb26d5..d7a96b3 100644
--- a/tests/core/libcore/org/Android.mk
+++ b/tests/core/libcore/org/Android.mk
@@ -20,4 +20,5 @@
 
 include $(CLEAR_VARS)
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.org
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/sun/Android.mk b/tests/core/libcore/sun/Android.mk
index d2754eb..44d3d70 100644
--- a/tests/core/libcore/sun/Android.mk
+++ b/tests/core/libcore/sun/Android.mk
@@ -20,4 +20,5 @@
 
 include $(CLEAR_VARS)
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.sun
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/tests/Android.mk b/tests/core/libcore/tests/Android.mk
index 0c1024e..bfd235f 100644
--- a/tests/core/libcore/tests/Android.mk
+++ b/tests/core/libcore/tests/Android.mk
@@ -20,4 +20,5 @@
 
 include $(CLEAR_VARS)
 LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.tests
+LOCAL_STATIC_JAVA_LIBRARIES := core-tests
 include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/jni/Android.mk b/tests/jni/Android.mk
index 0f7511e..39aafa1 100644
--- a/tests/jni/Android.mk
+++ b/tests/jni/Android.mk
@@ -23,7 +23,6 @@
 
 LOCAL_SRC_FILES := \
 		CtsJniOnLoad.cpp \
-		android_os_cts_OSFeatures.cpp \
 		android_os_cts_FileUtils.cpp \
 		android_net_cts_NetlinkSocket.cpp
 
diff --git a/tests/jni/CtsJniOnLoad.cpp b/tests/jni/CtsJniOnLoad.cpp
index 99ea37e..d029b2d 100644
--- a/tests/jni/CtsJniOnLoad.cpp
+++ b/tests/jni/CtsJniOnLoad.cpp
@@ -20,8 +20,6 @@
 
 extern int register_android_os_cts_CpuFeatures(JNIEnv*);
 
-extern int register_android_os_cts_OSFeatures(JNIEnv*);
-
 extern int register_android_os_cts_FileUtils(JNIEnv*);
 
 jint JNI_OnLoad(JavaVM *vm, void *reserved) {
@@ -35,10 +33,6 @@
         return JNI_ERR;
     }
 
-    if (register_android_os_cts_OSFeatures(env)) {
-        return JNI_ERR;
-    }
-
     if (register_android_os_cts_FileUtils(env)) {
       return JNI_ERR;
     }
diff --git a/tests/jni/android_os_cts_OSFeatures.cpp b/tests/jni/android_os_cts_OSFeatures.cpp
deleted file mode 100644
index 50baaa2..0000000
--- a/tests/jni/android_os_cts_OSFeatures.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- *
- */
-#include <jni.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <linux/filter.h>
-#include <linux/seccomp.h>
-
-#include <sys/prctl.h>
-#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#define DENY BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_KILL)
-
-static void test_seccomp() {
-    if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) {
-        _exit(0);
-    }
-
-    struct sock_filter filter[] = { DENY };
-    struct sock_fprog prog;
-    memset(&prog, 0, sizeof(prog));
-    prog.len = sizeof(filter) / sizeof(filter[0]);
-    prog.filter = filter;
-
-    if (prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog) < 0) {
-        _exit(0);
-    }
-
-    _exit(0);  // should crash with SIGSYS
-}
-
-jboolean android_os_cts_OSFeatures_hasSeccompSupport(JNIEnv* env, jobject thiz)
-{
-    pid_t pid = fork();
-    if (pid == -1) {
-        return false;
-    }
-    if (pid == 0) {
-        // child
-        test_seccomp();
-        _exit(0);
-    }
-
-    int status;
-    waitpid(pid, &status, 0);
-    return WIFSIGNALED(status) && (WTERMSIG(status) == SIGSYS);
-}
-
-jboolean android_os_cts_OSFeatures_needsSeccompSupport(JNIEnv* env, jobject thiz)
-{
-#if !defined(__arm__) && !defined(__i386__) && !defined(__x86_64__)
-    // Seccomp support is only available for ARM and x86.
-    return false;
-#endif
-
-    int major;
-    int minor;
-    struct utsname uts;
-    if (uname(&uts) == -1) {
-        return false;
-    }
-
-    if (sscanf(uts.release, "%d.%d", &major, &minor) != 2) {
-        return false;
-    }
-
-    // Kernels before 3.5 don't have seccomp
-    if ((major < 3) || ((major == 3) && (minor < 5))) {
-        return false;
-    }
-
-    return true;
-}
-
-static JNINativeMethod gMethods[] = {
-    {  "hasSeccompSupport", "()Z",
-            (void *) android_os_cts_OSFeatures_hasSeccompSupport  },
-    {  "needsSeccompSupport", "()Z",
-            (void *) android_os_cts_OSFeatures_needsSeccompSupport  },
-};
-
-int register_android_os_cts_OSFeatures(JNIEnv* env)
-{
-    jclass clazz = env->FindClass("android/os/cts/OSFeatures");
-
-    return env->RegisterNatives(clazz, gMethods,
-            sizeof(gMethods) / sizeof(JNINativeMethod));
-}
diff --git a/tests/src/android/os/cts/OSFeatures.java b/tests/src/android/os/cts/OSFeatures.java
deleted file mode 100644
index 036d4c9..0000000
--- a/tests/src/android/os/cts/OSFeatures.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.os.cts;
-
-public class OSFeatures {
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasSeccompSupport();
-    public static native boolean needsSeccompSupport();
-}
diff --git a/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java b/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
new file mode 100644
index 0000000..ff6d15d
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.media.cts;
+
+import android.media.MediaDrm;
+import android.media.MediaDrm.ProvisionRequest;
+import android.media.MediaDrm.LicenseRequest;
+import android.media.MediaDrmException;
+import android.test.AndroidTestCase;
+import android.util.Log;
+import java.util.HashMap;
+import java.util.Arrays;
+import java.util.UUID;
+
+// This test works with the MediaDrm mock plugin
+public class MediaDrmMockTest extends AndroidTestCase {
+    private static final String TAG = "MediaDrmMockTest";
+
+    // The scheme supported by the mock drm plugin
+    static final UUID mockScheme = new UUID(0x0102030405060708L, 0x090a0b0c0d0e0f10L);
+    static final UUID badScheme = new UUID(0xffffffffffffffffL, 0xffffffffffffffffL);
+
+    private boolean isMockPluginInstalled() {
+        return MediaDrm.isCryptoSchemeSupported(mockScheme);
+    }
+
+    public void testIsCryptoSchemeNotSupported() throws Exception {
+        assertFalse(MediaDrm.isCryptoSchemeSupported(badScheme));
+    }
+
+    public void testMediaDrmConstructor() throws Exception {
+        if (isMockPluginInstalled()) {
+            MediaDrm md = new MediaDrm(mockScheme);
+        } else {
+            Log.w(TAG, "optional plugin libmockdrmcryptoplugin.so is not installed");
+            Log.w(TAG, "To verify the MediaDrm APIs, you should install this plugin");
+        }
+    }
+
+    public void testMediaDrmConstructorFails() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        boolean gotException = false;
+        try {
+            MediaDrm md = new MediaDrm(badScheme);
+        } catch (MediaDrmException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testStringProperties() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        md.setPropertyString("test-string", "test-value");
+        assertTrue(md.getPropertyString("test-string").equals("test-value")); 
+    }
+
+    public void testByteArrayProperties() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        byte testArray[] = {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x10, 0x11, 0x12};
+        md.setPropertyByteArray("test-array", testArray);
+        assertTrue(Arrays.equals(md.getPropertyByteArray("test-array"), testArray));
+    }
+
+    public void testMissingPropertyString() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        boolean gotException = false;
+        try {
+            md.getPropertyString("missing-property");
+        } catch (IllegalArgumentException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testNullPropertyString() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        boolean gotException = false;
+        try {
+            md.getPropertyString(null);
+        } catch (IllegalArgumentException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testMissingPropertyByteArray() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        boolean gotException = false;
+        try {
+            md.getPropertyByteArray("missing-property");
+        } catch (IllegalArgumentException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testNullPropertyByteArray() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        boolean gotException = false;
+        try {
+            md.getPropertyByteArray(null);
+        } catch (IllegalArgumentException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testOpenCloseSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = md.openSession();
+        md.closeSession(sessionId);
+    }
+
+    public void testBadSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = {0x05, 0x6, 0x7, 0x8};
+        boolean gotException = false;
+        try {
+            md.closeSession(sessionId);
+        } catch (IllegalArgumentException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testNullSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = null;
+        boolean gotException = false;
+        try {
+            md.closeSession(sessionId);
+        } catch (IllegalArgumentException e) {
+            gotException = true;
+        }
+        assertTrue(gotException);
+    }
+
+    public void testGetLicenseRequest() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = md.openSession();
+
+        // Set up mock expected responses using properties
+        byte testRequest[] = {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x10, 0x11, 0x12};
+        md.setPropertyByteArray("mock-request", testRequest);
+        String testDefaultUrl = "http://1.2.3.4:8080/blah";
+        md.setPropertyString("mock-defaultUrl", testDefaultUrl);
+
+        byte[] initData = {0x0a, 0x0b, 0x0c, 0x0d};
+        HashMap<String, String> optionalParameters = new HashMap<String, String>();
+        optionalParameters.put("param1", "value1");
+        optionalParameters.put("param2", "value2");
+
+        String mimeType = "video/iso.segment";
+        LicenseRequest request = md.getLicenseRequest(sessionId, initData, mimeType,
+                                                      MediaDrm.MEDIA_DRM_LICENSE_TYPE_STREAMING,
+                                                      optionalParameters);
+        assertTrue(Arrays.equals(request.data, testRequest));
+        assertTrue(request.defaultUrl.equals(testDefaultUrl));
+
+        assertTrue(Arrays.equals(initData, md.getPropertyByteArray("mock-initdata")));
+        assertTrue(mimeType.equals(md.getPropertyString("mock-mimetype")));
+        assertTrue(md.getPropertyString("mock-licensetype").equals("1"));
+        assertTrue(md.getPropertyString("mock-optparams").equals("{param1,value1},{param2,value2}"));
+
+        md.closeSession(sessionId);
+    }
+
+    public void testGetLicenseRequestNoOptionalParameters() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = md.openSession();
+
+        // Set up mock expected responses using properties
+        byte testRequest[] = {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x10, 0x11, 0x12};
+        md.setPropertyByteArray("mock-request", testRequest);
+        String testDefaultUrl = "http://1.2.3.4:8080/blah";
+        md.setPropertyString("mock-defaultUrl", testDefaultUrl);
+
+        byte[] initData = {0x0a, 0x0b, 0x0c, 0x0d};
+
+        String mimeType = "video/iso.segment";
+        LicenseRequest request = md.getLicenseRequest(sessionId, initData, mimeType,
+                                                      MediaDrm.MEDIA_DRM_LICENSE_TYPE_STREAMING,
+                                                      null);
+        assertTrue(Arrays.equals(request.data, testRequest));
+        assertTrue(request.defaultUrl.equals(testDefaultUrl));
+
+        assertTrue(Arrays.equals(initData, md.getPropertyByteArray("mock-initdata")));
+        assertTrue(mimeType.equals(md.getPropertyString("mock-mimetype")));
+        assertTrue(md.getPropertyString("mock-licensetype").equals("1"));
+
+        md.closeSession(sessionId);
+    }
+
+    public void testProvideLicenseResponse() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = md.openSession();
+
+        // Set up mock expected responses using properties
+        byte testResponse[] = {0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20};
+
+        md.provideLicenseResponse(sessionId, testResponse);
+
+        assertTrue(Arrays.equals(testResponse, md.getPropertyByteArray("mock-response")));
+        md.closeSession(sessionId);
+    }
+
+    public void testRemoveLicense() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = md.openSession();
+        md.removeLicense(sessionId);
+        md.closeSession(sessionId);
+    }
+
+    public void testQueryLicenseStatus() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+        byte[] sessionId = md.openSession();
+        HashMap<String, String> infoMap = md.queryLicenseStatus(sessionId);
+
+        // these are canned strings returned by the mock
+        assertTrue(infoMap.containsKey("purchaseDuration"));
+        assertTrue(infoMap.get("purchaseDuration").equals(("1000")));
+        assertTrue(infoMap.containsKey("licenseDuration"));
+        assertTrue(infoMap.get("licenseDuration").equals(("100")));
+
+        md.closeSession(sessionId);
+    }
+
+    public void testGetProvisionRequest() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        // Set up mock expected responses using properties
+        byte testRequest[] = {0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x60, 0x61, 0x62};
+        md.setPropertyByteArray("mock-request", testRequest);
+        String testDefaultUrl = "http://1.2.3.4:8080/bar";
+        md.setPropertyString("mock-defaultUrl", testDefaultUrl);
+
+        ProvisionRequest request = md.getProvisionRequest();
+        assertTrue(Arrays.equals(request.data, testRequest));
+        assertTrue(request.defaultUrl.equals(testDefaultUrl));
+    }
+
+    public void testProvideProvisionResponse() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        // Set up mock expected responses using properties
+        byte testResponse[] = {0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20};
+
+        md.provideProvisionResponse(testResponse);
+        assertTrue(Arrays.equals(testResponse, md.getPropertyByteArray("mock-response")));
+    }
+
+    public void testMultipleSessions() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
+        MediaDrm md = new MediaDrm(mockScheme);
+
+        byte[] session1 = md.openSession();
+        byte[] session2 = md.openSession();
+        byte[] session3 = md.openSession();
+
+        assertFalse(Arrays.equals(session1, session2));
+        assertFalse(Arrays.equals(session2, session3));
+
+        md.closeSession(session1);
+        md.closeSession(session2);
+        md.closeSession(session3);
+    }
+
+}
diff --git a/tests/tests/media/src/android/media/cts/MediaMuxerTest.java b/tests/tests/media/src/android/media/cts/MediaMuxerTest.java
index 4e928a5..b44321c 100644
--- a/tests/tests/media/src/android/media/cts/MediaMuxerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaMuxerTest.java
@@ -22,8 +22,8 @@
 import android.media.MediaCodec.BufferInfo;
 import android.media.MediaExtractor;
 import android.media.MediaFormat;
+import android.media.MediaMetadataRetriever;
 import android.media.MediaMuxer;
-import android.media.MediaPlayer;
 import android.test.AndroidTestCase;
 import android.util.Log;
 
@@ -52,7 +52,7 @@
     public void testVideoAudio() throws Exception {
         int source = R.raw.video_176x144_3gp_h263_300kbps_25fps_aac_stereo_128kbps_11025hz;
         String outputFile = "/sdcard/videoAudio.mp4";
-        cloneAndVerify(source, outputFile, 2);
+        cloneAndVerify(source, outputFile, 2, 90);
     }
 
     /**
@@ -61,7 +61,7 @@
     public void testAudioOnly() throws Exception {
         int source = R.raw.sinesweepm4a;
         String outputFile = "/sdcard/audioOnly.mp4";
-        cloneAndVerify(source, outputFile, 1);
+        cloneAndVerify(source, outputFile, 1, -1);
     }
 
     /**
@@ -70,7 +70,7 @@
     public void testVideoOnly() throws Exception {
         int source = R.raw.video_only_176x144_3gp_h263_25fps;
         String outputFile = "/sdcard/videoOnly.mp4";
-        cloneAndVerify(source, outputFile, 1);
+        cloneAndVerify(source, outputFile, 1, 180);
     }
 
     /**
@@ -88,7 +88,7 @@
 
         // Throws exception b/c start() is not called.
         muxer = new MediaMuxer(outputFile, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
-        muxer.addTrack(MediaFormat.createVideoFormat("video/mp4", 480, 320));
+        muxer.addTrack(MediaFormat.createVideoFormat("video/avc", 480, 320));
 
         try {
             muxer.stop();
@@ -99,10 +99,10 @@
 
         // Throws exception b/c 2 video tracks were added.
         muxer = new MediaMuxer(outputFile, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
-        muxer.addTrack(MediaFormat.createVideoFormat("video/mp4", 480, 320));
+        muxer.addTrack(MediaFormat.createVideoFormat("video/avc", 480, 320));
 
         try {
-            muxer.addTrack(MediaFormat.createVideoFormat("video/mp4", 480, 320));
+            muxer.addTrack(MediaFormat.createVideoFormat("video/avc", 480, 320));
             fail("should throw IllegalStateException.");
         } catch (IllegalStateException e) {
             // expected
@@ -110,9 +110,9 @@
 
         // Throws exception b/c 2 audio tracks were added.
         muxer = new MediaMuxer(outputFile, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
-        muxer.addTrack(MediaFormat.createAudioFormat("audio/mp4", 48000, 1));
+        muxer.addTrack(MediaFormat.createAudioFormat("audio/mp4a-latm", 48000, 1));
         try {
-            muxer.addTrack(MediaFormat.createAudioFormat("audio/mp4", 48000, 1));
+            muxer.addTrack(MediaFormat.createAudioFormat("audio/mp4a-latm", 48000, 1));
             fail("should throw IllegalStateException.");
         } catch (IllegalStateException e) {
             // expected
@@ -120,11 +120,11 @@
 
         // Throws exception b/c 3 tracks were added.
         muxer = new MediaMuxer(outputFile, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);
-        muxer.addTrack(MediaFormat.createVideoFormat("video/mp4", 480, 320));
-        muxer.addTrack(MediaFormat.createAudioFormat("audio/mp4", 48000, 1));
+        muxer.addTrack(MediaFormat.createVideoFormat("video/avc", 480, 320));
+        muxer.addTrack(MediaFormat.createAudioFormat("audio/mp4a-latm", 48000, 1));
         try {
 
-            muxer.addTrack(MediaFormat.createVideoFormat("video/mp4", 480, 320));
+            muxer.addTrack(MediaFormat.createVideoFormat("video/avc", 480, 320));
             fail("should throw IllegalStateException.");
         } catch (IllegalStateException e) {
             // expected
@@ -154,7 +154,7 @@
      * Using the MediaMuxer to clone a media file.
      */
     private void cloneMediaUsingMuxer(int srcMedia, String dstMediaPath,
-            int expectedTrackCount) throws IOException {
+            int expectedTrackCount, int degrees) throws IOException {
         // Set up MediaExtractor to read from the source.
         AssetFileDescriptor srcFd = mResources.openRawResourceFd(srcMedia);
         MediaExtractor extractor = new MediaExtractor();
@@ -185,6 +185,10 @@
 
         ByteBuffer dstBuf = ByteBuffer.allocate(bufferSize);
         BufferInfo bufferInfo = new BufferInfo();
+
+        if (degrees >= 0) {
+            muxer.setOrientationHint(degrees);
+        }
         muxer.start();
         while (!sawEOS) {
             bufferInfo.offset = offset;
@@ -227,10 +231,10 @@
      * sure they match.
      */
     private void cloneAndVerify(int srcMedia, String outputMediaFile,
-            int expectedTrackCount) throws IOException {
+            int expectedTrackCount, int degrees) throws IOException {
         try {
-            cloneMediaUsingMuxer(srcMedia, outputMediaFile, expectedTrackCount);
-            verifyAttributesMatch(srcMedia, outputMediaFile);
+            cloneMediaUsingMuxer(srcMedia, outputMediaFile, expectedTrackCount, degrees);
+            verifyAttributesMatch(srcMedia, outputMediaFile, degrees);
             // Check the sample on 1s and 0.5s.
             verifySamplesMatch(srcMedia, outputMediaFile, 1000000);
             verifySamplesMatch(srcMedia, outputMediaFile, 500000);
@@ -240,51 +244,50 @@
     }
 
     /**
-     * Compares some attributes using MediaPlayer to make sure the cloned
-     * media file matches the source file.
+     * Compares some attributes using MediaMetadataRetriever to make sure the
+     * cloned media file matches the source file.
      */
-    private void verifyAttributesMatch(int srcMedia, String testMediaPath) {
+    private void verifyAttributesMatch(int srcMedia, String testMediaPath,
+            int degrees) {
         AssetFileDescriptor testFd = mResources.openRawResourceFd(srcMedia);
-        MediaPlayer playerSrc = new MediaPlayer();
-        MediaPlayer playerTest = new MediaPlayer();
-        try {
-            playerSrc.setDataSource(testFd.getFileDescriptor(),
-                    testFd.getStartOffset(), testFd.getLength());
-            playerTest.setDataSource(testMediaPath);
 
-            playerSrc.prepare();
-            playerTest.prepare();
+        MediaMetadataRetriever retrieverSrc = new MediaMetadataRetriever();
+        retrieverSrc.setDataSource(testFd.getFileDescriptor(),
+                testFd.getStartOffset(), testFd.getLength());
 
-            int durationSrc = playerSrc.getDuration();
-            int durationTest = playerTest.getDuration();
+        MediaMetadataRetriever retrieverTest = new MediaMetadataRetriever();
+        retrieverTest.setDataSource(testMediaPath);
 
-            int heightSrc = playerSrc.getVideoHeight();
-            int heightTest = playerTest.getVideoHeight();
-
-            int widthSrc = playerSrc.getVideoWidth();
-            int widthTest = playerTest.getVideoWidth();
-
-            if (VERBOSE) {
-                Log.d(TAG, "Source video info : width " + widthSrc + " height "
-                        + heightSrc + " duration " + durationSrc);
-                Log.d(TAG, "Test video info : width " + widthTest + " height "
-                        + heightTest + " duration " + durationTest);
-            }
-
-            assertEquals("Different duration", durationSrc, durationTest);
-            assertEquals("Different height", heightSrc, heightTest);
-            assertEquals("Different width", widthSrc, widthTest);
-
-            playerSrc.stop();
-            playerTest.stop();
-
-            playerSrc.release();
-            playerTest.release();
-        } catch (Exception e) {
-            // Don't expect seeing any exception here.
-            assertTrue("verifyTwoVideos failed!", false);
+        String testDegrees = retrieverTest.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
+        if (testDegrees != null) {
+            assertEquals("Different degrees", degrees,
+                    Integer.parseInt(testDegrees));
         }
 
+        String heightSrc = retrieverSrc.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
+        String heightTest = retrieverTest.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
+        assertEquals("Different height", heightSrc,
+                heightTest);
+
+        String widthSrc = retrieverSrc.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
+        String widthTest = retrieverTest.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
+        assertEquals("Different height", widthSrc,
+                widthTest);
+
+        String durationSrc = retrieverSrc.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
+        String durationTest = retrieverTest.extractMetadata(
+                MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
+        assertEquals("Different height", durationSrc,
+                durationTest);
+
+        retrieverSrc.release();
+        retrieverTest.release();
     }
 
     /**
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
index 16dc57d..8719b6b 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
@@ -122,7 +122,13 @@
         assertNotNull(wifiInfo.toString());
         SupplicantState.isValidState(wifiInfo.getSupplicantState());
         WifiInfo.getDetailedStateOf(SupplicantState.DISCONNECTED);
-        wifiInfo.getSSID();
+        String ssid = wifiInfo.getSSID();
+        if (ssid.startsWith("0x") == false) {
+            // Non-hex string should be quoted
+            assertTrue(ssid.charAt(0) == '"');
+            assertTrue(ssid.charAt(ssid.length() - 1) == '"');
+        }
+
         wifiInfo.getBSSID();
         wifiInfo.getIpAddress();
         wifiInfo.getLinkSpeed();
diff --git a/tests/tests/os/src/android/os/cts/SeccompTest.java b/tests/tests/os/src/android/os/cts/SeccompTest.java
deleted file mode 100644
index 6842582..0000000
--- a/tests/tests/os/src/android/os/cts/SeccompTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.os.cts;
-
-import junit.framework.TestCase;
-
-public class SeccompTest extends TestCase {
-
-    /**
-     * Verify that seccomp is enabled in Linux kernel versions
-     * 3.5 and greater.
-     *
-     * IMPORTANT NOTE: If you are running an ARM kernel between
-     * version 3.5 and 3.8, you will need to apply the following patches:
-     *
-     *   ARM: 7580/1: arch/select HAVE_ARCH_SECCOMP_FILTER
-     *   http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4095ccc
-     *
-     *   ARM: 7579/1: arch/allow a scno of -1 to not cause a SIGILL
-     *   http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ad75b51
-     *
-     *   ARM: 7578/1: arch/move secure_computing into trace
-     *   http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=9b790d7
-     *
-     *   ARM: 7577/1: arch/add syscall_get_arch
-     *   http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=1f59d13
-     */
-    public void testSeccomp() {
-        if (OSFeatures.needsSeccompSupport()) {
-            assertTrue("Please enable seccomp support in your kernel "
-                       + "(CONFIG_SECCOMP_FILTER=y). Please see CTS "
-                       + "test javadocs for important details.",
-                       OSFeatures.hasSeccompSupport());
-        }
-    }
-}
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 28dc766..c5c158f 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -564,49 +564,21 @@
         }
     }
 
-    // This set contains all exceptions for writable sysfs, if it is a
-    // directory, all files below that directory are included, so be
-    // careful.
-    private static final Set<String> SYS_EXCEPTIONS = new HashSet<String>(
+    private static final Set<File> SYS_EXCEPTIONS = new HashSet<File>(
             Arrays.asList(
-                "/sys/kernel/debug/tracing/trace_marker",
-                "/sys/fs/selinux"
+                new File("/sys/kernel/debug/tracing/trace_marker"),
+                new File("/sys/fs/selinux/member"),
+                new File("/sys/fs/selinux/user"),
+                new File("/sys/fs/selinux/relabel"),
+                new File("/sys/fs/selinux/create"),
+                new File("/sys/fs/selinux/access"),
+                new File("/sys/fs/selinux/context")
             ));
 
-    private static Set <File> getIgnorablesFromPaths(Set <String> paths) {
-
-        Set <File> ignorable = new HashSet <File> ();
-
-        for(String ignore : paths) {
-               File tmp = new File(ignore);
-
-               File[] files = null;
-               if(tmp.isDirectory()) {
-                    files = tmp.listFiles(new FileFilter() {
-                       @Override public boolean accept(File pathname) {
-                           return pathname.isFile();
-                       }
-                   });
-               }
-               else if(tmp.isFile()){
-                   files = new File[1];
-                   files [0] = tmp;
-               }
-               else {
-                   // Should this be an Exception?
-                   continue;
-               }
-               ignorable.addAll(Arrays.asList(files));
-        }
-        return ignorable;
-    }
-
     @LargeTest
     public void testAllFilesInSysAreNotWritable() throws Exception {
         Set<File> writable = getAllWritableFilesInDirAndSubDir(new File("/sys"));
-        Set<File> ignorables = getIgnorablesFromPaths(SYS_EXCEPTIONS);
-
-        writable.removeAll(ignorables);
+        writable.removeAll(SYS_EXCEPTIONS);
         assertTrue("Found writable: " + writable.toString(),
                 writable.isEmpty());
     }
diff --git a/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java b/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
index 3aa8f35..b249b9e 100644
--- a/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
+++ b/tests/tests/text/src/android/text/cts/StaticLayoutLineBreakingTest.java
@@ -49,7 +49,7 @@
         @Override
         public float getTextRunAdvances(char[] chars, int index, int count,
                 int contextIndex, int contextCount, int flags, float[] advances,
-                int advancesIndex, int reserved) {
+                int advancesIndex) {
 
             // Conditions copy pasted from Paint
             if (chars == null) {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 6f61874..7acc3cd 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -731,7 +731,10 @@
         // Snippet of HTML that will prevent favicon requests to the test server.
         final String HTML_HEADER = "<html><head><link rel=\"shortcut icon\" href=\"#\" /></head>";
 
-        // Check that we can access relative URLs and that reported URL is supplied history URL.
+        // Trying to resolve a relative URL against a data URL without a base URL
+        // will fail and we won't make a request to the test web server.
+        // By using the test web server as the base URL we expect to see a request
+        // for the relative URL in the test server.
         startWebServer(false);
         String baseUrl = mWebServer.getAssetUrl("foo.html");
         String historyUrl = "http://www.example.com/";
@@ -739,7 +742,8 @@
         mOnUiThread.loadDataWithBaseURLAndWaitForCompletion(baseUrl,
                 HTML_HEADER + "<body><img src=\"" + imgUrl + "\"/></body></html>",
                 "text/html", "UTF-8", historyUrl);
-        assertTrue("last request is " + mWebServer.getLastRequestUrl(), mWebServer.getLastRequestUrl().endsWith(imgUrl));
+        // Verify that the resource request makes it to the server.
+        assertTrue(mWebServer.wasResourceRequested(imgUrl));
         assertEquals(historyUrl, mWebView.getUrl());
 
         // Check that reported URL is "about:blank" when supplied history URL
@@ -748,7 +752,7 @@
         mOnUiThread.loadDataWithBaseURLAndWaitForCompletion(baseUrl,
                 HTML_HEADER + "<body><img src=\"" + imgUrl + "\"/></body></html>",
                 "text/html", "UTF-8", null);
-        assertTrue("last request is " + mWebServer.getLastRequestUrl(), mWebServer.getLastRequestUrl().endsWith(imgUrl));
+        assertTrue(mWebServer.wasResourceRequested(imgUrl));
         assertEquals("about:blank", mWebView.getUrl());
 
         // Test that JavaScript can access content from the same origin as the base URL.
diff --git a/tools/device-setup/TestDeviceSetup/Android.mk b/tools/device-setup/TestDeviceSetup/Android.mk
index 5642736..f6c1079 100644
--- a/tools/device-setup/TestDeviceSetup/Android.mk
+++ b/tools/device-setup/TestDeviceSetup/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := 16
 
 LOCAL_PACKAGE_NAME := TestDeviceSetup
 
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index 6c8959c..3cb986f 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -146,7 +146,8 @@
     plan.Include('android\.bluetooth')
     plan.Include('android\.graphics.*')
     plan.Include('android\.hardware')
-    plan.Include('android\.media.*')
+    plan.Include('android\.media')
+    plan.Exclude('android\.mediastress')
     plan.Include('android\.net')
     plan.Include('android\.opengl.*')
     plan.Include('android\.renderscript')
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index bd688fe..20429f0 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -576,14 +576,6 @@
         }
 
         // find the @title/@constraint in javadoc comment for this method
-        Scanner scanner2;
-        try {
-            // using platform's default charset
-            scanner2 = new Scanner(f);
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("error while reading to file: " + e.getClass().getName() +
-                    ", msg:" + e.getMessage());
-        }
         // using platform's default charset
         String all = new String(FileUtils.readFile(f));
         // System.out.println("grepping javadoc found for method " + method +
@@ -630,9 +622,6 @@
         if (scanner != null) {
             scanner.close();
         }
-        if (scanner2 != null) {
-            scanner2.close();
-        }
         return md;
     }