blob: 1e154343261fdca363ff4156ae500048b93fd76b [file] [log] [blame]
Jeff Browne1045962012-09-04 21:38:42 -07001/*
2 * Copyright (C) 2012 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 <stdint.h>
18#include <sys/types.h>
19
20#include <media/IRemoteDisplay.h>
21
22namespace android {
23
24enum {
Jeff Brown455d02e2012-09-05 17:48:03 -070025 DISPOSE = IBinder::FIRST_CALL_TRANSACTION,
Andreas Huber5131d122012-11-16 10:38:11 -080026 PAUSE,
27 RESUME,
Jeff Browne1045962012-09-04 21:38:42 -070028};
29
30class BpRemoteDisplay: public BpInterface<IRemoteDisplay>
31{
32public:
33 BpRemoteDisplay(const sp<IBinder>& impl)
34 : BpInterface<IRemoteDisplay>(impl)
35 {
36 }
37
Andreas Huber5131d122012-11-16 10:38:11 -080038 virtual status_t pause() {
39 Parcel data, reply;
40 data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
41 remote()->transact(PAUSE, data, &reply);
42 return reply.readInt32();
43 }
44
45 virtual status_t resume() {
46 Parcel data, reply;
47 data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
48 remote()->transact(RESUME, data, &reply);
49 return reply.readInt32();
50 }
51
Jeff Brown455d02e2012-09-05 17:48:03 -070052 status_t dispose()
Jeff Browne1045962012-09-04 21:38:42 -070053 {
54 Parcel data, reply;
55 data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
Jeff Brown455d02e2012-09-05 17:48:03 -070056 remote()->transact(DISPOSE, data, &reply);
Jeff Browne1045962012-09-04 21:38:42 -070057 return reply.readInt32();
58 }
59};
60
61IMPLEMENT_META_INTERFACE(RemoteDisplay, "android.media.IRemoteDisplay");
62
63// ----------------------------------------------------------------------
64
65status_t BnRemoteDisplay::onTransact(
66 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
67{
68 switch (code) {
Jeff Brown455d02e2012-09-05 17:48:03 -070069 case DISPOSE: {
Jeff Browne1045962012-09-04 21:38:42 -070070 CHECK_INTERFACE(IRemoteDisplay, data, reply);
Jeff Brown455d02e2012-09-05 17:48:03 -070071 reply->writeInt32(dispose());
Jeff Browne1045962012-09-04 21:38:42 -070072 return NO_ERROR;
73 }
Andreas Huber5131d122012-11-16 10:38:11 -080074
75 case PAUSE:
76 {
77 CHECK_INTERFACE(IRemoteDisplay, data, reply);
78 reply->writeInt32(pause());
79 return OK;
80 }
81
82 case RESUME:
83 {
84 CHECK_INTERFACE(IRemoteDisplay, data, reply);
85 reply->writeInt32(resume());
86 return OK;
87 }
88
Jeff Browne1045962012-09-04 21:38:42 -070089 default:
90 return BBinder::onTransact(code, data, reply, flags);
91 }
92}
93
94}; // namespace android