blob: 859c3b8332ce2fe3881ff07490aff619ff57849f [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#define LOG_TAG "InputFlinger"
18
Jeff Brown40c9e0a2013-07-15 13:27:05 -070019
20#include <stdint.h>
21#include <unistd.h>
22
23#include <sys/types.h>
24
Michael Wright6f783602015-02-13 17:35:16 -080025#include "InputFlinger.h"
26#include "InputDriver.h"
27
Jeff Brown40c9e0a2013-07-15 13:27:05 -070028#include <binder/IPCThreadState.h>
29#include <binder/PermissionCache.h>
Michael Wright6f783602015-02-13 17:35:16 -080030#include <hardware/input.h>
Jeff Brown40c9e0a2013-07-15 13:27:05 -070031#include <cutils/log.h>
32#include <private/android_filesystem_config.h>
33
34namespace android {
35
36const String16 sAccessInputFlingerPermission("android.permission.ACCESS_INPUT_FLINGER");
37const String16 sDumpPermission("android.permission.DUMP");
38
39
40InputFlinger::InputFlinger() :
41 BnInputFlinger() {
42 ALOGI("InputFlinger is starting");
Michael Wright6f783602015-02-13 17:35:16 -080043 mHost = new InputHost();
44 mHost->registerInputDriver(new InputDriver(INPUT_INSTANCE_EVDEV));
Jeff Brown40c9e0a2013-07-15 13:27:05 -070045}
46
47InputFlinger::~InputFlinger() {
48}
49
Jeff Brown40c9e0a2013-07-15 13:27:05 -070050status_t InputFlinger::dump(int fd, const Vector<String16>& args) {
51 String8 result;
52 const IPCThreadState* ipc = IPCThreadState::self();
53 const int pid = ipc->getCallingPid();
54 const int uid = ipc->getCallingUid();
55 if ((uid != AID_SHELL)
56 && !PermissionCache::checkPermission(sDumpPermission, pid, uid)) {
57 result.appendFormat("Permission Denial: "
58 "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
59 } else {
60 dumpInternal(result);
61 }
62 write(fd, result.string(), result.size());
63 return OK;
64}
65
66void InputFlinger::dumpInternal(String8& result) {
67 result.append("INPUT FLINGER (dumpsys inputflinger)\n");
Michael Wright6f783602015-02-13 17:35:16 -080068 mHost->dump(result);
Jeff Brown40c9e0a2013-07-15 13:27:05 -070069}
70
71}; // namespace android