blob: 30fbb64dcbc4b7f521ca384c4a076d03c0734267 [file] [log] [blame]
Saurabh Shah86c17292013-02-08 15:24:13 -08001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
4 *
5 * Not a Contribution, Apache license notifications and license are
6 * retained for attribution purposes only.
7
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#include <sys/types.h>
22#include <binder/Parcel.h>
23#include <binder/IBinder.h>
24#include <binder/IInterface.h>
25#include <utils/Errors.h>
26#include <IQClient.h>
27
28using namespace android;
29
30// ---------------------------------------------------------------------------
31
32namespace qClient {
33
34enum {
35 NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
36};
37
38class BpQClient : public BpInterface<IQClient>
39{
40public:
41 BpQClient(const sp<IBinder>& impl)
42 : BpInterface<IQClient>(impl) {}
43
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080044 virtual status_t notifyCallback(uint32_t msg, uint32_t value) {
Saurabh Shah86c17292013-02-08 15:24:13 -080045 Parcel data, reply;
46 data.writeInterfaceToken(IQClient::getInterfaceDescriptor());
47 data.writeInt32(msg);
48 data.writeInt32(value);
49 remote()->transact(NOTIFY_CALLBACK, data, &reply);
Jeykumar Sankaran9f59a762013-02-28 10:45:56 -080050 status_t result = reply.readInt32();
51 return result;
Saurabh Shah86c17292013-02-08 15:24:13 -080052 }
53};
54
55IMPLEMENT_META_INTERFACE(QClient, "android.display.IQClient");
56
57// ----------------------------------------------------------------------
58
59status_t BnQClient::onTransact(
60 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
61{
62 switch(code) {
63 case NOTIFY_CALLBACK: {
64 CHECK_INTERFACE(IQClient, data, reply);
65 uint32_t msg = data.readInt32();
66 uint32_t value = data.readInt32();
67 notifyCallback(msg, value);
68 return NO_ERROR;
69 } break;
70 default:
71 return BBinder::onTransact(code, data, reply, flags);
72 }
73}
74
75}; // namespace qClient