3 ** Copyright 2014, The Android Open Source Project
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
9 ** http://www.apache.org/licenses/LICENSE-2.0
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.
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>
29 ON_RECOGNITION_EVENT = IBinder::FIRST_CALL_TRANSACTION,
31 ON_SERVICE_STATE_CHANGE
34 class BpSoundTriggerClient: public BpInterface<ISoundTriggerClient>
38 BpSoundTriggerClient(const sp<IBinder>& impl)
39 : BpInterface<ISoundTriggerClient>(impl)
43 virtual void onRecognitionEvent(const sp<IMemory>& eventMemory)
46 data.writeInterfaceToken(ISoundTriggerClient::getInterfaceDescriptor());
47 data.writeStrongBinder(eventMemory->asBinder());
48 remote()->transact(ON_RECOGNITION_EVENT,
53 virtual void onSoundModelEvent(const sp<IMemory>& eventMemory)
56 data.writeInterfaceToken(ISoundTriggerClient::getInterfaceDescriptor());
57 data.writeStrongBinder(eventMemory->asBinder());
58 remote()->transact(ON_SOUNDMODEL_EVENT,
62 virtual void onServiceStateChange(const sp<IMemory>& eventMemory)
65 data.writeInterfaceToken(ISoundTriggerClient::getInterfaceDescriptor());
66 data.writeStrongBinder(eventMemory->asBinder());
67 remote()->transact(ON_SERVICE_STATE_CHANGE,
73 IMPLEMENT_META_INTERFACE(SoundTriggerClient,
74 "android.hardware.ISoundTriggerClient");
76 // ----------------------------------------------------------------------
78 status_t BnSoundTriggerClient::onTransact(
79 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
82 case ON_RECOGNITION_EVENT: {
83 CHECK_INTERFACE(ISoundTriggerClient, data, reply);
84 sp<IMemory> eventMemory = interface_cast<IMemory>(
85 data.readStrongBinder());
86 onRecognitionEvent(eventMemory);
89 case ON_SOUNDMODEL_EVENT: {
90 CHECK_INTERFACE(ISoundTriggerClient, data, reply);
91 sp<IMemory> eventMemory = interface_cast<IMemory>(
92 data.readStrongBinder());
93 onSoundModelEvent(eventMemory);
96 case ON_SERVICE_STATE_CHANGE: {
97 CHECK_INTERFACE(ISoundTriggerClient, data, reply);
98 sp<IMemory> eventMemory = interface_cast<IMemory>(
99 data.readStrongBinder());
100 onServiceStateChange(eventMemory);
104 return BBinder::onTransact(code, data, reply, flags);
108 // ----------------------------------------------------------------------------
110 }; // namespace android