blob: 6fa56fc33dd6d38f3696717d06a6b1ac86d15d55 [file] [log] [blame]
Ronghua Wu231c3d12015-03-11 15:10:32 -07001/*
2**
3** Copyright 2015, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#include <utils/RefBase.h>
19#include <binder/IInterface.h>
20#include <binder/Parcel.h>
21
22#include <media/IResourceManagerClient.h>
23
24namespace android {
25
26enum {
27 RECLAIM_RESOURCE = IBinder::FIRST_CALL_TRANSACTION,
28};
29
30class BpResourceManagerClient: public BpInterface<IResourceManagerClient>
31{
32public:
33 BpResourceManagerClient(const sp<IBinder> &impl)
34 : BpInterface<IResourceManagerClient>(impl)
35 {
36 }
37
38 virtual bool reclaimResource() {
39 Parcel data, reply;
40 data.writeInterfaceToken(IResourceManagerClient::getInterfaceDescriptor());
41
42 bool ret = false;
43 status_t status = remote()->transact(RECLAIM_RESOURCE, data, &reply);
44 if (status == NO_ERROR) {
45 ret = (bool)reply.readInt32();
46 }
47 return ret;
48 }
49};
50
51IMPLEMENT_META_INTERFACE(ResourceManagerClient, "android.media.IResourceManagerClient");
52
53// ----------------------------------------------------------------------
54
55status_t BnResourceManagerClient::onTransact(
56 uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
57{
58 switch (code) {
59 case RECLAIM_RESOURCE: {
60 CHECK_INTERFACE(IResourceManagerClient, data, reply);
61 bool ret = reclaimResource();
62 reply->writeInt32(ret);
63 return NO_ERROR;
64 } break;
65 default:
66 return BBinder::onTransact(code, data, reply, flags);
67 }
68}
69
70}; // namespace android