Fix MediaDrm cts tests

Moving the build of the mock MediaDrm plugin back to
frameworks/av since it can't be installed by cts.

b/10668350

Change-Id: Ic3b3c23de8993577b56ae86a553dcada0b61c606
diff --git a/tests/tests/media/Android.mk b/tests/tests/media/Android.mk
index c116162..f7639a4 100644
--- a/tests/tests/media/Android.mk
+++ b/tests/tests/media/Android.mk
@@ -28,9 +28,6 @@
 
 LOCAL_PACKAGE_NAME := CtsMediaTestCases
 
-LOCAL_JNI_SHARED_LIBRARIES := libmockdrmcryptoplugin
-
-
 # uncomment when dalvik.annotation.Test* are removed or part of SDK
 #LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java b/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
index c0350d7..a09d368 100644
--- a/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaDrmMockTest.java
@@ -41,7 +41,7 @@
     static final UUID mockScheme = new UUID(0x0102030405060708L, 0x090a0b0c0d0e0f10L);
     static final UUID badScheme = new UUID(0xffffffffffffffffL, 0xffffffffffffffffL);
 
-    private boolean testIsCryptoSchemeSupported() {
+    private boolean isMockPluginInstalled() {
         return MediaDrm.isCryptoSchemeSupported(mockScheme);
     }
 
@@ -49,27 +49,36 @@
         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 testIsMimeTypeSupported() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
         String mimeType = "video/mp4";
         assertTrue(MediaDrm.isCryptoSchemeSupported(mockScheme, mimeType));
     }
 
     public void testIsMimeTypeNotSupported() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
         String mimeType = "video/foo";
         assertFalse(MediaDrm.isCryptoSchemeSupported(mockScheme, mimeType));
     }
 
-    public void testMediaDrmConstructor() throws Exception {
-        boolean gotException = false;
-        try {
-            MediaDrm md = new MediaDrm(mockScheme);
-        } catch (MediaDrmException e) {
-            gotException = true;
-        }
-        assertFalse(gotException);
-    }
-
     public void testMediaDrmConstructorFails() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         boolean gotException = false;
         try {
             MediaDrm md = new MediaDrm(badScheme);
@@ -80,6 +89,10 @@
     }
 
     public void testStringProperties() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         md.setPropertyString("test-string", "test-value");
@@ -87,6 +100,10 @@
     }
 
     public void testByteArrayProperties() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte testArray[] = {0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x10, 0x11, 0x12};
@@ -95,6 +112,10 @@
     }
 
     public void testMissingPropertyString() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         boolean gotException = false;
@@ -107,6 +128,10 @@
     }
 
     public void testNullPropertyString() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         boolean gotException = false;
@@ -119,6 +144,10 @@
     }
 
     public void testMissingPropertyByteArray() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         boolean gotException = false;
@@ -131,6 +160,10 @@
     }
 
     public void testNullPropertyByteArray() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         boolean gotException = false;
@@ -143,12 +176,20 @@
     }
 
     public void testOpenCloseSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
         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;
@@ -161,6 +202,10 @@
     }
 
     public void testNullSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = null;
         boolean gotException = false;
@@ -173,6 +218,10 @@
     }
 
     public void testGetKeyRequest() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -203,6 +252,10 @@
     }
 
     public void testGetKeyRequestNoOptionalParameters() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -229,6 +282,10 @@
     }
 
     public void testGetKeyRequestOffline() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -255,6 +312,10 @@
     }
 
     public void testGetKeyRequestRelease() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -278,6 +339,10 @@
     }
 
     public void testProvideKeyResponse() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -291,6 +356,10 @@
     }
 
     public void testRemoveKeys() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -302,6 +371,10 @@
     }
 
     public void testRestoreKeys() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
 
@@ -315,6 +388,10 @@
     }
 
     public void testQueryKeyStatus() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
         byte[] sessionId = openSession(md);
         HashMap<String, String> infoMap = md.queryKeyStatus(sessionId);
@@ -329,6 +406,10 @@
     }
 
     public void testGetProvisionRequest() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         // Set up mock expected responses using properties
@@ -343,6 +424,10 @@
     }
 
     public void testProvideProvisionResponse() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         // Set up mock expected responses using properties
@@ -353,6 +438,10 @@
     }
 
     public void testGetSecureStops() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         // Set up mock expected responses using properties
@@ -374,6 +463,10 @@
     }
 
     public void testReleaseSecureStops() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         // Set up mock expected responses using properties
@@ -384,6 +477,10 @@
     }
 
     public void testMultipleSessions() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte[] session1 = openSession(md);
@@ -399,6 +496,10 @@
     }
 
     public void testCryptoSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte[] sessionId = openSession(md);
@@ -407,6 +508,10 @@
     }
 
     public void testBadCryptoSession() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         boolean gotException = false;
@@ -420,6 +525,10 @@
     }
 
     public void testCryptoSessionEncrypt() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte[] sessionId = openSession(md);
@@ -442,6 +551,10 @@
     }
 
     public void testCryptoSessionDecrypt() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte[] sessionId = openSession(md);
@@ -464,6 +577,10 @@
     }
 
     public void testCryptoSessionSign() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte[] sessionId = openSession(md);
@@ -484,6 +601,10 @@
     }
 
     public void testCryptoSessionVerify() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
         MediaDrm md = new MediaDrm(mockScheme);
 
         byte[] sessionId = openSession(md);
@@ -511,6 +632,10 @@
     private boolean mGotEvent = false;
 
     public void testEventNoSessionNoData() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
 
         new Thread() {
             @Override
@@ -577,6 +702,10 @@
     }
 
     public void testEventWithSessionAndData() throws Exception {
+        if (!isMockPluginInstalled()) {
+            return;
+        }
+
 
         new Thread() {
             @Override
diff --git a/tests/tests/mediadrm/Android.mk b/tests/tests/mediadrm/Android.mk
deleted file mode 100644
index ef8c633..0000000
--- a/tests/tests/mediadrm/Android.mk
+++ /dev/null
@@ -1,17 +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 $(call all-subdir-makefiles)
-
-
diff --git a/tests/tests/mediadrm/lib/Android.mk b/tests/tests/mediadrm/lib/Android.mk
deleted file mode 100644
index 42a5e1b..0000000
--- a/tests/tests/mediadrm/lib/Android.mk
+++ /dev/null
@@ -1,35 +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.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
-    MockDrmCryptoPlugin.cpp
-
-LOCAL_MODULE := libmockdrmcryptoplugin
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)/mediadrm
-
-LOCAL_SHARED_LIBRARIES := \
-    libutils liblog
-
-LOCAL_C_INCLUDES += \
-    $(TOP)/frameworks/av/include \
-    $(TOP)/frameworks/native/include/media
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/mediadrm/lib/MockDrmCryptoPlugin.cpp b/tests/tests/mediadrm/lib/MockDrmCryptoPlugin.cpp
deleted file mode 100644
index f2cadf7..0000000
--- a/tests/tests/mediadrm/lib/MockDrmCryptoPlugin.cpp
+++ /dev/null
@@ -1,705 +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.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "MockDrmCryptoPlugin"
-#include <utils/Log.h>
-
-
-#include "drm/DrmAPI.h"
-#include "MockDrmCryptoPlugin.h"
-#include "media/stagefright/MediaErrors.h"
-
-using namespace android;
-
-// Shared library entry point
-DrmFactory *createDrmFactory()
-{
-    return new MockDrmFactory();
-}
-
-// Shared library entry point
-CryptoFactory *createCryptoFactory()
-{
-    return new MockCryptoFactory();
-}
-
-const uint8_t mock_uuid[16] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
-                               0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
-
-namespace android {
-
-    // MockDrmFactory
-    bool MockDrmFactory::isCryptoSchemeSupported(const uint8_t uuid[16])
-    {
-        return (!memcmp(uuid, mock_uuid, sizeof(uuid)));
-    }
-
-    bool MockDrmFactory::isContentTypeSupported(const String8 &mimeType)
-    {
-        if (mimeType != "video/mp4") {
-            return false;
-        }
-        return true;
-    }
-
-    status_t MockDrmFactory::createDrmPlugin(const uint8_t uuid[16], DrmPlugin **plugin)
-    {
-        *plugin = new MockDrmPlugin();
-        return OK;
-    }
-
-    // MockCryptoFactory
-    bool MockCryptoFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) const
-    {
-        return (!memcmp(uuid, mock_uuid, sizeof(uuid)));
-    }
-
-    status_t MockCryptoFactory::createPlugin(const uint8_t uuid[16], const void *data,
-                                             size_t size, CryptoPlugin **plugin)
-    {
-        *plugin = new MockCryptoPlugin();
-        return OK;
-    }
-
-
-    // MockDrmPlugin methods
-
-    status_t MockDrmPlugin::openSession(Vector<uint8_t> &sessionId)
-    {
-        const size_t kSessionIdSize = 8;
-
-        Mutex::Autolock lock(mLock);
-        for (size_t i = 0; i < kSessionIdSize / sizeof(long); i++) {
-            long r = random();
-            sessionId.appendArray((uint8_t *)&r, sizeof(long));
-        }
-        mSessions.add(sessionId);
-
-        ALOGD("MockDrmPlugin::openSession() -> %s", vectorToString(sessionId).string());
-        return OK;
-    }
-
-    status_t MockDrmPlugin::closeSession(Vector<uint8_t> const &sessionId)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::closeSession(%s)", vectorToString(sessionId).string());
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-        mSessions.removeAt(index);
-        return OK;
-    }
-
-
-    status_t MockDrmPlugin::getKeyRequest(Vector<uint8_t> const &sessionId,
-                                          Vector<uint8_t> const &initData,
-                                          String8 const &mimeType, KeyType keyType,
-                                          KeyedVector<String8, String8> const &optionalParameters,
-                                          Vector<uint8_t> &request, String8 &defaultUrl)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::getKeyRequest(sessionId=%s, initData=%s, mimeType=%s"
-              ", keyType=%d, optionalParameters=%s))",
-              vectorToString(sessionId).string(), vectorToString(initData).string(), mimeType.string(),
-              keyType, stringMapToString(optionalParameters).string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] initData           -> mock-initdata
-        //   string mimeType           -> mock-mimetype
-        //   string keyType            -> mock-keytype
-        //   string optionalParameters -> mock-optparams formatted as {key1,value1},{key2,value2}
-
-        mByteArrayProperties.add(String8("mock-initdata"), initData);
-        mStringProperties.add(String8("mock-mimetype"), mimeType);
-
-        String8 keyTypeStr;
-        keyTypeStr.appendFormat("%d", (int)keyType);
-        mStringProperties.add(String8("mock-keytype"), keyTypeStr);
-
-        String8 params;
-        for (size_t i = 0; i < optionalParameters.size(); i++) {
-            params.appendFormat("%s{%s,%s}", i ? "," : "",
-                                optionalParameters.keyAt(i).string(),
-                                optionalParameters.valueAt(i).string());
-        }
-        mStringProperties.add(String8("mock-optparams"), params);
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   byte[] mock-request       -> request
-        //   string mock-default-url   -> defaultUrl
-
-        index = mByteArrayProperties.indexOfKey(String8("mock-request"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-request' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            request = mByteArrayProperties.valueAt(index);
-        }
-
-        index = mStringProperties.indexOfKey(String8("mock-defaultUrl"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-defaultUrl' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            defaultUrl = mStringProperties.valueAt(index);
-        }
-        return OK;
-    }
-
-    status_t MockDrmPlugin::provideKeyResponse(Vector<uint8_t> const &sessionId,
-                                               Vector<uint8_t> const &response,
-                                               Vector<uint8_t> &keySetId)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::provideKeyResponse(sessionId=%s, response=%s)",
-              vectorToString(sessionId).string(), vectorToString(response).string());
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-        if (response.size() == 0) {
-            return BAD_VALUE;
-        }
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] response            -> mock-response
-        mByteArrayProperties.add(String8("mock-response"), response);
-
-        const size_t kKeySetIdSize = 8;
-
-        for (size_t i = 0; i < kKeySetIdSize / sizeof(long); i++) {
-            long r = random();
-            keySetId.appendArray((uint8_t *)&r, sizeof(long));
-        }
-        mKeySets.add(keySetId);
-
-        return OK;
-    }
-
-    status_t MockDrmPlugin::removeKeys(Vector<uint8_t> const &keySetId)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::removeKeys(keySetId=%s)",
-              vectorToString(keySetId).string());
-
-        ssize_t index = findKeySet(keySetId);
-        if (index == kNotFound) {
-            ALOGD("Invalid keySetId");
-            return BAD_VALUE;
-        }
-        mKeySets.removeAt(index);
-
-        return OK;
-    }
-
-    status_t MockDrmPlugin::restoreKeys(Vector<uint8_t> const &sessionId,
-                                        Vector<uint8_t> const &keySetId)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::restoreKeys(sessionId=%s, keySetId=%s)",
-              vectorToString(sessionId).string(),
-              vectorToString(keySetId).string());
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        index = findKeySet(keySetId);
-        if (index == kNotFound) {
-            ALOGD("Invalid keySetId");
-            return BAD_VALUE;
-        }
-
-        return OK;
-    }
-
-    status_t MockDrmPlugin::queryKeyStatus(Vector<uint8_t> const &sessionId,
-                                               KeyedVector<String8, String8> &infoMap) const
-    {
-        ALOGD("MockDrmPlugin::queryKeyStatus(sessionId=%s)",
-              vectorToString(sessionId).string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        infoMap.add(String8("purchaseDuration"), String8("1000"));
-        infoMap.add(String8("licenseDuration"), String8("100"));
-        return OK;
-    }
-
-    status_t MockDrmPlugin::getProvisionRequest(Vector<uint8_t> &request,
-                                                String8 &defaultUrl)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::getProvisionRequest()");
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   byte[] mock-request       -> request
-        //   string mock-default-url   -> defaultUrl
-
-        ssize_t index = mByteArrayProperties.indexOfKey(String8("mock-request"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-request' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            request = mByteArrayProperties.valueAt(index);
-        }
-
-        index = mStringProperties.indexOfKey(String8("mock-defaultUrl"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-defaultUrl' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            defaultUrl = mStringProperties.valueAt(index);
-        }
-        return OK;
-    }
-
-    status_t MockDrmPlugin::provideProvisionResponse(Vector<uint8_t> const &response)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::provideProvisionResponse(%s)",
-              vectorToString(response).string());
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] response            -> mock-response
-
-        mByteArrayProperties.add(String8("mock-response"), response);
-        return OK;
-    }
-
-    status_t MockDrmPlugin::getSecureStops(List<Vector<uint8_t> > &secureStops)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::getSecureStops()");
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   byte[] mock-secure-stop1  -> first secure stop in list
-        //   byte[] mock-secure-stop2  -> second secure stop in list
-
-        Vector<uint8_t> ss1, ss2;
-        ssize_t index = mByteArrayProperties.indexOfKey(String8("mock-secure-stop1"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-secure-stop1' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            ss1 = mByteArrayProperties.valueAt(index);
-        }
-
-        index = mByteArrayProperties.indexOfKey(String8("mock-secure-stop2"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-secure-stop2' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            ss2 = mByteArrayProperties.valueAt(index);
-        }
-
-        secureStops.push_back(ss1);
-        secureStops.push_back(ss2);
-        return OK;
-    }
-
-    status_t MockDrmPlugin::releaseSecureStops(Vector<uint8_t> const &ssRelease)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::releaseSecureStops(%s)",
-              vectorToString(ssRelease).string());
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] secure-stop-release  -> mock-ssrelease
-        mByteArrayProperties.add(String8("mock-ssrelease"), ssRelease);
-
-        return OK;
-    }
-
-    status_t MockDrmPlugin::getPropertyString(String8 const &name, String8 &value) const
-    {
-        ALOGD("MockDrmPlugin::getPropertyString(name=%s)", name.string());
-        ssize_t index = mStringProperties.indexOfKey(name);
-        if (index < 0) {
-            ALOGD("no property for '%s'", name.string());
-            return BAD_VALUE;
-        }
-        value = mStringProperties.valueAt(index);
-        return OK;
-    }
-
-    status_t MockDrmPlugin::getPropertyByteArray(String8 const &name,
-                                                 Vector<uint8_t> &value) const
-    {
-        ALOGD("MockDrmPlugin::getPropertyByteArray(name=%s)", name.string());
-        ssize_t index = mByteArrayProperties.indexOfKey(name);
-        if (index < 0) {
-            ALOGD("no property for '%s'", name.string());
-            return BAD_VALUE;
-        }
-        value = mByteArrayProperties.valueAt(index);
-        return OK;
-    }
-
-    status_t MockDrmPlugin::setPropertyString(String8 const &name,
-                                              String8 const &value)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::setPropertyString(name=%s, value=%s)",
-              name.string(), value.string());
-
-        if (name == "mock-send-event") {
-            unsigned code, extra;
-            sscanf(value.string(), "%d %d", &code, &extra);
-            DrmPlugin::EventType eventType = (DrmPlugin::EventType)code;
-
-            Vector<uint8_t> const *pSessionId = NULL;
-            ssize_t index = mByteArrayProperties.indexOfKey(String8("mock-event-session-id"));
-            if (index >= 0) {
-                pSessionId = &mByteArrayProperties[index];
-            }
-
-            Vector<uint8_t> const *pData = NULL;
-            index = mByteArrayProperties.indexOfKey(String8("mock-event-data"));
-            if (index >= 0) {
-                pData = &mByteArrayProperties[index];
-            }
-            ALOGD("sending event from mock drm plugin: %d %d %s %s",
-                  (int)code, extra, pSessionId ? vectorToString(*pSessionId) : "{}",
-                  pData ? vectorToString(*pData) : "{}");
-
-            sendEvent(eventType, extra, pSessionId, pData);
-        } else {
-            mStringProperties.add(name, value);
-        }
-        return OK;
-    }
-
-    status_t MockDrmPlugin::setPropertyByteArray(String8 const &name,
-                                                 Vector<uint8_t> const &value)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::setPropertyByteArray(name=%s, value=%s)",
-              name.string(), vectorToString(value).string());
-        mByteArrayProperties.add(name, value);
-        return OK;
-    }
-
-    status_t MockDrmPlugin::setCipherAlgorithm(Vector<uint8_t> const &sessionId,
-                                               String8 const &algorithm)
-    {
-        Mutex::Autolock lock(mLock);
-
-        ALOGD("MockDrmPlugin::setCipherAlgorithm(sessionId=%s, algorithm=%s)",
-              vectorToString(sessionId).string(), algorithm.string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        if (algorithm == "AES/CBC/NoPadding") {
-            return OK;
-        }
-        return BAD_VALUE;
-    }
-
-    status_t MockDrmPlugin::setMacAlgorithm(Vector<uint8_t> const &sessionId,
-                                            String8 const &algorithm)
-    {
-        Mutex::Autolock lock(mLock);
-
-        ALOGD("MockDrmPlugin::setMacAlgorithm(sessionId=%s, algorithm=%s)",
-              vectorToString(sessionId).string(), algorithm.string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        if (algorithm == "HmacSHA256") {
-            return OK;
-        }
-        return BAD_VALUE;
-    }
-
-    status_t MockDrmPlugin::encrypt(Vector<uint8_t> const &sessionId,
-                                    Vector<uint8_t> const &keyId,
-                                    Vector<uint8_t> const &input,
-                                    Vector<uint8_t> const &iv,
-                                    Vector<uint8_t> &output)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::encrypt(sessionId=%s, keyId=%s, input=%s, iv=%s)",
-              vectorToString(sessionId).string(),
-              vectorToString(keyId).string(),
-              vectorToString(input).string(),
-              vectorToString(iv).string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] keyId              -> mock-keyid
-        //   byte[] input              -> mock-input
-        //   byte[] iv                 -> mock-iv
-        mByteArrayProperties.add(String8("mock-keyid"), keyId);
-        mByteArrayProperties.add(String8("mock-input"), input);
-        mByteArrayProperties.add(String8("mock-iv"), iv);
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   byte[] mock-output        -> output
-        index = mByteArrayProperties.indexOfKey(String8("mock-output"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-request' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            output = mByteArrayProperties.valueAt(index);
-        }
-        return OK;
-    }
-
-    status_t MockDrmPlugin::decrypt(Vector<uint8_t> const &sessionId,
-                                    Vector<uint8_t> const &keyId,
-                                    Vector<uint8_t> const &input,
-                                    Vector<uint8_t> const &iv,
-                                    Vector<uint8_t> &output)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::decrypt(sessionId=%s, keyId=%s, input=%s, iv=%s)",
-              vectorToString(sessionId).string(),
-              vectorToString(keyId).string(),
-              vectorToString(input).string(),
-              vectorToString(iv).string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] keyId              -> mock-keyid
-        //   byte[] input              -> mock-input
-        //   byte[] iv                 -> mock-iv
-        mByteArrayProperties.add(String8("mock-keyid"), keyId);
-        mByteArrayProperties.add(String8("mock-input"), input);
-        mByteArrayProperties.add(String8("mock-iv"), iv);
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   byte[] mock-output        -> output
-        index = mByteArrayProperties.indexOfKey(String8("mock-output"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-request' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            output = mByteArrayProperties.valueAt(index);
-        }
-        return OK;
-    }
-
-    status_t MockDrmPlugin::sign(Vector<uint8_t> const &sessionId,
-                                 Vector<uint8_t> const &keyId,
-                                 Vector<uint8_t> const &message,
-                                 Vector<uint8_t> &signature)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::sign(sessionId=%s, keyId=%s, message=%s)",
-              vectorToString(sessionId).string(),
-              vectorToString(keyId).string(),
-              vectorToString(message).string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] keyId              -> mock-keyid
-        //   byte[] message            -> mock-message
-        mByteArrayProperties.add(String8("mock-keyid"), keyId);
-        mByteArrayProperties.add(String8("mock-message"), message);
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   byte[] mock-signature        -> signature
-        index = mByteArrayProperties.indexOfKey(String8("mock-signature"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-request' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            signature = mByteArrayProperties.valueAt(index);
-        }
-        return OK;
-    }
-
-    status_t MockDrmPlugin::verify(Vector<uint8_t> const &sessionId,
-                                   Vector<uint8_t> const &keyId,
-                                   Vector<uint8_t> const &message,
-                                   Vector<uint8_t> const &signature,
-                                   bool &match)
-    {
-        Mutex::Autolock lock(mLock);
-        ALOGD("MockDrmPlugin::verify(sessionId=%s, keyId=%s, message=%s, signature=%s)",
-              vectorToString(sessionId).string(),
-              vectorToString(keyId).string(),
-              vectorToString(message).string(),
-              vectorToString(signature).string());
-
-        ssize_t index = findSession(sessionId);
-        if (index == kNotFound) {
-            ALOGD("Invalid sessionId");
-            return BAD_VALUE;
-        }
-
-        // Properties used in mock test, set by mock plugin and verifed cts test app
-        //   byte[] keyId              -> mock-keyid
-        //   byte[] message            -> mock-message
-        //   byte[] signature          -> mock-signature
-        mByteArrayProperties.add(String8("mock-keyid"), keyId);
-        mByteArrayProperties.add(String8("mock-message"), message);
-        mByteArrayProperties.add(String8("mock-signature"), signature);
-
-        // Properties used in mock test, set by cts test app returned from mock plugin
-        //   String mock-match "1" or "0"         -> match
-        index = mStringProperties.indexOfKey(String8("mock-match"));
-        if (index < 0) {
-            ALOGD("Missing 'mock-request' parameter for mock");
-            return BAD_VALUE;
-        } else {
-            match = atol(mStringProperties.valueAt(index).string());
-        }
-        return OK;
-    }
-
-    ssize_t MockDrmPlugin::findSession(Vector<uint8_t> const &sessionId) const
-    {
-        ALOGD("findSession: nsessions=%d, size=%d", mSessions.size(), sessionId.size());
-        for (size_t i = 0; i < mSessions.size(); ++i) {
-            if (memcmp(mSessions[i].array(), sessionId.array(), sessionId.size()) == 0) {
-                return i;
-            }
-        }
-        return kNotFound;
-    }
-
-    ssize_t MockDrmPlugin::findKeySet(Vector<uint8_t> const &keySetId) const
-    {
-        ALOGD("findKeySet: nkeySets=%d, size=%d", mKeySets.size(), keySetId.size());
-        for (size_t i = 0; i < mKeySets.size(); ++i) {
-            if (memcmp(mKeySets[i].array(), keySetId.array(), keySetId.size()) == 0) {
-                return i;
-            }
-        }
-        return kNotFound;
-    }
-
-
-    // Conversion utilities
-    String8 MockDrmPlugin::vectorToString(Vector<uint8_t> const &vector) const
-    {
-        return arrayToString(vector.array(), vector.size());
-    }
-
-    String8 MockDrmPlugin::arrayToString(uint8_t const *array, size_t len) const
-    {
-        String8 result("{ ");
-        for (size_t i = 0; i < len; i++) {
-            result.appendFormat("0x%02x ", array[i]);
-        }
-        result += "}";
-        return result;
-    }
-
-    String8 MockDrmPlugin::stringMapToString(KeyedVector<String8, String8> map) const
-    {
-        String8 result("{ ");
-        for (size_t i = 0; i < map.size(); i++) {
-            result.appendFormat("%s{name=%s, value=%s}", i > 0 ? ", " : "",
-                                map.keyAt(i).string(), map.valueAt(i).string());
-        }
-        return result + " }";
-    }
-
-    bool operator<(Vector<uint8_t> const &lhs, Vector<uint8_t> const &rhs) {
-        return lhs.size() < rhs.size() || (memcmp(lhs.array(), rhs.array(), lhs.size()) < 0);
-    }
-
-    //
-    // Crypto Plugin
-    //
-
-    bool MockCryptoPlugin::requiresSecureDecoderComponent(const char *mime) const
-    {
-        ALOGD("MockCryptoPlugin::requiresSecureDecoderComponent(mime=%s)", mime);
-        return false;
-    }
-
-    ssize_t
-    MockCryptoPlugin::decrypt(bool secure, const uint8_t key[16], const uint8_t iv[16],
-                              Mode mode, const void *srcPtr, const SubSample *subSamples,
-                              size_t numSubSamples, void *dstPtr, AString *errorDetailMsg)
-    {
-        ALOGD("MockCryptoPlugin::decrypt(secure=%d, key=%s, iv=%s, mode=%d, src=%p, "
-              "subSamples=%s, dst=%p)",
-              (int)secure,
-              arrayToString(key, sizeof(key)).string(),
-              arrayToString(iv, sizeof(iv)).string(),
-              (int)mode, srcPtr,
-              subSamplesToString(subSamples, numSubSamples).string(),
-              dstPtr);
-        return OK;
-    }
-
-    // Conversion utilities
-    String8 MockCryptoPlugin::arrayToString(uint8_t const *array, size_t len) const
-    {
-        String8 result("{ ");
-        for (size_t i = 0; i < len; i++) {
-            result.appendFormat("0x%02x ", array[i]);
-        }
-        result += "}";
-        return result;
-    }
-
-    String8 MockCryptoPlugin::subSamplesToString(SubSample const *subSamples,
-                                                 size_t numSubSamples) const
-    {
-        String8 result;
-        for (size_t i = 0; i < numSubSamples; i++) {
-            result.appendFormat("[%d] {clear:%d, encrypted:%d} ", i,
-                                subSamples[i].mNumBytesOfClearData,
-                                subSamples[i].mNumBytesOfEncryptedData);
-        }
-        return result;
-    }
-
-};
diff --git a/tests/tests/mediadrm/lib/MockDrmCryptoPlugin.h b/tests/tests/mediadrm/lib/MockDrmCryptoPlugin.h
deleted file mode 100644
index 2297f9b..0000000
--- a/tests/tests/mediadrm/lib/MockDrmCryptoPlugin.h
+++ /dev/null
@@ -1,156 +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 <utils/Mutex.h>
-
-#include "drm/DrmAPI.h"
-#include "hardware/CryptoAPI.h"
-
-extern "C" {
-      android::DrmFactory *createDrmFactory();
-      android::CryptoFactory *createCryptoFactory();
-}
-
-namespace android {
-
-    class MockDrmFactory : public DrmFactory {
-    public:
-        MockDrmFactory() {}
-        virtual ~MockDrmFactory() {}
-
-        bool isCryptoSchemeSupported(const uint8_t uuid[16]);
-        bool isContentTypeSupported(const String8 &mimeType);
-        status_t createDrmPlugin(const uint8_t uuid[16], DrmPlugin **plugin);
-    };
-
-    class MockCryptoFactory : public CryptoFactory {
-    public:
-        MockCryptoFactory() {}
-        virtual ~MockCryptoFactory() {}
-
-        bool isCryptoSchemeSupported(const uint8_t uuid[16]) const;
-        status_t createPlugin(
-            const uint8_t uuid[16], const void *data, size_t size,
-            CryptoPlugin **plugin);
-    };
-
-
-
-    class MockDrmPlugin : public DrmPlugin {
-    public:
-        MockDrmPlugin() {}
-        virtual ~MockDrmPlugin() {}
-
-        // from DrmPlugin
-        status_t openSession(Vector<uint8_t> &sessionId);
-        status_t closeSession(Vector<uint8_t> const &sessionId);
-
-        status_t getKeyRequest(Vector<uint8_t> const &sessionId,
-                               Vector<uint8_t> const &initData,
-                               String8 const &mimeType, KeyType keyType,
-                               KeyedVector<String8, String8> const &optionalParameters,
-                               Vector<uint8_t> &request, String8 &defaultUrl);
-
-        status_t provideKeyResponse(Vector<uint8_t> const &sessionId,
-                                    Vector<uint8_t> const &response,
-                                    Vector<uint8_t> &keySetId);
-
-        status_t removeKeys(Vector<uint8_t> const &keySetId);
-
-        status_t restoreKeys(Vector<uint8_t> const &sessionId,
-                             Vector<uint8_t> const &keySetId);
-
-        status_t queryKeyStatus(Vector<uint8_t> const &sessionId,
-                                KeyedVector<String8, String8> &infoMap) const;
-
-        status_t getProvisionRequest(Vector<uint8_t> &request,
-                                             String8 &defaultUrl);
-
-        status_t provideProvisionResponse(Vector<uint8_t> const &response);
-
-        status_t getSecureStops(List<Vector<uint8_t> > &secureStops);
-        status_t releaseSecureStops(Vector<uint8_t> const &ssRelease);
-
-        status_t getPropertyString(String8 const &name, String8 &value ) const;
-        status_t getPropertyByteArray(String8 const &name,
-                                              Vector<uint8_t> &value ) const;
-
-        status_t setPropertyString(String8 const &name,
-                                   String8 const &value );
-        status_t setPropertyByteArray(String8 const &name,
-                                      Vector<uint8_t> const &value );
-
-        status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId,
-                                    String8 const &algorithm);
-
-        status_t setMacAlgorithm(Vector<uint8_t> const &sessionId,
-                                 String8 const &algorithm);
-
-        status_t encrypt(Vector<uint8_t> const &sessionId,
-                         Vector<uint8_t> const &keyId,
-                         Vector<uint8_t> const &input,
-                         Vector<uint8_t> const &iv,
-                         Vector<uint8_t> &output);
-
-        status_t decrypt(Vector<uint8_t> const &sessionId,
-                         Vector<uint8_t> const &keyId,
-                         Vector<uint8_t> const &input,
-                         Vector<uint8_t> const &iv,
-                         Vector<uint8_t> &output);
-
-        status_t sign(Vector<uint8_t> const &sessionId,
-                      Vector<uint8_t> const &keyId,
-                      Vector<uint8_t> const &message,
-                      Vector<uint8_t> &signature);
-
-        status_t verify(Vector<uint8_t> const &sessionId,
-                        Vector<uint8_t> const &keyId,
-                        Vector<uint8_t> const &message,
-                        Vector<uint8_t> const &signature,
-                        bool &match);
-
-    private:
-        String8 vectorToString(Vector<uint8_t> const &vector) const;
-        String8 arrayToString(uint8_t const *array, size_t len) const;
-        String8 stringMapToString(KeyedVector<String8, String8> map) const;
-
-        SortedVector<Vector<uint8_t> > mSessions;
-        SortedVector<Vector<uint8_t> > mKeySets;
-
-        static const ssize_t kNotFound = -1;
-        ssize_t findSession(Vector<uint8_t> const &sessionId) const;
-        ssize_t findKeySet(Vector<uint8_t> const &keySetId) const;
-
-        Mutex mLock;
-        KeyedVector<String8, String8> mStringProperties;
-        KeyedVector<String8, Vector<uint8_t> > mByteArrayProperties;
-    };
-
-
-    class MockCryptoPlugin : public CryptoPlugin {
-
-        bool requiresSecureDecoderComponent(const char *mime) const;
-
-        ssize_t decrypt(bool secure,
-            const uint8_t key[16], const uint8_t iv[16],
-            Mode mode, const void *srcPtr,
-            const SubSample *subSamples, size_t numSubSamples,
-            void *dstPtr, AString *errorDetailMsg);
-    private:
-        String8 subSamplesToString(CryptoPlugin::SubSample const *subSamples, size_t numSubSamples) const;
-        String8 arrayToString(uint8_t const *array, size_t len) const;
-    };
-};