├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── Application.mk ├── README.md ├── art └── img.jpg ├── bin ├── Android Event Injector.apk ├── AndroidManifest.xml ├── classes.dex ├── classes │ └── net │ │ └── pocketmagic │ │ └── android │ │ ├── eventinjector │ │ ├── BuildConfig.class │ │ ├── Events$InputDevice.class │ │ ├── Events.class │ │ ├── MainActivity$1.class │ │ ├── MainActivity$2.class │ │ ├── MainActivity$3.class │ │ ├── MainActivity$4.class │ │ ├── MainActivity$5.class │ │ ├── MainActivity$6.class │ │ ├── MainActivity$7$1.class │ │ ├── MainActivity$7.class │ │ ├── MainActivity.class │ │ ├── R$attr.class │ │ ├── R$drawable.class │ │ ├── R$string.class │ │ ├── R.class │ │ ├── Shell$InputStreamHandler.class │ │ ├── Shell$OUTPUT.class │ │ └── Shell.class │ │ └── utils │ │ ├── CustomAdapter.class │ │ ├── CustomAdapterView.class │ │ └── ListViewItem.class ├── res │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ ├── list.png │ │ ├── list_open.png │ │ └── panel_item.9.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ └── drawable-xhdpi │ │ └── ic_launcher.png └── resources.ap_ ├── gen └── net │ └── pocketmagic │ └── android │ └── eventinjector │ ├── BuildConfig.java │ └── R.java ├── jni ├── Android.mk ├── EventInjector.c ├── EventInjector.h └── gpl-2.0.txt ├── libs ├── android-support-v4.jar └── armeabi │ └── libEventInjector.so ├── obj └── local │ └── armeabi │ ├── libEventInjector.so │ └── objs │ └── EventInjector │ ├── EventInjector.o │ └── EventInjector.o.d ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ ├── ic_launcher.png │ ├── list.png │ ├── list_open.png │ └── panel_item.9.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png └── values │ └── strings.xml └── src └── net └── pocketmagic └── android ├── eventinjector ├── Events.java ├── MainActivity.java └── Shell.java └── utils ├── CustomAdapter.java └── ListViewItem.java /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Android Event Injector 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 3 | org.eclipse.jdt.core.compiler.compliance=1.5 4 | org.eclipse.jdt.core.compiler.source=1.5 5 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | APP_PROJECT_PATH := $(call my-dir) 2 | APP_MODULES := EventInjector 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Android-Event-Injector 2 | ====================== 3 | 4 | It's a mirror of Android Event Injector on google code : https://code.google.com/p/android-event-injector/ 5 | 6 | 7 | Impression: 8 | 9 | ![art1](https://github.com/Ryfthink/Android-Event-Injector/blob/master/art/img.jpg) 10 | 11 | -------------------------------------------------------------------------------- /art/img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/art/img.jpg -------------------------------------------------------------------------------- /bin/Android Event Injector.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/Android Event Injector.apk -------------------------------------------------------------------------------- /bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes.dex -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/BuildConfig.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/Events$InputDevice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/Events$InputDevice.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/Events.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/Events.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$1.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$2.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$3.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$4.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$5.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$6.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$7$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$7$1.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity$7.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/MainActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/MainActivity.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/R$attr.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/R$drawable.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/R$string.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/R.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/Shell$InputStreamHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/Shell$InputStreamHandler.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/Shell$OUTPUT.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/Shell$OUTPUT.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/eventinjector/Shell.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/eventinjector/Shell.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/utils/CustomAdapter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/utils/CustomAdapter.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/utils/CustomAdapterView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/utils/CustomAdapterView.class -------------------------------------------------------------------------------- /bin/classes/net/pocketmagic/android/utils/ListViewItem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/classes/net/pocketmagic/android/utils/ListViewItem.class -------------------------------------------------------------------------------- /bin/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/drawable-hdpi/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/res/drawable-hdpi/list.png -------------------------------------------------------------------------------- /bin/res/drawable-hdpi/list_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/res/drawable-hdpi/list_open.png -------------------------------------------------------------------------------- /bin/res/drawable-hdpi/panel_item.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/res/drawable-hdpi/panel_item.9.png -------------------------------------------------------------------------------- /bin/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/bin/resources.ap_ -------------------------------------------------------------------------------- /gen/net/pocketmagic/android/eventinjector/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package net.pocketmagic.android.eventinjector; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /gen/net/pocketmagic/android/eventinjector/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package net.pocketmagic.android.eventinjector; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class drawable { 14 | public static final int ic_launcher=0x7f020000; 15 | public static final int list=0x7f020001; 16 | public static final int list_open=0x7f020002; 17 | public static final int panel_item=0x7f020003; 18 | } 19 | public static final class string { 20 | public static final int app_name=0x7f030000; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_LDLIBS := -llog 5 | LOCAL_MODULE := EventInjector 6 | LOCAL_SRC_FILES := EventInjector.c 7 | include $(BUILD_SHARED_LIBRARY) 8 | -------------------------------------------------------------------------------- /jni/EventInjector.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Android Event Injector 3 | * 4 | * Copyright (c) 2013 by Radu Motisan , radu.motisan@gmail.com 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | * For more information on the GPL, please go to: 21 | * http://www.gnu.org/copyleft/gpl.html 22 | * 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | #define TAG "EventInjector::JNI" 49 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , TAG, __VA_ARGS__) 50 | #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) 51 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) 52 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) 53 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) 54 | 55 | #include "EventInjector.h" 56 | 57 | 58 | 59 | /* Debug tools 60 | */ 61 | int g_debug = 0; 62 | 63 | 64 | void debug(char *szFormat, ...) 65 | { 66 | if (g_debug == 0) return; 67 | //if (strlen(szDbgfile) == 0) return; 68 | 69 | char szBuffer[4096]; //in this buffer we form the message 70 | const size_t NUMCHARS = sizeof(szBuffer) / sizeof(szBuffer[0]); 71 | const int LASTCHAR = NUMCHARS - 1; 72 | //format the input string 73 | va_list pArgs; 74 | va_start(pArgs, szFormat); 75 | // use a bounded buffer size to prevent buffer overruns. Limit count to 76 | // character size minus one to allow for a NULL terminating character. 77 | vsnprintf(szBuffer, NUMCHARS - 1, szFormat, pArgs); 78 | va_end(pArgs); 79 | //ensure that the formatted string is NULL-terminated 80 | szBuffer[LASTCHAR] = '\0'; 81 | 82 | LOGD(szBuffer); 83 | //TextCallback(szBuffer); 84 | } 85 | 86 | 87 | 88 | jint Java_net_pocketmagic_android_eventinjector_Events_intEnableDebug( JNIEnv* env,jobject thiz, jint enable ) { 89 | 90 | g_debug = enable; 91 | return g_debug; 92 | } 93 | 94 | jint JNI_OnLoad(JavaVM *vm, void *reserved) 95 | { 96 | debug("eventinterceptor native lib loaded."); 97 | return JNI_VERSION_1_2; //1_2 1_4 98 | } 99 | 100 | void JNI_OnUnload(JavaVM *vm, void *reserved) 101 | { 102 | debug("eventinterceptor native lib unloaded."); 103 | } 104 | 105 | static struct typedev { 106 | struct pollfd ufds; 107 | char *device_path; 108 | char *device_name; 109 | } *pDevs = NULL; 110 | struct pollfd *ufds; 111 | static int nDevsCount; 112 | 113 | const char *device_path = "/dev/input"; 114 | 115 | int g_Polling = 0; 116 | struct input_event event; 117 | int c; 118 | int i; 119 | int pollres; 120 | int get_time = 0; 121 | char *newline = "\n"; 122 | uint16_t get_switch = 0; 123 | struct input_event event; 124 | int version; 125 | 126 | int dont_block = -1; 127 | int event_count = 0; 128 | int sync_rate = 0; 129 | int64_t last_sync_time = 0; 130 | const char *device = NULL; 131 | 132 | 133 | static int open_device(int index) 134 | { 135 | if (index >= nDevsCount || pDevs == NULL) return -1; 136 | debug("open_device prep to open"); 137 | char *device = pDevs[index].device_path; 138 | 139 | debug("open_device call %s", device); 140 | int version; 141 | int fd; 142 | 143 | char name[80]; 144 | char location[80]; 145 | char idstr[80]; 146 | struct input_id id; 147 | 148 | fd = open(device, O_RDWR); 149 | if(fd < 0) { 150 | pDevs[index].ufds.fd = -1; 151 | 152 | pDevs[index].device_name = NULL; 153 | debug("could not open %s, %s", device, strerror(errno)); 154 | return -1; 155 | } 156 | 157 | pDevs[index].ufds.fd = fd; 158 | ufds[index].fd = fd; 159 | 160 | name[sizeof(name) - 1] = '\0'; 161 | if(ioctl(fd, EVIOCGNAME(sizeof(name) - 1), &name) < 1) { 162 | debug("could not get device name for %s, %s", device, strerror(errno)); 163 | name[0] = '\0'; 164 | } 165 | debug("Device %d: %s: %s", nDevsCount, device, name); 166 | 167 | pDevs[index].device_name = strdup(name); 168 | 169 | 170 | return 0; 171 | } 172 | 173 | int remove_device(int index) 174 | { 175 | if (index >= nDevsCount || pDevs == NULL ) return -1; 176 | 177 | int count = nDevsCount - index - 1; 178 | debug("remove device %d", index); 179 | free(pDevs[index].device_path); 180 | free(pDevs[index].device_name); 181 | 182 | memmove(&pDevs[index], &pDevs[index+1], sizeof(pDevs[0]) * count); 183 | nDevsCount--; 184 | return 0; 185 | } 186 | 187 | 188 | 189 | static int scan_dir(const char *dirname) 190 | { 191 | nDevsCount = 0; 192 | char devname[PATH_MAX]; 193 | char *filename; 194 | DIR *dir; 195 | struct dirent *de; 196 | dir = opendir(dirname); 197 | if(dir == NULL) 198 | return -1; 199 | strcpy(devname, dirname); 200 | filename = devname + strlen(devname); 201 | *filename++ = '/'; 202 | while((de = readdir(dir))) { 203 | if(de->d_name[0] == '.' && 204 | (de->d_name[1] == '\0' || 205 | (de->d_name[1] == '.' && de->d_name[2] == '\0'))) 206 | continue; 207 | strcpy(filename, de->d_name); 208 | debug("scan_dir:prepare to open:%s", devname); 209 | // add new filename to our structure: devname 210 | struct typedev *new_pDevs = realloc(pDevs, sizeof(pDevs[0]) * (nDevsCount + 1)); 211 | if(new_pDevs == NULL) { 212 | debug("out of memory"); 213 | return -1; 214 | } 215 | pDevs = new_pDevs; 216 | 217 | struct pollfd *new_ufds = realloc(ufds, sizeof(ufds[0]) * (nDevsCount + 1)); 218 | if(new_ufds == NULL) { 219 | debug("out of memory"); 220 | return -1; 221 | } 222 | ufds = new_ufds; 223 | ufds[nDevsCount].events = POLLIN; 224 | 225 | pDevs[nDevsCount].ufds.events = POLLIN; 226 | pDevs[nDevsCount].device_path = strdup(devname); 227 | 228 | nDevsCount++; 229 | } 230 | closedir(dir); 231 | return 0; 232 | } 233 | 234 | jint Java_net_pocketmagic_android_eventinjector_Events_intSendEvent(JNIEnv* env,jobject thiz, jint index, uint16_t type, uint16_t code, int32_t value) { 235 | if (index >= nDevsCount || pDevs[index].ufds.fd == -1) return -1; 236 | int fd = pDevs[index].ufds.fd; 237 | debug("SendEvent call (%d,%d,%d,%d)", fd, type, code, value); 238 | struct uinput_event event; 239 | int len; 240 | 241 | if (fd <= fileno(stderr)) return; 242 | 243 | memset(&event, 0, sizeof(event)); 244 | event.type = type; 245 | event.code = code; 246 | event.value = value; 247 | 248 | len = write(fd, &event, sizeof(event)); 249 | debug("SendEvent done:%d",len); 250 | } 251 | 252 | 253 | 254 | jint Java_net_pocketmagic_android_eventinjector_Events_ScanFiles( JNIEnv* env,jobject thiz ) { 255 | int res = scan_dir(device_path); 256 | if(res < 0) { 257 | debug("scan dir failed for %s:", device_path); 258 | return -1; 259 | } 260 | 261 | return nDevsCount; 262 | } 263 | 264 | jstring Java_net_pocketmagic_android_eventinjector_Events_getDevPath( JNIEnv* env,jobject thiz, jint index) { 265 | return (*env)->NewStringUTF(env, pDevs[index].device_path); 266 | } 267 | jstring Java_net_pocketmagic_android_eventinjector_Events_getDevName( JNIEnv* env,jobject thiz, jint index) { 268 | if (pDevs[index].device_name == NULL) return NULL; 269 | else return (*env)->NewStringUTF(env, pDevs[index].device_name); 270 | } 271 | 272 | jint Java_net_pocketmagic_android_eventinjector_Events_OpenDev( JNIEnv* env,jobject thiz, jint index ) { 273 | return open_device(index); 274 | } 275 | 276 | jint Java_net_pocketmagic_android_eventinjector_Events_RemoveDev( JNIEnv* env,jobject thiz, jint index ) { 277 | return remove_device(index); 278 | } 279 | 280 | jint Java_net_pocketmagic_android_eventinjector_Events_PollDev( JNIEnv* env,jobject thiz, jint index ) { 281 | if (index >= nDevsCount || pDevs[index].ufds.fd == -1) return -1; 282 | int pollres = poll(ufds, nDevsCount, -1); 283 | if(ufds[index].revents) { 284 | if(ufds[index].revents & POLLIN) { 285 | int res = read(ufds[index].fd, &event, sizeof(event)); 286 | if(res < (int)sizeof(event)) { 287 | return 1; 288 | } 289 | else return 0; 290 | } 291 | } 292 | return -1; 293 | } 294 | 295 | jint Java_net_pocketmagic_android_eventinjector_Events_getType( JNIEnv* env,jobject thiz ) { 296 | return event.type; 297 | } 298 | 299 | jint Java_net_pocketmagic_android_eventinjector_Events_getCode( JNIEnv* env,jobject thiz ) { 300 | return event.code; 301 | } 302 | 303 | jint Java_net_pocketmagic_android_eventinjector_Events_getValue( JNIEnv* env,jobject thiz ) { 304 | return event.value; 305 | } -------------------------------------------------------------------------------- /jni/EventInjector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Android Event Injector 3 | * 4 | * Copyright (c) 2013 by Radu Motisan , radu.motisan@gmail.com 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | * For more information on the GPL, please go to: 21 | * http://www.gnu.org/copyleft/gpl.html 22 | * 23 | */ 24 | 25 | #include 26 | 27 | struct uinput_event { 28 | struct timeval time; 29 | uint16_t type; 30 | uint16_t code; 31 | int32_t value; 32 | }; 33 | 34 | struct label { 35 | const char *name; 36 | int value; 37 | }; 38 | 39 | #define LABEL(constant) { #constant, constant } 40 | #define LABEL_END { NULL, -1 } 41 | 42 | static struct label input_prop_labels[] = { 43 | LABEL(INPUT_PROP_POINTER), 44 | LABEL(INPUT_PROP_DIRECT), 45 | LABEL(INPUT_PROP_BUTTONPAD), 46 | LABEL(INPUT_PROP_SEMI_MT), 47 | LABEL_END, 48 | }; 49 | 50 | static struct label ev_labels[] = { 51 | LABEL(EV_SYN), 52 | LABEL(EV_KEY), 53 | LABEL(EV_REL), 54 | LABEL(EV_ABS), 55 | LABEL(EV_MSC), 56 | LABEL(EV_SW), 57 | LABEL(EV_LED), 58 | LABEL(EV_SND), 59 | LABEL(EV_REP), 60 | LABEL(EV_FF), 61 | LABEL(EV_PWR), 62 | LABEL(EV_FF_STATUS), 63 | LABEL_END, 64 | }; 65 | 66 | static struct label syn_labels[] = { 67 | LABEL(SYN_REPORT), 68 | LABEL(SYN_CONFIG), 69 | LABEL(SYN_MT_REPORT), 70 | LABEL(SYN_DROPPED), 71 | LABEL_END, 72 | }; 73 | 74 | static struct label key_labels[] = { 75 | LABEL(KEY_RESERVED), 76 | LABEL(KEY_ESC), 77 | LABEL(KEY_1), 78 | LABEL(KEY_2), 79 | LABEL(KEY_3), 80 | LABEL(KEY_4), 81 | LABEL(KEY_5), 82 | LABEL(KEY_6), 83 | LABEL(KEY_7), 84 | LABEL(KEY_8), 85 | LABEL(KEY_9), 86 | LABEL(KEY_0), 87 | LABEL(KEY_MINUS), 88 | LABEL(KEY_EQUAL), 89 | LABEL(KEY_BACKSPACE), 90 | LABEL(KEY_TAB), 91 | LABEL(KEY_Q), 92 | LABEL(KEY_W), 93 | LABEL(KEY_E), 94 | LABEL(KEY_R), 95 | LABEL(KEY_T), 96 | LABEL(KEY_Y), 97 | LABEL(KEY_U), 98 | LABEL(KEY_I), 99 | LABEL(KEY_O), 100 | LABEL(KEY_P), 101 | LABEL(KEY_LEFTBRACE), 102 | LABEL(KEY_RIGHTBRACE), 103 | LABEL(KEY_ENTER), 104 | LABEL(KEY_LEFTCTRL), 105 | LABEL(KEY_A), 106 | LABEL(KEY_S), 107 | LABEL(KEY_D), 108 | LABEL(KEY_F), 109 | LABEL(KEY_G), 110 | LABEL(KEY_H), 111 | LABEL(KEY_J), 112 | LABEL(KEY_K), 113 | LABEL(KEY_L), 114 | LABEL(KEY_SEMICOLON), 115 | LABEL(KEY_APOSTROPHE), 116 | LABEL(KEY_GRAVE), 117 | LABEL(KEY_LEFTSHIFT), 118 | LABEL(KEY_BACKSLASH), 119 | LABEL(KEY_Z), 120 | LABEL(KEY_X), 121 | LABEL(KEY_C), 122 | LABEL(KEY_V), 123 | LABEL(KEY_B), 124 | LABEL(KEY_N), 125 | LABEL(KEY_M), 126 | LABEL(KEY_COMMA), 127 | LABEL(KEY_DOT), 128 | LABEL(KEY_SLASH), 129 | LABEL(KEY_RIGHTSHIFT), 130 | LABEL(KEY_KPASTERISK), 131 | LABEL(KEY_LEFTALT), 132 | LABEL(KEY_SPACE), 133 | LABEL(KEY_CAPSLOCK), 134 | LABEL(KEY_F1), 135 | LABEL(KEY_F2), 136 | LABEL(KEY_F3), 137 | LABEL(KEY_F4), 138 | LABEL(KEY_F5), 139 | LABEL(KEY_F6), 140 | LABEL(KEY_F7), 141 | LABEL(KEY_F8), 142 | LABEL(KEY_F9), 143 | LABEL(KEY_F10), 144 | LABEL(KEY_NUMLOCK), 145 | LABEL(KEY_SCROLLLOCK), 146 | LABEL(KEY_KP7), 147 | LABEL(KEY_KP8), 148 | LABEL(KEY_KP9), 149 | LABEL(KEY_KPMINUS), 150 | LABEL(KEY_KP4), 151 | LABEL(KEY_KP5), 152 | LABEL(KEY_KP6), 153 | LABEL(KEY_KPPLUS), 154 | LABEL(KEY_KP1), 155 | LABEL(KEY_KP2), 156 | LABEL(KEY_KP3), 157 | LABEL(KEY_KP0), 158 | LABEL(KEY_KPDOT), 159 | LABEL(KEY_ZENKAKUHANKAKU), 160 | LABEL(KEY_102ND), 161 | LABEL(KEY_F11), 162 | LABEL(KEY_F12), 163 | LABEL(KEY_RO), 164 | LABEL(KEY_KATAKANA), 165 | LABEL(KEY_HIRAGANA), 166 | LABEL(KEY_HENKAN), 167 | LABEL(KEY_KATAKANAHIRAGANA), 168 | LABEL(KEY_MUHENKAN), 169 | LABEL(KEY_KPJPCOMMA), 170 | LABEL(KEY_KPENTER), 171 | LABEL(KEY_RIGHTCTRL), 172 | LABEL(KEY_KPSLASH), 173 | LABEL(KEY_SYSRQ), 174 | LABEL(KEY_RIGHTALT), 175 | LABEL(KEY_LINEFEED), 176 | LABEL(KEY_HOME), 177 | LABEL(KEY_UP), 178 | LABEL(KEY_PAGEUP), 179 | LABEL(KEY_LEFT), 180 | LABEL(KEY_RIGHT), 181 | LABEL(KEY_END), 182 | LABEL(KEY_DOWN), 183 | LABEL(KEY_PAGEDOWN), 184 | LABEL(KEY_INSERT), 185 | LABEL(KEY_DELETE), 186 | LABEL(KEY_MACRO), 187 | LABEL(KEY_MUTE), 188 | LABEL(KEY_VOLUMEDOWN), 189 | LABEL(KEY_VOLUMEUP), 190 | LABEL(KEY_POWER), 191 | LABEL(KEY_KPEQUAL), 192 | LABEL(KEY_KPPLUSMINUS), 193 | LABEL(KEY_PAUSE), 194 | LABEL(KEY_SCALE), 195 | LABEL(KEY_KPCOMMA), 196 | LABEL(KEY_HANGEUL), 197 | LABEL(KEY_HANGUEL), 198 | LABEL(KEY_HANJA), 199 | LABEL(KEY_YEN), 200 | LABEL(KEY_LEFTMETA), 201 | LABEL(KEY_RIGHTMETA), 202 | LABEL(KEY_COMPOSE), 203 | LABEL(KEY_STOP), 204 | LABEL(KEY_AGAIN), 205 | LABEL(KEY_PROPS), 206 | LABEL(KEY_UNDO), 207 | LABEL(KEY_FRONT), 208 | LABEL(KEY_COPY), 209 | LABEL(KEY_OPEN), 210 | LABEL(KEY_PASTE), 211 | LABEL(KEY_FIND), 212 | LABEL(KEY_CUT), 213 | LABEL(KEY_HELP), 214 | LABEL(KEY_MENU), 215 | LABEL(KEY_CALC), 216 | LABEL(KEY_SETUP), 217 | LABEL(KEY_SLEEP), 218 | LABEL(KEY_WAKEUP), 219 | LABEL(KEY_FILE), 220 | LABEL(KEY_SENDFILE), 221 | LABEL(KEY_DELETEFILE), 222 | LABEL(KEY_XFER), 223 | LABEL(KEY_PROG1), 224 | LABEL(KEY_PROG2), 225 | LABEL(KEY_WWW), 226 | LABEL(KEY_MSDOS), 227 | LABEL(KEY_COFFEE), 228 | LABEL(KEY_SCREENLOCK), 229 | LABEL(KEY_DIRECTION), 230 | LABEL(KEY_CYCLEWINDOWS), 231 | LABEL(KEY_MAIL), 232 | LABEL(KEY_BOOKMARKS), 233 | LABEL(KEY_COMPUTER), 234 | LABEL(KEY_BACK), 235 | LABEL(KEY_FORWARD), 236 | LABEL(KEY_CLOSECD), 237 | LABEL(KEY_EJECTCD), 238 | LABEL(KEY_EJECTCLOSECD), 239 | LABEL(KEY_NEXTSONG), 240 | LABEL(KEY_PLAYPAUSE), 241 | LABEL(KEY_PREVIOUSSONG), 242 | LABEL(KEY_STOPCD), 243 | LABEL(KEY_RECORD), 244 | LABEL(KEY_REWIND), 245 | LABEL(KEY_PHONE), 246 | LABEL(KEY_ISO), 247 | LABEL(KEY_CONFIG), 248 | LABEL(KEY_HOMEPAGE), 249 | LABEL(KEY_REFRESH), 250 | LABEL(KEY_EXIT), 251 | LABEL(KEY_MOVE), 252 | LABEL(KEY_EDIT), 253 | LABEL(KEY_SCROLLUP), 254 | LABEL(KEY_SCROLLDOWN), 255 | LABEL(KEY_KPLEFTPAREN), 256 | LABEL(KEY_KPRIGHTPAREN), 257 | LABEL(KEY_NEW), 258 | LABEL(KEY_REDO), 259 | LABEL(KEY_F13), 260 | LABEL(KEY_F14), 261 | LABEL(KEY_F15), 262 | LABEL(KEY_F16), 263 | LABEL(KEY_F17), 264 | LABEL(KEY_F18), 265 | LABEL(KEY_F19), 266 | LABEL(KEY_F20), 267 | LABEL(KEY_F21), 268 | LABEL(KEY_F22), 269 | LABEL(KEY_F23), 270 | LABEL(KEY_F24), 271 | LABEL(KEY_PLAYCD), 272 | LABEL(KEY_PAUSECD), 273 | LABEL(KEY_PROG3), 274 | LABEL(KEY_PROG4), 275 | LABEL(KEY_DASHBOARD), 276 | LABEL(KEY_SUSPEND), 277 | LABEL(KEY_CLOSE), 278 | LABEL(KEY_PLAY), 279 | LABEL(KEY_FASTFORWARD), 280 | LABEL(KEY_BASSBOOST), 281 | LABEL(KEY_PRINT), 282 | LABEL(KEY_HP), 283 | LABEL(KEY_CAMERA), 284 | LABEL(KEY_SOUND), 285 | LABEL(KEY_QUESTION), 286 | LABEL(KEY_EMAIL), 287 | LABEL(KEY_CHAT), 288 | LABEL(KEY_SEARCH), 289 | LABEL(KEY_CONNECT), 290 | LABEL(KEY_FINANCE), 291 | LABEL(KEY_SPORT), 292 | LABEL(KEY_SHOP), 293 | LABEL(KEY_ALTERASE), 294 | LABEL(KEY_CANCEL), 295 | LABEL(KEY_BRIGHTNESSDOWN), 296 | LABEL(KEY_BRIGHTNESSUP), 297 | LABEL(KEY_MEDIA), 298 | LABEL(KEY_SWITCHVIDEOMODE), 299 | LABEL(KEY_KBDILLUMTOGGLE), 300 | LABEL(KEY_KBDILLUMDOWN), 301 | LABEL(KEY_KBDILLUMUP), 302 | LABEL(KEY_SEND), 303 | LABEL(KEY_REPLY), 304 | LABEL(KEY_FORWARDMAIL), 305 | LABEL(KEY_SAVE), 306 | LABEL(KEY_DOCUMENTS), 307 | LABEL(KEY_BATTERY), 308 | LABEL(KEY_BLUETOOTH), 309 | LABEL(KEY_WLAN), 310 | LABEL(KEY_UWB), 311 | LABEL(KEY_UNKNOWN), 312 | LABEL(KEY_VIDEO_NEXT), 313 | LABEL(KEY_VIDEO_PREV), 314 | LABEL(KEY_BRIGHTNESS_CYCLE), 315 | LABEL(KEY_BRIGHTNESS_ZERO), 316 | LABEL(KEY_DISPLAY_OFF), 317 | LABEL(KEY_WIMAX), 318 | LABEL(KEY_RFKILL), 319 | LABEL(BTN_0), 320 | LABEL(BTN_1), 321 | LABEL(BTN_2), 322 | LABEL(BTN_3), 323 | LABEL(BTN_4), 324 | LABEL(BTN_5), 325 | LABEL(BTN_6), 326 | LABEL(BTN_7), 327 | LABEL(BTN_8), 328 | LABEL(BTN_9), 329 | LABEL(BTN_LEFT), 330 | LABEL(BTN_RIGHT), 331 | LABEL(BTN_MIDDLE), 332 | LABEL(BTN_SIDE), 333 | LABEL(BTN_EXTRA), 334 | LABEL(BTN_FORWARD), 335 | LABEL(BTN_BACK), 336 | LABEL(BTN_TASK), 337 | LABEL(BTN_JOYSTICK), 338 | LABEL(BTN_TRIGGER), 339 | LABEL(BTN_THUMB), 340 | LABEL(BTN_THUMB2), 341 | LABEL(BTN_TOP), 342 | LABEL(BTN_TOP2), 343 | LABEL(BTN_PINKIE), 344 | LABEL(BTN_BASE), 345 | LABEL(BTN_BASE2), 346 | LABEL(BTN_BASE3), 347 | LABEL(BTN_BASE4), 348 | LABEL(BTN_BASE5), 349 | LABEL(BTN_BASE6), 350 | LABEL(BTN_DEAD), 351 | LABEL(BTN_A), 352 | LABEL(BTN_B), 353 | LABEL(BTN_C), 354 | LABEL(BTN_X), 355 | LABEL(BTN_Y), 356 | LABEL(BTN_Z), 357 | LABEL(BTN_TL), 358 | LABEL(BTN_TR), 359 | LABEL(BTN_TL2), 360 | LABEL(BTN_TR2), 361 | LABEL(BTN_SELECT), 362 | LABEL(BTN_START), 363 | LABEL(BTN_MODE), 364 | LABEL(BTN_THUMBL), 365 | LABEL(BTN_THUMBR), 366 | LABEL(BTN_TOOL_PEN), 367 | LABEL(BTN_TOOL_RUBBER), 368 | LABEL(BTN_TOOL_BRUSH), 369 | LABEL(BTN_TOOL_PENCIL), 370 | LABEL(BTN_TOOL_AIRBRUSH), 371 | LABEL(BTN_TOOL_FINGER), 372 | LABEL(BTN_TOOL_MOUSE), 373 | LABEL(BTN_TOOL_LENS), 374 | LABEL(BTN_TOUCH), 375 | LABEL(BTN_STYLUS), 376 | LABEL(BTN_STYLUS2), 377 | LABEL(BTN_TOOL_DOUBLETAP), 378 | LABEL(BTN_TOOL_TRIPLETAP), 379 | LABEL(BTN_TOOL_QUADTAP), 380 | LABEL(BTN_GEAR_DOWN), 381 | LABEL(BTN_GEAR_UP), 382 | LABEL(KEY_OK), 383 | LABEL(KEY_SELECT), 384 | LABEL(KEY_GOTO), 385 | LABEL(KEY_CLEAR), 386 | LABEL(KEY_POWER2), 387 | LABEL(KEY_OPTION), 388 | LABEL(KEY_INFO), 389 | LABEL(KEY_TIME), 390 | LABEL(KEY_VENDOR), 391 | LABEL(KEY_ARCHIVE), 392 | LABEL(KEY_PROGRAM), 393 | LABEL(KEY_CHANNEL), 394 | LABEL(KEY_FAVORITES), 395 | LABEL(KEY_EPG), 396 | LABEL(KEY_PVR), 397 | LABEL(KEY_MHP), 398 | LABEL(KEY_LANGUAGE), 399 | LABEL(KEY_TITLE), 400 | LABEL(KEY_SUBTITLE), 401 | LABEL(KEY_ANGLE), 402 | LABEL(KEY_ZOOM), 403 | LABEL(KEY_MODE), 404 | LABEL(KEY_KEYBOARD), 405 | LABEL(KEY_SCREEN), 406 | LABEL(KEY_PC), 407 | LABEL(KEY_TV), 408 | LABEL(KEY_TV2), 409 | LABEL(KEY_VCR), 410 | LABEL(KEY_VCR2), 411 | LABEL(KEY_SAT), 412 | LABEL(KEY_SAT2), 413 | LABEL(KEY_CD), 414 | LABEL(KEY_TAPE), 415 | LABEL(KEY_RADIO), 416 | LABEL(KEY_TUNER), 417 | LABEL(KEY_PLAYER), 418 | LABEL(KEY_TEXT), 419 | LABEL(KEY_DVD), 420 | LABEL(KEY_AUX), 421 | LABEL(KEY_MP3), 422 | LABEL(KEY_AUDIO), 423 | LABEL(KEY_VIDEO), 424 | LABEL(KEY_DIRECTORY), 425 | LABEL(KEY_LIST), 426 | LABEL(KEY_MEMO), 427 | LABEL(KEY_CALENDAR), 428 | LABEL(KEY_RED), 429 | LABEL(KEY_GREEN), 430 | LABEL(KEY_YELLOW), 431 | LABEL(KEY_BLUE), 432 | LABEL(KEY_CHANNELUP), 433 | LABEL(KEY_CHANNELDOWN), 434 | LABEL(KEY_FIRST), 435 | LABEL(KEY_LAST), 436 | LABEL(KEY_AB), 437 | LABEL(KEY_NEXT), 438 | LABEL(KEY_RESTART), 439 | LABEL(KEY_SLOW), 440 | LABEL(KEY_SHUFFLE), 441 | LABEL(KEY_BREAK), 442 | LABEL(KEY_PREVIOUS), 443 | LABEL(KEY_DIGITS), 444 | LABEL(KEY_TEEN), 445 | LABEL(KEY_TWEN), 446 | LABEL(KEY_VIDEOPHONE), 447 | LABEL(KEY_GAMES), 448 | LABEL(KEY_ZOOMIN), 449 | LABEL(KEY_ZOOMOUT), 450 | LABEL(KEY_ZOOMRESET), 451 | LABEL(KEY_WORDPROCESSOR), 452 | LABEL(KEY_EDITOR), 453 | LABEL(KEY_SPREADSHEET), 454 | LABEL(KEY_GRAPHICSEDITOR), 455 | LABEL(KEY_PRESENTATION), 456 | LABEL(KEY_DATABASE), 457 | LABEL(KEY_NEWS), 458 | LABEL(KEY_VOICEMAIL), 459 | LABEL(KEY_ADDRESSBOOK), 460 | LABEL(KEY_MESSENGER), 461 | LABEL(KEY_DISPLAYTOGGLE), 462 | LABEL(KEY_SPELLCHECK), 463 | LABEL(KEY_LOGOFF), 464 | LABEL(KEY_DOLLAR), 465 | LABEL(KEY_EURO), 466 | LABEL(KEY_FRAMEBACK), 467 | LABEL(KEY_FRAMEFORWARD), 468 | LABEL(KEY_CONTEXT_MENU), 469 | LABEL(KEY_MEDIA_REPEAT), 470 | LABEL(KEY_10CHANNELSUP), 471 | LABEL(KEY_10CHANNELSDOWN), 472 | LABEL(KEY_IMAGES), 473 | LABEL(KEY_DEL_EOL), 474 | LABEL(KEY_DEL_EOS), 475 | LABEL(KEY_INS_LINE), 476 | LABEL(KEY_DEL_LINE), 477 | LABEL(KEY_FN), 478 | LABEL(KEY_FN_ESC), 479 | LABEL(KEY_FN_F1), 480 | LABEL(KEY_FN_F2), 481 | LABEL(KEY_FN_F3), 482 | LABEL(KEY_FN_F4), 483 | LABEL(KEY_FN_F5), 484 | LABEL(KEY_FN_F6), 485 | LABEL(KEY_FN_F7), 486 | LABEL(KEY_FN_F8), 487 | LABEL(KEY_FN_F9), 488 | LABEL(KEY_FN_F10), 489 | LABEL(KEY_FN_F11), 490 | LABEL(KEY_FN_F12), 491 | LABEL(KEY_FN_1), 492 | LABEL(KEY_FN_2), 493 | LABEL(KEY_FN_D), 494 | LABEL(KEY_FN_E), 495 | LABEL(KEY_FN_F), 496 | LABEL(KEY_FN_S), 497 | LABEL(KEY_FN_B), 498 | LABEL(KEY_BRL_DOT1), 499 | LABEL(KEY_BRL_DOT2), 500 | LABEL(KEY_BRL_DOT3), 501 | LABEL(KEY_BRL_DOT4), 502 | LABEL(KEY_BRL_DOT5), 503 | LABEL(KEY_BRL_DOT6), 504 | LABEL(KEY_BRL_DOT7), 505 | LABEL(KEY_BRL_DOT8), 506 | LABEL(KEY_BRL_DOT9), 507 | LABEL(KEY_BRL_DOT10), 508 | LABEL(KEY_NUMERIC_0), 509 | LABEL(KEY_NUMERIC_1), 510 | LABEL(KEY_NUMERIC_2), 511 | LABEL(KEY_NUMERIC_3), 512 | LABEL(KEY_NUMERIC_4), 513 | LABEL(KEY_NUMERIC_5), 514 | LABEL(KEY_NUMERIC_6), 515 | LABEL(KEY_NUMERIC_7), 516 | LABEL(KEY_NUMERIC_8), 517 | LABEL(KEY_NUMERIC_9), 518 | LABEL(KEY_NUMERIC_STAR), 519 | LABEL(KEY_NUMERIC_POUND), 520 | LABEL(KEY_CAMERA_FOCUS), 521 | LABEL(KEY_WPS_BUTTON), 522 | LABEL(KEY_TOUCHPAD_TOGGLE), 523 | LABEL(KEY_TOUCHPAD_ON), 524 | LABEL(KEY_TOUCHPAD_OFF), 525 | LABEL(KEY_CAMERA_ZOOMIN), 526 | LABEL(KEY_CAMERA_ZOOMOUT), 527 | LABEL(KEY_CAMERA_UP), 528 | LABEL(KEY_CAMERA_DOWN), 529 | LABEL(KEY_CAMERA_LEFT), 530 | LABEL(KEY_CAMERA_RIGHT), 531 | LABEL(BTN_TRIGGER_HAPPY1), 532 | LABEL(BTN_TRIGGER_HAPPY2), 533 | LABEL(BTN_TRIGGER_HAPPY3), 534 | LABEL(BTN_TRIGGER_HAPPY4), 535 | LABEL(BTN_TRIGGER_HAPPY5), 536 | LABEL(BTN_TRIGGER_HAPPY6), 537 | LABEL(BTN_TRIGGER_HAPPY7), 538 | LABEL(BTN_TRIGGER_HAPPY8), 539 | LABEL(BTN_TRIGGER_HAPPY9), 540 | LABEL(BTN_TRIGGER_HAPPY10), 541 | LABEL(BTN_TRIGGER_HAPPY11), 542 | LABEL(BTN_TRIGGER_HAPPY12), 543 | LABEL(BTN_TRIGGER_HAPPY13), 544 | LABEL(BTN_TRIGGER_HAPPY14), 545 | LABEL(BTN_TRIGGER_HAPPY15), 546 | LABEL(BTN_TRIGGER_HAPPY16), 547 | LABEL(BTN_TRIGGER_HAPPY17), 548 | LABEL(BTN_TRIGGER_HAPPY18), 549 | LABEL(BTN_TRIGGER_HAPPY19), 550 | LABEL(BTN_TRIGGER_HAPPY20), 551 | LABEL(BTN_TRIGGER_HAPPY21), 552 | LABEL(BTN_TRIGGER_HAPPY22), 553 | LABEL(BTN_TRIGGER_HAPPY23), 554 | LABEL(BTN_TRIGGER_HAPPY24), 555 | LABEL(BTN_TRIGGER_HAPPY25), 556 | LABEL(BTN_TRIGGER_HAPPY26), 557 | LABEL(BTN_TRIGGER_HAPPY27), 558 | LABEL(BTN_TRIGGER_HAPPY28), 559 | LABEL(BTN_TRIGGER_HAPPY29), 560 | LABEL(BTN_TRIGGER_HAPPY30), 561 | LABEL(BTN_TRIGGER_HAPPY31), 562 | LABEL(BTN_TRIGGER_HAPPY32), 563 | LABEL(BTN_TRIGGER_HAPPY33), 564 | LABEL(BTN_TRIGGER_HAPPY34), 565 | LABEL(BTN_TRIGGER_HAPPY35), 566 | LABEL(BTN_TRIGGER_HAPPY36), 567 | LABEL(BTN_TRIGGER_HAPPY37), 568 | LABEL(BTN_TRIGGER_HAPPY38), 569 | LABEL(BTN_TRIGGER_HAPPY39), 570 | LABEL(BTN_TRIGGER_HAPPY40), 571 | LABEL_END, 572 | }; 573 | 574 | static struct label rel_labels[] = { 575 | LABEL(REL_X), 576 | LABEL(REL_Y), 577 | LABEL(REL_Z), 578 | LABEL(REL_RX), 579 | LABEL(REL_RY), 580 | LABEL(REL_RZ), 581 | LABEL(REL_HWHEEL), 582 | LABEL(REL_DIAL), 583 | LABEL(REL_WHEEL), 584 | LABEL(REL_MISC), 585 | LABEL_END, 586 | }; 587 | 588 | static struct label abs_labels[] = { 589 | LABEL(ABS_X), 590 | LABEL(ABS_Y), 591 | LABEL(ABS_Z), 592 | LABEL(ABS_RX), 593 | LABEL(ABS_RY), 594 | LABEL(ABS_RZ), 595 | LABEL(ABS_THROTTLE), 596 | LABEL(ABS_RUDDER), 597 | LABEL(ABS_WHEEL), 598 | LABEL(ABS_GAS), 599 | LABEL(ABS_BRAKE), 600 | LABEL(ABS_HAT0X), 601 | LABEL(ABS_HAT0Y), 602 | LABEL(ABS_HAT1X), 603 | LABEL(ABS_HAT1Y), 604 | LABEL(ABS_HAT2X), 605 | LABEL(ABS_HAT2Y), 606 | LABEL(ABS_HAT3X), 607 | LABEL(ABS_HAT3Y), 608 | LABEL(ABS_PRESSURE), 609 | LABEL(ABS_DISTANCE), 610 | LABEL(ABS_TILT_X), 611 | LABEL(ABS_TILT_Y), 612 | LABEL(ABS_TOOL_WIDTH), 613 | LABEL(ABS_VOLUME), 614 | LABEL(ABS_MISC), 615 | LABEL(ABS_MT_SLOT), 616 | LABEL(ABS_MT_TOUCH_MAJOR), 617 | LABEL(ABS_MT_TOUCH_MINOR), 618 | LABEL(ABS_MT_WIDTH_MAJOR), 619 | LABEL(ABS_MT_WIDTH_MINOR), 620 | LABEL(ABS_MT_ORIENTATION), 621 | LABEL(ABS_MT_POSITION_X), 622 | LABEL(ABS_MT_POSITION_Y), 623 | LABEL(ABS_MT_TOOL_TYPE), 624 | LABEL(ABS_MT_BLOB_ID), 625 | LABEL(ABS_MT_TRACKING_ID), 626 | LABEL(ABS_MT_PRESSURE), 627 | LABEL(ABS_MT_DISTANCE), 628 | LABEL_END, 629 | }; 630 | 631 | static struct label sw_labels[] = { 632 | LABEL(SW_LID), 633 | LABEL(SW_TABLET_MODE), 634 | LABEL(SW_HEADPHONE_INSERT), 635 | LABEL(SW_RFKILL_ALL), 636 | LABEL(SW_RADIO), 637 | LABEL(SW_MICROPHONE_INSERT), 638 | LABEL(SW_DOCK), 639 | LABEL(SW_LINEOUT_INSERT), 640 | LABEL(SW_JACK_PHYSICAL_INSERT), 641 | LABEL(SW_VIDEOOUT_INSERT), 642 | LABEL(SW_CAMERA_LENS_COVER), 643 | LABEL(SW_KEYPAD_SLIDE), 644 | LABEL(SW_FRONT_PROXIMITY), 645 | LABEL(SW_ROTATE_LOCK), 646 | LABEL_END, 647 | }; 648 | 649 | static struct label msc_labels[] = { 650 | LABEL(MSC_SERIAL), 651 | LABEL(MSC_PULSELED), 652 | LABEL(MSC_GESTURE), 653 | LABEL(MSC_RAW), 654 | LABEL(MSC_SCAN), 655 | LABEL_END, 656 | }; 657 | 658 | static struct label led_labels[] = { 659 | LABEL(LED_NUML), 660 | LABEL(LED_CAPSL), 661 | LABEL(LED_SCROLLL), 662 | LABEL(LED_COMPOSE), 663 | LABEL(LED_KANA), 664 | LABEL(LED_SLEEP), 665 | LABEL(LED_SUSPEND), 666 | LABEL(LED_MUTE), 667 | LABEL(LED_MISC), 668 | LABEL(LED_MAIL), 669 | LABEL(LED_CHARGING), 670 | LABEL_END, 671 | }; 672 | 673 | static struct label rep_labels[] = { 674 | LABEL(REP_DELAY), 675 | LABEL(REP_PERIOD), 676 | LABEL_END, 677 | }; 678 | 679 | static struct label snd_labels[] = { 680 | LABEL(SND_CLICK), 681 | LABEL(SND_BELL), 682 | LABEL(SND_TONE), 683 | LABEL_END, 684 | }; 685 | 686 | static struct label id_labels[] = { 687 | LABEL(ID_BUS), 688 | LABEL(ID_VENDOR), 689 | LABEL(ID_PRODUCT), 690 | LABEL(ID_VERSION), 691 | LABEL_END, 692 | }; 693 | 694 | static struct label bus_labels[] = { 695 | LABEL(BUS_PCI), 696 | LABEL(BUS_ISAPNP), 697 | LABEL(BUS_USB), 698 | LABEL(BUS_HIL), 699 | LABEL(BUS_BLUETOOTH), 700 | LABEL(BUS_VIRTUAL), 701 | LABEL(BUS_ISA), 702 | LABEL(BUS_I8042), 703 | LABEL(BUS_XTKBD), 704 | LABEL(BUS_RS232), 705 | LABEL(BUS_GAMEPORT), 706 | LABEL(BUS_PARPORT), 707 | LABEL(BUS_AMIGA), 708 | LABEL(BUS_ADB), 709 | LABEL(BUS_I2C), 710 | LABEL(BUS_HOST), 711 | LABEL(BUS_GSC), 712 | LABEL(BUS_ATARI), 713 | LABEL(BUS_SPI), 714 | LABEL_END, 715 | }; 716 | 717 | static struct label mt_tool_labels[] = { 718 | LABEL(MT_TOOL_FINGER), 719 | LABEL(MT_TOOL_PEN), 720 | LABEL(MT_TOOL_MAX), 721 | LABEL_END, 722 | }; 723 | 724 | static struct label ff_status_labels[] = { 725 | LABEL(FF_STATUS_STOPPED), 726 | LABEL(FF_STATUS_PLAYING), 727 | LABEL(FF_STATUS_MAX), 728 | LABEL_END, 729 | }; 730 | 731 | static struct label ff_labels[] = { 732 | LABEL(FF_RUMBLE), 733 | LABEL(FF_PERIODIC), 734 | LABEL(FF_CONSTANT), 735 | LABEL(FF_SPRING), 736 | LABEL(FF_FRICTION), 737 | LABEL(FF_DAMPER), 738 | LABEL(FF_INERTIA), 739 | LABEL(FF_RAMP), 740 | LABEL(FF_SQUARE), 741 | LABEL(FF_TRIANGLE), 742 | LABEL(FF_SINE), 743 | LABEL(FF_SAW_UP), 744 | LABEL(FF_SAW_DOWN), 745 | LABEL(FF_CUSTOM), 746 | LABEL(FF_GAIN), 747 | LABEL(FF_AUTOCENTER), 748 | LABEL_END, 749 | }; 750 | 751 | static struct label key_value_labels[] = { 752 | { "UP", 0 }, 753 | { "DOWN", 1 }, 754 | { "REPEAT", 2 }, 755 | LABEL_END, 756 | }; 757 | -------------------------------------------------------------------------------- /jni/gpl-2.0.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/armeabi/libEventInjector.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/libs/armeabi/libEventInjector.so -------------------------------------------------------------------------------- /obj/local/armeabi/libEventInjector.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/obj/local/armeabi/libEventInjector.so -------------------------------------------------------------------------------- /obj/local/armeabi/objs/EventInjector/EventInjector.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/obj/local/armeabi/objs/EventInjector/EventInjector.o -------------------------------------------------------------------------------- /obj/local/armeabi/objs/EventInjector/EventInjector.o.d: -------------------------------------------------------------------------------- 1 | obj/local/armeabi/objs/EventInjector/EventInjector.o: jni/EventInjector.c \ 2 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/string.h \ 3 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/cdefs.h \ 4 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/cdefs_elf.h \ 5 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/malloc.h \ 6 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/stdint.h \ 7 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/_types.h \ 8 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/_types.h \ 9 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h \ 10 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/stdlib.h \ 11 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/alloca.h \ 12 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/strings.h \ 13 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/types.h \ 14 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/posix_types.h \ 15 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/stddef.h \ 16 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/compiler.h \ 17 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/posix_types.h \ 18 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/types.h \ 19 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/types.h \ 20 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/kernel.h \ 21 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/sysmacros.h \ 22 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/memory.h \ 23 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/unistd.h \ 24 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/select.h \ 25 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/time.h \ 26 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/time.h \ 27 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/signal.h \ 28 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/limits.h \ 29 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/limits.h \ 30 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/limits.h \ 31 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/internal_types.h \ 32 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/limits.h \ 33 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/syslimits.h \ 34 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/signal.h \ 35 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/signal.h \ 36 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/sigcontext.h \ 37 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/siginfo.h \ 38 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/siginfo.h \ 39 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/sysconf.h \ 40 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/capability.h \ 41 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/pathconf.h \ 42 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/fcntl.h \ 43 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/fcntl.h \ 44 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/fcntl.h \ 45 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/fcntl.h \ 46 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/stdio.h \ 47 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/dirent.h \ 48 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/time.h \ 49 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/errno.h \ 50 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/errno.h \ 51 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/errno.h \ 52 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/errno.h \ 53 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/errno-base.h \ 54 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/ioctl.h \ 55 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/ioctl.h \ 56 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/ioctl.h \ 57 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/ioctl.h \ 58 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/ioctls.h \ 59 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/termbits.h \ 60 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/ioctl_compat.h \ 61 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/mman.h \ 62 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/mman.h \ 63 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/mman.h \ 64 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/page.h \ 65 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/inotify.h \ 66 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/inotify.h \ 67 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/poll.h \ 68 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/poll.h \ 69 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/poll.h \ 70 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/poll.h \ 71 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/fb.h \ 72 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/kd.h \ 73 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/input.h \ 74 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/android/log.h \ 75 | jni/EventInjector.h 76 | 77 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/string.h: 78 | 79 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/cdefs.h: 80 | 81 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/cdefs_elf.h: 82 | 83 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/malloc.h: 84 | 85 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/stdint.h: 86 | 87 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/_types.h: 88 | 89 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/_types.h: 90 | 91 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h: 92 | 93 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/stdlib.h: 94 | 95 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/alloca.h: 96 | 97 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/strings.h: 98 | 99 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/types.h: 100 | 101 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/posix_types.h: 102 | 103 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/stddef.h: 104 | 105 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/compiler.h: 106 | 107 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/posix_types.h: 108 | 109 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/types.h: 110 | 111 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/types.h: 112 | 113 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/kernel.h: 114 | 115 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/sysmacros.h: 116 | 117 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/memory.h: 118 | 119 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/unistd.h: 120 | 121 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/select.h: 122 | 123 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/time.h: 124 | 125 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/time.h: 126 | 127 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/signal.h: 128 | 129 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/limits.h: 130 | 131 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/limits.h: 132 | 133 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/limits.h: 134 | 135 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/internal_types.h: 136 | 137 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/machine/limits.h: 138 | 139 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/syslimits.h: 140 | 141 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/signal.h: 142 | 143 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/signal.h: 144 | 145 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/sigcontext.h: 146 | 147 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/siginfo.h: 148 | 149 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/siginfo.h: 150 | 151 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/sysconf.h: 152 | 153 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/capability.h: 154 | 155 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/pathconf.h: 156 | 157 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/fcntl.h: 158 | 159 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/fcntl.h: 160 | 161 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/fcntl.h: 162 | 163 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/fcntl.h: 164 | 165 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/stdio.h: 166 | 167 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/dirent.h: 168 | 169 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/time.h: 170 | 171 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/errno.h: 172 | 173 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/errno.h: 174 | 175 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/errno.h: 176 | 177 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/errno.h: 178 | 179 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/errno-base.h: 180 | 181 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/ioctl.h: 182 | 183 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/ioctl.h: 184 | 185 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/ioctl.h: 186 | 187 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/ioctl.h: 188 | 189 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/ioctls.h: 190 | 191 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/termbits.h: 192 | 193 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/ioctl_compat.h: 194 | 195 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/mman.h: 196 | 197 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/mman.h: 198 | 199 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm-generic/mman.h: 200 | 201 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/page.h: 202 | 203 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/inotify.h: 204 | 205 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/inotify.h: 206 | 207 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/sys/poll.h: 208 | 209 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/poll.h: 210 | 211 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/poll.h: 212 | 213 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/asm/poll.h: 214 | 215 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/fb.h: 216 | 217 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/kd.h: 218 | 219 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/linux/input.h: 220 | 221 | c:/home/work_code/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/android/log.h: 222 | 223 | jni/EventInjector.h: 224 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-10 15 | -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-hdpi/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/res/drawable-hdpi/list.png -------------------------------------------------------------------------------- /res/drawable-hdpi/list_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/res/drawable-hdpi/list_open.png -------------------------------------------------------------------------------- /res/drawable-hdpi/panel_item.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/res/drawable-hdpi/panel_item.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oksep/Android-Event-Injector/0596226f9a36a4945fbf47d0f6902062029b8a90/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Android Event Injector 4 | 5 | -------------------------------------------------------------------------------- /src/net/pocketmagic/android/eventinjector/Events.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Android Event Injector 3 | * 4 | * Copyright (c) 2013 by Radu Motisan , radu.motisan@gmail.com 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | * For more information on the GPL, please go to: 21 | * http://www.gnu.org/copyleft/gpl.html 22 | * 23 | */ 24 | 25 | package net.pocketmagic.android.eventinjector; 26 | 27 | import java.util.ArrayList; 28 | 29 | import android.util.Log; 30 | 31 | 32 | public class Events 33 | { 34 | 35 | private final static String LT = "Events"; 36 | 37 | public class InputDevice { 38 | 39 | private int m_nId; 40 | private String m_szPath, m_szName; 41 | private boolean m_bOpen; 42 | 43 | InputDevice(int id, String path) { 44 | m_nId = id; m_szPath = path; 45 | } 46 | 47 | public int InjectEvent() { 48 | return 0; 49 | } 50 | 51 | public int getPollingEvent() { 52 | return PollDev(m_nId); 53 | } 54 | 55 | public int getSuccessfulPollingType() { 56 | return getType(); 57 | } 58 | public int getSuccessfulPollingCode() { 59 | return getCode(); 60 | } 61 | public int getSuccessfulPollingValue() { 62 | return getValue(); 63 | } 64 | 65 | public boolean getOpen() { 66 | return m_bOpen; 67 | } 68 | public int getId() { 69 | return m_nId; 70 | } 71 | public String getPath() { 72 | return m_szPath; 73 | } 74 | public String getName() { 75 | return m_szName; 76 | } 77 | 78 | public void Close() { 79 | m_bOpen = false; 80 | RemoveDev(m_nId); 81 | } 82 | 83 | final int EV_KEY = 0x01, 84 | EV_REL = 0x02, 85 | EV_ABS = 0x03, 86 | REL_X = 0x00, 87 | REL_Y = 0x01, 88 | REL_Z = 0x02, 89 | BTN_TOUCH = 0x14a;// 330 90 | 91 | public int SendKey(int key, boolean state) { 92 | if (state) 93 | return intSendEvent(m_nId, EV_KEY, key, 1); //key down 94 | else 95 | return intSendEvent(m_nId, EV_KEY, key, 0); //key up 96 | } 97 | public int SendTouchButton(boolean state) { 98 | if (state) 99 | //return intSendEvent(m_nId, EV_KEY, BTN_TOUCH, 1); //touch down 100 | { 101 | intSendEvent(m_nId, EV_ABS, 24,100); 102 | intSendEvent(m_nId, EV_ABS, 28,1); 103 | intSendEvent(m_nId, 1, 330, 1); // touch down 104 | } 105 | else 106 | //return intSendEvent(m_nId, EV_KEY, BTN_TOUCH, 0); //touch up 107 | { 108 | intSendEvent(m_nId, EV_ABS, 24,0); 109 | intSendEvent(m_nId, EV_ABS, 28,0); 110 | intSendEvent(m_nId, 1, 330, 0); // touch down 111 | } 112 | return 1; 113 | } 114 | public int SendTouchAbsCoord(int x, int y ) { 115 | intSendEvent(m_nId, EV_ABS, REL_X, x); //set x coord 116 | intSendEvent(m_nId, EV_ABS, REL_Y, y); //set y coord 117 | intSendEvent(m_nId, EV_ABS, 53,x); 118 | intSendEvent(m_nId, EV_ABS, 54,y); 119 | intSendEvent(m_nId, EV_ABS, 48,100); 120 | intSendEvent(m_nId, EV_ABS, 50,0); 121 | intSendEvent(m_nId, 0, 2,0); 122 | intSendEvent(m_nId, 0, 2,0); 123 | intSendEvent(m_nId, 0, 0,0); 124 | return 0; 125 | } 126 | public int SendTouchDownAbs(int x, int y ) { 127 | intSendEvent(m_nId, EV_ABS, REL_X, x); //set x coord 128 | intSendEvent(m_nId, EV_ABS, REL_Y, y); //set y coord 129 | intSendEvent(m_nId, EV_ABS, 24,100); 130 | intSendEvent(m_nId, EV_ABS, 28,1); 131 | intSendEvent(m_nId, 1, 330, 1); // touch down 132 | intSendEvent(m_nId, EV_ABS, 53,x); 133 | intSendEvent(m_nId, EV_ABS, 54,y); 134 | intSendEvent(m_nId, EV_ABS, 48,100); 135 | intSendEvent(m_nId, EV_ABS, 50,0); 136 | intSendEvent(m_nId, 0, 2,0); 137 | intSendEvent(m_nId, 0, 2,0); 138 | intSendEvent(m_nId, 0, 0,0); 139 | intSendEvent(m_nId, EV_ABS, 24,0); 140 | intSendEvent(m_nId, EV_ABS, 28,0); 141 | intSendEvent(m_nId, 1, 330,0); //touch up 142 | intSendEvent(m_nId, EV_ABS, 53,0); 143 | intSendEvent(m_nId, EV_ABS, 54,0); 144 | intSendEvent(m_nId, EV_ABS, 48,0); 145 | intSendEvent(m_nId, EV_ABS, 50,0); 146 | intSendEvent(m_nId, 0, 2,0); 147 | intSendEvent(m_nId, 0, 2,0); 148 | intSendEvent(m_nId, 0, 0,0); 149 | return 1; 150 | } 151 | public int SendTouchDown(int x, int y, int screenW, int screenH ) { 152 | int absx = (570 * x ) / screenW, 153 | absy = (950 * x ) / screenH; 154 | return SendTouchDownAbs(absx, absy); 155 | } 156 | /** 157 | * function Open : opens an input event node 158 | * @param forceOpen will try to set permissions and then reopen if first open attempt fails 159 | * @return true if input event node has been opened 160 | */ 161 | public boolean Open(boolean forceOpen) { 162 | int res = OpenDev(m_nId); 163 | // if opening fails, we might not have the correct permissions, try changing 660 to 666 164 | if (res != 0) { 165 | // possible only if we have root 166 | if(forceOpen && Shell.isSuAvailable()) { 167 | // set new permissions 168 | Shell.runCommand("chmod 666 "+ m_szPath); 169 | // reopen 170 | res = OpenDev(m_nId); 171 | } 172 | } 173 | m_szName = getDevName(m_nId); 174 | m_bOpen = (res == 0); 175 | // debug 176 | Log.d(LT, "Open:"+m_szPath+" Name:"+m_szName+" Result:"+m_bOpen); 177 | // done, return 178 | return m_bOpen; 179 | } 180 | } 181 | 182 | // top level structures 183 | public ArrayList m_Devs = new ArrayList(); 184 | 185 | 186 | public int Init() { 187 | m_Devs.clear(); 188 | int n = ScanFiles(); // return number of devs 189 | 190 | for (int i=0;i < n;i++) 191 | m_Devs.add(new InputDevice(i, getDevPath(i))); 192 | return n; 193 | } 194 | 195 | public void Release() { 196 | for (InputDevice idev: m_Devs) 197 | idev.Close(); 198 | } 199 | 200 | // JNI native code interface 201 | public native static void intEnableDebug(int enable); 202 | 203 | private native static int ScanFiles(); // return number of devs 204 | private native static int OpenDev(int devid); 205 | private native static int RemoveDev(int devid); 206 | private native static String getDevPath(int devid); 207 | private native static String getDevName(int devid); 208 | private native static int PollDev(int devid); 209 | private native static int getType(); 210 | private native static int getCode(); 211 | private native static int getValue(); 212 | // injector: 213 | private native static int intSendEvent(int devid, int type, int code, int value); 214 | 215 | static { 216 | System.loadLibrary("EventInjector"); 217 | } 218 | 219 | } 220 | 221 | 222 | -------------------------------------------------------------------------------- /src/net/pocketmagic/android/eventinjector/MainActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Android Event Injector 3 | * 4 | * Copyright (c) 2013 by Radu Motisan , radu.motisan@gmail.com 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | * For more information on the GPL, please go to: 21 | * http://www.gnu.org/copyleft/gpl.html 22 | * 23 | */ 24 | 25 | package net.pocketmagic.android.eventinjector; 26 | 27 | import java.util.ArrayList; 28 | 29 | import net.pocketmagic.android.eventinjector.Events.InputDevice; 30 | import net.pocketmagic.android.utils.CustomAdapter; 31 | import net.pocketmagic.android.utils.ListViewItem; 32 | import android.os.Bundle; 33 | import android.app.Activity; 34 | import android.graphics.Color; 35 | import android.graphics.drawable.GradientDrawable; 36 | import android.graphics.drawable.GradientDrawable.Orientation; 37 | import android.util.Log; 38 | import android.view.KeyEvent; 39 | import android.view.Menu; 40 | import android.view.MenuItem; 41 | import android.view.View; 42 | import android.view.View.OnClickListener; 43 | import android.view.ViewGroup.LayoutParams; 44 | import android.view.Window; 45 | import android.widget.AdapterView; 46 | import android.widget.AdapterView.OnItemSelectedListener; 47 | import android.widget.ArrayAdapter; 48 | import android.widget.Button; 49 | import android.widget.LinearLayout; 50 | import android.widget.ListView; 51 | import android.widget.RelativeLayout; 52 | import android.widget.Spinner; 53 | import android.widget.TextView; 54 | import android.widget.Toast; 55 | import android.support.v4.app.NavUtils; 56 | 57 | public class MainActivity extends Activity implements OnClickListener, OnItemSelectedListener { 58 | final static String LT = "MainActivity"; 59 | 60 | Events events = new Events(); 61 | boolean m_bMonitorOn = false; // used in the thread to poll for input event node messages 62 | 63 | // interface view ids 64 | final static int idButScan = Menu.FIRST + 1001, 65 | idLVDevices = Menu.FIRST + 1002, 66 | idSelSpin = Menu.FIRST + 1003, 67 | idButInjectKey = Menu.FIRST + 1004, 68 | idButInjectTouch = Menu.FIRST + 1005, 69 | idButMonitorStart = Menu.FIRST + 1006, 70 | idButMonitorStop = Menu.FIRST + 1007, 71 | idButTest = Menu.FIRST + 1008, 72 | idLVFirstItem = Menu.FIRST + 5000; 73 | // interface views 74 | TextView m_tvMonitor; // used to display monitored events, in the format code-type-value. See input.h in the NDK 75 | ListView m_lvDevices; // the listview showing devices found 76 | Spinner m_selDevSpinner; // The spinner is used to select a target for the Key and Touch buttons 77 | int m_selectedDev = -1; // index of spinner selected device, or -1 is no selection 78 | 79 | @Override 80 | public void onCreate(Bundle savedInstanceState) { 81 | super.onCreate(savedInstanceState); 82 | Log.d(LT, "App created."); 83 | 84 | Events.intEnableDebug(1); 85 | 86 | // disable the titlebar 87 | requestWindowFeature(Window.FEATURE_NO_TITLE); 88 | 89 | 90 | // create a basic user interface 91 | LinearLayout panel = new LinearLayout(this); 92 | panel.setOrientation(LinearLayout.VERTICAL); 93 | setContentView(panel); 94 | //-- 95 | Button b = new Button(this); 96 | b.setText("Scan Input Devs"); 97 | b.setId(idButScan); 98 | b.setOnClickListener(this); 99 | panel.addView(b); 100 | //-- 101 | m_lvDevices = new ListView(this); 102 | m_lvDevices.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 103 | m_lvDevices.setId(idLVDevices); 104 | m_lvDevices.setDividerHeight(0); 105 | m_lvDevices.setFadingEdgeLength(0); 106 | m_lvDevices.setCacheColorHint(0); 107 | m_lvDevices.setAdapter(null); 108 | panel.addView(m_lvDevices); 109 | //-- 110 | LinearLayout panelH = new LinearLayout(this); 111 | panelH.setOrientation(LinearLayout.HORIZONTAL); 112 | panel.addView(panelH); 113 | //-- 114 | m_selDevSpinner = new Spinner(this); 115 | m_selDevSpinner.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); 116 | m_selDevSpinner.setId(idSelSpin); 117 | m_selDevSpinner.setOnItemSelectedListener((OnItemSelectedListener) this); 118 | panelH.addView(m_selDevSpinner); 119 | //-- simulate key event 120 | b = new Button(this); 121 | b.setText(">Key"); 122 | b.setId(idButInjectKey); 123 | b.setOnClickListener(this); 124 | panelH.addView(b); 125 | //-- simulate touch event 126 | b = new Button(this); 127 | b.setText(">Tch"); 128 | b.setId(idButInjectTouch); 129 | b.setOnClickListener(this); 130 | panelH.addView(b); 131 | 132 | //-- 133 | m_tvMonitor = new TextView(this); 134 | m_tvMonitor.setText("Event Monitor stopped."); 135 | panel.addView(m_tvMonitor); 136 | //-- 137 | panelH = new LinearLayout(this); 138 | panelH.setOrientation(LinearLayout.HORIZONTAL); 139 | panel.addView(panelH); 140 | //-- 141 | b = new Button(this); 142 | b.setText("Monitor Start"); 143 | b.setId(idButMonitorStart); 144 | b.setOnClickListener(this); 145 | panelH.addView(b); 146 | //-- 147 | b = new Button(this); 148 | b.setText("Monitor Stop"); 149 | b.setId(idButMonitorStop); 150 | b.setOnClickListener(this); 151 | panelH.addView(b); 152 | //-- simulate test event 153 | b = new Button(this); 154 | b.setText(">Test"); 155 | b.setId(idButTest); 156 | b.setOnClickListener(this); 157 | panelH.addView(b); 158 | 159 | 160 | } 161 | 162 | @Override 163 | public void onDestroy() { 164 | super.onDestroy(); 165 | Log.d(LT, "App destroyed."); 166 | StopEventMonitor(); 167 | events.Release(); 168 | } 169 | 170 | public void onClick(View v) { 171 | int id = v.getId(); 172 | if (id >= idLVFirstItem) { 173 | int nLVIndexClick = id - idLVFirstItem; 174 | Log.d(LT, "LV Item Click:"+nLVIndexClick); 175 | for (InputDevice idev:events.m_Devs) { 176 | if (idev.getId() == nLVIndexClick) { 177 | if (idev.Open(true)) { 178 | // refresh listview 179 | PopulateListView(); 180 | // inform user 181 | Toast.makeText(this, "Device opened successfully!", Toast.LENGTH_SHORT).show(); 182 | } else { 183 | Toast.makeText(this, "Device failed to open. Do you have root?", Toast.LENGTH_SHORT).show(); 184 | } 185 | break; 186 | } 187 | } 188 | } 189 | 190 | switch (id) { 191 | case idButScan: { 192 | Log.d(LT, "Scanning for input dev files."); 193 | // init event node files 194 | int res = events.Init(); 195 | // debug results 196 | Log.d(LT, "Event files:"+ res); 197 | // try opening all 198 | PopulateListView(); 199 | } 200 | case idButInjectKey: 201 | if (m_selectedDev != -1) { 202 | //see input.h in Android NDK, sequence represents the codes for pocketmagic.net 203 | final int keys[] = new int[]{25,24,46,37,18,20,50,30,34,23,46,52,49,18,20}; 204 | // send all these keys with half a second delay 205 | Thread sender = new Thread(new Runnable() { 206 | public void run() { 207 | for (int i = 0; i< keys.length;i++) { 208 | Log.d(LT, "Sending:"+keys[i]+ " to:"+events.m_Devs.get(m_selectedDev).getName()); 209 | events.m_Devs.get(m_selectedDev).SendKey(keys[i], true); //key down 210 | events.m_Devs.get(m_selectedDev).SendKey(keys[i], false); //key up 211 | // a short delay before next character, just for testing purposes 212 | try { Thread.sleep(1000);} catch (InterruptedException e) { e.printStackTrace(); } 213 | } 214 | 215 | } 216 | }); 217 | sender.start(); 218 | } else 219 | Toast.makeText(this, "Select a valid device first, using the spinner to the left.", Toast.LENGTH_SHORT).show(); 220 | break; 221 | 222 | case idButInjectTouch: 223 | //absolute coordinates, on my device they go up to 570x960 224 | if (m_selectedDev!=-1) 225 | events.m_Devs.get(m_selectedDev).SendTouchDownAbs(155,183); 226 | else 227 | Toast.makeText(this, "Select a valid device first, using the spinner to the left.", Toast.LENGTH_SHORT).show(); 228 | break; 229 | 230 | case idButTest: 231 | Thread sender = new Thread(new Runnable() { 232 | public void run() { 233 | for (int i=0;i<5;i++) { 234 | SendHomeKeyToKeypad(); 235 | //a short delay before next character, just for testing purposes 236 | try { Thread.sleep(2000);} catch (InterruptedException e) { e.printStackTrace(); } 237 | } 238 | } 239 | 240 | 241 | }); 242 | sender.start(); 243 | 244 | break; 245 | case idButMonitorStart: 246 | if (m_bMonitorOn) 247 | Toast.makeText(this, "Event monitor already working. Consider opening more devices to monitor.", Toast.LENGTH_SHORT).show(); 248 | else { 249 | m_tvMonitor.post(new Runnable() { 250 | 251 | public void run() { 252 | m_tvMonitor.setText("Event Monitor running, waiting for data."); 253 | } 254 | }); 255 | StartEventMonitor(); 256 | } 257 | break; 258 | case idButMonitorStop: 259 | Toast.makeText(this, "Event monitor stopped.", Toast.LENGTH_SHORT).show(); 260 | 261 | StopEventMonitor(); 262 | m_tvMonitor.post(new Runnable() { 263 | 264 | public void run() { 265 | m_tvMonitor.setText("Event Monitor stopped."); 266 | } 267 | }); 268 | break; 269 | 270 | } 271 | } 272 | 273 | /** 274 | * Handle events when the user selects a new item in the spinner. 275 | * The spinner is used to select a target for the Key and Touch buttons 276 | * So what we do here, is to find which open-dev has been selected from within our global events.m_Devs structure 277 | * result saved in m_selectedDev, as the index of our selected open dev. 278 | */ 279 | public void onItemSelected(AdapterView arg0, View arg1, int arg2, 280 | long arg3) { 281 | int sel = arg2; 282 | 283 | int i = 0, j = 0; 284 | m_selectedDev = -1; 285 | for (InputDevice idev:events.m_Devs) { 286 | if (idev.getOpen()) { 287 | if (i == sel) { m_selectedDev = j; break; } 288 | else 289 | i++; 290 | } 291 | j ++; 292 | } 293 | if (m_selectedDev != -1) { 294 | String name = events.m_Devs.get(m_selectedDev).getName(); 295 | Log.d(LT, "spinner selected:"+sel+ " Name:"+name); 296 | Toast.makeText(this, "New device selected:"+name, Toast.LENGTH_SHORT).show(); 297 | } else 298 | Toast.makeText(this, "Invalid device selection!", Toast.LENGTH_SHORT).show(); 299 | 300 | } 301 | 302 | // not used 303 | public void onNothingSelected(AdapterView arg0) {} 304 | 305 | /** 306 | * Populated the listview with discovered devices, and the spinner with those that are open 307 | */ 308 | private void PopulateListView() { 309 | m_lvDevices.post(new Runnable() { 310 | public void run() { 311 | m_lvDevices.setAdapter(null); 312 | ArrayList m_Devices = new ArrayList(); 313 | for (InputDevice idev:events.m_Devs) { 314 | ListViewItem device = new ListViewItem( 315 | idev.getName(), 316 | idev.getPath(), 317 | idev.getOpen(), 318 | idLVFirstItem + idev.getId() 319 | ); 320 | m_Devices.add(device); 321 | } 322 | CustomAdapter m_lvAdapter = new CustomAdapter(MainActivity.this, m_Devices); 323 | if (m_lvDevices != null) m_lvDevices.setAdapter(m_lvAdapter); 324 | } 325 | }); 326 | m_selDevSpinner.post(new Runnable() { 327 | public void run() { 328 | ArrayList openDevs = new ArrayList(); 329 | 330 | for (InputDevice idev:events.m_Devs) { 331 | if (idev.getOpen()) 332 | openDevs.add(idev.getName()); 333 | } 334 | // populate spinner 335 | ArrayAdapteradapter = new ArrayAdapter( 336 | MainActivity.this, android.R.layout.simple_spinner_item, 337 | openDevs); 338 | adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice); 339 | // changes spin size and popup box size/color 340 | m_selDevSpinner.setAdapter(adapter); 341 | 342 | } 343 | }); 344 | } 345 | 346 | /** 347 | * Stops our event monitor thread 348 | */ 349 | public void StopEventMonitor() { 350 | m_bMonitorOn = false; //stop reading thread 351 | } 352 | 353 | 354 | /** 355 | * Starts our event monitor thread that does the data extraction via polling 356 | * all data is displayed in the textview, as type-code-value, see input.h in the Android NDK for more details 357 | * Monitor output is also sent to Logcat, so make sure you used that as well 358 | */ 359 | public void StartEventMonitor() { 360 | m_bMonitorOn = true; 361 | Thread b = new Thread(new Runnable() { 362 | public void run() { 363 | while (m_bMonitorOn) { 364 | for (InputDevice idev:events.m_Devs) { 365 | // Open more devices to see their messages 366 | if (idev.getOpen() && (0 == idev.getPollingEvent())) { 367 | final String line = idev.getName()+ 368 | ":" + idev.getSuccessfulPollingType()+ 369 | " " + idev.getSuccessfulPollingCode() + 370 | " " + idev.getSuccessfulPollingValue(); 371 | Log.d(LT, "Event:"+line); 372 | // update textview to show data 373 | //if (idev.getSuccessfulPollingValue() != 0) 374 | m_tvMonitor.post(new Runnable() { 375 | public void run() { 376 | m_tvMonitor.setText(line); 377 | } 378 | }); 379 | } 380 | 381 | } 382 | } 383 | } 384 | }); 385 | b.start(); 386 | } 387 | 388 | /** 389 | * Finds an open device that has a name containing keypad. This probably is the event node associated with the keypad 390 | * Its purpose is to handle all hardware Android buttons such as Back, Home, Volume, etc 391 | * Key codes are defined in input.h (see NDK) , or use the Event Monitor to see keypad messages 392 | * This function sends the Settings key 393 | */ 394 | public void SendSettingsKeyToKeypad() { 395 | for (InputDevice idev:events.m_Devs) { 396 | //* Finds an open device that has a name containing keypad. This probably is the keypad associated event node 397 | if (idev.getOpen() && idev.getName().contains("keypad")) { 398 | idev.SendKey(139, true); // settings key down 399 | idev.SendKey(139, false); // settings key up 400 | } 401 | } 402 | } 403 | /** 404 | * Finds an open device that has a name containing keypad. This probably is the event node associated with the keypad 405 | * Its purpose is to handle all hardware Android buttons such as Back, Home, Volume, etc 406 | * Key codes are defined in input.h (see NDK) , or use the Event Monitor to see keypad messages 407 | * This function sends the HOME key 408 | */ 409 | public void SendHomeKeyToKeypad() { 410 | boolean found = false; 411 | for (InputDevice idev:events.m_Devs) { 412 | //* Finds an open device that has a name containing keypad. This probably is the keypad associated event node 413 | if (idev.getOpen() && idev.getName().contains("keypad")) { 414 | idev.SendKey(102, true); // home key down 415 | idev.SendKey(102, false); // home key up 416 | found = true; break; 417 | } 418 | } 419 | if (found == false) 420 | Toast.makeText(this, "Keypad not found.", Toast.LENGTH_SHORT).show(); 421 | } 422 | /** 423 | * Finds an open device that has a name containing keypad. This probably is the event node associated with the keypad 424 | * Its purpose is to handle all hardware Android buttons such as Back, Home, Volume, etc 425 | * Key codes are defined in input.h (see NDK) , or use the Event Monitor to see keypad messages 426 | * This function sends the BACK key 427 | */ 428 | public void SendBackKeyToKeypad() { 429 | for (InputDevice idev:events.m_Devs) { 430 | //* Finds an open device that has a name containing keypad. This probably is the keypad associated event node 431 | if (idev.getOpen() && idev.getName().contains("keypad")) { 432 | idev.SendKey(158, true); // Back key down 433 | idev.SendKey(158, false); // back key up 434 | } 435 | } 436 | } 437 | } 438 | -------------------------------------------------------------------------------- /src/net/pocketmagic/android/eventinjector/Shell.java: -------------------------------------------------------------------------------- 1 | package net.pocketmagic.android.eventinjector; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.*; 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * Interface to the Superuser shell on Android devices with some helper functions.

11 | * Common usage for su shell:

12 | * if(ShellInterface.isSuAvailable()) { ShellInterface.runCommand("reboot"); } 13 | *

14 | * To get process output as a String:

15 | * if(ShellInterface.isSuAvailable()) { String date = ShellInterface.getProcessOutput("date"); } 16 | *

17 | * To run command with standard shell (no root permissions): 18 | * ShellInterface.setShell("sh");

19 | * ShellInterface.runCommand("date"); 20 | *

21 | * Date: Mar 24, 2010 22 | * Time: 4:14:07 PM 23 | * 24 | * @author serge 25 | */ 26 | 27 | public class Shell { 28 | private static final String TAG = "Shell"; 29 | 30 | private static String shell; 31 | 32 | // uid=0(root) gid=0(root) 33 | private static final Pattern UID_PATTERN = Pattern.compile("^uid=(\\d+).*?"); 34 | 35 | enum OUTPUT { 36 | STDOUT, 37 | STDERR, 38 | BOTH 39 | } 40 | 41 | private static final String EXIT = "exit\n"; 42 | 43 | private static final String[] SU_COMMANDS = new String[]{ 44 | "su", 45 | "/system/xbin/su", 46 | "/system/bin/su" 47 | }; 48 | 49 | private static final String[] TEST_COMMANDS = new String[]{ 50 | "id", 51 | "/system/xbin/id", 52 | "/system/bin/id" 53 | }; 54 | 55 | public static synchronized boolean isSuAvailable() { 56 | if (shell == null) { 57 | checkSu(); 58 | } 59 | return shell != null; 60 | } 61 | 62 | public static synchronized void setShell(String shell) { 63 | Shell.shell = shell; 64 | } 65 | 66 | private static boolean checkSu() { 67 | for (String command : SU_COMMANDS) { 68 | shell = command; 69 | if (isRootUid()) return true; 70 | } 71 | shell = null; 72 | return false; 73 | } 74 | 75 | private static boolean isRootUid() { 76 | String out = null; 77 | for (String command : TEST_COMMANDS) { 78 | out = getProcessOutput(command); 79 | if (out != null && out.length() > 0) break; 80 | } 81 | if (out == null || out.length() == 0) return false; 82 | Matcher matcher = UID_PATTERN.matcher(out); 83 | if (matcher.matches()) { 84 | if ("0".equals(matcher.group(1))) { 85 | return true; 86 | } 87 | } 88 | return false; 89 | } 90 | 91 | public static String getProcessOutput(String command) { 92 | try { 93 | return _runCommand(command, OUTPUT.STDERR); 94 | } catch (IOException ignored) { 95 | return null; 96 | } 97 | } 98 | 99 | public static boolean runCommand(String command) { 100 | try { 101 | _runCommand(command, OUTPUT.BOTH); 102 | return true; 103 | } catch (IOException ignored) { 104 | return false; 105 | } 106 | } 107 | 108 | private static String _runCommand(String command, OUTPUT o) throws IOException { 109 | DataOutputStream os = null; 110 | Process process = null; 111 | try { 112 | process = Runtime.getRuntime().exec(shell); 113 | os = new DataOutputStream(process.getOutputStream()); 114 | InputStreamHandler sh = sinkProcessOutput(process, o); 115 | os.writeBytes(command + '\n'); 116 | os.flush(); 117 | os.writeBytes(EXIT); 118 | os.flush(); 119 | process.waitFor(); 120 | if (sh != null) { 121 | String output = sh.getOutput(); 122 | Log.d(TAG, command + " output: " + output); 123 | return output; 124 | } else { 125 | return null; 126 | } 127 | } catch (Exception e) { 128 | final String msg = e.getMessage(); 129 | Log.e(TAG, "runCommand error: " + msg); 130 | throw new IOException(msg); 131 | } finally { 132 | try { 133 | if (os != null) { 134 | os.close(); 135 | } 136 | if (process != null) { 137 | process.destroy(); 138 | } 139 | } catch (Exception ignored) {} 140 | } 141 | } 142 | 143 | public static InputStreamHandler sinkProcessOutput(Process p, OUTPUT o) { 144 | InputStreamHandler output = null; 145 | switch (o) { 146 | case STDOUT: 147 | output = new InputStreamHandler(p.getErrorStream(), false); 148 | new InputStreamHandler(p.getInputStream(), true); 149 | break; 150 | case STDERR: 151 | output = new InputStreamHandler(p.getInputStream(), false); 152 | new InputStreamHandler(p.getErrorStream(), true); 153 | break; 154 | case BOTH: 155 | new InputStreamHandler(p.getInputStream(), true); 156 | new InputStreamHandler(p.getErrorStream(), true); 157 | break; 158 | } 159 | return output; 160 | } 161 | 162 | private static class InputStreamHandler extends Thread { 163 | private final InputStream stream; 164 | private final boolean sink; 165 | StringBuffer output; 166 | 167 | public String getOutput() { 168 | return output.toString(); 169 | } 170 | 171 | InputStreamHandler(InputStream stream, boolean sink) { 172 | this.sink = sink; 173 | this.stream = stream; 174 | start(); 175 | } 176 | 177 | @Override 178 | public void run() { 179 | try { 180 | if (sink) { 181 | while (stream.read() != -1) {} 182 | } else { 183 | output = new StringBuffer(); 184 | BufferedReader b = new BufferedReader(new InputStreamReader(stream)); 185 | String s; 186 | while ((s = b.readLine()) != null) { 187 | output.append(s); 188 | } 189 | } 190 | } catch (IOException ignored) {} 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /src/net/pocketmagic/android/utils/CustomAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Android Event Injector 3 | * 4 | * Copyright (c) 2013 by Radu Motisan , radu.motisan@gmail.com 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | * For more information on the GPL, please go to: 21 | * http://www.gnu.org/copyleft/gpl.html 22 | * 23 | */ 24 | package net.pocketmagic.android.utils; 25 | 26 | import android.content.Context; 27 | import android.graphics.Typeface; 28 | import android.util.TypedValue; 29 | import android.view.View; 30 | import android.view.View.OnClickListener; 31 | //import android.view.View.OnClickListener; 32 | import android.view.ViewGroup; 33 | import android.widget.LinearLayout; 34 | import android.widget.RelativeLayout; 35 | import android.widget.TextView; 36 | import android.widget.BaseAdapter; 37 | import android.widget.ImageView; 38 | import java.util.List; 39 | 40 | import net.pocketmagic.android.eventinjector.R; 41 | 42 | 43 | 44 | 45 | class CustomAdapterView extends RelativeLayout { 46 | public CustomAdapterView(Context context, ListViewItem device) 47 | { 48 | super( context ); 49 | // get/set ID 50 | setId(device.getDeviceID()); 51 | // get image 52 | int padding = 5; 53 | int resImg = 0; 54 | String szStatus =""; 55 | if (device.getDeviceStatus()) { 56 | resImg = R.drawable.list_open; 57 | szStatus = "Open"; 58 | } else { 59 | resImg = R.drawable.list; 60 | szStatus = "Not open"; 61 | } 62 | 63 | 64 | 65 | // Configure holder layout 66 | setBackgroundResource(R.drawable.panel_item); 67 | //setOrientation(LinearLayout.HORIZONTAL); 68 | setPadding(padding, 0, padding, 0); 69 | //setGravity(Gravity.CENTER_VERTICAL); 70 | 71 | // LKEFT 72 | ImageView ivLogo = new ImageView(context); 73 | ivLogo.setId(100); 74 | ivLogo.setImageDrawable(context.getResources().getDrawable(resImg)); 75 | //ivLogo.setBackgroundColor(Color.BLACK); 76 | RelativeLayout.LayoutParams lp_ivLogo = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 77 | lp_ivLogo.addRule(RelativeLayout.CENTER_VERTICAL); 78 | lp_ivLogo.addRule(RelativeLayout.ALIGN_PARENT_LEFT); 79 | addView(ivLogo, lp_ivLogo); 80 | 81 | 82 | 83 | LinearLayout panelV = new LinearLayout(context); 84 | //panelV.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); 85 | panelV.setOrientation(LinearLayout.VERTICAL); 86 | panelV.setPadding(padding,0,0,0); 87 | 88 | RelativeLayout.LayoutParams lp_panel = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 89 | lp_panel.addRule(RelativeLayout.CENTER_VERTICAL); 90 | lp_panel.addRule(RelativeLayout.RIGHT_OF, ivLogo.getId()); 91 | //lp_panel.addRule(RelativeLayout.LEFT_OF, b.getId()); 92 | addView(panelV, lp_panel); 93 | 94 | // row1 95 | TextView textName = new TextView( context ); 96 | textName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f); 97 | textName.setTypeface(Typeface.DEFAULT, Typeface.BOLD); 98 | 99 | textName.setText( device.getDeviceName()); 100 | panelV.addView(textName); 101 | // row2 102 | TextView textAddress = new TextView( context ); 103 | textAddress.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f); 104 | textAddress.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); 105 | textAddress.setText(device.getDevicePath()); 106 | panelV.addView(textAddress); 107 | // row3 108 | TextView textStatus = new TextView( context ); 109 | textStatus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10f); 110 | textStatus.setTypeface(Typeface.DEFAULT, Typeface.BOLD); 111 | textStatus.setText(szStatus); 112 | panelV.addView(textStatus); 113 | 114 | 115 | 116 | } 117 | } 118 | 119 | public class CustomAdapter extends BaseAdapter { 120 | 121 | private Context context; 122 | private List deviceList; 123 | 124 | public CustomAdapter(Context context, List deviceList ) { 125 | this.context = context; 126 | this.deviceList = deviceList; 127 | } 128 | 129 | public int getCount() { 130 | return deviceList.size(); 131 | } 132 | 133 | public Object getItem(int position) { 134 | return deviceList.get(position); 135 | } 136 | 137 | public long getItemId(int position) { 138 | return position; 139 | } 140 | 141 | public View getView(int position, View convertView, ViewGroup parent) 142 | { 143 | ListViewItem device = deviceList.get(position); 144 | View v = new CustomAdapterView(this.context, device ); 145 | v.setOnClickListener((OnClickListener) context); 146 | return v; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/net/pocketmagic/android/utils/ListViewItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Android Event Injector 3 | * 4 | * Copyright (c) 2013 by Radu Motisan , radu.motisan@gmail.com 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2 9 | * of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | * For more information on the GPL, please go to: 21 | * http://www.gnu.org/copyleft/gpl.html 22 | * 23 | */ 24 | 25 | package net.pocketmagic.android.utils; 26 | 27 | 28 | public class ListViewItem { 29 | 30 | private String m_szDeviceName; 31 | private String m_szDevicePath; 32 | private boolean m_bConnected; 33 | private int m_nDeviceID, m_nConType; 34 | 35 | public ListViewItem( String deviceName, String DevicePath, boolean deviceStatus, int deviceID ) { 36 | m_szDeviceName = deviceName; 37 | m_szDevicePath = DevicePath; 38 | m_bConnected = deviceStatus; 39 | m_nDeviceID = deviceID; 40 | } 41 | 42 | 43 | public String getDeviceName() { return m_szDeviceName; } 44 | public void setDeviceName(String deviceName) { m_szDeviceName = deviceName;} 45 | 46 | public String getDevicePath() {return m_szDevicePath;} 47 | public void setDevicePath(String DevicePath) {m_szDevicePath = DevicePath;} 48 | 49 | 50 | public boolean getDeviceStatus() { return m_bConnected; } 51 | public void setDeviceStatus(boolean deviceStatus) { m_bConnected = deviceStatus;} 52 | 53 | public int getDeviceID() { return m_nDeviceID; } 54 | public void setDeviceID(int deviceID) { m_nDeviceID = deviceID;} 55 | } --------------------------------------------------------------------------------