rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | diff --git a/hardware/libhardware_legacy/wifi/wifi.c b/hardware/libhardware_legacy/wifi/wifi.c |
| 2 | old mode 100644 |
| 3 | new mode 100755 |
| 4 | index 880f6fc..7e9aa80 |
| 5 | --- a/hardware/libhardware_legacy/wifi/wifi.c |
| 6 | +++ b/hardware/libhardware_legacy/wifi/wifi.c |
| 7 | @@ -33,17 +33,17 @@ |
| 8 | #include "cutils/log.h" |
| 9 | #include "cutils/memory.h" |
| 10 | #include "cutils/misc.h" |
| 11 | -#include "cutils/properties.h" |
| 12 | +//#include "cutils/properties.h" |
| 13 | #include "private/android_filesystem_config.h" |
| 14 | |
| 15 | #define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ |
| 16 | -#include <sys/_system_properties.h> |
| 17 | +//#include <sys/_system_properties.h> |
| 18 | |
| 19 | -extern int do_dhcp(); |
| 20 | +//extern int do_dhcp(); |
| 21 | extern int ifc_init(); |
| 22 | extern void ifc_close(); |
| 23 | -extern char *dhcp_lasterror(); |
| 24 | -extern void get_dhcp_info(); |
| 25 | +//extern char *dhcp_lasterror(); |
| 26 | +//extern void get_dhcp_info(); |
| 27 | extern int init_module(void *, unsigned long, const char *); |
| 28 | extern int delete_module(const char *, unsigned int); |
| 29 | void wifi_close_sockets(); |
| 30 | @@ -64,6 +64,9 @@ int wpa_ctrl_recv(struct wpa_ctrl *ctrl, char *reply, size_t *reply_len) |
| 31 | int wpa_ctrl_get_fd(struct wpa_ctrl *ctrl) { return 0; } |
| 32 | #endif |
| 33 | |
| 34 | +#define PROPERTY_VALUE_MAX 100 |
| 35 | +#define PROPERTY_KEY_MAX 100 |
| 36 | + |
| 37 | static struct wpa_ctrl *ctrl_conn; |
| 38 | static struct wpa_ctrl *monitor_conn; |
| 39 | |
| 40 | @@ -168,6 +171,7 @@ static int rmmod(const char *modname) |
| 41 | return ret; |
| 42 | } |
| 43 | |
| 44 | +#if 0 |
| 45 | int do_dhcp_request(int *ipaddr, int *gateway, int *mask, |
| 46 | int *dns1, int *dns2, int *server, int *lease) { |
| 47 | /* For test driver, always report success */ |
| 48 | @@ -189,6 +193,7 @@ int do_dhcp_request(int *ipaddr, int *gateway, int *mask, |
| 49 | const char *get_dhcp_error_string() { |
| 50 | return dhcp_lasterror(); |
| 51 | } |
| 52 | +#endif |
| 53 | |
| 54 | #ifdef WIFI_DRIVER_STATE_CTRL_PARAM |
| 55 | int wifi_change_driver_state(const char *state) |
| 56 | @@ -199,13 +204,13 @@ int wifi_change_driver_state(const char *state) |
| 57 | |
| 58 | if (!state) |
| 59 | return -1; |
| 60 | - fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_STATE_CTRL_PARAM, O_WRONLY)); |
| 61 | + fd = (open(WIFI_DRIVER_STATE_CTRL_PARAM, O_WRONLY); |
| 62 | if (fd < 0) { |
| 63 | ALOGE("Failed to open driver state control param (%s)", strerror(errno)); |
| 64 | return -1; |
| 65 | } |
| 66 | len = strlen(state) + 1; |
| 67 | - if (TEMP_FAILURE_RETRY(write(fd, state, len)) != len) { |
| 68 | + if ((write(fd, state, len)) != len) { |
| 69 | ALOGE("Failed to write driver state control param (%s)", strerror(errno)); |
| 70 | ret = -1; |
| 71 | } |
| 72 | @@ -221,8 +226,8 @@ int is_wifi_driver_loaded() { |
| 73 | char line[sizeof(DRIVER_MODULE_TAG)+10]; |
| 74 | #endif |
| 75 | |
| 76 | - if (!property_get(DRIVER_PROP_NAME, driver_status, NULL) |
| 77 | - || strcmp(driver_status, "ok") != 0) { |
| 78 | + if (!/*property_get(DRIVER_PROP_NAME, driver_status, NULL) |
| 79 | + || */strcmp(driver_status, "ok") != 0) { |
| 80 | return 0; /* driver not loaded */ |
| 81 | } |
| 82 | #ifdef WIFI_DRIVER_MODULE_PATH |
| 83 | @@ -234,7 +239,7 @@ int is_wifi_driver_loaded() { |
| 84 | */ |
| 85 | if ((proc = fopen(MODULE_FILE, "r")) == NULL) { |
| 86 | ALOGW("Could not open %s: %s", MODULE_FILE, strerror(errno)); |
| 87 | - property_set(DRIVER_PROP_NAME, "unloaded"); |
| 88 | + //property_set(DRIVER_PROP_NAME, "unloaded"); |
| 89 | return 0; |
| 90 | } |
| 91 | while ((fgets(line, sizeof(line), proc)) != NULL) { |
| 92 | @@ -244,7 +249,7 @@ int is_wifi_driver_loaded() { |
| 93 | } |
| 94 | } |
| 95 | fclose(proc); |
| 96 | - property_set(DRIVER_PROP_NAME, "unloaded"); |
| 97 | + //property_set(DRIVER_PROP_NAME, "unloaded"); |
| 98 | return 0; |
| 99 | #else |
| 100 | return 1; |
| 101 | @@ -266,14 +271,14 @@ int wifi_load_driver() |
| 102 | |
| 103 | if (strcmp(FIRMWARE_LOADER,"") == 0) { |
| 104 | /* usleep(WIFI_DRIVER_LOADER_DELAY); */ |
| 105 | - property_set(DRIVER_PROP_NAME, "ok"); |
| 106 | + //property_set(DRIVER_PROP_NAME, "ok"); |
| 107 | } |
| 108 | else { |
| 109 | - property_set("ctl.start", FIRMWARE_LOADER); |
| 110 | + //property_set("ctl.start", FIRMWARE_LOADER); |
| 111 | } |
| 112 | sched_yield(); |
| 113 | while (count-- > 0) { |
| 114 | - if (property_get(DRIVER_PROP_NAME, driver_status, NULL)) { |
| 115 | + if (/*property_get(DRIVER_PROP_NAME, driver_status, NULL)*/) { |
| 116 | if (strcmp(driver_status, "ok") == 0) |
| 117 | return 0; |
| 118 | else if (strcmp(driver_status, "failed") == 0) { |
| 119 | @@ -283,7 +288,7 @@ int wifi_load_driver() |
| 120 | } |
| 121 | usleep(200000); |
| 122 | } |
| 123 | - property_set(DRIVER_PROP_NAME, "timeout"); |
| 124 | + //property_set(DRIVER_PROP_NAME, "timeout"); |
| 125 | wifi_unload_driver(); |
| 126 | return -1; |
| 127 | #else |
| 128 | @@ -295,7 +300,7 @@ int wifi_load_driver() |
| 129 | if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0) |
| 130 | return -1; |
| 131 | #endif |
| 132 | - property_set(DRIVER_PROP_NAME, "ok"); |
| 133 | + //property_set(DRIVER_PROP_NAME, "ok"); |
| 134 | return 0; |
| 135 | #endif |
| 136 | } |
| 137 | @@ -325,7 +330,7 @@ int wifi_unload_driver() |
| 138 | return -1; |
| 139 | } |
| 140 | #endif |
| 141 | - property_set(DRIVER_PROP_NAME, "unloaded"); |
| 142 | + //property_set(DRIVER_PROP_NAME, "unloaded"); |
| 143 | return 0; |
| 144 | #endif |
| 145 | } |
| 146 | @@ -344,13 +349,13 @@ int ensure_entropy_file_exists() |
| 147 | } |
| 148 | return 0; |
| 149 | } |
| 150 | - destfd = TEMP_FAILURE_RETRY(open(SUPP_ENTROPY_FILE, O_CREAT|O_RDWR, 0660)); |
| 151 | + destfd = (open(SUPP_ENTROPY_FILE, O_CREAT|O_RDWR, 0660)); |
| 152 | if (destfd < 0) { |
| 153 | ALOGE("Cannot create \"%s\": %s", SUPP_ENTROPY_FILE, strerror(errno)); |
| 154 | return -1; |
| 155 | } |
| 156 | |
| 157 | - if (TEMP_FAILURE_RETRY(write(destfd, dummy_key, sizeof(dummy_key))) != sizeof(dummy_key)) { |
| 158 | + if ((write(destfd, dummy_key, sizeof(dummy_key))) != sizeof(dummy_key)) { |
| 159 | ALOGE("Error writing \"%s\": %s", SUPP_ENTROPY_FILE, strerror(errno)); |
| 160 | close(destfd); |
| 161 | return -1; |
| 162 | @@ -395,20 +400,20 @@ int ensure_config_file_exists(const char *config_file) |
| 163 | return -1; |
| 164 | } |
| 165 | |
| 166 | - srcfd = TEMP_FAILURE_RETRY(open(SUPP_CONFIG_TEMPLATE, O_RDONLY)); |
| 167 | + srcfd = (open(SUPP_CONFIG_TEMPLATE, O_RDONLY)); |
| 168 | if (srcfd < 0) { |
| 169 | ALOGE("Cannot open \"%s\": %s", SUPP_CONFIG_TEMPLATE, strerror(errno)); |
| 170 | return -1; |
| 171 | } |
| 172 | |
| 173 | - destfd = TEMP_FAILURE_RETRY(open(config_file, O_CREAT|O_RDWR, 0660)); |
| 174 | + destfd = (open(config_file, O_CREAT|O_RDWR, 0660)); |
| 175 | if (destfd < 0) { |
| 176 | close(srcfd); |
| 177 | ALOGE("Cannot create \"%s\": %s", config_file, strerror(errno)); |
| 178 | return -1; |
| 179 | } |
| 180 | |
| 181 | - while ((nread = TEMP_FAILURE_RETRY(read(srcfd, buf, sizeof(buf)))) != 0) { |
| 182 | + while ((nread = (read(srcfd, buf, sizeof(buf)))) != 0) { |
| 183 | if (nread < 0) { |
| 184 | ALOGE("Error reading \"%s\": %s", SUPP_CONFIG_TEMPLATE, strerror(errno)); |
| 185 | close(srcfd); |
| 186 | @@ -416,7 +421,7 @@ int ensure_config_file_exists(const char *config_file) |
| 187 | unlink(config_file); |
| 188 | return -1; |
| 189 | } |
| 190 | - TEMP_FAILURE_RETRY(write(destfd, buf, nread)); |
| 191 | + (write(destfd, buf, nread)); |
| 192 | } |
| 193 | |
| 194 | close(destfd); |
| 195 | @@ -443,7 +448,7 @@ int wifi_start_supplicant(int p2p_supported) |
| 196 | { |
| 197 | char supp_status[PROPERTY_VALUE_MAX] = {'\0'}; |
| 198 | int count = 200; /* wait at most 20 seconds for completion */ |
| 199 | - const prop_info *pi; |
| 200 | + //const prop_info *pi; |
| 201 | unsigned serial = 0, i; |
| 202 | |
| 203 | if (p2p_supported) { |
| 204 | @@ -462,8 +467,8 @@ int wifi_start_supplicant(int p2p_supported) |
| 205 | } |
| 206 | |
| 207 | /* Check whether already running */ |
| 208 | - if (property_get(supplicant_prop_name, supp_status, NULL) |
| 209 | - && strcmp(supp_status, "running") == 0) { |
| 210 | + if (/*property_get(supplicant_prop_name, supp_status, NULL) |
| 211 | + && */strcmp(supp_status, "running") == 0) { |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | @@ -490,23 +495,20 @@ int wifi_start_supplicant(int p2p_supported) |
| 216 | * it starts in the stopped state and never manages to start |
| 217 | * running at all. |
| 218 | */ |
| 219 | - pi = __system_property_find(supplicant_prop_name); |
| 220 | + /*pi = __system_property_find(supplicant_prop_name); |
| 221 | if (pi != NULL) { |
| 222 | serial = __system_property_serial(pi); |
| 223 | - } |
| 224 | - property_get("wifi.interface", primary_iface, WIFI_TEST_INTERFACE); |
| 225 | + }*/ |
| 226 | + //property_get("wifi.interface", primary_iface, WIFI_TEST_INTERFACE); |
| 227 | |
| 228 | - property_set("ctl.start", supplicant_name); |
| 229 | + //property_set("ctl.start", supplicant_name); |
| 230 | sched_yield(); |
| 231 | - |
| 232 | +/* |
| 233 | while (count-- > 0) { |
| 234 | if (pi == NULL) { |
| 235 | pi = __system_property_find(supplicant_prop_name); |
| 236 | } |
| 237 | if (pi != NULL) { |
| 238 | - /* |
| 239 | - * property serial updated means that init process is scheduled |
| 240 | - * after we sched_yield, further property status checking is based on this */ |
| 241 | if (__system_property_serial(pi) != serial) { |
| 242 | __system_property_read(pi, NULL, supp_status); |
| 243 | if (strcmp(supp_status, "running") == 0) { |
| 244 | @@ -517,7 +519,7 @@ int wifi_start_supplicant(int p2p_supported) |
| 245 | } |
| 246 | } |
| 247 | usleep(100000); |
| 248 | - } |
| 249 | + }*/ |
| 250 | return -1; |
| 251 | } |
| 252 | |
| 253 | @@ -535,16 +537,16 @@ int wifi_stop_supplicant(int p2p_supported) |
| 254 | } |
| 255 | |
| 256 | /* Check whether supplicant already stopped */ |
| 257 | - if (property_get(supplicant_prop_name, supp_status, NULL) |
| 258 | - && strcmp(supp_status, "stopped") == 0) { |
| 259 | + if (/*property_get(supplicant_prop_name, supp_status, NULL) |
| 260 | + &&*/ strcmp(supp_status, "stopped") == 0) { |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | - property_set("ctl.stop", supplicant_name); |
| 265 | + //property_set("ctl.stop", supplicant_name); |
| 266 | sched_yield(); |
| 267 | |
| 268 | while (count-- > 0) { |
| 269 | - if (property_get(supplicant_prop_name, supp_status, NULL)) { |
| 270 | + if (/*property_get(supplicant_prop_name, supp_status, NULL)*/1) { |
| 271 | if (strcmp(supp_status, "stopped") == 0) |
| 272 | return 0; |
| 273 | } |
| 274 | @@ -559,8 +561,8 @@ int wifi_connect_on_socket_path(const char *path) |
| 275 | char supp_status[PROPERTY_VALUE_MAX] = {'\0'}; |
| 276 | |
| 277 | /* Make sure supplicant is running */ |
| 278 | - if (!property_get(supplicant_prop_name, supp_status, NULL) |
| 279 | - || strcmp(supp_status, "running") != 0) { |
| 280 | + if (!/*property_get(supplicant_prop_name, supp_status, NULL) |
| 281 | + ||*/ strcmp(supp_status, "running") != 0) { |
| 282 | ALOGE("Supplicant not running, cannot connect"); |
| 283 | return -1; |
| 284 | } |
| 285 | @@ -618,7 +620,7 @@ int wifi_send_command(const char *cmd, char *reply, size_t *reply_len) |
| 286 | if (ret == -2) { |
| 287 | ALOGD("'%s' command timed out.\n", cmd); |
| 288 | /* unblocks the monitor receive socket for termination */ |
| 289 | - TEMP_FAILURE_RETRY(write(exit_sockets[0], "T", 1)); |
| 290 | + (write(exit_sockets[0], "T", 1)); |
| 291 | return -2; |
| 292 | } else if (ret < 0 || strncmp(reply, "FAIL", 4) == 0) { |
| 293 | return -1; |
| 294 | @@ -631,13 +633,14 @@ int wifi_send_command(const char *cmd, char *reply, size_t *reply_len) |
| 295 | |
| 296 | int wifi_supplicant_connection_active() |
| 297 | { |
| 298 | + #if 0 |
| 299 | char supp_status[PROPERTY_VALUE_MAX] = {'\0'}; |
| 300 | |
| 301 | - if (property_get(supplicant_prop_name, supp_status, NULL)) { |
| 302 | + if (/*property_get(supplicant_prop_name, supp_status, NULL)*/1) { |
| 303 | if (strcmp(supp_status, "stopped") == 0) |
| 304 | return -1; |
| 305 | } |
| 306 | - |
| 307 | + #endif |
| 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | @@ -653,7 +656,7 @@ int wifi_ctrl_recv(char *reply, size_t *reply_len) |
| 312 | rfds[1].fd = exit_sockets[1]; |
| 313 | rfds[1].events |= POLLIN; |
| 314 | do { |
| 315 | - res = TEMP_FAILURE_RETRY(poll(rfds, 2, 30000)); |
| 316 | + res = (poll(rfds, 2, 30000)); |
| 317 | if (res < 0) { |
| 318 | ALOGE("Error poll = %d", res); |
| 319 | return res; |
| 320 | @@ -785,7 +788,7 @@ void wifi_close_supplicant_connection() |
| 321 | wifi_close_sockets(); |
| 322 | |
| 323 | while (count-- > 0) { |
| 324 | - if (property_get(supplicant_prop_name, supp_status, NULL)) { |
| 325 | + if (/*property_get(supplicant_prop_name, supp_status, NULL)*/1) { |
| 326 | if (strcmp(supp_status, "stopped") == 0) |
| 327 | return; |
| 328 | } |
| 329 | @@ -819,13 +822,13 @@ int wifi_change_fw_path(const char *fwpath) |
| 330 | |
| 331 | if (!fwpath) |
| 332 | return ret; |
| 333 | - fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_FW_PATH_PARAM, O_WRONLY)); |
| 334 | + fd = (open(WIFI_DRIVER_FW_PATH_PARAM, O_WRONLY)); |
| 335 | if (fd < 0) { |
| 336 | ALOGE("Failed to open wlan fw path param (%s)", strerror(errno)); |
| 337 | return -1; |
| 338 | } |
| 339 | len = strlen(fwpath) + 1; |
| 340 | - if (TEMP_FAILURE_RETRY(write(fd, fwpath, len)) != len) { |
| 341 | + if ((write(fd, fwpath, len)) != len) { |
| 342 | ALOGE("Failed to write wlan fw path param (%s)", strerror(errno)); |
| 343 | ret = -1; |
| 344 | } |