示例#1
0
int eng_linuxcmd_infactorymode(char *req, char *rsp)
{
    char *ptr;
    int status;
    int length=strlen(req);
    ENG_LOG("%s: req=%s\n",__FUNCTION__, req);
    if((ptr=strchr(req, '?'))!= NULL){
        status = eng_sql_string2int_get(ENG_TESTMODE);
        if(status==ENG_SQLSTR2INT_ERR)
            status = 1;
        sprintf(rsp, "%d%s%s%s", status, ENG_STREND,SPRDENG_OK,ENG_STREND);
    } else if ((ptr=strchr(req, '='))!= NULL) {
        ptr++;
        if(ptr <= (req+length)) {
            status = atoi(ptr);
            ENG_LOG("%s: status=%d\n",__FUNCTION__, status);
            if(status==0||status==1) {
                eng_sql_string2int_set(ENG_TESTMODE, status);
                eng_check_factorymode(0);
                sprintf(rsp, "%s\r\n", SPRDENG_OK);
            } else {
                sprintf(rsp, "%s\r\n", SPRDENG_ERROR);
            }
        } else {
            sprintf(rsp, "%s\r\n", SPRDENG_ERROR);
        }
    } else {
        sprintf(rsp, "%s\r\n", SPRDENG_ERROR);
    }
    ENG_LOG("%s: rsp=%s\n",__FUNCTION__, rsp);

    return 0;
}
示例#2
0
int eng_linuxcmd_mmitest(char *req, char *rsp)
{
    int rc;

    rc = eng_sql_string2int_get("result");

    if(rc == ENG_SQLSTR2INT_ERR)
        sprintf(rsp, "%d%s%s%s", rc, ENG_STREND, SPRDENG_ERROR, ENG_STREND);
    else
        sprintf(rsp, "%d%s%s%s", rc, ENG_STREND, SPRDENG_OK, ENG_STREND);

    return 0;

}
void eng_check_factorymode_fornand(void)
{
	int ret;
	int fd;
	int status = eng_sql_string2int_get(ENG_TESTMODE);
	char status_buf[8];
	char config_property[64];


#ifdef USE_BOOT_AT_DIAG
	ENG_LOG("%s: status=%x\n",__func__, status);
	property_get("persist.sys.usb.config", config_property, "");
	if((status==1)||(status == ENG_SQLSTR2INT_ERR)) {
		fd=open(ENG_FACOTRYMODE_FILE, O_RDWR|O_CREAT|O_TRUNC);
		if(fd > 0)
			close(fd);
		if (strstr(config_property, "adb")) { 
			property_set("sys.usb.config","adb,vser,gser");
			property_set("persist.sys.usb.config","mass_storage,adb,vser,gser");
		} else {
			property_set("sys.usb.config","vser,gser");
			property_set("persist.sys.usb.config","vser,gser");
		}
	} else if (status == 0) {
		if (strstr(config_property, "vser,gser")) {
			if (strstr(config_property, "adb")) {
				property_set("sys.usb.config","adb");
				property_set("persist.sys.usb.config","adb");
			} else {
				property_set("sys.usb.config","");
				property_set("persist.sys.usb.config","");
			}
		} 
		remove(ENG_FACOTRYMODE_FILE);
	} else {
		remove(ENG_FACOTRYMODE_FILE);
	}
#endif

	fd=open(ENG_FACOTRYSYNC_FILE, O_RDWR|O_CREAT|O_TRUNC);
	if(fd > 0)
		close(fd);
}
void eng_check_factorymode_formmc(void)
{
	int ret;
	int fd;
	int status = eng_sql_string2int_get(ENG_TESTMODE);
	char status_buf[8];

	do {
		usleep(100*1000);
		memset(status_buf, 0, sizeof(status_buf));
		property_get(RAWDATA_PROPERTY, status_buf, "");
		ret = atoi(status_buf);
		LOGD("%s: %s is %s, n=%d\n",__FUNCTION__, RAWDATA_PROPERTY, status_buf,ret);
	}while(ret!=1);
	
	fd=open(ENG_FACOTRYMODE_FILE, O_RDWR|O_CREAT|O_TRUNC);

	LOGD("%s: fd=%d, status=%x\n",__FUNCTION__, fd, status);

	if(fd >= 0) {
		if((status==1)||(status == ENG_SQLSTR2INT_ERR)) {
			sprintf(status_buf, "%s", "1");
		} else if (status == 0) {
			sprintf(status_buf, "%s", "0");
		} else {
			sprintf(status_buf, "%s", "0");
		}

		ret = write(fd, status_buf, strlen(status_buf)+1);

		LOGD("%s: write %d bytes to %s",__FUNCTION__, ret, ENG_FACOTRYMODE_FILE);

		close(fd);
	}

	fd=open(ENG_FACOTRYSYNC_FILE, O_RDWR|O_CREAT|O_TRUNC);
	if(fd > 0)
		close(fd);
}
int main(void)
{
	int fd, rc, califlag=0;
	int engtest=0;
	char cmdline[ENG_CMDLINE_LEN];
    eng_thread_t t1,t2, t3,t4, t5;

#if 0
	int index;
	index = eng_sql_string2int_get("index");
	if(index == ENG_SQLSTR2INT_ERR){
		index = 0;
	} else {
		index++;
	}
	eng_sql_string2int_set("index", index);
	memset(cmdline, 0, ENG_CMDLINE_LEN);
	sprintf(cmdline, "logcat > /data/eng_%d.log &", index);
	system(cmdline);

#endif
	eng_sqlite_create();

	memset(cmdline, 0, ENG_CMDLINE_LEN);
	fd = open("/proc/cmdline", O_RDONLY);
	if(fd > 0) {
		rc = read(fd, cmdline, sizeof(cmdline));
		ENG_LOG("ENGTEST_MODE: cmdline=%s\n", cmdline);
		if(rc > 0) {
			if(strstr(cmdline,ENG_CALISTR) != NULL)
				califlag = 1;
			if(strstr(cmdline,"engtest") != NULL)
				engtest = 1;
		}
	}
	ALOGD("eng_pcclient califlag=%d, engtest=%d\n",califlag, engtest);

	if(engtest == 1) {
		eng_ctpcali();
	}

	if(califlag == 1){ //at handler in calibration mode
		eng_atcali_thread();
		return 0;
	}

#ifdef CONFIG_EMMC
	eng_check_factorymode_formmc();
#else
	eng_check_factorymode_fornand();
#endif

	set_vlog_priority();
	
	if (0 != eng_thread_create( &t1, eng_vlog_thread, NULL)){
		ENG_LOG("vlog thread start error");
	}

	if (0 != eng_thread_create( &t2, eng_vdiag_thread, NULL)){
		ENG_LOG("vdiag thread start error");
	}

	if (0 != eng_thread_create( &t3, eng_modemreset_thread, NULL)){
		ENG_LOG("vdiag thread start error");
	}

	if (0 != eng_thread_create( &t4, eng_sd_log, NULL)){
		ENG_LOG("sd log thread start error");
	}


	rc = eng_pcclient_init();

	if(rc == -1) {
		ENG_LOG("%s: init fail, exit\n",__func__);
		return -1;
	}

	if (0 != eng_thread_create( &t5, eng_atauto_thread, NULL)){
		ENG_LOG("atauto thread start error");
	}	

	eng_pcclient_hdlr(NULL);

	return 0;

}