1 /*
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
22 namespace android {
23
24 enum {
25 DISPOSE = IBinder::FIRST_CALL_TRANSACTION,
26 PAUSE,
27 RESUME,
28 };
29
30 class BpRemoteDisplay: public BpInterface<IRemoteDisplay>
31 {
32 public:
BpRemoteDisplay(const sp<IBinder> & impl)33 BpRemoteDisplay(const sp<IBinder>& impl)
34 : BpInterface<IRemoteDisplay>(impl)
35 {
36 }
37
pause()38 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
resume()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
dispose()52 status_t dispose()
53 {
54 Parcel data, reply;
55 data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
56 remote()->transact(DISPOSE, data, &reply);
57 return reply.readInt32();
58 }
59 };
60
61 IMPLEMENT_META_INTERFACE(RemoteDisplay, "android.media.IRemoteDisplay");
62
63 // ----------------------------------------------------------------------
64
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)65 status_t BnRemoteDisplay::onTransact(
66 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
67 {
68 switch (code) {
69 case DISPOSE: {
70 CHECK_INTERFACE(IRemoteDisplay, data, reply);
71 reply->writeInt32(dispose());
72 return NO_ERROR;
73 }
74
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
89 default:
90 return BBinder::onTransact(code, data, reply, flags);
91 }
92 }
93
94 } // namespace android
95