Jeff Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 1 | /* |
| 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 Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <unistd.h> |
| 22 | |
| 23 | #include <sys/types.h> |
| 24 | |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 25 | #include "InputFlinger.h" |
| 26 | #include "InputDriver.h" |
| 27 | |
Jeff Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 28 | #include <binder/IPCThreadState.h> |
| 29 | #include <binder/PermissionCache.h> |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 30 | #include <hardware/input.h> |
Jeff Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 31 | #include <cutils/log.h> |
| 32 | #include <private/android_filesystem_config.h> |
| 33 | |
| 34 | namespace android { |
| 35 | |
| 36 | const String16 sAccessInputFlingerPermission("android.permission.ACCESS_INPUT_FLINGER"); |
| 37 | const String16 sDumpPermission("android.permission.DUMP"); |
| 38 | |
| 39 | |
| 40 | InputFlinger::InputFlinger() : |
| 41 | BnInputFlinger() { |
| 42 | ALOGI("InputFlinger is starting"); |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 43 | mHost = new InputHost(); |
| 44 | mHost->registerInputDriver(new InputDriver(INPUT_INSTANCE_EVDEV)); |
Jeff Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | InputFlinger::~InputFlinger() { |
| 48 | } |
| 49 | |
Jeff Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 50 | status_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 | |
| 66 | void InputFlinger::dumpInternal(String8& result) { |
| 67 | result.append("INPUT FLINGER (dumpsys inputflinger)\n"); |
Michael Wright | 6f78360 | 2015-02-13 17:35:16 -0800 | [diff] [blame] | 68 | mHost->dump(result); |
Jeff Brown | 40c9e0a | 2013-07-15 13:27:05 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | }; // namespace android |