blob: 1d0c0ec6a37424cad1d28515b16ee99e222ad88b [file] [log] [blame]
Eric Laurentb7a11d82014-04-18 17:40:41 -07001/*
2**
3** Copyright 2014, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18#include <stdint.h>
19#include <sys/types.h>
20#include <binder/IMemory.h>
21#include <binder/Parcel.h>
22#include <binder/IPCThreadState.h>
23#include <binder/IServiceManager.h>
24#include <soundtrigger/ISoundTriggerClient.h>
25
26namespace android {
27
28enum {
29 ON_RECOGNITION_EVENT = IBinder::FIRST_CALL_TRANSACTION,
30};
31
32class BpSoundTriggerClient: public BpInterface<ISoundTriggerClient>
33{
34
35public:
36 BpSoundTriggerClient(const sp<IBinder>& impl)
37 : BpInterface<ISoundTriggerClient>(impl)
38 {
39 }
40
41 virtual void onRecognitionEvent(const sp<IMemory>& eventMemory)
42 {
43 Parcel data, reply;
44 data.writeInterfaceToken(ISoundTriggerClient::getInterfaceDescriptor());
45 data.writeStrongBinder(eventMemory->asBinder());
46 remote()->transact(ON_RECOGNITION_EVENT,
47 data,
48 &reply);
49 }
50};
51
52IMPLEMENT_META_INTERFACE(SoundTriggerClient,
53 "android.hardware.ISoundTriggerClient");
54
55// ----------------------------------------------------------------------
56
57status_t BnSoundTriggerClient::onTransact(
58 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
59{
60 switch(code) {
61 case ON_RECOGNITION_EVENT: {
62 CHECK_INTERFACE(ISoundTriggerClient, data, reply);
63 sp<IMemory> eventMemory = interface_cast<IMemory>(
64 data.readStrongBinder());
65 onRecognitionEvent(eventMemory);
66 return NO_ERROR;
67 } break;
68 default:
69 return BBinder::onTransact(code, data, reply, flags);
70 }
71}
72
73// ----------------------------------------------------------------------------
74
75}; // namespace android