blob: 8edea3f7f67380b1bf505256a90f5ff86049fb73 [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#include <stdint.h>
Mark Salyzyna5e161b2016-09-29 08:08:05 -070020#include <sys/types.h>
Jeff Brown40c9e0a2013-07-15 13:27:05 -070021#include <unistd.h>
22
Mark Salyzyna5e161b2016-09-29 08:08:05 -070023#include <android/log.h>
Jeff Brown40c9e0a2013-07-15 13:27:05 -070024#include <binder/IPCThreadState.h>
25#include <binder/PermissionCache.h>
Michael Wright6f783602015-02-13 17:35:16 -080026#include <hardware/input.h>
Jeff Brown40c9e0a2013-07-15 13:27:05 -070027#include <private/android_filesystem_config.h>
28
Mark Salyzyna5e161b2016-09-29 08:08:05 -070029#include "InputFlinger.h"
30#include "InputDriver.h"
31
Jeff Brown40c9e0a2013-07-15 13:27:05 -070032namespace android {
33
34const String16 sAccessInputFlingerPermission("android.permission.ACCESS_INPUT_FLINGER");
35const String16 sDumpPermission("android.permission.DUMP");
36
37
38InputFlinger::InputFlinger() :
39 BnInputFlinger() {
40 ALOGI("InputFlinger is starting");
Michael Wright6f783602015-02-13 17:35:16 -080041 mHost = new InputHost();
42 mHost->registerInputDriver(new InputDriver(INPUT_INSTANCE_EVDEV));
Jeff Brown40c9e0a2013-07-15 13:27:05 -070043}
44
45InputFlinger::~InputFlinger() {
46}
47
Jeff Brown40c9e0a2013-07-15 13:27:05 -070048status_t InputFlinger::dump(int fd, const Vector<String16>& args) {
49 String8 result;
50 const IPCThreadState* ipc = IPCThreadState::self();
51 const int pid = ipc->getCallingPid();
52 const int uid = ipc->getCallingUid();
53 if ((uid != AID_SHELL)
54 && !PermissionCache::checkPermission(sDumpPermission, pid, uid)) {
55 result.appendFormat("Permission Denial: "
56 "can't dump SurfaceFlinger from pid=%d, uid=%d\n", pid, uid);
57 } else {
58 dumpInternal(result);
59 }
60 write(fd, result.string(), result.size());
61 return OK;
62}
63
64void InputFlinger::dumpInternal(String8& result) {
65 result.append("INPUT FLINGER (dumpsys inputflinger)\n");
Michael Wright6f783602015-02-13 17:35:16 -080066 mHost->dump(result);
Jeff Brown40c9e0a2013-07-15 13:27:05 -070067}
68
69}; // namespace android