可以在工模WIFI测试中添加以下patch
Index: vendor/mediatek/proprietary/factory/src/factory.cpp
===================================================================
--- vendor/mediatek/proprietary/factory/src/factory.cpp (revision 668)
+++ vendor/mediatek/proprietary/factory/src/factory.cpp (revision 669)
@@ -72,6 +72,7 @@
#define MAX_RETRY_COUNT 20
#define MAX_MODEM_INDEX 3
+extern "C" int write_wifi_addr(void);
static item_t ftm_menu_items[] = {
//item(ITEM_MUI_TEST,"Mini-UI Test"),
@@ -375,6 +376,99 @@
}
//tony end
#endif
+
+static void GetRandomValue(unsigned char string[6]);
+static void GetRandomValue(unsigned char string[6])
+{
+ int iRandom = 0;
+ int fd = 0;
+ unsigned long seed;
+
+ LOGD("Enable random generation\n");
+
+ /* initialize random seed */
+ srand (time(NULL));
+ iRandom = rand();
+ LOGD("iRandom = [%d]", iRandom);
+ string[0] = (((iRandom>>24|iRandom>>16) & (0xFE)) | (0x02)); /* must use private bit(1) and no BCMC bit 0 */
+ string[0] =0x80;
+ /* second seed */
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ srand (tv.tv_usec);
+ iRandom = rand();
+ LOGD("iRandom = [%d]", iRandom);
+ string[1] = ((iRandom>>8) & 0xFF);
+ string[1] = 0x0c;
+
+ /* third seed */
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd > 0){
+ if (read(fd, &seed, sizeof(unsigned long)) > 0){
+ srand (seed);
+ iRandom = rand();
+ }
+ close(fd);
+ }
+
+ LOGD("iRandom = [%d]", iRandom);
+ string[5] = (iRandom & 0xFF);
+
+ return;
+}
+
+static int WriteBDAddrToNvram(unsigned char * ucBDAddr)
+{
+ F_ID wifi_nvram_fd = {0};
+ int rec_size = 0;
+ int rec_num = 0;
+ wifi_nvram_fd = NVM_GetFileDesc(AP_CFG_RDEB_FILE_WIFI_LID, &rec_size, &rec_num, ISWRITE);
+ if(wifi_nvram_fd.iFileDesc < 0){
+ LOGE("Open WIFI NVRAM fails errno %d\n", errno);
+ return -1;
+ }
+
+ if(rec_num != 1){
+ LOGE("Unexpected record num %d\n", rec_num);
+ NVM_CloseFileDesc(wifi_nvram_fd);
+ return -1;
+ }
+
+ if(rec_size != sizeof(WIFI_CFG_PARAM_STRUCT)){
+ LOGE("Unexpected record size %d ap_nvram_btradio_mt6610_struct %d\n",
+ rec_size, sizeof(WIFI_CFG_PARAM_STRUCT));
+ NVM_CloseFileDesc(wifi_nvram_fd);
+ return -1;
+ }
+
+ lseek(wifi_nvram_fd.iFileDesc, 4, 0);
+
+ /* Update BD address */
+ if (write(wifi_nvram_fd.iFileDesc, ucBDAddr, 6) < 0){
+ LOGE("Write WIFI NVRAM fails errno %d\n", errno);
+ NVM_CloseFileDesc(wifi_nvram_fd);
+ return -1;
+ }
+
+ NVM_CloseFileDesc(wifi_nvram_fd);
+ return 0;
+}
+
+int write_wifi_addr(void)
+{
+ unsigned char addr[6];
+ GetRandomValue(addr);
+ WriteBDAddrToNvram(addr);
+ /*backup data to nv bin region */
+ if( FileOp_BackupToBinRegion_All())
+ {
+ LOGE("FileOp_BackupToBinRegion_All errno \n");
+ return -1;
+ }
+ return 0;
+}
+
static int item_test_report(item_t *items, char *buf, int bufsz)
{
Index: vendor/mediatek/proprietary/factory/src/test/ftm_wifi.c
===================================================================
--- vendor/mediatek/proprietary/factory/src/test/ftm_wifi.c (revision 668)
+++ vendor/mediatek/proprietary/factory/src/test/ftm_wifi.c (revision 669)
@@ -40,6 +40,8 @@
#include "miniui.h"
#include "ftm.h"
+extern int write_wifi_addr(void);
+
#ifdef FEATURE_FTM_WIFI
#define TAG "[FT_WIFI] "
@@ -277,7 +279,7 @@
int curStatus = -1; //disconnect
LOGD(TAG "%s new\n", __FUNCTION__);
-
+ write_wifi_addr();
memset(&wififm->info[0], 0, sizeof(wififm->info));
memset(&wififm->info[0], '\n', 10);