InputFlinger.cpp revision 6f783602c05c519238200fed55b0afa097737ca1
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 19 20#include <stdint.h> 21#include <unistd.h> 22 23#include <sys/types.h> 24 25#include "InputFlinger.h" 26#include "InputDriver.h" 27 28#include <binder/IPCThreadState.h> 29#include <binder/PermissionCache.h> 30#include <hardware/input.h> 31#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"); 43 mHost = new InputHost(); 44 mHost->registerInputDriver(new InputDriver(INPUT_INSTANCE_EVDEV)); 45} 46 47InputFlinger::~InputFlinger() { 48} 49 50status_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"); 68 mHost->dump(result); 69} 70 71}; // namespace android 72