blob: 47a2c0c347e6448193a3c2c3c70ece04d91eb0a2 [file] [log] [blame]
Jeff Brown40c9e0a2013-07-15 13:27:05 -07001/*
2 * Copyright (C) 2013 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 <binder/Parcel.h>
21#include <binder/IPCThreadState.h>
22#include <binder/IServiceManager.h>
23
24#include <input/IInputFlinger.h>
25
Jeff Brown40c9e0a2013-07-15 13:27:05 -070026namespace android {
27
28class BpInputFlinger : public BpInterface<IInputFlinger> {
29public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070030 explicit BpInputFlinger(const sp<IBinder>& impl) :
Jeff Brown40c9e0a2013-07-15 13:27:05 -070031 BpInterface<IInputFlinger>(impl) { }
32
Robert Carr1cc78672018-07-31 14:25:57 -070033 virtual void setInputWindows(const Vector<InputWindowInfo>& inputInfo) {
Jeff Brown40c9e0a2013-07-15 13:27:05 -070034 Parcel data, reply;
35 data.writeInterfaceToken(IInputFlinger::getInterfaceDescriptor());
Robert Carr1cc78672018-07-31 14:25:57 -070036
37 data.writeUint32(static_cast<uint32_t>(inputInfo.size()));
38 for (const auto& info : inputInfo) {
39 info.write(data);
40 }
41 remote()->transact(BnInputFlinger::SET_INPUT_WINDOWS_TRANSACTION, data, &reply);
Jeff Brown40c9e0a2013-07-15 13:27:05 -070042 }
43};
44
45IMPLEMENT_META_INTERFACE(InputFlinger, "android.input.IInputFlinger");
46
Jeff Brown40c9e0a2013-07-15 13:27:05 -070047status_t BnInputFlinger::onTransact(
48 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
49 switch(code) {
Robert Carr1cc78672018-07-31 14:25:57 -070050 case SET_INPUT_WINDOWS_TRANSACTION: {
Jeff Brown40c9e0a2013-07-15 13:27:05 -070051 CHECK_INTERFACE(IInputFlinger, data, reply);
Robert Carr1cc78672018-07-31 14:25:57 -070052 size_t count = data.readUint32();
53 if (count > data.dataSize()) {
54 return BAD_VALUE;
55 }
56 Vector<InputWindowInfo> handles;
57 handles.setCapacity(count);
58 for (size_t i = 0; i < count; i++) {
59 handles.add(InputWindowInfo(data));
60 }
61 setInputWindows(handles);
Jeff Brown40c9e0a2013-07-15 13:27:05 -070062 break;
63 }
64 default:
65 return BBinder::onTransact(code, data, reply, flags);
66 }
67 return NO_ERROR;
68}
69
70};