DrmManagerService.cpp revision d6d4ba97bcb39bf6d0cde32ce7bef1753e420548
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//#define LOG_NDEBUG 0
18#define LOG_TAG "DrmManagerService(Native)"
19#include <utils/Log.h>
20
21#include <errno.h>
22#include <utils/threads.h>
23#include <binder/IServiceManager.h>
24#include <sys/stat.h>
25#include "DrmManagerService.h"
26#include "DrmManager.h"
27
28using namespace android;
29
30#define SUCCESS 0
31
32void DrmManagerService::instantiate() {
33    LOGV("instantiate");
34    defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
35}
36
37DrmManagerService::DrmManagerService() {
38    LOGV("created");
39    mDrmManager = NULL;
40    mDrmManager = new DrmManager();
41}
42
43DrmManagerService::~DrmManagerService() {
44    LOGV("Destroyed");
45    delete mDrmManager; mDrmManager = NULL;
46}
47
48int DrmManagerService::addUniqueId(int uniqueId) {
49    return mDrmManager->addUniqueId(uniqueId);
50}
51
52void DrmManagerService::removeUniqueId(int uniqueId) {
53    mDrmManager->removeUniqueId(uniqueId);
54}
55
56status_t DrmManagerService::loadPlugIns(int uniqueId) {
57    LOGV("Entering load plugins");
58    return mDrmManager->loadPlugIns(uniqueId);
59}
60
61status_t DrmManagerService::loadPlugIns(int uniqueId, const String8& plugInDirPath) {
62    LOGV("Entering load plugins from path");
63    return mDrmManager->loadPlugIns(uniqueId, plugInDirPath);
64}
65
66status_t DrmManagerService::setDrmServiceListener(
67            int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
68    LOGV("Entering setDrmServiceListener");
69    mDrmManager->setDrmServiceListener(uniqueId, drmServiceListener);
70    return DRM_NO_ERROR;
71}
72
73status_t DrmManagerService::unloadPlugIns(int uniqueId) {
74    LOGV("Entering unload plugins");
75    return mDrmManager->unloadPlugIns(uniqueId);
76}
77
78status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
79    LOGV("Entering installDrmEngine");
80    return mDrmManager->installDrmEngine(uniqueId, drmEngineFile);
81}
82
83DrmConstraints* DrmManagerService::getConstraints(
84            int uniqueId, const String8* path, const int action) {
85    LOGV("Entering getConstraints from content");
86    return mDrmManager->getConstraints(uniqueId, path, action);
87}
88
89bool DrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
90    LOGV("Entering canHandle");
91    return mDrmManager->canHandle(uniqueId, path, mimeType);
92}
93
94DrmInfoStatus* DrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
95    LOGV("Entering processDrmInfo");
96    return mDrmManager->processDrmInfo(uniqueId, drmInfo);
97}
98
99DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
100    LOGV("Entering acquireDrmInfo");
101    return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest);
102}
103
104status_t DrmManagerService::saveRights(
105            int uniqueId, const DrmRights& drmRights,
106            const String8& rightsPath, const String8& contentPath) {
107    LOGV("Entering saveRights");
108    return mDrmManager->saveRights(uniqueId, drmRights, rightsPath, contentPath);
109}
110
111String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
112    LOGV("Entering getOriginalMimeType");
113    return mDrmManager->getOriginalMimeType(uniqueId, path);
114}
115
116int DrmManagerService::getDrmObjectType(
117           int uniqueId, const String8& path, const String8& mimeType) {
118    LOGV("Entering getDrmObjectType");
119    return mDrmManager->getDrmObjectType(uniqueId, path, mimeType);
120}
121
122int DrmManagerService::checkRightsStatus(
123            int uniqueId, const String8& path, int action) {
124    LOGV("Entering checkRightsStatus");
125    return mDrmManager->checkRightsStatus(uniqueId, path, action);
126}
127
128status_t DrmManagerService::consumeRights(
129            int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
130    LOGV("Entering consumeRights");
131    return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
132}
133
134status_t DrmManagerService::setPlaybackStatus(
135            int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
136    LOGV("Entering setPlaybackStatus");
137    return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
138}
139
140bool DrmManagerService::validateAction(
141            int uniqueId, const String8& path,
142            int action, const ActionDescription& description) {
143    LOGV("Entering validateAction");
144    return mDrmManager->validateAction(uniqueId, path, action, description);
145}
146
147status_t DrmManagerService::removeRights(int uniqueId, const String8& path) {
148    LOGV("Entering removeRights");
149    return mDrmManager->removeRights(uniqueId, path);
150}
151
152status_t DrmManagerService::removeAllRights(int uniqueId) {
153    LOGV("Entering removeAllRights");
154    return mDrmManager->removeAllRights(uniqueId);
155}
156
157int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
158    LOGV("Entering openConvertSession");
159    return mDrmManager->openConvertSession(uniqueId, mimeType);
160}
161
162DrmConvertedStatus* DrmManagerService::convertData(
163            int uniqueId, int convertId, const DrmBuffer* inputData) {
164    LOGV("Entering convertData");
165    return mDrmManager->convertData(uniqueId, convertId, inputData);
166}
167
168DrmConvertedStatus* DrmManagerService::closeConvertSession(int uniqueId, int convertId) {
169    LOGV("Entering closeConvertSession");
170    return mDrmManager->closeConvertSession(uniqueId, convertId);
171}
172
173status_t DrmManagerService::getAllSupportInfo(
174            int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) {
175    LOGV("Entering getAllSupportInfo");
176    return mDrmManager->getAllSupportInfo(uniqueId, length, drmSupportInfoArray);
177}
178
179DecryptHandle* DrmManagerService::openDecryptSession(
180            int uniqueId, int fd, int offset, int length) {
181    LOGV("Entering DrmManagerService::openDecryptSession");
182    return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
183}
184
185status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
186    LOGV("Entering closeDecryptSession");
187    return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
188}
189
190status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
191            int decryptUnitId, const DrmBuffer* headerInfo) {
192    LOGV("Entering initializeDecryptUnit");
193    return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
194}
195
196status_t DrmManagerService::decrypt(
197            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
198            const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
199    LOGV("Entering decrypt");
200    return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
201}
202
203status_t DrmManagerService::finalizeDecryptUnit(
204            int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
205    LOGV("Entering finalizeDecryptUnit");
206    return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
207}
208
209ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
210            void* buffer, ssize_t numBytes, off_t offset) {
211    LOGV("Entering pread");
212    return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
213}
214
215