1e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown/*
2e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * Copyright (C) 2012 The Android Open Source Project
3e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown *
4e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * Licensed under the Apache License, Version 2.0 (the "License");
5e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * you may not use this file except in compliance with the License.
6e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * You may obtain a copy of the License at
7e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown *
8e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown *      http://www.apache.org/licenses/LICENSE-2.0
9e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown *
10e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * Unless required by applicable law or agreed to in writing, software
11e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * distributed under the License is distributed on an "AS IS" BASIS,
12e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * See the License for the specific language governing permissions and
14e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown * limitations under the License.
15e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown */
16e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
17e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown#include <stdint.h>
18e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown#include <sys/types.h>
19e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
20e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown#include <media/IRemoteDisplay.h>
21e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
22e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownnamespace android {
23e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
24e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownenum {
25455d02eca342d8159637af317a5d83219d267812Jeff Brown    DISPOSE = IBinder::FIRST_CALL_TRANSACTION,
265131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    PAUSE,
275131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    RESUME,
28e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown};
29e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
30e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownclass BpRemoteDisplay: public BpInterface<IRemoteDisplay>
31e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown{
32e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownpublic:
33e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    BpRemoteDisplay(const sp<IBinder>& impl)
34e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown        : BpInterface<IRemoteDisplay>(impl)
35e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    {
36e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    }
37e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
385131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    virtual status_t pause() {
395131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        Parcel data, reply;
405131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
415131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        remote()->transact(PAUSE, data, &reply);
425131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        return reply.readInt32();
435131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    }
445131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
455131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    virtual status_t resume() {
465131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        Parcel data, reply;
475131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
485131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        remote()->transact(RESUME, data, &reply);
495131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        return reply.readInt32();
505131d127a042ee88f903370be88845dc8c9f8578Andreas Huber    }
515131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
52455d02eca342d8159637af317a5d83219d267812Jeff Brown    status_t dispose()
53e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    {
54e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown        Parcel data, reply;
55e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown        data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
56455d02eca342d8159637af317a5d83219d267812Jeff Brown        remote()->transact(DISPOSE, data, &reply);
57e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown        return reply.readInt32();
58e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    }
59e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown};
60e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
61e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff BrownIMPLEMENT_META_INTERFACE(RemoteDisplay, "android.media.IRemoteDisplay");
62e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
63e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown// ----------------------------------------------------------------------
64e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
65e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brownstatus_t BnRemoteDisplay::onTransact(
66e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
67e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown{
68e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    switch (code) {
69455d02eca342d8159637af317a5d83219d267812Jeff Brown        case DISPOSE: {
70e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown            CHECK_INTERFACE(IRemoteDisplay, data, reply);
71455d02eca342d8159637af317a5d83219d267812Jeff Brown            reply->writeInt32(dispose());
72e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown            return NO_ERROR;
73e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown        }
745131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
755131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        case PAUSE:
765131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        {
775131d127a042ee88f903370be88845dc8c9f8578Andreas Huber            CHECK_INTERFACE(IRemoteDisplay, data, reply);
785131d127a042ee88f903370be88845dc8c9f8578Andreas Huber            reply->writeInt32(pause());
795131d127a042ee88f903370be88845dc8c9f8578Andreas Huber            return OK;
805131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        }
815131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
825131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        case RESUME:
835131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        {
845131d127a042ee88f903370be88845dc8c9f8578Andreas Huber            CHECK_INTERFACE(IRemoteDisplay, data, reply);
855131d127a042ee88f903370be88845dc8c9f8578Andreas Huber            reply->writeInt32(resume());
865131d127a042ee88f903370be88845dc8c9f8578Andreas Huber            return OK;
875131d127a042ee88f903370be88845dc8c9f8578Andreas Huber        }
885131d127a042ee88f903370be88845dc8c9f8578Andreas Huber
89e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown        default:
90e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown            return BBinder::onTransact(code, data, reply, flags);
91e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown    }
92e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown}
93e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown
94e104596061b219e9bce6d4db49a9d15242f8d2e5Jeff Brown}; // namespace android
95