1791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang/*
2791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * Copyright (C) 2017 The Android Open Source Project
3791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang *
4791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * Licensed under the Apache License, Version 2.0 (the "License");
5791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * you may not use this file except in compliance with the License.
6791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * You may obtain a copy of the License at
7791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang *
8791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang *      http://www.apache.org/licenses/LICENSE-2.0
9791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang *
10791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * Unless required by applicable law or agreed to in writing, software
11791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * distributed under the License is distributed on an "AS IS" BASIS,
12791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * See the License for the specific language governing permissions and
14791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang * limitations under the License.
15791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang */
16791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
17791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#define LOG_NDEBUG 0
18791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#define LOG_TAG "MockCasPlugin"
19791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
20791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include <media/stagefright/foundation/hexdump.h>
21791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include <media/stagefright/MediaErrors.h>
22791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include <utils/Log.h>
23791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
24791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include "MockCasPlugin.h"
25791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang#include "MockSessionLibrary.h"
26791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
27791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangandroid::CasFactory* createCasFactory() {
28791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return new android::MockCasFactory();
29791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
30791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
31791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangandroid::DescramblerFactory* createDescramblerFactory() {
32791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return new android::MockDescramblerFactory();
33791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
34791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
35791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangnamespace android {
36791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
37791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatic const int32_t sMockId = 0xFFFF;
38791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
39791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangbool MockCasFactory::isSystemIdSupported(int32_t CA_system_id) const {
40791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return CA_system_id == sMockId;
41791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
42791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
43791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasFactory::queryPlugins(
44791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        std::vector<CasPluginDescriptor> *descriptors) const {
45791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    descriptors->clear();
46791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    descriptors->push_back({sMockId, String8("MockCAS")});
47791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
48791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
49791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
50791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasFactory::createPlugin(
51791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        int32_t CA_system_id,
52791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        uint64_t appData,
53791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        CasPluginCallback callback,
54791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        CasPlugin **plugin) {
55791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (!isSystemIdSupported(CA_system_id)) {
56791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        return BAD_VALUE;
57791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
58791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
59791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    *plugin = new MockCasPlugin();
60791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
61791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
62791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
63791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang///////////////////////////////////////////////////////////////////////////////
64791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
65791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangbool MockDescramblerFactory::isSystemIdSupported(int32_t CA_system_id) const {
66791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return CA_system_id == sMockId;
67791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
68791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
69791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockDescramblerFactory::createPlugin(
70791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        int32_t CA_system_id, DescramblerPlugin** plugin) {
71791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (!isSystemIdSupported(CA_system_id)) {
72791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        return BAD_VALUE;
73791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
74791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
75791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    *plugin = new MockDescramblerPlugin();
76791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
77791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
78791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
79791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang///////////////////////////////////////////////////////////////////////////////
80791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
81791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatic String8 arrayToString(const std::vector<uint8_t> &array) {
82791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    String8 result;
83791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    for (size_t i = 0; i < array.size(); i++) {
84791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        result.appendFormat("%02x ", array[i]);
85791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
86791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (result.isEmpty()) {
87791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        result.append("(null)");
88791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
89791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return result;
90791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
91791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
92791a1a206b56be8601a6fffd2614926e67d64790Chong ZhangMockCasPlugin::MockCasPlugin() {
93791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("CTOR");
94791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
95791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
96791a1a206b56be8601a6fffd2614926e67d64790Chong ZhangMockCasPlugin::~MockCasPlugin() {
97791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("DTOR");
98791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    MockSessionLibrary::get()->destroyPlugin(this);
99791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
100791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
101791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::setPrivateData(const CasData &data) {
102791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("setPrivateData");
103791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
104791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
105791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
106a78c1cc9773532b1f9d066ed8fa0d9414c1bb8bbChong Zhangstatus_t MockCasPlugin::openSession(CasSessionId* sessionId) {
107a78c1cc9773532b1f9d066ed8fa0d9414c1bb8bbChong Zhang    ALOGV("openSession");
108a78c1cc9773532b1f9d066ed8fa0d9414c1bb8bbChong Zhang    return MockSessionLibrary::get()->addSession(this, sessionId);
109791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
110791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
111791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::closeSession(const CasSessionId &sessionId) {
112791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("closeSession: sessionId=%s", arrayToString(sessionId).string());
113791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
114791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
115791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    sp<MockCasSession> session =
116791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang            MockSessionLibrary::get()->findSession(sessionId);
117791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (session == NULL) {
118791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        return BAD_VALUE;
119791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
120791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
121791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    MockSessionLibrary::get()->destroySession(sessionId);
122791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
123791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
124791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
125791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::setSessionPrivateData(
126791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        const CasSessionId &sessionId, const CasData &data) {
127791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("setSessionPrivateData: sessionId=%s",
128791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang            arrayToString(sessionId).string());
129791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
130791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
131791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    sp<MockCasSession> session =
132791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang            MockSessionLibrary::get()->findSession(sessionId);
133791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (session == NULL) {
134791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        return BAD_VALUE;
135791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
136791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
137791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
138791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
139791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::processEcm(
140791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        const CasSessionId &sessionId, const CasEcm& ecm) {
141791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("processEcm: sessionId=%s", arrayToString(sessionId).string());
142791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
143791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
144791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    sp<MockCasSession> session =
145791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang            MockSessionLibrary::get()->findSession(sessionId);
146791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (session == NULL) {
147791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        return BAD_VALUE;
148791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
149791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("ECM: size=%d", ecm.size());
150791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("ECM: data=%s", arrayToString(ecm).string());
151791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
152791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
153791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
154791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
155791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::processEmm(const CasEmm& emm) {
156791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("processEmm");
157791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
158791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
159791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("EMM: size=%d", emm.size());
160791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("EMM: data=%s", arrayToString(emm).string());
161791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
162791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
163791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
164791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
165791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::sendEvent(
166791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        int32_t event, int arg, const CasData &eventData) {
167791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("sendEvent: event=%d", event);
168791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
169791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
170791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
171791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
172791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
173791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::provision(const String8 &str) {
174791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("provision: provisionString=%s", str.string());
175791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
176791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
177791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
178791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
179791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
180791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockCasPlugin::refreshEntitlements(
181791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        int32_t refreshType, const CasData &refreshData) {
182791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("refreshEntitlements: refreshData=%s", arrayToString(refreshData).string());
183791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    Mutex::Autolock lock(mLock);
184791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
185791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
186791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
187791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
188791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang/////////////////////////////////////////////////////////////////
189791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangbool MockDescramblerPlugin::requiresSecureDecoderComponent(
190791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        const char *mime) const {
191791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("MockDescramblerPlugin::requiresSecureDecoderComponent"
192791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang            "(mime=%s)", mime);
193791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return false;
194791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
195791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
196791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangstatus_t MockDescramblerPlugin::setMediaCasSession(
197791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        const CasSessionId &sessionId) {
198791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("MockDescramblerPlugin::setMediaCasSession");
199791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    sp<MockCasSession> session =
200791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang            MockSessionLibrary::get()->findSession(sessionId);
201791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
202791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    if (session == NULL) {
203791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        ALOGE("MockDescramblerPlugin: session not found");
204791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        return ERROR_DRM_SESSION_NOT_OPENED;
205791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
206791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
207791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return OK;
208791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
209791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
210791a1a206b56be8601a6fffd2614926e67d64790Chong Zhangssize_t MockDescramblerPlugin::descramble(
211791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        bool secure,
212791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        ScramblingControl scramblingControl,
213791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        size_t numSubSamples,
214791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        const SubSample *subSamples,
215791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        const void *srcPtr,
216791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        int32_t srcOffset,
217791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        void *dstPtr,
218791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        int32_t dstOffset,
219791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        AString *errorDetailMsg) {
220791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    ALOGV("MockDescramblerPlugin::descramble(secure=%d, sctrl=%d,"
221791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang          "subSamples=%s, srcPtr=%p, dstPtr=%p, srcOffset=%d, dstOffset=%d)",
222791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang          (int)secure, (int)scramblingControl,
223791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang          subSamplesToString(subSamples, numSubSamples).string(),
224791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang          srcPtr, dstPtr, srcOffset, dstOffset);
225791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
226791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return 0;
227791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
228791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
229791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang// Conversion utilities
230791a1a206b56be8601a6fffd2614926e67d64790Chong ZhangString8 MockDescramblerPlugin::arrayToString(
231791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        uint8_t const *array, size_t len) const
232791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang{
233791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    String8 result("{ ");
234791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    for (size_t i = 0; i < len; i++) {
235791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        result.appendFormat("0x%02x ", array[i]);
236791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
237791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    result += "}";
238791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return result;
239791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
240791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
241791a1a206b56be8601a6fffd2614926e67d64790Chong ZhangString8 MockDescramblerPlugin::subSamplesToString(
242791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        SubSample const *subSamples, size_t numSubSamples) const
243791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang{
244791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    String8 result;
245791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    for (size_t i = 0; i < numSubSamples; i++) {
246791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang        result.appendFormat("[%zu] {clear:%u, encrypted:%u} ", i,
247791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang                            subSamples[i].mNumBytesOfClearData,
248791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang                            subSamples[i].mNumBytesOfEncryptedData);
249791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    }
250791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang    return result;
251791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang}
252791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
253791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang} // namespace android
254791a1a206b56be8601a6fffd2614926e67d64790Chong Zhang
255