├── .classpath ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── GPLV3.TXT ├── README.TXT ├── jni ├── Android.mk ├── com_googlecode_android_wifi_tether_system_NativeTask.c └── com_googlecode_android_wifi_tether_system_NativeTask.h ├── libs ├── android-support-v4.jar └── armeabi │ └── libwtnativetask.so ├── lint.xml ├── native ├── ifconfig │ ├── Android.mk │ └── ifconfig.c ├── rfkill │ ├── Android.mk │ ├── COPYING │ ├── README │ ├── core.h │ ├── rfkill.c │ └── rfkill.h └── tether │ ├── Android.mk │ ├── edify │ ├── Android.mk │ ├── README │ ├── expr.c │ ├── expr.h │ ├── lexer.l │ ├── main.c │ ├── parser.y │ └── yydefs.h │ ├── install.c │ ├── install.h │ ├── sha1.c │ ├── sha1.h │ ├── tether.c │ └── tether.h ├── project.properties ├── res ├── drawable-hdpi │ ├── appwidget_bg.9.png │ ├── appwidget_divider.9.png │ ├── appwidget_ind_mid_c.9.png │ ├── appwidget_ind_off_c.9.png │ ├── appwidget_ind_on_c.9.png │ ├── appwidget_inner_focus_c.9.png │ ├── appwidget_inner_press_c.9.png │ ├── icon.png │ ├── tether_wifi_off.png │ └── tether_wifi_on.png ├── drawable-mdpi │ ├── appwidget_bg.9.png │ ├── appwidget_divider.9.png │ ├── appwidget_ind_mid_c.9.png │ ├── appwidget_ind_off_c.9.png │ ├── appwidget_ind_on_c.9.png │ ├── appwidget_inner_focus_c.9.png │ ├── appwidget_inner_press_c.9.png │ ├── icon.png │ ├── tether_wifi_off.png │ └── tether_wifi_on.png ├── drawable │ ├── appwidget_button.xml │ ├── background.9.png │ ├── battery.png │ ├── sechigh.png │ ├── seclow.png │ ├── secmedium.png │ ├── start.png │ ├── start_notification.png │ ├── stop.png │ ├── stop_notification.png │ ├── tether_start_button.xml │ └── tether_stop_button.xml ├── layout │ ├── aboutview.xml │ ├── accesscontrolview.xml │ ├── clientrow.xml │ ├── donateview.xml │ ├── hidessidwarningview.xml │ ├── logview.xml │ ├── main.xml │ ├── noaccesscontrolview.xml │ ├── nonetfilterview.xml │ ├── norootview.xml │ ├── setupview.xml │ ├── txpowerwarningview.xml │ ├── updateview.xml │ └── widget.xml ├── raw │ ├── dnsmasq │ ├── fixpersist_sh │ ├── hostapd_conf_droi │ ├── hostapd_conf_mini │ ├── hostapd_conf_tiap │ ├── ifconfig │ ├── iptables │ ├── iwconfig │ ├── rfkill │ ├── tether │ ├── tether_edify │ ├── tiwlan_ini │ └── wpa_supplicant_conf ├── values-de │ └── strings.xml ├── values-it │ └── strings.xml ├── values-v11 │ └── themes.xml ├── values-zh-rCN │ └── strings.xml ├── values │ ├── colors.xml │ ├── strings.xml │ └── themes.xml └── xml │ └── appwidget_info.xml └── src └── com └── googlecode └── android └── wifi └── tether ├── AccessControlActivity.java ├── LogActivity.java ├── MainActivity.java ├── SetupActivity.java ├── TetherApplication.java ├── TetherService.java ├── TetherServiceReceiver.java ├── TetherWidget.java ├── WifiStateChangeReceiver.java ├── data ├── ClientAdapter.java └── ClientData.java ├── system ├── Configuration.java ├── CoreTask.java ├── FallbackTether.java ├── NativeTask.java ├── ServiceHandler.java ├── UntetherHelper.java ├── WebserviceTask.java └── WimaxHelper.java └── ui └── SeekBarPreference.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | andTether 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 | #Wed Jan 18 21:54:36 CET 2012 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.source=1.5 6 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- 1 | WiFi Tether for Root Users 2 | -------------------------- 3 | 4 | WiFi Tether for Root Users 5 | 6 | *** Use this application at your own risk. It is possible that use of this program may violate your carrier's Terms of Use/Terms of Service. *** 7 | 8 | This program enables wifi-tethering for "rooted" handsets. 9 | 10 | Clients (your laptop for example) can connect via wifi and get access to the internet using the mobile connection (4G, 3G, 2G) of your phone. 11 | 12 | Wifi-tethering creates a so called adhoc (peer-to-peer) network on most devices. 13 | Infrastructure-mode is supported for a large set of devices. 14 | 15 | ** PREREQUISITE ** 16 | 17 | 1) Root 18 | 2) Netfilter-enabled kernel (most stock-kernel nowadays come with such a kernel). 19 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE := libwtnativetask 5 | LOCAL_SRC_FILES := com_googlecode_android_wifi_tether_system_NativeTask.c 6 | #LOCAL_SHARED_LIBRARIES := libcutils 7 | 8 | include $(BUILD_SHARED_LIBRARY) 9 | -------------------------------------------------------------------------------- /jni/com_googlecode_android_wifi_tether_system_NativeTask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "com_googlecode_android_wifi_tether_system_NativeTask.h" 8 | 9 | #define PROPERTY_KEY_MAX 32 10 | #define PROPERTY_VALUE_MAX 92 11 | 12 | JNIEXPORT jstring JNICALL Java_com_googlecode_android_wifi_tether_system_NativeTask_getProp 13 | (JNIEnv *env, jclass class, jstring name) 14 | { 15 | const char *nameString; 16 | nameString = (*env)->GetStringUTFChars(env, name, 0); 17 | 18 | char value[PROPERTY_VALUE_MAX]; 19 | char *default_value; 20 | jstring jstrOutput; 21 | 22 | default_value = "undefined"; 23 | property_get(nameString, value, default_value); 24 | 25 | jstrOutput = (*env)->NewStringUTF(env, value); 26 | 27 | (*env)->ReleaseStringUTFChars(env, name, nameString); 28 | 29 | return jstrOutput; 30 | } 31 | 32 | JNIEXPORT jint JNICALL Java_com_googlecode_android_wifi_tether_system_NativeTask_runCommand 33 | (JNIEnv *env, jclass class, jstring command) 34 | { 35 | const char *commandString; 36 | commandString = (*env)->GetStringUTFChars(env, command, 0); 37 | int exitcode = system(commandString); 38 | (*env)->ReleaseStringUTFChars(env, command, commandString); 39 | return (jint)exitcode; 40 | } 41 | 42 | int property_get(const char *key, char *value, const char *default_value) 43 | { 44 | int len; 45 | 46 | len = __system_property_get(key, value); 47 | if(len > 0) { 48 | return len; 49 | } 50 | 51 | if(default_value) { 52 | len = strlen(default_value); 53 | memcpy(value, default_value, len + 1); 54 | } 55 | return len; 56 | } 57 | -------------------------------------------------------------------------------- /jni/com_googlecode_android_wifi_tether_system_NativeTask.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_googlecode_android_wifi_tether_system_NativeTask */ 4 | 5 | #ifndef _Included_com_googlecode_android_wifi_tether_system_NativeTask 6 | #define _Included_com_googlecode_android_wifi_tether_system_NativeTask 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_googlecode_android_wifi_tether_system_NativeTask 12 | * Method: getProp 13 | * Signature: (Ljava/lang/String;)Ljava/lang/String; 14 | */ 15 | JNIEXPORT jstring JNICALL Java_com_googlecode_android_wifi_tether_system_NativeTask_getProp 16 | (JNIEnv *, jclass, jstring); 17 | 18 | /* 19 | * Class: com_googlecode_android_wifi_tether_system_NativeTask 20 | * Method: runCommand 21 | * Signature: (Ljava/lang/String;)I 22 | */ 23 | JNIEXPORT jint JNICALL Java_com_googlecode_android_wifi_tether_system_NativeTask_runCommand 24 | (JNIEnv *, jclass, jstring); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/armeabi/libwtnativetask.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/libs/armeabi/libwtnativetask.so -------------------------------------------------------------------------------- /lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /native/ifconfig/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(TARGET_SIMULATOR),true) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_SRC_FILES:= ifconfig.c 7 | LOCAL_MODULE := ifconfig-tether 8 | 9 | #LOCAL_SHARED_LIBRARIES := libcutils 10 | 11 | include $(BUILD_EXECUTABLE) 12 | 13 | endif # TARGET_SIMULATOR != true 14 | -------------------------------------------------------------------------------- /native/rfkill/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq ($(TARGET_SIMULATOR),true) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_SRC_FILES:= rfkill.c 7 | LOCAL_MODULE := rfkill 8 | 9 | #LOCAL_SHARED_LIBRARIES := libcutils 10 | 11 | include $(BUILD_EXECUTABLE) 12 | 13 | LOCAL_MODULE_TAGS := optional 14 | 15 | endif # TARGET_SIMULATOR != true 16 | -------------------------------------------------------------------------------- /native/rfkill/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2009 Johannes Berg 2 | Copyright 2009 Marcel Holtmann 3 | Copyright 2009 Tim Gardner 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /native/rfkill/README: -------------------------------------------------------------------------------- 1 | 2 | This is 'rfkill', a tool to use /dev/rfkill. 3 | 4 | 5 | To build rfkill, just enter 'make'. 6 | 7 | 'rfkill' is currently maintained at http://git.sipsolutions.net/rfkill.git/, 8 | some more documentation is available at 9 | http://wireless.kernel.org/en/users/Documentation/rfkill. 10 | 11 | Please send all patches to Johannes Berg 12 | and CC linux-wireless@vger.kernel.org for community review. 13 | -------------------------------------------------------------------------------- /native/rfkill/core.h: -------------------------------------------------------------------------------- 1 | #ifndef __CORE 2 | #define __CORE 3 | 4 | #include "rfkill.h" 5 | 6 | extern const char rfkill_version[]; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /native/rfkill/rfkill.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rfkill userspace tool 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "rfkill.h" 18 | #include "core.h" 19 | 20 | static void rfkill_event(void) 21 | { 22 | struct rfkill_event event; 23 | struct timeval tv; 24 | struct pollfd p; 25 | ssize_t len; 26 | int fd, n; 27 | 28 | fd = open("/dev/rfkill", O_RDONLY); 29 | if (fd < 0) { 30 | perror("Can't open RFKILL control device"); 31 | return; 32 | } 33 | 34 | memset(&p, 0, sizeof(p)); 35 | p.fd = fd; 36 | p.events = POLLIN | POLLHUP; 37 | 38 | while (1) { 39 | n = poll(&p, 1, -1); 40 | if (n < 0) { 41 | perror("Failed to poll RFKILL control device"); 42 | break; 43 | } 44 | 45 | if (n == 0) 46 | continue; 47 | 48 | len = read(fd, &event, sizeof(event)); 49 | if (len < 0) { 50 | perror("Reading of RFKILL events failed"); 51 | break; 52 | } 53 | 54 | if (len != RFKILL_EVENT_SIZE_V1) { 55 | fprintf(stderr, "Wrong size of RFKILL event\n"); 56 | continue; 57 | } 58 | 59 | gettimeofday(&tv, NULL); 60 | printf("%ld.%06u: idx %u type %u op %u soft %u hard %u\n", 61 | (long) tv.tv_sec, (unsigned int) tv.tv_usec, 62 | event.idx, event.type, event.op, event.soft, event.hard); 63 | fflush(stdout); 64 | } 65 | 66 | close(fd); 67 | } 68 | 69 | static const char *get_name(__u32 idx) 70 | { 71 | static char name[128]; 72 | ssize_t len; 73 | char *pos, filename[64]; 74 | int fd; 75 | 76 | snprintf(filename, sizeof(filename) - 1, 77 | "/sys/class/rfkill/rfkill%u/name", idx); 78 | 79 | fd = open(filename, O_RDONLY); 80 | if (fd < 0) 81 | return NULL; 82 | 83 | memset(name, 0, sizeof(name)); 84 | len = read(fd, name, sizeof(name) - 1); 85 | 86 | pos = strchr(name, '\n'); 87 | if (pos) 88 | *pos = '\0'; 89 | 90 | close(fd); 91 | 92 | return name; 93 | } 94 | 95 | static const char *type2string(enum rfkill_type type) 96 | { 97 | switch (type) { 98 | case RFKILL_TYPE_ALL: 99 | return "All"; 100 | case RFKILL_TYPE_WLAN: 101 | return "Wireless LAN"; 102 | case RFKILL_TYPE_BLUETOOTH: 103 | return "Bluetooth"; 104 | case RFKILL_TYPE_UWB: 105 | return "Ultra-Wideband"; 106 | case RFKILL_TYPE_WIMAX: 107 | return "WiMAX"; 108 | case RFKILL_TYPE_WWAN: 109 | return "Wireless WAN"; 110 | case RFKILL_TYPE_GPS: 111 | return "GPS"; 112 | case RFKILL_TYPE_FM: 113 | return "FM"; 114 | case NUM_RFKILL_TYPES: 115 | return NULL; 116 | } 117 | 118 | return NULL; 119 | } 120 | 121 | struct rfkill_type_str { 122 | enum rfkill_type type; 123 | const char *name; 124 | }; 125 | static const struct rfkill_type_str rfkill_type_strings[] = { 126 | { .type = RFKILL_TYPE_ALL, .name = "all" }, 127 | { .type = RFKILL_TYPE_WLAN, .name = "wifi" }, 128 | { .type = RFKILL_TYPE_WLAN, .name = "wlan" }, /* alias */ 129 | { .type = RFKILL_TYPE_BLUETOOTH, .name = "bluetooth" }, 130 | { .type = RFKILL_TYPE_UWB, .name = "uwb" }, 131 | { .type = RFKILL_TYPE_UWB, .name = "ultrawideband" }, /* alias */ 132 | { .type = RFKILL_TYPE_WIMAX, .name = "wimax" }, 133 | { .type = RFKILL_TYPE_WWAN, .name = "wwan" }, 134 | { .type = RFKILL_TYPE_GPS, .name = "gps" }, 135 | { .type = RFKILL_TYPE_FM, .name = "fm" }, 136 | { .name = NULL } 137 | }; 138 | 139 | struct rfkill_id { 140 | union { 141 | enum rfkill_type type; 142 | __u32 index; 143 | }; 144 | enum { 145 | RFKILL_IS_INVALID, 146 | RFKILL_IS_TYPE, 147 | RFKILL_IS_INDEX, 148 | } result; 149 | }; 150 | 151 | static struct rfkill_id rfkill_id_to_type(const char *s) 152 | { 153 | const struct rfkill_type_str *p; 154 | struct rfkill_id ret; 155 | 156 | if (islower(*s)) { 157 | for (p = rfkill_type_strings; p->name != NULL; p++) { 158 | if ((strlen(s) == strlen(p->name)) && (!strcmp(s,p->name))) { 159 | ret.type = p->type; 160 | ret.result = RFKILL_IS_TYPE; 161 | return ret; 162 | } 163 | } 164 | } else if (isdigit(*s)) { 165 | /* assume a numeric character implies an index. */ 166 | ret.index = atoi(s); 167 | ret.result = RFKILL_IS_INDEX; 168 | return ret; 169 | } 170 | 171 | ret.result = RFKILL_IS_INVALID; 172 | return ret; 173 | } 174 | 175 | static int rfkill_list(const char *param) 176 | { 177 | struct rfkill_id id = { .result = RFKILL_IS_INVALID }; 178 | struct rfkill_event event; 179 | const char *name; 180 | ssize_t len; 181 | int fd; 182 | 183 | if (param) { 184 | id = rfkill_id_to_type(param); 185 | if (id.result == RFKILL_IS_INVALID) { 186 | fprintf(stderr, "Bogus %s argument '%s'.\n", "list", param); 187 | return 2; 188 | } 189 | /* don't filter "all" */ 190 | if (id.result == RFKILL_IS_TYPE && id.type == RFKILL_TYPE_ALL) 191 | id.result = RFKILL_IS_INVALID; 192 | } 193 | 194 | fd = open("/dev/rfkill", O_RDONLY); 195 | if (fd < 0) { 196 | perror("Can't open RFKILL control device"); 197 | return 1; 198 | } 199 | 200 | if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { 201 | perror("Can't set RFKILL control device to non-blocking"); 202 | close(fd); 203 | return 1; 204 | } 205 | 206 | while (1) { 207 | len = read(fd, &event, sizeof(event)); 208 | if (len < 0) { 209 | if (errno == EAGAIN) 210 | break; 211 | perror("Reading of RFKILL events failed"); 212 | break; 213 | } 214 | 215 | if (len != RFKILL_EVENT_SIZE_V1) { 216 | fprintf(stderr, "Wrong size of RFKILL event\n"); 217 | continue; 218 | } 219 | 220 | if (event.op != RFKILL_OP_ADD) 221 | continue; 222 | 223 | /* filter out unwanted results */ 224 | switch (id.result) 225 | { 226 | case RFKILL_IS_TYPE: 227 | if (event.type != id.type) 228 | continue; 229 | break; 230 | case RFKILL_IS_INDEX: 231 | if (event.idx != id.index) 232 | continue; 233 | break; 234 | case RFKILL_IS_INVALID:; /* must be last */ 235 | } 236 | 237 | name = get_name(event.idx); 238 | 239 | printf("%u: %s: %s\n", event.idx, name, 240 | type2string(event.type)); 241 | printf("\tSoft blocked: %s\n", event.soft ? "yes" : "no"); 242 | printf("\tHard blocked: %s\n", event.hard ? "yes" : "no"); 243 | } 244 | 245 | close(fd); 246 | return 0; 247 | } 248 | 249 | static int rfkill_block(__u8 block, const char *param) 250 | { 251 | struct rfkill_id id; 252 | struct rfkill_event event; 253 | ssize_t len; 254 | int fd; 255 | 256 | id = rfkill_id_to_type(param); 257 | if (id.result == RFKILL_IS_INVALID) { 258 | fprintf(stderr, "Bogus %s argument '%s'.\n", block ? "block" : "unblock", param); 259 | return 2; 260 | } 261 | 262 | fd = open("/dev/rfkill", O_RDWR); 263 | if (fd < 0) { 264 | perror("Can't open RFKILL control device"); 265 | return 1; 266 | } 267 | 268 | memset(&event, 0, sizeof(event)); 269 | switch (id.result) { 270 | case RFKILL_IS_TYPE: 271 | event.op = RFKILL_OP_CHANGE_ALL; 272 | event.type = id.type; 273 | break; 274 | case RFKILL_IS_INDEX: 275 | event.op = RFKILL_OP_CHANGE; 276 | event.idx = id.index; 277 | break; 278 | case RFKILL_IS_INVALID:; /* must be last */ 279 | } 280 | event.soft = block; 281 | 282 | len = write(fd, &event, sizeof(event)); 283 | if (len < 0) 284 | perror("Failed to change RFKILL state"); 285 | 286 | close(fd); 287 | return 0; 288 | } 289 | 290 | static const char *argv0; 291 | 292 | static void usage(void) 293 | { 294 | const struct rfkill_type_str *p; 295 | 296 | fprintf(stderr, "Usage:\t%s [options] command\n", argv0); 297 | fprintf(stderr, "Options:\n"); 298 | fprintf(stderr, "Commands:\n"); 299 | fprintf(stderr, "\thelp\n"); 300 | fprintf(stderr, "\tevent\n"); 301 | fprintf(stderr, "\tlist [IDENTIFIER]\n"); 302 | fprintf(stderr, "\tblock IDENTIFIER\n"); 303 | fprintf(stderr, "\tunblock IDENTIFIER\n"); 304 | fprintf(stderr, "where IDENTIFIER is the index no. of an rfkill switch or one of:\n"); 305 | fprintf(stderr, "\t"); 306 | for (p = rfkill_type_strings; p->name != NULL; p++) 307 | fprintf(stderr, " %s", p->name); 308 | fprintf(stderr, "\n"); 309 | } 310 | 311 | /*static void version(void) 312 | { 313 | printf("rfkill %s\n", rfkill_version); 314 | }*/ 315 | 316 | int main(int argc, char **argv) 317 | { 318 | int ret = 0; 319 | 320 | /* strip off self */ 321 | argc--; 322 | argv0 = *argv++; 323 | 324 | if (argc > 0 && strcmp(*argv, "--version") == 0) { 325 | //version(); 326 | return 0; 327 | } 328 | 329 | if (argc == 0 || strcmp(*argv, "help") == 0) { 330 | usage(); 331 | return 0; 332 | } 333 | 334 | if (strcmp(*argv, "event") == 0) { 335 | rfkill_event(); 336 | } else if (strcmp(*argv, "list") == 0) { 337 | argc--; 338 | argv++; 339 | rfkill_list(*argv); /* NULL is acceptable */ 340 | } else if (strcmp(*argv, "block") == 0 && argc > 1) { 341 | argc--; 342 | argv++; 343 | ret = rfkill_block(1,*argv); 344 | } else if (strcmp(*argv, "unblock") == 0 && argc > 1) { 345 | argc--; 346 | argv++; 347 | ret = rfkill_block(0,*argv); 348 | } else { 349 | usage(); 350 | return 1; 351 | } 352 | 353 | return ret; 354 | } 355 | -------------------------------------------------------------------------------- /native/rfkill/rfkill.h: -------------------------------------------------------------------------------- 1 | #ifndef __RFKILL_H 2 | #define __RFKILL_H 3 | 4 | /* 5 | * Copyright (C) 2006 - 2007 Ivo van Doorn 6 | * Copyright (C) 2007 Dmitry Torokhov 7 | * Copyright 2009 Johannes Berg 8 | * 9 | * Permission to use, copy, modify, and/or distribute this software for any 10 | * purpose with or without fee is hereby granted, provided that the above 11 | * copyright notice and this permission notice appear in all copies. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | /* define userspace visible states */ 25 | #define RFKILL_STATE_SOFT_BLOCKED 0 26 | #define RFKILL_STATE_UNBLOCKED 1 27 | #define RFKILL_STATE_HARD_BLOCKED 2 28 | 29 | /** 30 | * enum rfkill_type - type of rfkill switch. 31 | * 32 | * @RFKILL_TYPE_ALL: toggles all switches (userspace only) 33 | * @RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. 34 | * @RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. 35 | * @RFKILL_TYPE_UWB: switch is on a ultra wideband device. 36 | * @RFKILL_TYPE_WIMAX: switch is on a WiMAX device. 37 | * @RFKILL_TYPE_WWAN: switch is on a wireless WAN device. 38 | * @RFKILL_TYPE_GPS: switch is on a GPS device. 39 | * @RFKILL_TYPE_FM: switch is on a FM radio device. 40 | * @NUM_RFKILL_TYPES: number of defined rfkill types 41 | */ 42 | enum rfkill_type { 43 | RFKILL_TYPE_ALL = 0, 44 | RFKILL_TYPE_WLAN, 45 | RFKILL_TYPE_BLUETOOTH, 46 | RFKILL_TYPE_UWB, 47 | RFKILL_TYPE_WIMAX, 48 | RFKILL_TYPE_WWAN, 49 | RFKILL_TYPE_GPS, 50 | RFKILL_TYPE_FM, 51 | NUM_RFKILL_TYPES, 52 | }; 53 | 54 | /** 55 | * enum rfkill_operation - operation types 56 | * @RFKILL_OP_ADD: a device was added 57 | * @RFKILL_OP_DEL: a device was removed 58 | * @RFKILL_OP_CHANGE: a device's state changed -- userspace changes one device 59 | * @RFKILL_OP_CHANGE_ALL: userspace changes all devices (of a type, or all) 60 | */ 61 | enum rfkill_operation { 62 | RFKILL_OP_ADD = 0, 63 | RFKILL_OP_DEL, 64 | RFKILL_OP_CHANGE, 65 | RFKILL_OP_CHANGE_ALL, 66 | }; 67 | 68 | /** 69 | * struct rfkill_event - events for userspace on /dev/rfkill 70 | * @idx: index of dev rfkill 71 | * @type: type of the rfkill struct 72 | * @op: operation code 73 | * @hard: hard state (0/1) 74 | * @soft: soft state (0/1) 75 | * 76 | * Structure used for userspace communication on /dev/rfkill, 77 | * used for events from the kernel and control to the kernel. 78 | */ 79 | struct rfkill_event { 80 | __u32 idx; 81 | __u8 type; 82 | __u8 op; 83 | __u8 soft, hard; 84 | } __packed; 85 | 86 | /* 87 | * We are planning to be backward and forward compatible with changes 88 | * to the event struct, by adding new, optional, members at the end. 89 | * When reading an event (whether the kernel from userspace or vice 90 | * versa) we need to accept anything that's at least as large as the 91 | * version 1 event size, but might be able to accept other sizes in 92 | * the future. 93 | * 94 | * One exception is the kernel -- we already have two event sizes in 95 | * that we've made the 'hard' member optional since our only option 96 | * is to ignore it anyway. 97 | */ 98 | #define RFKILL_EVENT_SIZE_V1 8 99 | 100 | /* ioctl for turning off rfkill-input (if present) */ 101 | #define RFKILL_IOC_MAGIC 'R' 102 | #define RFKILL_IOC_NOINPUT 1 103 | #define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) 104 | 105 | /* and that's all userspace gets */ 106 | #ifdef __KERNEL__ 107 | /* don't allow anyone to use these in the kernel */ 108 | enum rfkill_user_states { 109 | RFKILL_USER_STATE_SOFT_BLOCKED = RFKILL_STATE_SOFT_BLOCKED, 110 | RFKILL_USER_STATE_UNBLOCKED = RFKILL_STATE_UNBLOCKED, 111 | RFKILL_USER_STATE_HARD_BLOCKED = RFKILL_STATE_HARD_BLOCKED, 112 | }; 113 | #undef RFKILL_STATE_SOFT_BLOCKED 114 | #undef RFKILL_STATE_UNBLOCKED 115 | #undef RFKILL_STATE_HARD_BLOCKED 116 | 117 | #include 118 | #include 119 | #include 120 | #include 121 | #include 122 | #include 123 | 124 | /* this is opaque */ 125 | struct rfkill; 126 | 127 | /** 128 | * struct rfkill_ops - rfkill driver methods 129 | * 130 | * @poll: poll the rfkill block state(s) -- only assign this method 131 | * when you need polling. When called, simply call one of the 132 | * rfkill_set{,_hw,_sw}_state family of functions. If the hw 133 | * is getting unblocked you need to take into account the return 134 | * value of those functions to make sure the software block is 135 | * properly used. 136 | * @query: query the rfkill block state(s) and call exactly one of the 137 | * rfkill_set{,_hw,_sw}_state family of functions. Assign this 138 | * method if input events can cause hardware state changes to make 139 | * the rfkill core query your driver before setting a requested 140 | * block. 141 | * @set_block: turn the transmitter on (blocked == false) or off 142 | * (blocked == true) -- ignore and return 0 when hard blocked. 143 | * This callback must be assigned. 144 | */ 145 | struct rfkill_ops { 146 | void (*poll)(struct rfkill *rfkill, void *data); 147 | void (*query)(struct rfkill *rfkill, void *data); 148 | int (*set_block)(void *data, bool blocked); 149 | }; 150 | 151 | #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) 152 | /** 153 | * rfkill_alloc - allocate rfkill structure 154 | * @name: name of the struct -- the string is not copied internally 155 | * @parent: device that has rf switch on it 156 | * @type: type of the switch (RFKILL_TYPE_*) 157 | * @ops: rfkill methods 158 | * @ops_data: data passed to each method 159 | * 160 | * This function should be called by the transmitter driver to allocate an 161 | * rfkill structure. Returns %NULL on failure. 162 | */ 163 | struct rfkill * __must_check rfkill_alloc(const char *name, 164 | struct device *parent, 165 | const enum rfkill_type type, 166 | const struct rfkill_ops *ops, 167 | void *ops_data); 168 | 169 | /** 170 | * rfkill_register - Register a rfkill structure. 171 | * @rfkill: rfkill structure to be registered 172 | * 173 | * This function should be called by the transmitter driver to register 174 | * the rfkill structure. Before calling this function the driver needs 175 | * to be ready to service method calls from rfkill. 176 | * 177 | * If rfkill_init_sw_state() is not called before registration, 178 | * set_block() will be called to initialize the software blocked state 179 | * to a default value. 180 | * 181 | * If the hardware blocked state is not set before registration, 182 | * it is assumed to be unblocked. 183 | */ 184 | int __must_check rfkill_register(struct rfkill *rfkill); 185 | 186 | /** 187 | * rfkill_pause_polling(struct rfkill *rfkill) 188 | * 189 | * Pause polling -- say transmitter is off for other reasons. 190 | * NOTE: not necessary for suspend/resume -- in that case the 191 | * core stops polling anyway 192 | */ 193 | void rfkill_pause_polling(struct rfkill *rfkill); 194 | 195 | /** 196 | * rfkill_resume_polling(struct rfkill *rfkill) 197 | * 198 | * Pause polling -- say transmitter is off for other reasons. 199 | * NOTE: not necessary for suspend/resume -- in that case the 200 | * core stops polling anyway 201 | */ 202 | void rfkill_resume_polling(struct rfkill *rfkill); 203 | 204 | 205 | /** 206 | * rfkill_unregister - Unregister a rfkill structure. 207 | * @rfkill: rfkill structure to be unregistered 208 | * 209 | * This function should be called by the network driver during device 210 | * teardown to destroy rfkill structure. Until it returns, the driver 211 | * needs to be able to service method calls. 212 | */ 213 | void rfkill_unregister(struct rfkill *rfkill); 214 | 215 | /** 216 | * rfkill_destroy - free rfkill structure 217 | * @rfkill: rfkill structure to be destroyed 218 | * 219 | * Destroys the rfkill structure. 220 | */ 221 | void rfkill_destroy(struct rfkill *rfkill); 222 | 223 | /** 224 | * rfkill_set_hw_state - Set the internal rfkill hardware block state 225 | * @rfkill: pointer to the rfkill class to modify. 226 | * @state: the current hardware block state to set 227 | * 228 | * rfkill drivers that get events when the hard-blocked state changes 229 | * use this function to notify the rfkill core (and through that also 230 | * userspace) of the current state. They should also use this after 231 | * resume if the state could have changed. 232 | * 233 | * You need not (but may) call this function if poll_state is assigned. 234 | * 235 | * This function can be called in any context, even from within rfkill 236 | * callbacks. 237 | * 238 | * The function returns the combined block state (true if transmitter 239 | * should be blocked) so that drivers need not keep track of the soft 240 | * block state -- which they might not be able to. 241 | */ 242 | bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked); 243 | 244 | /** 245 | * rfkill_set_sw_state - Set the internal rfkill software block state 246 | * @rfkill: pointer to the rfkill class to modify. 247 | * @state: the current software block state to set 248 | * 249 | * rfkill drivers that get events when the soft-blocked state changes 250 | * (yes, some platforms directly act on input but allow changing again) 251 | * use this function to notify the rfkill core (and through that also 252 | * userspace) of the current state. 253 | * 254 | * Drivers should also call this function after resume if the state has 255 | * been changed by the user. This only makes sense for "persistent" 256 | * devices (see rfkill_init_sw_state()). 257 | * 258 | * This function can be called in any context, even from within rfkill 259 | * callbacks. 260 | * 261 | * The function returns the combined block state (true if transmitter 262 | * should be blocked). 263 | */ 264 | bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked); 265 | 266 | /** 267 | * rfkill_init_sw_state - Initialize persistent software block state 268 | * @rfkill: pointer to the rfkill class to modify. 269 | * @state: the current software block state to set 270 | * 271 | * rfkill drivers that preserve their software block state over power off 272 | * use this function to notify the rfkill core (and through that also 273 | * userspace) of their initial state. It should only be used before 274 | * registration. 275 | * 276 | * In addition, it marks the device as "persistent", an attribute which 277 | * can be read by userspace. Persistent devices are expected to preserve 278 | * their own state when suspended. 279 | */ 280 | void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked); 281 | 282 | /** 283 | * rfkill_set_states - Set the internal rfkill block states 284 | * @rfkill: pointer to the rfkill class to modify. 285 | * @sw: the current software block state to set 286 | * @hw: the current hardware block state to set 287 | * 288 | * This function can be called in any context, even from within rfkill 289 | * callbacks. 290 | */ 291 | void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw); 292 | 293 | /** 294 | * rfkill_blocked - query rfkill block 295 | * 296 | * @rfkill: rfkill struct to query 297 | */ 298 | bool rfkill_blocked(struct rfkill *rfkill); 299 | #else /* !RFKILL */ 300 | static inline struct rfkill * __must_check 301 | rfkill_alloc(const char *name, 302 | struct device *parent, 303 | const enum rfkill_type type, 304 | const struct rfkill_ops *ops, 305 | void *ops_data) 306 | { 307 | return ERR_PTR(-ENODEV); 308 | } 309 | 310 | static inline int __must_check rfkill_register(struct rfkill *rfkill) 311 | { 312 | if (rfkill == ERR_PTR(-ENODEV)) 313 | return 0; 314 | return -EINVAL; 315 | } 316 | 317 | static inline void rfkill_pause_polling(struct rfkill *rfkill) 318 | { 319 | } 320 | 321 | static inline void rfkill_resume_polling(struct rfkill *rfkill) 322 | { 323 | } 324 | 325 | static inline void rfkill_unregister(struct rfkill *rfkill) 326 | { 327 | } 328 | 329 | static inline void rfkill_destroy(struct rfkill *rfkill) 330 | { 331 | } 332 | 333 | static inline bool rfkill_set_hw_state(struct rfkill *rfkill, bool blocked) 334 | { 335 | return blocked; 336 | } 337 | 338 | static inline bool rfkill_set_sw_state(struct rfkill *rfkill, bool blocked) 339 | { 340 | return blocked; 341 | } 342 | 343 | static inline void rfkill_init_sw_state(struct rfkill *rfkill, bool blocked) 344 | { 345 | } 346 | 347 | static inline void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) 348 | { 349 | } 350 | 351 | static inline bool rfkill_blocked(struct rfkill *rfkill) 352 | { 353 | return false; 354 | } 355 | #endif /* RFKILL || RFKILL_MODULE */ 356 | 357 | 358 | #ifdef CONFIG_RFKILL_LEDS 359 | /** 360 | * rfkill_get_led_trigger_name - Get the LED trigger name for the button's LED. 361 | * This function might return a NULL pointer if registering of the 362 | * LED trigger failed. Use this as "default_trigger" for the LED. 363 | */ 364 | const char *rfkill_get_led_trigger_name(struct rfkill *rfkill); 365 | 366 | /** 367 | * rfkill_set_led_trigger_name -- set the LED trigger name 368 | * @rfkill: rfkill struct 369 | * @name: LED trigger name 370 | * 371 | * This function sets the LED trigger name of the radio LED 372 | * trigger that rfkill creates. It is optional, but if called 373 | * must be called before rfkill_register() to be effective. 374 | */ 375 | void rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name); 376 | #else 377 | static inline const char *rfkill_get_led_trigger_name(struct rfkill *rfkill) 378 | { 379 | return NULL; 380 | } 381 | 382 | static inline void 383 | rfkill_set_led_trigger_name(struct rfkill *rfkill, const char *name) 384 | { 385 | } 386 | #endif 387 | 388 | #endif /* __KERNEL__ */ 389 | 390 | #endif /* RFKILL_H */ 391 | -------------------------------------------------------------------------------- /native/tether/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2009 The Android Open Source Project 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | updater_src_files := \ 6 | sha1.c\ 7 | install.c\ 8 | tether.c\ 9 | 10 | include $(CLEAR_VARS) 11 | 12 | LOCAL_SRC_FILES := $(updater_src_files) 13 | 14 | LOCAL_C_INCLUDES += $(dir $(inc)) 15 | 16 | LOCAL_CFLAGS := -DINTERNAL_SHA1 -DCONFIG_CRYPTO_INTERNAL -DCONFIG_NO_T_PRF -DCONFIG_NO_TLS_PRF 17 | 18 | LOCAL_STATIC_LIBRARIES := libedify 19 | 20 | LOCAL_SHARED_LIBRARIES := libcutils\ 21 | libhardware_legacy\ 22 | libc\ 23 | libnetutils\ 24 | libsysutils 25 | 26 | LOCAL_MODULE := tether 27 | 28 | include $(BUILD_EXECUTABLE) 29 | 30 | ##################### 31 | #include $(CLEAR_VARS) 32 | #LOCAL_SRC_FILES := ultra_bcm_config.c\ 33 | # wpa_supplicant/sha1.c\ 34 | # wpa_supplicant/md5.c\ 35 | # wpa_supplicant/os_unix.c\ 36 | # wpa_supplicant/des.c\ 37 | # wpa_supplicant/crypto_openssl.c 38 | #LOCAL_C_INCLUDES:= \ 39 | # external/openssl/include 40 | #LOCAL_MODULE := ultra_bcm_config 41 | #LOCAL_STATIC_LIBRARIES := iwlib 42 | #LOCAL_SHARED_LIBRARIES := libc libcutils libcrypto libssl 43 | #LOCAL_CFLAGS := $(WT_INCS) $(WT_DEFS) 44 | #include $(BUILD_EXECUTABLE) 45 | ##################### 46 | 47 | 48 | -------------------------------------------------------------------------------- /native/tether/edify/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2009 The Android Open Source Project 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | edify_src_files := \ 6 | lexer.l \ 7 | parser.y \ 8 | expr.c 9 | 10 | # "-x c" forces the lex/yacc files to be compiled as c; 11 | # the build system otherwise forces them to be c++. 12 | edify_cflags := -x c 13 | 14 | # 15 | # Build the host-side command line tool 16 | # 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_SRC_FILES := \ 20 | $(edify_src_files) \ 21 | main.c 22 | 23 | LOCAL_CFLAGS := $(edify_cflags) -g -O0 24 | LOCAL_MODULE := edify 25 | LOCAL_YACCFLAGS := -v 26 | 27 | include $(BUILD_HOST_EXECUTABLE) 28 | 29 | # 30 | # Build the device-side library 31 | # 32 | include $(CLEAR_VARS) 33 | 34 | LOCAL_SRC_FILES := $(edify_src_files) 35 | 36 | LOCAL_CFLAGS := $(edify_cflags) 37 | LOCAL_MODULE := libedify 38 | 39 | include $(BUILD_STATIC_LIBRARY) 40 | -------------------------------------------------------------------------------- /native/tether/edify/README: -------------------------------------------------------------------------------- 1 | Update scripts (from donut onwards) are written in a new little 2 | scripting language ("edify") that is superficially somewhat similar to 3 | the old one ("amend"). This is a brief overview of the new language. 4 | 5 | - The entire script is a single expression. 6 | 7 | - All expressions are string-valued. 8 | 9 | - String literals appear in double quotes. \n, \t, \", and \\ are 10 | understood, as are hexadecimal escapes like \x4a. 11 | 12 | - String literals consisting of only letters, numbers, colons, 13 | underscores, slashes, and periods don't need to be in double quotes. 14 | 15 | - The following words are reserved: 16 | 17 | if then else endif 18 | 19 | They have special meaning when unquoted. (In quotes, they are just 20 | string literals.) 21 | 22 | - When used as a boolean, the empty string is "false" and all other 23 | strings are "true". 24 | 25 | - All functions are actually macros (in the Lisp sense); the body of 26 | the function can control which (if any) of the arguments are 27 | evaluated. This means that functions can act as control 28 | structures. 29 | 30 | - Operators (like "&&" and "||") are just syntactic sugar for builtin 31 | functions, so they can act as control structures as well. 32 | 33 | - ";" is a binary operator; evaluating it just means to first evaluate 34 | the left side, then the right. It can also appear after any 35 | expression. 36 | 37 | - Comments start with "#" and run to the end of the line. 38 | 39 | 40 | 41 | Some examples: 42 | 43 | - There's no distinction between quoted and unquoted strings; the 44 | quotes are only needed if you want characters like whitespace to 45 | appear in the string. The following expressions all evaluate to the 46 | same string. 47 | 48 | "a b" 49 | a + " " + b 50 | "a" + " " + "b" 51 | "a\x20b" 52 | a + "\x20b" 53 | concat(a, " ", "b") 54 | "concat"(a, " ", "b") 55 | 56 | As shown in the last example, function names are just strings, 57 | too. They must be string *literals*, however. This is not legal: 58 | 59 | ("con" + "cat")(a, " ", b) # syntax error! 60 | 61 | 62 | - The ifelse() builtin takes three arguments: it evaluates exactly 63 | one of the second and third, depending on whether the first one is 64 | true. There is also some syntactic sugar to make expressions that 65 | look like if/else statements: 66 | 67 | # these are all equivalent 68 | ifelse(something(), "yes", "no") 69 | if something() then yes else no endif 70 | if something() then "yes" else "no" endif 71 | 72 | The else part is optional. 73 | 74 | if something() then "yes" endif # if something() is false, 75 | # evaluates to false 76 | 77 | ifelse(condition(), "", abort()) # abort() only called if 78 | # condition() is false 79 | 80 | The last example is equivalent to: 81 | 82 | assert(condition()) 83 | 84 | 85 | - The && and || operators can be used similarly; they evaluate their 86 | second argument only if it's needed to determine the truth of the 87 | expression. Their value is the value of the last-evaluated 88 | argument: 89 | 90 | file_exists("/data/system/bad") && delete("/data/system/bad") 91 | 92 | file_exists("/data/system/missing") || create("/data/system/missing") 93 | 94 | get_it() || "xxx" # returns value of get_it() if that value is 95 | # true, otherwise returns "xxx" 96 | 97 | 98 | - The purpose of ";" is to simulate imperative statements, of course, 99 | but the operator can be used anywhere. Its value is the value of 100 | its right side: 101 | 102 | concat(a;b;c, d, e;f) # evaluates to "cdf" 103 | 104 | A more useful example might be something like: 105 | 106 | ifelse(condition(), 107 | (first_step(); second_step();), # second ; is optional 108 | alternative_procedure()) 109 | -------------------------------------------------------------------------------- /native/tether/edify/expr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "expr.h" 25 | 26 | // Functions should: 27 | // 28 | // - return a malloc()'d string 29 | // - if Evaluate() on any argument returns NULL, return NULL. 30 | 31 | int BooleanString(const char* s) { 32 | return s[0] != '\0'; 33 | } 34 | 35 | char* Evaluate(State* state, Expr* expr) { 36 | return expr->fn(expr->name, state, expr->argc, expr->argv); 37 | } 38 | 39 | char* ConcatFn(const char* name, State* state, int argc, Expr* argv[]) { 40 | if (argc == 0) { 41 | return strdup(""); 42 | } 43 | char** strings = malloc(argc * sizeof(char*)); 44 | int i; 45 | for (i = 0; i < argc; ++i) { 46 | strings[i] = NULL; 47 | } 48 | char* result = NULL; 49 | int length = 0; 50 | for (i = 0; i < argc; ++i) { 51 | strings[i] = Evaluate(state, argv[i]); 52 | if (strings[i] == NULL) { 53 | goto done; 54 | } 55 | length += strlen(strings[i]); 56 | } 57 | 58 | result = malloc(length+1); 59 | int p = 0; 60 | for (i = 0; i < argc; ++i) { 61 | strcpy(result+p, strings[i]); 62 | p += strlen(strings[i]); 63 | } 64 | result[p] = '\0'; 65 | 66 | done: 67 | for (i = 0; i < argc; ++i) { 68 | free(strings[i]); 69 | } 70 | return result; 71 | } 72 | 73 | char* IfElseFn(const char* name, State* state, int argc, Expr* argv[]) { 74 | if (argc != 2 && argc != 3) { 75 | free(state->errmsg); 76 | state->errmsg = strdup("ifelse expects 2 or 3 arguments"); 77 | return NULL; 78 | } 79 | char* cond = Evaluate(state, argv[0]); 80 | if (cond == NULL) { 81 | return NULL; 82 | } 83 | 84 | if (BooleanString(cond) == true) { 85 | free(cond); 86 | return Evaluate(state, argv[1]); 87 | } else { 88 | if (argc == 3) { 89 | free(cond); 90 | return Evaluate(state, argv[2]); 91 | } else { 92 | return cond; 93 | } 94 | } 95 | } 96 | 97 | char* AbortFn(const char* name, State* state, int argc, Expr* argv[]) { 98 | char* msg = NULL; 99 | if (argc > 0) { 100 | msg = Evaluate(state, argv[0]); 101 | } 102 | free(state->errmsg); 103 | if (msg) { 104 | state->errmsg = msg; 105 | } else { 106 | state->errmsg = strdup("called abort()"); 107 | } 108 | return NULL; 109 | } 110 | 111 | char* AssertFn(const char* name, State* state, int argc, Expr* argv[]) { 112 | int i; 113 | for (i = 0; i < argc; ++i) { 114 | char* v = Evaluate(state, argv[i]); 115 | if (v == NULL) { 116 | return NULL; 117 | } 118 | int b = BooleanString(v); 119 | free(v); 120 | if (!b) { 121 | int prefix_len; 122 | int len = argv[i]->end - argv[i]->start; 123 | char* err_src = malloc(len + 20); 124 | strcpy(err_src, "assert failed: "); 125 | prefix_len = strlen(err_src); 126 | memcpy(err_src + prefix_len, state->script + argv[i]->start, len); 127 | err_src[prefix_len + len] = '\0'; 128 | free(state->errmsg); 129 | state->errmsg = err_src; 130 | return NULL; 131 | } 132 | } 133 | return strdup(""); 134 | } 135 | 136 | char* SleepFn(const char* name, State* state, int argc, Expr* argv[]) { 137 | char* val = Evaluate(state, argv[0]); 138 | if (val == NULL) { 139 | return NULL; 140 | } 141 | int v = strtol(val, NULL, 10); 142 | sleep(v); 143 | return val; 144 | } 145 | 146 | char* StdoutFn(const char* name, State* state, int argc, Expr* argv[]) { 147 | int i; 148 | for (i = 0; i < argc; ++i) { 149 | char* v = Evaluate(state, argv[i]); 150 | if (v == NULL) { 151 | return NULL; 152 | } 153 | fputs(v, stdout); 154 | free(v); 155 | } 156 | return strdup(""); 157 | } 158 | 159 | char* LogicalAndFn(const char* name, State* state, 160 | int argc, Expr* argv[]) { 161 | char* left = Evaluate(state, argv[0]); 162 | if (left == NULL) return NULL; 163 | if (BooleanString(left) == true) { 164 | free(left); 165 | return Evaluate(state, argv[1]); 166 | } else { 167 | return left; 168 | } 169 | } 170 | 171 | char* LogicalOrFn(const char* name, State* state, 172 | int argc, Expr* argv[]) { 173 | char* left = Evaluate(state, argv[0]); 174 | if (left == NULL) return NULL; 175 | if (BooleanString(left) == false) { 176 | free(left); 177 | return Evaluate(state, argv[1]); 178 | } else { 179 | return left; 180 | } 181 | } 182 | 183 | char* LogicalNotFn(const char* name, State* state, 184 | int argc, Expr* argv[]) { 185 | char* val = Evaluate(state, argv[0]); 186 | if (val == NULL) return NULL; 187 | bool bv = BooleanString(val); 188 | free(val); 189 | if (bv) { 190 | return strdup(""); 191 | } else { 192 | return strdup("t"); 193 | } 194 | } 195 | 196 | char* SubstringFn(const char* name, State* state, 197 | int argc, Expr* argv[]) { 198 | char* needle = Evaluate(state, argv[0]); 199 | if (needle == NULL) return NULL; 200 | char* haystack = Evaluate(state, argv[1]); 201 | if (haystack == NULL) { 202 | free(needle); 203 | return NULL; 204 | } 205 | 206 | char* result = strdup(strstr(haystack, needle) ? "t" : ""); 207 | free(needle); 208 | free(haystack); 209 | return result; 210 | } 211 | 212 | char* EqualityFn(const char* name, State* state, int argc, Expr* argv[]) { 213 | char* left = Evaluate(state, argv[0]); 214 | if (left == NULL) return NULL; 215 | char* right = Evaluate(state, argv[1]); 216 | if (right == NULL) { 217 | free(left); 218 | return NULL; 219 | } 220 | 221 | char* result = strdup(strcmp(left, right) == 0 ? "t" : ""); 222 | free(left); 223 | free(right); 224 | return result; 225 | } 226 | 227 | char* InequalityFn(const char* name, State* state, int argc, Expr* argv[]) { 228 | char* left = Evaluate(state, argv[0]); 229 | if (left == NULL) return NULL; 230 | char* right = Evaluate(state, argv[1]); 231 | if (right == NULL) { 232 | free(left); 233 | return NULL; 234 | } 235 | 236 | char* result = strdup(strcmp(left, right) != 0 ? "t" : ""); 237 | free(left); 238 | free(right); 239 | return result; 240 | } 241 | 242 | char* SequenceFn(const char* name, State* state, int argc, Expr* argv[]) { 243 | char* left = Evaluate(state, argv[0]); 244 | if (left == NULL) return NULL; 245 | free(left); 246 | return Evaluate(state, argv[1]); 247 | } 248 | 249 | char* LessThanIntFn(const char* name, State* state, int argc, Expr* argv[]) { 250 | if (argc != 2) { 251 | free(state->errmsg); 252 | state->errmsg = strdup("less_than_int expects 2 arguments"); 253 | return NULL; 254 | } 255 | 256 | char* left; 257 | char* right; 258 | if (ReadArgs(state, argv, 2, &left, &right) < 0) return NULL; 259 | 260 | bool result = false; 261 | char* end; 262 | 263 | long l_int = strtol(left, &end, 10); 264 | if (left[0] == '\0' || *end != '\0') { 265 | fprintf(stderr, "[%s] is not an int\n", left); 266 | goto done; 267 | } 268 | 269 | long r_int = strtol(right, &end, 10); 270 | if (right[0] == '\0' || *end != '\0') { 271 | fprintf(stderr, "[%s] is not an int\n", right); 272 | goto done; 273 | } 274 | 275 | result = l_int < r_int; 276 | 277 | done: 278 | free(left); 279 | free(right); 280 | return strdup(result ? "t" : ""); 281 | } 282 | 283 | char* GreaterThanIntFn(const char* name, State* state, int argc, Expr* argv[]) { 284 | if (argc != 2) { 285 | free(state->errmsg); 286 | state->errmsg = strdup("greater_than_int expects 2 arguments"); 287 | return NULL; 288 | } 289 | 290 | Expr* temp[2]; 291 | temp[0] = argv[1]; 292 | temp[1] = argv[0]; 293 | 294 | return LessThanIntFn(name, state, 2, temp); 295 | } 296 | 297 | char* Literal(const char* name, State* state, int argc, Expr* argv[]) { 298 | return strdup(name); 299 | } 300 | 301 | Expr* Build(Function fn, YYLTYPE loc, int count, ...) { 302 | va_list v; 303 | va_start(v, count); 304 | Expr* e = malloc(sizeof(Expr)); 305 | e->fn = fn; 306 | e->name = "(operator)"; 307 | e->argc = count; 308 | e->argv = malloc(count * sizeof(Expr*)); 309 | int i; 310 | for (i = 0; i < count; ++i) { 311 | e->argv[i] = va_arg(v, Expr*); 312 | } 313 | va_end(v); 314 | e->start = loc.start; 315 | e->end = loc.end; 316 | return e; 317 | } 318 | 319 | // ----------------------------------------------------------------- 320 | // the function table 321 | // ----------------------------------------------------------------- 322 | 323 | static int fn_entries = 0; 324 | static int fn_size = 0; 325 | NamedFunction* fn_table = NULL; 326 | 327 | void RegisterFunction(const char* name, Function fn) { 328 | if (fn_entries >= fn_size) { 329 | fn_size = fn_size*2 + 1; 330 | fn_table = realloc(fn_table, fn_size * sizeof(NamedFunction)); 331 | } 332 | fn_table[fn_entries].name = name; 333 | fn_table[fn_entries].fn = fn; 334 | ++fn_entries; 335 | } 336 | 337 | static int fn_entry_compare(const void* a, const void* b) { 338 | const char* na = ((const NamedFunction*)a)->name; 339 | const char* nb = ((const NamedFunction*)b)->name; 340 | return strcmp(na, nb); 341 | } 342 | 343 | void FinishRegistration() { 344 | qsort(fn_table, fn_entries, sizeof(NamedFunction), fn_entry_compare); 345 | } 346 | 347 | Function FindFunction(const char* name) { 348 | NamedFunction key; 349 | key.name = name; 350 | NamedFunction* nf = bsearch(&key, fn_table, fn_entries, 351 | sizeof(NamedFunction), fn_entry_compare); 352 | if (nf == NULL) { 353 | return NULL; 354 | } 355 | return nf->fn; 356 | } 357 | 358 | void RegisterBuiltins() { 359 | RegisterFunction("ifelse", IfElseFn); 360 | RegisterFunction("abort", AbortFn); 361 | RegisterFunction("assert", AssertFn); 362 | RegisterFunction("concat", ConcatFn); 363 | RegisterFunction("is_substring", SubstringFn); 364 | RegisterFunction("stdout", StdoutFn); 365 | RegisterFunction("sleep", SleepFn); 366 | 367 | RegisterFunction("less_than_int", LessThanIntFn); 368 | RegisterFunction("greater_than_int", GreaterThanIntFn); 369 | } 370 | 371 | 372 | // ----------------------------------------------------------------- 373 | // convenience methods for functions 374 | // ----------------------------------------------------------------- 375 | 376 | // Evaluate the expressions in argv, giving 'count' char* (the ... is 377 | // zero or more char** to put them in). If any expression evaluates 378 | // to NULL, free the rest and return -1. Return 0 on success. 379 | int ReadArgs(State* state, Expr* argv[], int count, ...) { 380 | char** args = malloc(count * sizeof(char*)); 381 | va_list v; 382 | va_start(v, count); 383 | int i; 384 | for (i = 0; i < count; ++i) { 385 | args[i] = Evaluate(state, argv[i]); 386 | if (args[i] == NULL) { 387 | va_end(v); 388 | int j; 389 | for (j = 0; j < i; ++j) { 390 | free(args[j]); 391 | } 392 | return -1; 393 | } 394 | *(va_arg(v, char**)) = args[i]; 395 | } 396 | va_end(v); 397 | return 0; 398 | } 399 | 400 | // Evaluate the expressions in argv, returning an array of char* 401 | // results. If any evaluate to NULL, free the rest and return NULL. 402 | // The caller is responsible for freeing the returned array and the 403 | // strings it contains. 404 | char** ReadVarArgs(State* state, int argc, Expr* argv[]) { 405 | char** args = (char**)malloc(argc * sizeof(char*)); 406 | int i = 0; 407 | for (i = 0; i < argc; ++i) { 408 | args[i] = Evaluate(state, argv[i]); 409 | if (args[i] == NULL) { 410 | int j; 411 | for (j = 0; j < i; ++j) { 412 | free(args[j]); 413 | } 414 | free(args); 415 | return NULL; 416 | } 417 | } 418 | return args; 419 | } 420 | 421 | // Use printf-style arguments to compose an error message to put into 422 | // *state. Returns NULL. 423 | char* ErrorAbort(State* state, char* format, ...) { 424 | char* buffer = malloc(4096); 425 | va_list v; 426 | va_start(v, format); 427 | vsnprintf(buffer, 4096, format, v); 428 | va_end(v); 429 | free(state->errmsg); 430 | state->errmsg = buffer; 431 | return NULL; 432 | } 433 | -------------------------------------------------------------------------------- /native/tether/edify/expr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EXPRESSION_H 18 | #define _EXPRESSION_H 19 | 20 | #include "yydefs.h" 21 | 22 | #define MAX_STRING_LEN 1024 23 | 24 | typedef struct Expr Expr; 25 | 26 | typedef struct { 27 | // Optional pointer to app-specific data; the core of edify never 28 | // uses this value. 29 | void* cookie; 30 | 31 | // The source of the original script. Must be NULL-terminated, 32 | // and in writable memory (Evaluate may make temporary changes to 33 | // it but will restore it when done). 34 | char* script; 35 | 36 | // The error message (if any) returned if the evaluation aborts. 37 | // Should be NULL initially, will be either NULL or a malloc'd 38 | // pointer after Evaluate() returns. 39 | char* errmsg; 40 | } State; 41 | 42 | typedef char* (*Function)(const char* name, State* state, 43 | int argc, Expr* argv[]); 44 | 45 | struct Expr { 46 | Function fn; 47 | char* name; 48 | int argc; 49 | Expr** argv; 50 | int start, end; 51 | }; 52 | 53 | char* Evaluate(State* state, Expr* expr); 54 | 55 | // Glue to make an Expr out of a literal. 56 | char* Literal(const char* name, State* state, int argc, Expr* argv[]); 57 | 58 | // Functions corresponding to various syntactic sugar operators. 59 | // ("concat" is also available as a builtin function, to concatenate 60 | // more than two strings.) 61 | char* ConcatFn(const char* name, State* state, int argc, Expr* argv[]); 62 | char* LogicalAndFn(const char* name, State* state, int argc, Expr* argv[]); 63 | char* LogicalOrFn(const char* name, State* state, int argc, Expr* argv[]); 64 | char* LogicalNotFn(const char* name, State* state, int argc, Expr* argv[]); 65 | char* SubstringFn(const char* name, State* state, int argc, Expr* argv[]); 66 | char* EqualityFn(const char* name, State* state, int argc, Expr* argv[]); 67 | char* InequalityFn(const char* name, State* state, int argc, Expr* argv[]); 68 | char* SequenceFn(const char* name, State* state, int argc, Expr* argv[]); 69 | 70 | // Convenience function for building expressions with a fixed number 71 | // of arguments. 72 | Expr* Build(Function fn, YYLTYPE loc, int count, ...); 73 | 74 | // Global builtins, registered by RegisterBuiltins(). 75 | char* IfElseFn(const char* name, State* state, int argc, Expr* argv[]); 76 | char* AssertFn(const char* name, State* state, int argc, Expr* argv[]); 77 | char* AbortFn(const char* name, State* state, int argc, Expr* argv[]); 78 | 79 | 80 | // For setting and getting the global error string (when returning 81 | // NULL from a function). 82 | void SetError(const char* message); // makes a copy 83 | const char* GetError(); // retains ownership 84 | void ClearError(); 85 | 86 | 87 | typedef struct { 88 | const char* name; 89 | Function fn; 90 | } NamedFunction; 91 | 92 | // Register a new function. The same Function may be registered under 93 | // multiple names, but a given name should only be used once. 94 | void RegisterFunction(const char* name, Function fn); 95 | 96 | // Register all the builtins. 97 | void RegisterBuiltins(); 98 | 99 | // Call this after all calls to RegisterFunction() but before parsing 100 | // any scripts to finish building the function table. 101 | void FinishRegistration(); 102 | 103 | // Find the Function for a given name; return NULL if no such function 104 | // exists. 105 | Function FindFunction(const char* name); 106 | 107 | 108 | // --- convenience functions for use in functions --- 109 | 110 | // Evaluate the expressions in argv, giving 'count' char* (the ... is 111 | // zero or more char** to put them in). If any expression evaluates 112 | // to NULL, free the rest and return -1. Return 0 on success. 113 | int ReadArgs(State* state, Expr* argv[], int count, ...); 114 | 115 | // Evaluate the expressions in argv, returning an array of char* 116 | // results. If any evaluate to NULL, free the rest and return NULL. 117 | // The caller is responsible for freeing the returned array and the 118 | // strings it contains. 119 | char** ReadVarArgs(State* state, int argc, Expr* argv[]); 120 | 121 | // Use printf-style arguments to compose an error message to put into 122 | // *state. Returns NULL. 123 | char* ErrorAbort(State* state, char* format, ...); 124 | 125 | 126 | #endif // _EXPRESSION_H 127 | -------------------------------------------------------------------------------- /native/tether/edify/lexer.l: -------------------------------------------------------------------------------- 1 | %{ 2 | /* 3 | * Copyright (C) 2009 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include "expr.h" 19 | #include "yydefs.h" 20 | #include "parser.h" 21 | 22 | int gLine = 1; 23 | int gColumn = 1; 24 | int gPos = 0; 25 | 26 | // TODO: enforce MAX_STRING_LEN during lexing 27 | char string_buffer[MAX_STRING_LEN]; 28 | char* string_pos; 29 | 30 | #define ADVANCE do {yylloc.start=gPos; yylloc.end=gPos+yyleng; \ 31 | gColumn+=yyleng; gPos+=yyleng;} while(0) 32 | 33 | %} 34 | 35 | %x STR 36 | 37 | %option noyywrap 38 | 39 | %% 40 | 41 | 42 | \" { 43 | BEGIN(STR); 44 | string_pos = string_buffer; 45 | yylloc.start = gPos; 46 | ++gColumn; 47 | ++gPos; 48 | } 49 | 50 | { 51 | \" { 52 | ++gColumn; 53 | ++gPos; 54 | BEGIN(INITIAL); 55 | *string_pos = '\0'; 56 | yylval.str = strdup(string_buffer); 57 | yylloc.end = gPos; 58 | return STRING; 59 | } 60 | 61 | \\n { gColumn += yyleng; gPos += yyleng; *string_pos++ = '\n'; } 62 | \\t { gColumn += yyleng; gPos += yyleng; *string_pos++ = '\t'; } 63 | \\\" { gColumn += yyleng; gPos += yyleng; *string_pos++ = '\"'; } 64 | \\\\ { gColumn += yyleng; gPos += yyleng; *string_pos++ = '\\'; } 65 | 66 | \\x[0-9a-fA-F]{2} { 67 | gColumn += yyleng; 68 | gPos += yyleng; 69 | int val; 70 | sscanf(yytext+2, "%x", &val); 71 | *string_pos++ = val; 72 | } 73 | 74 | \n { 75 | ++gLine; 76 | ++gPos; 77 | gColumn = 1; 78 | *string_pos++ = yytext[0]; 79 | } 80 | 81 | . { 82 | ++gColumn; 83 | ++gPos; 84 | *string_pos++ = yytext[0]; 85 | } 86 | } 87 | 88 | if ADVANCE; return IF; 89 | then ADVANCE; return THEN; 90 | else ADVANCE; return ELSE; 91 | endif ADVANCE; return ENDIF; 92 | 93 | [a-zA-Z0-9_:/.]+ { 94 | ADVANCE; 95 | yylval.str = strdup(yytext); 96 | return STRING; 97 | } 98 | 99 | \&\& ADVANCE; return AND; 100 | \|\| ADVANCE; return OR; 101 | == ADVANCE; return EQ; 102 | != ADVANCE; return NE; 103 | 104 | [+(),!;] ADVANCE; return yytext[0]; 105 | 106 | [ \t]+ ADVANCE; 107 | 108 | (#.*)?\n gPos += yyleng; ++gLine; gColumn = 1; 109 | 110 | . return BAD; 111 | -------------------------------------------------------------------------------- /native/tether/edify/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "expr.h" 22 | #include "parser.h" 23 | 24 | extern int yyparse(Expr** root, int* error_count); 25 | 26 | int expect(const char* expr_str, const char* expected, int* errors) { 27 | Expr* e; 28 | int error; 29 | char* result; 30 | 31 | printf("."); 32 | 33 | yy_scan_string(expr_str); 34 | int error_count = 0; 35 | error = yyparse(&e, &error_count); 36 | if (error > 0 || error_count > 0) { 37 | fprintf(stderr, "error parsing \"%s\" (%d errors)\n", 38 | expr_str, error_count); 39 | ++*errors; 40 | return 0; 41 | } 42 | 43 | State state; 44 | state.cookie = NULL; 45 | state.script = expr_str; 46 | state.errmsg = NULL; 47 | 48 | result = Evaluate(&state, e); 49 | free(state.errmsg); 50 | if (result == NULL && expected != NULL) { 51 | fprintf(stderr, "error evaluating \"%s\"\n", expr_str); 52 | ++*errors; 53 | return 0; 54 | } 55 | 56 | if (result == NULL && expected == NULL) { 57 | return 1; 58 | } 59 | 60 | if (strcmp(result, expected) != 0) { 61 | fprintf(stderr, "evaluating \"%s\": expected \"%s\", got \"%s\"\n", 62 | expr_str, expected, result); 63 | ++*errors; 64 | free(result); 65 | return 0; 66 | } 67 | 68 | free(result); 69 | return 1; 70 | } 71 | 72 | int test() { 73 | int errors = 0; 74 | 75 | expect("a", "a", &errors); 76 | expect("\"a\"", "a", &errors); 77 | expect("\"\\x61\"", "a", &errors); 78 | expect("# this is a comment\n" 79 | " a\n" 80 | " \n", 81 | "a", &errors); 82 | 83 | 84 | // sequence operator 85 | expect("a; b; c", "c", &errors); 86 | 87 | // string concat operator 88 | expect("a + b", "ab", &errors); 89 | expect("a + \n \"b\"", "ab", &errors); 90 | expect("a + b +\nc\n", "abc", &errors); 91 | 92 | // string concat function 93 | expect("concat(a, b)", "ab", &errors); 94 | expect("concat(a,\n \"b\")", "ab", &errors); 95 | expect("concat(a + b,\nc,\"d\")", "abcd", &errors); 96 | expect("\"concat\"(a + b,\nc,\"d\")", "abcd", &errors); 97 | 98 | // logical and 99 | expect("a && b", "b", &errors); 100 | expect("a && \"\"", "", &errors); 101 | expect("\"\" && b", "", &errors); 102 | expect("\"\" && \"\"", "", &errors); 103 | expect("\"\" && abort()", "", &errors); // test short-circuiting 104 | expect("t && abort()", NULL, &errors); 105 | 106 | // logical or 107 | expect("a || b", "a", &errors); 108 | expect("a || \"\"", "a", &errors); 109 | expect("\"\" || b", "b", &errors); 110 | expect("\"\" || \"\"", "", &errors); 111 | expect("a || abort()", "a", &errors); // test short-circuiting 112 | expect("\"\" || abort()", NULL, &errors); 113 | 114 | // logical not 115 | expect("!a", "", &errors); 116 | expect("! \"\"", "t", &errors); 117 | expect("!!a", "t", &errors); 118 | 119 | // precedence 120 | expect("\"\" == \"\" && b", "b", &errors); 121 | expect("a + b == ab", "t", &errors); 122 | expect("ab == a + b", "t", &errors); 123 | expect("a + (b == ab)", "a", &errors); 124 | expect("(ab == a) + b", "b", &errors); 125 | 126 | // substring function 127 | expect("is_substring(cad, abracadabra)", "t", &errors); 128 | expect("is_substring(abrac, abracadabra)", "t", &errors); 129 | expect("is_substring(dabra, abracadabra)", "t", &errors); 130 | expect("is_substring(cad, abracxadabra)", "", &errors); 131 | expect("is_substring(abrac, axbracadabra)", "", &errors); 132 | expect("is_substring(dabra, abracadabrxa)", "", &errors); 133 | 134 | // ifelse function 135 | expect("ifelse(t, yes, no)", "yes", &errors); 136 | expect("ifelse(!t, yes, no)", "no", &errors); 137 | expect("ifelse(t, yes, abort())", "yes", &errors); 138 | expect("ifelse(!t, abort(), no)", "no", &errors); 139 | 140 | // if "statements" 141 | expect("if t then yes else no endif", "yes", &errors); 142 | expect("if \"\" then yes else no endif", "no", &errors); 143 | expect("if \"\" then yes endif", "", &errors); 144 | expect("if \"\"; t then yes endif", "yes", &errors); 145 | 146 | // numeric comparisons 147 | expect("less_than_int(3, 14)", "t", &errors); 148 | expect("less_than_int(14, 3)", "", &errors); 149 | expect("less_than_int(x, 3)", "", &errors); 150 | expect("less_than_int(3, x)", "", &errors); 151 | expect("greater_than_int(3, 14)", "", &errors); 152 | expect("greater_than_int(14, 3)", "t", &errors); 153 | expect("greater_than_int(x, 3)", "", &errors); 154 | expect("greater_than_int(3, x)", "", &errors); 155 | 156 | printf("\n"); 157 | 158 | return errors; 159 | } 160 | 161 | void ExprDump(int depth, Expr* n, char* script) { 162 | printf("%*s", depth*2, ""); 163 | char temp = script[n->end]; 164 | script[n->end] = '\0'; 165 | printf("%s %p (%d-%d) \"%s\"\n", 166 | n->name == NULL ? "(NULL)" : n->name, n->fn, n->start, n->end, 167 | script+n->start); 168 | script[n->end] = temp; 169 | int i; 170 | for (i = 0; i < n->argc; ++i) { 171 | ExprDump(depth+1, n->argv[i], script); 172 | } 173 | } 174 | 175 | int main(int argc, char** argv) { 176 | RegisterBuiltins(); 177 | FinishRegistration(); 178 | 179 | if (argc == 1) { 180 | return test() != 0; 181 | } 182 | 183 | FILE* f = fopen(argv[1], "r"); 184 | char buffer[8192]; 185 | int size = fread(buffer, 1, 8191, f); 186 | fclose(f); 187 | buffer[size] = '\0'; 188 | 189 | Expr* root; 190 | int error_count = 0; 191 | yy_scan_bytes(buffer, size); 192 | int error = yyparse(&root, &error_count); 193 | printf("parse returned %d; %d errors encountered\n", error, error_count); 194 | if (error == 0 || error_count > 0) { 195 | 196 | ExprDump(0, root, buffer); 197 | 198 | State state; 199 | state.cookie = NULL; 200 | state.script = buffer; 201 | state.errmsg = NULL; 202 | 203 | char* result = Evaluate(&state, root); 204 | if (result == NULL) { 205 | printf("result was NULL, message is: %s\n", 206 | (state.errmsg == NULL ? "(NULL)" : state.errmsg)); 207 | free(state.errmsg); 208 | } else { 209 | printf("result is [%s]\n", result); 210 | } 211 | } 212 | return 0; 213 | } 214 | -------------------------------------------------------------------------------- /native/tether/edify/parser.y: -------------------------------------------------------------------------------- 1 | %{ 2 | /* 3 | * Copyright (C) 2009 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "expr.h" 23 | #include "yydefs.h" 24 | #include "parser.h" 25 | 26 | extern int gLine; 27 | extern int gColumn; 28 | 29 | void yyerror(Expr** root, int* error_count, const char* s); 30 | int yyparse(Expr** root, int* error_count); 31 | 32 | %} 33 | 34 | %locations 35 | 36 | %union { 37 | char* str; 38 | Expr* expr; 39 | struct { 40 | int argc; 41 | Expr** argv; 42 | } args; 43 | } 44 | 45 | %token AND OR SUBSTR SUPERSTR EQ NE IF THEN ELSE ENDIF 46 | %token STRING BAD 47 | %type expr 48 | %type arglist 49 | 50 | %parse-param {Expr** root} 51 | %parse-param {int* error_count} 52 | %error-verbose 53 | 54 | /* declarations in increasing order of precedence */ 55 | %left ';' 56 | %left ',' 57 | %left OR 58 | %left AND 59 | %left EQ NE 60 | %left '+' 61 | %right '!' 62 | 63 | %% 64 | 65 | input: expr { *root = $1; } 66 | ; 67 | 68 | expr: STRING { 69 | $$ = malloc(sizeof(Expr)); 70 | $$->fn = Literal; 71 | $$->name = $1; 72 | $$->argc = 0; 73 | $$->argv = NULL; 74 | $$->start = @$.start; 75 | $$->end = @$.end; 76 | } 77 | | '(' expr ')' { $$ = $2; $$->start=@$.start; $$->end=@$.end; } 78 | | expr ';' { $$ = $1; $$->start=@1.start; $$->end=@1.end; } 79 | | expr ';' expr { $$ = Build(SequenceFn, @$, 2, $1, $3); } 80 | | error ';' expr { $$ = $3; $$->start=@$.start; $$->end=@$.end; } 81 | | expr '+' expr { $$ = Build(ConcatFn, @$, 2, $1, $3); } 82 | | expr EQ expr { $$ = Build(EqualityFn, @$, 2, $1, $3); } 83 | | expr NE expr { $$ = Build(InequalityFn, @$, 2, $1, $3); } 84 | | expr AND expr { $$ = Build(LogicalAndFn, @$, 2, $1, $3); } 85 | | expr OR expr { $$ = Build(LogicalOrFn, @$, 2, $1, $3); } 86 | | '!' expr { $$ = Build(LogicalNotFn, @$, 1, $2); } 87 | | IF expr THEN expr ENDIF { $$ = Build(IfElseFn, @$, 2, $2, $4); } 88 | | IF expr THEN expr ELSE expr ENDIF { $$ = Build(IfElseFn, @$, 3, $2, $4, $6); } 89 | | STRING '(' arglist ')' { 90 | $$ = malloc(sizeof(Expr)); 91 | $$->fn = FindFunction($1); 92 | if ($$->fn == NULL) { 93 | char buffer[256]; 94 | snprintf(buffer, sizeof(buffer), "unknown function \"%s\"", $1); 95 | yyerror(root, error_count, buffer); 96 | YYERROR; 97 | } 98 | $$->name = $1; 99 | $$->argc = $3.argc; 100 | $$->argv = $3.argv; 101 | $$->start = @$.start; 102 | $$->end = @$.end; 103 | } 104 | ; 105 | 106 | arglist: /* empty */ { 107 | $$.argc = 0; 108 | $$.argv = NULL; 109 | } 110 | | expr { 111 | $$.argc = 1; 112 | $$.argv = malloc(sizeof(Expr*)); 113 | $$.argv[0] = $1; 114 | } 115 | | arglist ',' expr { 116 | $$.argc = $1.argc + 1; 117 | $$.argv = realloc($$.argv, $$.argc * sizeof(Expr*)); 118 | $$.argv[$$.argc-1] = $3; 119 | } 120 | ; 121 | 122 | %% 123 | 124 | void yyerror(Expr** root, int* error_count, const char* s) { 125 | if (strlen(s) == 0) { 126 | s = "syntax error"; 127 | } 128 | printf("line %d col %d: %s\n", gLine, gColumn, s); 129 | ++*error_count; 130 | } 131 | -------------------------------------------------------------------------------- /native/tether/edify/yydefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _YYDEFS_H_ 18 | #define _YYDEFS_H_ 19 | 20 | #define YYLTYPE YYLTYPE 21 | typedef struct { 22 | int start, end; 23 | } YYLTYPE; 24 | 25 | #define YYLLOC_DEFAULT(Current, Rhs, N) \ 26 | do { \ 27 | if (N) { \ 28 | (Current).start = YYRHSLOC(Rhs, 1).start; \ 29 | (Current).end = YYRHSLOC(Rhs, N).end; \ 30 | } else { \ 31 | (Current).start = YYRHSLOC(Rhs, 0).start; \ 32 | (Current).end = YYRHSLOC(Rhs, 0).end; \ 33 | } \ 34 | } while (0) 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /native/tether/install.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _UPDATER_INSTALL_H_ 18 | #define _UPDATER_INSTALL_H_ 19 | 20 | void RegisterInstallFunctions(); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /native/tether/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SHA1 hash implementation and interface functions 3 | * Copyright (c) 2003-2005, Jouni Malinen 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License version 2 as 7 | * published by the Free Software Foundation. 8 | * 9 | * Alternatively, this software may be distributed under the terms of BSD 10 | * license. 11 | * 12 | * See README and COPYING for more details. 13 | */ 14 | 15 | #ifndef SHA1_H 16 | #define SHA1_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #define os_memcpy memcpy 23 | #define os_memset memset 24 | #define os_memcmp memcmp 25 | #define os_strlen strlen 26 | 27 | #define MAX_SHA1_LEN 32 28 | #define SHA1_MAC_LEN 20 29 | 30 | typedef __u8 u8; 31 | typedef __u32 u32; 32 | 33 | static inline unsigned int wpa_swap_32(unsigned int v) 34 | { 35 | return ((v & 0xff) << 24) | ((v & 0xff00) << 8) | 36 | ((v & 0xff0000) >> 8) | (v >> 24); 37 | } 38 | 39 | #define be_to_host32(n) wpa_swap_32(n) 40 | #define host_to_be32(n) wpa_swap_32(n) 41 | 42 | void sha1_vector(size_t num_elem, const u8 *addr[], const size_t *len, 43 | u8 *mac); 44 | void hmac_sha1_vector(const u8 *key, size_t key_len, size_t num_elem, 45 | const u8 *addr[], const size_t *len, u8 *mac); 46 | void hmac_sha1(const u8 *key, size_t key_len, const u8 *data, size_t data_len, 47 | u8 *mac); 48 | void sha1_prf(const u8 *key, size_t key_len, const char *label, 49 | const u8 *data, size_t data_len, u8 *buf, size_t buf_len); 50 | void sha1_t_prf(const u8 *key, size_t key_len, const char *label, 51 | const u8 *seed, size_t seed_len, u8 *buf, size_t buf_len); 52 | int tls_prf(const u8 *secret, size_t secret_len, 53 | const char *label, const u8 *seed, size_t seed_len, 54 | u8 *out, size_t outlen); 55 | #ifdef __cplusplus 56 | extern "C" 57 | #endif 58 | void pbkdf2_sha1(const char *passphrase, const char *ssid, size_t ssid_len, 59 | int iterations, u8 *buf, size_t buflen); 60 | 61 | #ifdef CONFIG_CRYPTO_INTERNAL 62 | struct SHA1Context; 63 | 64 | void SHA1Init(struct SHA1Context *context); 65 | void SHA1Update(struct SHA1Context *context, const void *data, u32 len); 66 | void SHA1Final(unsigned char digest[20], struct SHA1Context *context); 67 | #endif /* CONFIG_CRYPTO_INTERNAL */ 68 | 69 | #endif /* SHA1_H */ 70 | -------------------------------------------------------------------------------- /native/tether/tether.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Ben Buxton 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "edify/expr.h" 25 | #include "tether.h" 26 | #include "install.h" 27 | 28 | // Where in the package we expect to find the edify script to execute. 29 | #define SCRIPT_NAME "/data/data/com.googlecode.android.wifi.tether/conf/tether.edify" 30 | 31 | int main(int argc, char** argv) { 32 | FILE *f; 33 | /* 34 | if (argc != 4) { 35 | fprintf(stderr, "unexpected number of arguments (%d)\n", argc); 36 | return 1; 37 | } 38 | 39 | */ 40 | // Set up the pipe for sending commands back to the parent process. 41 | //int fd = atoi(argv[2]); 42 | int fd = 1; 43 | FILE* cmd_pipe = fdopen(fd, "wb"); 44 | setlinebuf(cmd_pipe); 45 | 46 | struct stat st; 47 | if (stat(SCRIPT_NAME, &st) < 0) { 48 | fprintf(stderr, "Could not stat %s: %s", SCRIPT_NAME, strerror(errno)); 49 | return 1; 50 | } 51 | if (st.st_size > 128000) { 52 | fprintf(stderr, "%s too large (max 128k)", SCRIPT_NAME); 53 | return 1; 54 | } 55 | char *script = malloc(st.st_size+1); 56 | 57 | f = fopen(SCRIPT_NAME, "rb"); 58 | if (f == NULL) { 59 | fprintf(stderr, "Cannot read %s\n", SCRIPT_NAME); 60 | return 1; 61 | } 62 | if (fread(script, 1, st.st_size, f) != st.st_size) { 63 | fprintf(stderr, "Failed to read %d bytes from %s", st.st_size+1, SCRIPT_NAME); 64 | return 1; 65 | } 66 | script[st.st_size] = '\0'; 67 | fclose(f); 68 | 69 | // Configure edify's functions. 70 | 71 | RegisterBuiltins(); 72 | RegisterInstallFunctions(); 73 | FinishRegistration(); 74 | 75 | // Parse the script. 76 | 77 | Expr* root; 78 | int error_count = 0; 79 | yy_scan_string(script); 80 | int error = yyparse(&root, &error_count); 81 | if (error != 0 || error_count > 0) { 82 | fprintf(stderr, "%d parse errors\n", error_count); 83 | return 6; 84 | } 85 | 86 | // Evaluate the parsed script. 87 | 88 | UpdaterInfo updater_info; 89 | updater_info.cmd_pipe = cmd_pipe; 90 | updater_info.log_fd = fopen ("/data/data/com.googlecode.android.wifi.tether/var/tether.log","w"); 91 | 92 | updater_info.action = strdup(argv[1]); 93 | 94 | State state; 95 | state.cookie = &updater_info; 96 | state.script = script; 97 | state.errmsg = NULL; 98 | 99 | char* result = Evaluate(&state, root); 100 | if (result == NULL) { 101 | if (state.errmsg == NULL) { 102 | fprintf(stderr, "script aborted (no error message)\n"); 103 | fprintf(cmd_pipe, "ui_print script aborted (no error message)\n"); 104 | } else { 105 | fprintf(stderr, "script aborted: %s\n", state.errmsg); 106 | char* line = strtok(state.errmsg, "\n"); 107 | while (line) { 108 | fprintf(cmd_pipe, "ui_print %s\n", line); 109 | line = strtok(NULL, "\n"); 110 | } 111 | fprintf(cmd_pipe, "ui_print\n"); 112 | } 113 | free(state.errmsg); 114 | return 7; 115 | } else { 116 | fprintf(stderr, "script result was [%s]\n", result); 117 | free(result); 118 | } 119 | 120 | free(script); 121 | 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /native/tether/tether.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _UPDATER_UPDATER_H_ 18 | #define _UPDATER_UPDATER_H_ 19 | 20 | #include 21 | 22 | typedef struct { 23 | FILE* cmd_pipe; 24 | FILE* log_fd; 25 | char *action; 26 | } UpdaterInfo; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /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 use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Indicates whether an apk should be generated for each density. 11 | split.density=false 12 | # Project target. 13 | target=android-11 14 | apk-configurations= 15 | -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_bg.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_divider.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_divider.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_ind_mid_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_ind_mid_c.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_ind_off_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_ind_off_c.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_ind_on_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_ind_on_c.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_inner_focus_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_inner_focus_c.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/appwidget_inner_press_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/appwidget_inner_press_c.9.png -------------------------------------------------------------------------------- /res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-hdpi/tether_wifi_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/tether_wifi_off.png -------------------------------------------------------------------------------- /res/drawable-hdpi/tether_wifi_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-hdpi/tether_wifi_on.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_bg.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_bg.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_divider.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_divider.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_ind_mid_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_ind_mid_c.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_ind_off_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_ind_off_c.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_ind_on_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_ind_on_c.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_inner_focus_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_inner_focus_c.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/appwidget_inner_press_c.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/appwidget_inner_press_c.9.png -------------------------------------------------------------------------------- /res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /res/drawable-mdpi/tether_wifi_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/tether_wifi_off.png -------------------------------------------------------------------------------- /res/drawable-mdpi/tether_wifi_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable-mdpi/tether_wifi_on.png -------------------------------------------------------------------------------- /res/drawable/appwidget_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 19 | 21 | 22 | 25 | 26 | 28 | 29 | -------------------------------------------------------------------------------- /res/drawable/background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/background.9.png -------------------------------------------------------------------------------- /res/drawable/battery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/battery.png -------------------------------------------------------------------------------- /res/drawable/sechigh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/sechigh.png -------------------------------------------------------------------------------- /res/drawable/seclow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/seclow.png -------------------------------------------------------------------------------- /res/drawable/secmedium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/secmedium.png -------------------------------------------------------------------------------- /res/drawable/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/start.png -------------------------------------------------------------------------------- /res/drawable/start_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/start_notification.png -------------------------------------------------------------------------------- /res/drawable/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/stop.png -------------------------------------------------------------------------------- /res/drawable/stop_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmorciegov/android-wifi-tether/6231e1968be59c7a7499e45807121aad24c0579d/res/drawable/stop_notification.png -------------------------------------------------------------------------------- /res/drawable/tether_start_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /res/drawable/tether_stop_button.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /res/layout/aboutview.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 21 | 22 | 31 | 32 | 41 | 42 | 52 | 53 | 62 | 63 | 70 | 71 | 81 | 82 | 91 | 92 | 100 | 101 | 110 | 111 | 118 | 119 | 128 | 129 | 139 | 140 | 150 | 158 | 167 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /res/layout/accesscontrolview.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 23 | 33 | 34 | 43 | 49 | 54 |