Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 28 | using namespace android; |
| 29 | |
| 30 | // --------------------------------------------------------------------------- |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 31 | // XXX: Since qservice currently runs as part of hwc instead of a standalone |
| 32 | // process, the implementation below is overridden and the notifyCallback in |
| 33 | // hwc_qclient is directly called. |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 34 | |
| 35 | namespace qClient { |
| 36 | |
| 37 | enum { |
| 38 | NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION, |
| 39 | }; |
| 40 | |
| 41 | class BpQClient : public BpInterface<IQClient> |
| 42 | { |
| 43 | public: |
| 44 | BpQClient(const sp<IBinder>& impl) |
| 45 | : BpInterface<IQClient>(impl) {} |
| 46 | |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 47 | virtual status_t notifyCallback(uint32_t command, |
| 48 | const Parcel* inParcel, |
| 49 | Parcel* outParcel) { |
| 50 | Parcel data; |
| 51 | Parcel *reply = outParcel; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 52 | data.writeInterfaceToken(IQClient::getInterfaceDescriptor()); |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 53 | data.writeInt32(command); |
| 54 | if (inParcel->dataAvail()) |
| 55 | data.appendFrom(inParcel, inParcel->dataPosition(), |
| 56 | inParcel->dataAvail()); |
| 57 | status_t result = remote()->transact(NOTIFY_CALLBACK, data, reply); |
Jeykumar Sankaran | 9f59a76 | 2013-02-28 10:45:56 -0800 | [diff] [blame] | 58 | return result; |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 59 | } |
| 60 | }; |
| 61 | |
| 62 | IMPLEMENT_META_INTERFACE(QClient, "android.display.IQClient"); |
| 63 | |
| 64 | // ---------------------------------------------------------------------- |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 65 | //Stub implementation - nothing needed here |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 66 | status_t BnQClient::onTransact( |
| 67 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 68 | { |
| 69 | switch(code) { |
| 70 | case NOTIFY_CALLBACK: { |
| 71 | CHECK_INTERFACE(IQClient, data, reply); |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 72 | uint32_t command = data.readInt32(); |
| 73 | notifyCallback(command, &data, reply); |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 74 | return NO_ERROR; |
| 75 | } break; |
| 76 | default: |
| 77 | return BBinder::onTransact(code, data, reply, flags); |
| 78 | } |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame^] | 79 | |
Saurabh Shah | 86c1729 | 2013-02-08 15:24:13 -0800 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | }; // namespace qClient |