blob: cf9bab12fe9c3d94b61d61fcedb795e77b1ebbb1 [file] [log] [blame]
aimitakeshid074e302010-07-29 10:12:27 +09001/*
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
Takeshi Aimidc549d62010-09-20 23:40:41 +090017//#define LOG_NDEBUG 0
aimitakeshid074e302010-07-29 10:12:27 +090018#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
aimitakeshid074e302010-07-29 10:12:27 +090031
32void DrmManagerService::instantiate() {
33 LOGV("instantiate");
Gloria Wanga784d4e2010-10-26 12:11:55 -070034 defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
aimitakeshid074e302010-07-29 10:12:27 +090035}
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
Takeshi Aimidc549d62010-09-20 23:40:41 +090048int DrmManagerService::addUniqueId(int uniqueId) {
49 return mDrmManager->addUniqueId(uniqueId);
50}
51
52void DrmManagerService::removeUniqueId(int uniqueId) {
53 mDrmManager->removeUniqueId(uniqueId);
54}
55
aimitakeshid074e302010-07-29 10:12:27 +090056status_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
Takeshi Aimidc549d62010-09-20 23:40:41 +0900104status_t DrmManagerService::saveRights(
aimitakeshid074e302010-07-29 10:12:27 +0900105 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
Takeshi Aimidc549d62010-09-20 23:40:41 +0900128status_t DrmManagerService::consumeRights(
aimitakeshid074e302010-07-29 10:12:27 +0900129 int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
130 LOGV("Entering consumeRights");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900131 return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
aimitakeshid074e302010-07-29 10:12:27 +0900132}
133
Takeshi Aimidc549d62010-09-20 23:40:41 +0900134status_t DrmManagerService::setPlaybackStatus(
aimitakeshid074e302010-07-29 10:12:27 +0900135 int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
136 LOGV("Entering setPlaybackStatus");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900137 return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
aimitakeshid074e302010-07-29 10:12:27 +0900138}
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
Takeshi Aimidc549d62010-09-20 23:40:41 +0900147status_t DrmManagerService::removeRights(int uniqueId, const String8& path) {
aimitakeshid074e302010-07-29 10:12:27 +0900148 LOGV("Entering removeRights");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900149 return mDrmManager->removeRights(uniqueId, path);
aimitakeshid074e302010-07-29 10:12:27 +0900150}
151
Takeshi Aimidc549d62010-09-20 23:40:41 +0900152status_t DrmManagerService::removeAllRights(int uniqueId) {
aimitakeshid074e302010-07-29 10:12:27 +0900153 LOGV("Entering removeAllRights");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900154 return mDrmManager->removeAllRights(uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +0900155}
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
Takeshi Aimidc549d62010-09-20 23:40:41 +0900185status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
aimitakeshid074e302010-07-29 10:12:27 +0900186 LOGV("Entering closeDecryptSession");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900187 return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
aimitakeshid074e302010-07-29 10:12:27 +0900188}
189
Takeshi Aimidc549d62010-09-20 23:40:41 +0900190status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
aimitakeshid074e302010-07-29 10:12:27 +0900191 int decryptUnitId, const DrmBuffer* headerInfo) {
192 LOGV("Entering initializeDecryptUnit");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900193 return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
aimitakeshid074e302010-07-29 10:12:27 +0900194}
195
196status_t DrmManagerService::decrypt(
Takeshi Aimidc549d62010-09-20 23:40:41 +0900197 int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
198 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
aimitakeshid074e302010-07-29 10:12:27 +0900199 LOGV("Entering decrypt");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900200 return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
aimitakeshid074e302010-07-29 10:12:27 +0900201}
202
Takeshi Aimidc549d62010-09-20 23:40:41 +0900203status_t DrmManagerService::finalizeDecryptUnit(
aimitakeshid074e302010-07-29 10:12:27 +0900204 int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
205 LOGV("Entering finalizeDecryptUnit");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900206 return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
aimitakeshid074e302010-07-29 10:12:27 +0900207}
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