blob: e8deb4a955e2382b887dec0210b206d7195cd015 [file] [log] [blame]
Dongwon Kang2652c172015-12-14 21:59:19 +09001/*
2 * Copyright 2016 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 <binder/IMediaResourceMonitor.h>
18#include <binder/Parcel.h>
19#include <utils/Errors.h>
20#include <sys/types.h>
21
22namespace android {
23
24// ----------------------------------------------------------------------
25
26class BpMediaResourceMonitor : public BpInterface<IMediaResourceMonitor> {
27public:
28 BpMediaResourceMonitor(const sp<IBinder>& impl)
29 : BpInterface<IMediaResourceMonitor>(impl) {}
30
31 virtual void notifyResourceGranted(/*in*/ int32_t pid, /*in*/ const String16& type,
32 /*in*/ const String16& subType, /*in*/ int64_t value)
33 {
34 Parcel data, reply;
35 data.writeInterfaceToken(IMediaResourceMonitor::getInterfaceDescriptor());
36 data.writeInt32(pid);
37 data.writeString16(type);
38 data.writeString16(subType);
39 data.writeInt64(value);
40 remote()->transact(NOTIFY_RESOURCE_GRANTED, data, &reply, IBinder::FLAG_ONEWAY);
41 }
42};
43
44IMPLEMENT_META_INTERFACE(MediaResourceMonitor, "android.media.IMediaResourceMonitor");
45
46// ----------------------------------------------------------------------
47
48status_t BnMediaResourceMonitor::onTransact( uint32_t code, const Parcel& data, Parcel* reply,
49 uint32_t flags) {
50 switch(code) {
51 case NOTIFY_RESOURCE_GRANTED: {
52 CHECK_INTERFACE(IMediaResourceMonitor, data, reply);
53 int32_t pid = data.readInt32();
54 const String16 type = data.readString16();
55 const String16 subType = data.readString16();
56 int64_t value = data.readInt64();
57 notifyResourceGranted(/*in*/ pid, /*in*/ type, /*in*/ subType, /*in*/ value);
58 return NO_ERROR;
59 } break;
60 default:
61 return BBinder::onTransact(code, data, reply, flags);
62 }
63}
64
65// ----------------------------------------------------------------------
66
67}; // namespace android