blob: e44ca55e56315dea1beadba0a57539acc79184d3 [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
aimitakeshid074e302010-07-29 10:12:27 +090017#include <stdint.h>
18#include <sys/types.h>
19#include <binder/Parcel.h>
20#include <binder/IPCThreadState.h>
21#include <drm/drm_framework_common.h>
22#include "IDrmIOService.h"
23
24using namespace android;
25
26void BpDrmIOService::writeToFile(const String8& filePath, const String8& dataBuffer) {
27 Parcel data, reply;
28
29 data.writeInterfaceToken(IDrmIOService::getInterfaceDescriptor());
30 data.writeString8(filePath);
31 data.writeString8(dataBuffer);
32
33 remote()->transact(WRITE_TO_FILE, data, &reply);
34}
35
36String8 BpDrmIOService::readFromFile(const String8& filePath) {
37
38 Parcel data, reply;
39
40 data.writeInterfaceToken(IDrmIOService::getInterfaceDescriptor());
41 data.writeString8(filePath);
42
43 remote()->transact(READ_FROM_FILE, data, &reply);
44 return reply.readString8();
45}
46
47IMPLEMENT_META_INTERFACE(DrmIOService, "drm.IDrmIOService");
48
49status_t BnDrmIOService::onTransact(
50 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
51
52 switch (code) {
53 case WRITE_TO_FILE:
54 {
55 CHECK_INTERFACE(IDrmIOService, data, reply);
56
57 writeToFile(data.readString8(), data.readString8());
58 return DRM_NO_ERROR;
59 }
60
61 case READ_FROM_FILE:
62 {
63 CHECK_INTERFACE(IDrmIOService, data, reply);
64
65 String8 dataBuffer = readFromFile(data.readString8());
66 reply->writeString8(dataBuffer);
67 return DRM_NO_ERROR;
68 }
69
70 default:
71 return BBinder::onTransact(code, data, reply, flags);
72 }
73}
74