diff options
-rw-r--r-- | macloader/Android.mk | 8 | ||||
-rw-r--r-- | macloader/macloader.c | 95 | ||||
-rwxr-xr-x | ril/xmm6260/libril/ril.cpp | 14 | ||||
-rw-r--r-- | ril/xmm6262/libril/ril.cpp | 14 |
4 files changed, 117 insertions, 14 deletions
diff --git a/macloader/Android.mk b/macloader/Android.mk index 722325f..ee843be 100644 --- a/macloader/Android.mk +++ b/macloader/Android.mk @@ -3,6 +3,14 @@ ifeq ($(BOARD_HAVE_SAMSUNG_WIFI),true) LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) +ifdef WIFI_DRIVER_NVRAM_PATH +LOCAL_CFLAGS += -DWIFI_DRIVER_NVRAM_PATH=\"$(WIFI_DRIVER_NVRAM_PATH)\" +endif + +ifdef WIFI_DRIVER_NVRAM_PATH_PARAM +LOCAL_CFLAGS += -DWIFI_DRIVER_NVRAM_PATH_PARAM=\"$(WIFI_DRIVER_NVRAM_PATH_PARAM)\" +endif + LOCAL_SRC_FILES := \ macloader.c diff --git a/macloader/macloader.c b/macloader/macloader.c index 7e1a10c..bdf94b4 100644 --- a/macloader/macloader.c +++ b/macloader/macloader.c @@ -22,12 +22,22 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> #include <sys/stat.h> +#include <fcntl.h> #include <unistd.h> #include <pwd.h> #include <cutils/log.h> +#ifndef WIFI_DRIVER_NVRAM_PATH +#define WIFI_DRIVER_NVRAM_PATH NULL +#endif + +#ifndef WIFI_DRIVER_NVRAM_PATH_PARAM +#define WIFI_DRIVER_NVRAM_PATH_PARAM "/sys/module/wlan/parameters/nvram_path" +#endif + #define MACADDR_PATH "/efs/wifi/.mac.info" #define CID_PATH "/data/.cid.info" @@ -40,6 +50,82 @@ enum Type { WISOL }; +static int wifi_change_nvram_calibration(const char *nvram_file, + const char *type) +{ + int len; + int fd = -1; + int ret = 0; + struct stat sb; + char nvram_str[1024] = { 0 }; + + if (nvram_file == NULL || type == NULL) { + return -1; + } + + ret = stat(nvram_file, &sb); + if (ret != 0) { + ALOGE("Failed to check for NVRAM calibration file '%s' - error: %s", + nvram_file, + strerror(errno)); + return -1; + } + + ALOGD("Using NVRAM calibration file: %s\n", nvram_file); + + fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_NVRAM_PATH_PARAM, O_WRONLY)); + if (fd < 0) { + ALOGE("Failed to open wifi nvram config path %s - error: %s", + WIFI_DRIVER_NVRAM_PATH_PARAM, strerror(errno)); + return -1; + } + + len = strlen(nvram_file) + 1; + if (TEMP_FAILURE_RETRY(write(fd, nvram_file, len)) != len) { + ALOGE("Failed to write to wifi config path %s - error: %s", + WIFI_DRIVER_NVRAM_PATH_PARAM, strerror(errno)); + ret = -1; + goto out; + } + + snprintf(nvram_str, sizeof(nvram_str), "%s_%s", + nvram_file, type); + + ALOGD("Changing NVRAM calibration file for %s chipset\n", type); + + ret = stat(nvram_str, &sb); + if (ret != 0) { + ALOGW("NVRAM calibration file '%s' doesn't exist", nvram_str); + /* + * We were able to write the default calibration file. So + * continue here without returning an error. + */ + ret = 0; + goto out; + } + + len = strlen(nvram_str) + 1; + if (TEMP_FAILURE_RETRY(write(fd, nvram_str, len)) != len) { + ALOGW("Failed to write to wifi config path %s - error: %s", + WIFI_DRIVER_NVRAM_PATH_PARAM, strerror(errno)); + /* + * We were able to write the default calibration file. So + * continue here without returning an error. + */ + ret = 0; + goto out; + } + + ALOGD("NVRAM calibration file set to '%s'\n", nvram_str); + + ret = 0; +out: + if (fd != -1) { + close(fd); + } + return ret; +} + int main() { FILE* file; FILE* cidfile; @@ -108,6 +194,7 @@ int main() { } if (type != NONE) { + const char *nvram_file; const char *type_str; struct passwd *pwd; int fd; @@ -176,6 +263,14 @@ int main() { CID_PATH, strerror(errno)); return 1; } + + nvram_file = WIFI_DRIVER_NVRAM_PATH; + if (nvram_file != NULL) { + ret = wifi_change_nvram_calibration(nvram_file, type_str); + if (ret != 0) { + return 1; + } + } } else { /* delete cid file if no specific type */ ALOGD("Deleting file %s\n", CID_PATH); diff --git a/ril/xmm6260/libril/ril.cpp b/ril/xmm6260/libril/ril.cpp index 42b19ff..661d48d 100755 --- a/ril/xmm6260/libril/ril.cpp +++ b/ril/xmm6260/libril/ril.cpp @@ -3062,11 +3062,11 @@ static void debugCallback (int fd, short flags, void *param) { int data; unsigned int qxdm_data[6]; const char *deactData[1] = {"1"}; - char *actData[1]; RIL_Dial dialData; int hangupData[1] = {1}; int number; char **args; + int MAX_DIAL_ADDRESS = 128; acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen); @@ -3148,12 +3148,6 @@ static void debugCallback (int fd, short flags, void *param) { // Set network selection automatic. issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0); break; - case 6: - RLOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); - actData[0] = args[1]; - issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, - sizeof(actData)); - break; case 7: RLOGI("Debug port: Deactivate Data Call"); issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, @@ -3162,6 +3156,12 @@ static void debugCallback (int fd, short flags, void *param) { case 8: RLOGI("Debug port: Dial Call"); dialData.clir = 0; + if (strlen(args[1]) > MAX_DIAL_ADDRESS) { + RLOGE("Debug port: Error calling Dial"); + freeDebugCallbackArgs(number, args); + close(acceptFD); + return; + } dialData.address = args[1]; issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData)); break; diff --git a/ril/xmm6262/libril/ril.cpp b/ril/xmm6262/libril/ril.cpp index b5c124b..5473c20 100644 --- a/ril/xmm6262/libril/ril.cpp +++ b/ril/xmm6262/libril/ril.cpp @@ -3110,11 +3110,11 @@ static void debugCallback (int fd, short flags, void *param) { int data; unsigned int qxdm_data[6]; const char *deactData[1] = {"1"}; - char *actData[1]; RIL_Dial dialData; int hangupData[1] = {1}; int number; char **args; + int MAX_DIAL_ADDRESS = 128; acceptFD = accept (fd, (sockaddr *) &peeraddr, &socklen); @@ -3196,12 +3196,6 @@ static void debugCallback (int fd, short flags, void *param) { // Set network selection automatic. issueLocalRequest(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, NULL, 0); break; - case 6: - RLOGI("Debug port: Setup Data Call, Apn :%s\n", args[1]); - actData[0] = args[1]; - issueLocalRequest(RIL_REQUEST_SETUP_DATA_CALL, &actData, - sizeof(actData)); - break; case 7: RLOGI("Debug port: Deactivate Data Call"); issueLocalRequest(RIL_REQUEST_DEACTIVATE_DATA_CALL, &deactData, @@ -3210,6 +3204,12 @@ static void debugCallback (int fd, short flags, void *param) { case 8: RLOGI("Debug port: Dial Call"); dialData.clir = 0; + if (strlen(args[1]) > MAX_DIAL_ADDRESS) { + RLOGE("Debug port: Error calling Dial"); + freeDebugCallbackArgs(number, args); + close(acceptFD); + return; + } dialData.address = args[1]; issueLocalRequest(RIL_REQUEST_DIAL, &dialData, sizeof(dialData)); break; |