The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 <stdio.h> |
| 18 | #include <stdint.h> |
| 19 | #include <sys/types.h> |
| 20 | |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 21 | #include <binder/Parcel.h> |
| 22 | #include <binder/IInterface.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 24 | #include <ui/IOverlay.h> |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | enum { |
| 29 | DESTROY = IBinder::FIRST_CALL_TRANSACTION, // one-way transaction |
| 30 | }; |
| 31 | |
| 32 | class BpOverlay : public BpInterface<IOverlay> |
| 33 | { |
| 34 | public: |
| 35 | BpOverlay(const sp<IBinder>& impl) |
| 36 | : BpInterface<IOverlay>(impl) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | virtual void destroy() |
| 41 | { |
| 42 | Parcel data, reply; |
| 43 | data.writeInterfaceToken(IOverlay::getInterfaceDescriptor()); |
| 44 | remote()->transact(DESTROY, data, &reply, IBinder::FLAG_ONEWAY); |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | IMPLEMENT_META_INTERFACE(Overlay, "android.ui.IOverlay"); |
| 49 | |
| 50 | // ---------------------------------------------------------------------- |
| 51 | |
| 52 | #define CHECK_INTERFACE(interface, data, reply) \ |
| 53 | do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ |
| 54 | LOGW("Call incorrectly routed to " #interface); \ |
| 55 | return PERMISSION_DENIED; \ |
| 56 | } } while (0) |
| 57 | |
| 58 | status_t BnOverlay::onTransact( |
| 59 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 60 | { |
| 61 | switch(code) { |
| 62 | case DESTROY: { |
| 63 | CHECK_INTERFACE(IOverlay, data, reply); |
| 64 | destroy(); |
| 65 | return NO_ERROR; |
| 66 | } break; |
| 67 | default: |
| 68 | return BBinder::onTransact(code, data, reply, flags); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | }; // namespace android |