blob: efd7bae827befec14a94e0295fcdba0c9f7c24aa [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
aimitakeshid074e302010-07-29 10:12:27 +090030void DrmManagerService::instantiate() {
31 LOGV("instantiate");
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090032 defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
aimitakeshid074e302010-07-29 10:12:27 +090033}
34
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090035DrmManagerService::DrmManagerService() :
36 mDrmManager(NULL) {
aimitakeshid074e302010-07-29 10:12:27 +090037 LOGV("created");
aimitakeshid074e302010-07-29 10:12:27 +090038 mDrmManager = new DrmManager();
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090039 mDrmManager->loadPlugIns();
aimitakeshid074e302010-07-29 10:12:27 +090040}
41
42DrmManagerService::~DrmManagerService() {
43 LOGV("Destroyed");
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090044 mDrmManager->unloadPlugIns();
aimitakeshid074e302010-07-29 10:12:27 +090045 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
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090056void DrmManagerService::addClient(int uniqueId) {
57 mDrmManager->addClient(uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090058}
59
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +090060void DrmManagerService::removeClient(int uniqueId) {
61 mDrmManager->removeClient(uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +090062}
63
64status_t DrmManagerService::setDrmServiceListener(
65 int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
66 LOGV("Entering setDrmServiceListener");
67 mDrmManager->setDrmServiceListener(uniqueId, drmServiceListener);
68 return DRM_NO_ERROR;
69}
70
aimitakeshid074e302010-07-29 10:12:27 +090071status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
72 LOGV("Entering installDrmEngine");
73 return mDrmManager->installDrmEngine(uniqueId, drmEngineFile);
74}
75
76DrmConstraints* DrmManagerService::getConstraints(
77 int uniqueId, const String8* path, const int action) {
78 LOGV("Entering getConstraints from content");
79 return mDrmManager->getConstraints(uniqueId, path, action);
80}
81
82bool DrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
83 LOGV("Entering canHandle");
84 return mDrmManager->canHandle(uniqueId, path, mimeType);
85}
86
87DrmInfoStatus* DrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
88 LOGV("Entering processDrmInfo");
89 return mDrmManager->processDrmInfo(uniqueId, drmInfo);
90}
91
92DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
93 LOGV("Entering acquireDrmInfo");
94 return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest);
95}
96
Takeshi Aimidc549d62010-09-20 23:40:41 +090097status_t DrmManagerService::saveRights(
aimitakeshid074e302010-07-29 10:12:27 +090098 int uniqueId, const DrmRights& drmRights,
99 const String8& rightsPath, const String8& contentPath) {
100 LOGV("Entering saveRights");
101 return mDrmManager->saveRights(uniqueId, drmRights, rightsPath, contentPath);
102}
103
104String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
105 LOGV("Entering getOriginalMimeType");
106 return mDrmManager->getOriginalMimeType(uniqueId, path);
107}
108
109int DrmManagerService::getDrmObjectType(
110 int uniqueId, const String8& path, const String8& mimeType) {
111 LOGV("Entering getDrmObjectType");
112 return mDrmManager->getDrmObjectType(uniqueId, path, mimeType);
113}
114
115int DrmManagerService::checkRightsStatus(
116 int uniqueId, const String8& path, int action) {
117 LOGV("Entering checkRightsStatus");
118 return mDrmManager->checkRightsStatus(uniqueId, path, action);
119}
120
Takeshi Aimidc549d62010-09-20 23:40:41 +0900121status_t DrmManagerService::consumeRights(
aimitakeshid074e302010-07-29 10:12:27 +0900122 int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
123 LOGV("Entering consumeRights");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900124 return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
aimitakeshid074e302010-07-29 10:12:27 +0900125}
126
Takeshi Aimidc549d62010-09-20 23:40:41 +0900127status_t DrmManagerService::setPlaybackStatus(
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800128 int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
aimitakeshid074e302010-07-29 10:12:27 +0900129 LOGV("Entering setPlaybackStatus");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900130 return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
aimitakeshid074e302010-07-29 10:12:27 +0900131}
132
133bool DrmManagerService::validateAction(
134 int uniqueId, const String8& path,
135 int action, const ActionDescription& description) {
136 LOGV("Entering validateAction");
137 return mDrmManager->validateAction(uniqueId, path, action, description);
138}
139
Takeshi Aimidc549d62010-09-20 23:40:41 +0900140status_t DrmManagerService::removeRights(int uniqueId, const String8& path) {
aimitakeshid074e302010-07-29 10:12:27 +0900141 LOGV("Entering removeRights");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900142 return mDrmManager->removeRights(uniqueId, path);
aimitakeshid074e302010-07-29 10:12:27 +0900143}
144
Takeshi Aimidc549d62010-09-20 23:40:41 +0900145status_t DrmManagerService::removeAllRights(int uniqueId) {
aimitakeshid074e302010-07-29 10:12:27 +0900146 LOGV("Entering removeAllRights");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900147 return mDrmManager->removeAllRights(uniqueId);
aimitakeshid074e302010-07-29 10:12:27 +0900148}
149
150int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) {
151 LOGV("Entering openConvertSession");
152 return mDrmManager->openConvertSession(uniqueId, mimeType);
153}
154
155DrmConvertedStatus* DrmManagerService::convertData(
156 int uniqueId, int convertId, const DrmBuffer* inputData) {
157 LOGV("Entering convertData");
158 return mDrmManager->convertData(uniqueId, convertId, inputData);
159}
160
161DrmConvertedStatus* DrmManagerService::closeConvertSession(int uniqueId, int convertId) {
162 LOGV("Entering closeConvertSession");
163 return mDrmManager->closeConvertSession(uniqueId, convertId);
164}
165
166status_t DrmManagerService::getAllSupportInfo(
167 int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) {
168 LOGV("Entering getAllSupportInfo");
169 return mDrmManager->getAllSupportInfo(uniqueId, length, drmSupportInfoArray);
170}
171
172DecryptHandle* DrmManagerService::openDecryptSession(
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800173 int uniqueId, int fd, off64_t offset, off64_t length) {
aimitakeshid074e302010-07-29 10:12:27 +0900174 LOGV("Entering DrmManagerService::openDecryptSession");
175 return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
176}
177
Takeshi Aimic7b3ccc2010-10-08 23:05:49 +0900178DecryptHandle* DrmManagerService::openDecryptSession(
179 int uniqueId, const char* uri) {
180 LOGV("Entering DrmManagerService::openDecryptSession with uri");
181 return mDrmManager->openDecryptSession(uniqueId, uri);
182}
183
Takeshi Aimidc549d62010-09-20 23:40:41 +0900184status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
aimitakeshid074e302010-07-29 10:12:27 +0900185 LOGV("Entering closeDecryptSession");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900186 return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
aimitakeshid074e302010-07-29 10:12:27 +0900187}
188
Takeshi Aimidc549d62010-09-20 23:40:41 +0900189status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
aimitakeshid074e302010-07-29 10:12:27 +0900190 int decryptUnitId, const DrmBuffer* headerInfo) {
191 LOGV("Entering initializeDecryptUnit");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900192 return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
aimitakeshid074e302010-07-29 10:12:27 +0900193}
194
195status_t DrmManagerService::decrypt(
Takeshi Aimidc549d62010-09-20 23:40:41 +0900196 int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
197 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
aimitakeshid074e302010-07-29 10:12:27 +0900198 LOGV("Entering decrypt");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900199 return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
aimitakeshid074e302010-07-29 10:12:27 +0900200}
201
Takeshi Aimidc549d62010-09-20 23:40:41 +0900202status_t DrmManagerService::finalizeDecryptUnit(
aimitakeshid074e302010-07-29 10:12:27 +0900203 int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
204 LOGV("Entering finalizeDecryptUnit");
Takeshi Aimidc549d62010-09-20 23:40:41 +0900205 return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
aimitakeshid074e302010-07-29 10:12:27 +0900206}
207
208ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
Gloria Wang5fc3edb2010-11-19 15:19:36 -0800209 void* buffer, ssize_t numBytes, off64_t offset) {
aimitakeshid074e302010-07-29 10:12:27 +0900210 LOGV("Entering pread");
211 return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
212}
213