IDrmServiceListener.cpp revision 27ed8ad2db653f6ac07dcf8bcc05e2409c8bb024
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 "IDrmServiceListener" 19#include <utils/Log.h> 20 21#include <stdint.h> 22#include <sys/types.h> 23#include <binder/Parcel.h> 24#include <binder/IPCThreadState.h> 25#include <drm/drm_framework_common.h> 26#include <drm/DrmInfoEvent.h> 27#include "IDrmServiceListener.h" 28 29using namespace android; 30 31status_t BpDrmServiceListener::notify(const DrmInfoEvent& event) { 32 Parcel data, reply; 33 34 data.writeInterfaceToken(IDrmServiceListener::getInterfaceDescriptor()); 35 data.writeInt32(event.getUniqueId()); 36 data.writeInt32(event.getType()); 37 data.writeString8(event.getMessage()); 38 39 remote()->transact(NOTIFY, data, &reply); 40 return reply.readInt32(); 41} 42 43IMPLEMENT_META_INTERFACE(DrmServiceListener, "drm.IDrmServiceListener"); 44 45status_t BnDrmServiceListener::onTransact( 46 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { 47 48 switch (code) { 49 case NOTIFY: 50 { 51 CHECK_INTERFACE(IDrmServiceListener, data, reply); 52 int uniqueId = data.readInt32(); 53 int type = data.readInt32(); 54 const String8& message = data.readString8(); 55 56 status_t status = notify(DrmInfoEvent(uniqueId, type, message)); 57 reply->writeInt32(status); 58 59 return DRM_NO_ERROR; 60 } 61 default: 62 return BBinder::onTransact(code, data, reply, flags); 63 } 64} 65 66