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