Example #1
0
int lcd_init(void)
{
	int r;
	struct ftm_module *mod;
	lcd_module *lcd;

	write_int(BRIGHTNESS_FILE, 255);

	mod = ftm_alloc(ITEM_LCD, sizeof(lcd_module));
	if (!mod)
		return -ENOMEM;

	lcd = mod_to_lcd(mod);

	lcd->module = mod;
	lcd->itm_view = ui_new_itemview();
	if (!lcd->itm_view)
		return -ENOMEM;

	r = ftm_register(mod, lcd_entry, (void*)lcd);
	if (r) {
		LOGD(TAG "register LCD failed (%d)\n", r);
		return r;
	}

	return 0;
}
Example #2
0
int tvout_init(void)
{
	int r;
	struct ftm_module *mod;
	tvout_module *tvout;

	mod = ftm_alloc(ITEM_TVOUT, sizeof(tvout_module));
	if (!mod)
		return -ENOMEM;

	tvout = mod_to_tvout(mod);

	tvout->module = mod;
	tvout->itm_view = ui_new_itemview();
	if (!tvout->itm_view)
		return -ENOMEM;

	r = ftm_register(mod, tvout_entry, (void*)tvout);
	if (r) {
		LOGD(TAG "register TVOUT failed (%d)\n", r);
		return r;
	}

	return 0;
}
Example #3
0
/*---------------------------------------------------------------------------*/
int barometer_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct baro_data *dat = (struct baro_data *)priv;
    struct textview *tv;
    struct itemview *iv;
    struct statfs stat;
    int err;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&dat->title, param->name, COLOR_YELLOW);
    init_text(&dat->text, &dat->info[0], COLOR_YELLOW);
    init_text(&dat->left_btn, "Fail", COLOR_YELLOW);
    init_text(&dat->center_btn, "Pass", COLOR_YELLOW);
    init_text(&dat->right_btn, "Back", COLOR_YELLOW);
       
    snprintf(dat->info, sizeof(dat->info), "Initializing...\n");
    dat->exit_thd = false;  


    if (!dat->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        dat->iv = iv;
    }
    iv = dat->iv;
    iv->set_title(iv, &dat->title);
    iv->set_items(iv, barometer_items, 0);
    iv->set_text(iv, &dat->text);
    
    pthread_create(&dat->update_thd, NULL, barometer_update_iv_thread, priv);
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                dat->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                dat->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;            
            break;
        }
        
        if (exit) {
            dat->exit_thd = true;
            break;
        }        
    } while (1);
    pthread_join(dat->update_thd, NULL);

    return 0;
}
Example #4
0
int rf_c2k_test_entry(struct ftm_param *param, void *priv)
{
    bool exit = false;
    int  passCount = 0;
    struct rf_c2k_factory *rf = (struct rf_c2k_factory*)priv;
    struct itemview *iv = NULL;

    LOGD(TAG "%s: Start\n", __FUNCTION__);
    strcpy(rf->info,"");
    init_text(&rf->title, param->name, COLOR_YELLOW);
    init_text(&rf->text, &rf->info[0], COLOR_YELLOW);

    if (NULL == rf->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory for item view");
            return -1;
        }
        rf->iv = iv;
    }
    iv = rf->iv;
    iv->set_title(iv, &rf->title);
    iv->set_items(iv, rf_c2k_items, 0);
    iv->set_text(iv, &rf->text);
    iv->start_menu(iv,0);
    iv->redraw(iv);

    rf->exit_thread = false;

    pthread_create(&rf->update_thread, NULL, rf_c2k_update_thread, priv);


    strcpy(rf->info, "");
    rf->test_done = false;
    while (strlen(rf->info) == 0) {
        usleep(200000);
        if (strstr(rf->info, uistr_info_pass)) {
           passCount++;
        }
    }
    LOGD(TAG "passCount = %d\n", passCount);

    //Exit RF Test thread
    rf->exit_thread = true;
    rf->test_done = true;

    pthread_join(rf->update_thread, NULL);

    //Check test result
    if (passCount == 1) {
        rf->mod->test_result = FTM_TEST_PASS;
    } else {
        rf->mod->test_result = FTM_TEST_FAIL;
    }

    LOGD(TAG "%s: End\n", __FUNCTION__);

  return 0;
}
Example #5
0
int otg_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct otg *hds = (struct otg *)priv;
    struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    otg_update_info(hds, hds->info);

    hds->exit_thd = false;

	if (!hds->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    iv->set_items(iv, otg_items, 0);
    iv->set_text(iv, &hds->text);

    pthread_create(&hds->otg_update_thd, NULL, otg_update_iv_thread, priv);
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                hds->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                hds->mod->test_result = FTM_TEST_FAIL;
            }
            exit = true;
            break;
        }

        if (exit) {
            hds->exit_thd = true;
            break;
        }
    } while (1);
    pthread_join(hds->otg_update_thd, NULL);

    return 0;
}
//Auto-scan test
int mMATV_scan_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    int i;
    bool exit = false;
    FILE *pFileList = NULL;
    struct mMATV *mc = (struct mMATV *)priv;
    struct textview *tv;
    struct itemview *iv;
    mc->mod->test_result = FTM_TEST_FAIL;

    LOGD(TAG "--------------mMATV_entry----------------\n");
    LOGD(TAG "%s\n", __FUNCTION__);

    if (!mc->iv)
    {
        iv = ui_new_itemview();

        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }

        mc->iv = iv;
    }

    if (!mc->iv_country)
    {
        iv = ui_new_itemview();

        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }

        mc->iv_country = iv;
    }

    if (!mc->iv_ch_preview)
    {
        iv = ui_new_itemview();

        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }

        mc->iv_ch_preview = iv;
    }

    memset(mc->status, 0, sizeof(mc->status));
    memset(mc->country_name, 0, sizeof(mc->country_name));

    init_text(&mc->title, param->name, COLOR_YELLOW);
    init_text(&mc->text, (const char *)&mc->status, COLOR_YELLOW);

    iv = mc->iv;
    iv->set_title(iv, &mc->title);
    iv->set_items(iv, matv_autoscan_items, 0);
    iv->set_text(iv, &mc->text);
    mc->current_channel = 0;
    mc->ch_count = 0;
    iv->start_menu(iv, 0);
    iv->redraw(iv);

    if (matv_ts_init() != MATV_INIT_OK)
    {
        LOGE("matv_ts_init fail!!!!!");
        return -1;
    }

    matv_preview_init();

    Audio_enable = false;

    pFileList = fopen(CfgFileNamesdcard,"rb");
    if(pFileList != NULL)
    {
        sdcard_insert = true;
        fclose(pFileList);
        
        pFileList = NULL;
    }
    
    LOGD("matv_ts_init sdcard status %d!!!!!", sdcard_insert);

Auto_Check:

    if(matv_auto_check_iv(priv) == true)
        mc->mod->test_result = FTM_TEST_PASS;

EXIT_ATV:

    usleep(100 * 1000);


    matv_ts_shutdown();
    matv_preview_reset_layer_buffer();
    matv_preview_deinit();

    //remove temp file
    ///system("rm /data/matv_pattern.raw");

EXIT:
    return 0;
}
Example #7
0
int bt_entry(struct ftm_param *param, void *priv)
{
    char   *ptr;
    int    chosen;
    bool   exit = false;
    struct bt_factory *bf = (struct bt_factory *)priv;
    struct textview *tv;
    struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    memset(&bf->info[0], 0, sizeof(bf->info));
    memset(&bf->info[0], '\n', 10);

    init_text(&bf->title, param->name, COLOR_YELLOW);
    init_text(&bf->text, &bf->info[0], COLOR_YELLOW);

    /* show text view */
    if (!bf->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory for item view");
            return -1;
        }
        bf->iv = iv;
    }

    iv = bf->iv;
    iv->set_title(iv, &bf->title);
    iv->set_items(iv, bf_items, 0);
    iv->set_text(iv, &bf->text);

    /* initialize thread condition */
    bf->exit_thd = false;
    bf->result = false;
    pthread_create(&bf->update_thd, NULL, bt_update_thread, priv);

    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                bf->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                bf->mod->test_result = FTM_TEST_FAIL;
            }
            exit = true;
            break;
        }

        if (exit) {
            bf->exit_thd = true;
            break;
        }
    } while (1);

    pthread_join(bf->update_thd, NULL);

    FM_BT_deinit();

    return 0;
}
int battery_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct batteryFTM *batt = (struct batteryFTM *)priv;
    struct textview *tv;    
	struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&batt->title, param->name, COLOR_YELLOW);
    init_text(&batt->text, &batt->info[0], COLOR_YELLOW);
    init_text(&batt->left_btn, "Fail", COLOR_YELLOW);
    init_text(&batt->center_btn, "Pass", COLOR_YELLOW);
    init_text(&batt->right_btn, "Back", COLOR_YELLOW);

    battery_update_info(batt, batt->info);

    /* show text view */
    batt->exit_thd = false;     

#if 0
    pthread_create(&batt->batt_update_thd, NULL, battery_update_thread, priv);

    tv = &batt->tv;
    ui_init_textview(tv, battery_key_handler, (void*)batt);
    tv->set_title(tv, &batt->title);
    tv->set_text(tv, &batt->text);
    tv->set_btn(tv, &batt->left_btn, &batt->center_btn, &batt->right_btn);
    tv->run(tv);

    pthread_join(batt->batt_update_thd, NULL);
#else
	if (!batt->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        batt->iv = iv;
    }
    
    iv = batt->iv;
    iv->set_title(iv, &batt->title);
    iv->set_items(iv, battery_items, 0);
    iv->set_text(iv, &batt->text);
    
    pthread_create(&batt->batt_update_thd, NULL, battery_update_iv_thread, priv);
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
#ifndef MTK_NCP1851_SUPPORT
		case ITEM_AC_CHARGER:
			set_Charger_Current(AC_CHARGER_CURRENT);
			break;
		case ITEM_USB_CHARGER:	
			set_Charger_Current(USB_CHARGER_CURRENT);
			break;
#endif
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                batt->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                batt->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit) {
            batt->exit_thd = true;
            break;
        }        
    } while (1);
    pthread_join(batt->batt_update_thd, NULL);
#endif	

    return 0;
}
Example #9
0
int wifi_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct wifi_factory *wififm = (struct wifi_factory *)priv;
    struct textview *tv;
    struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    memset(&wififm->info[0], 0, sizeof(wififm->info));
    memset(&wififm->info[0], '\n', 10);

    init_text(&wififm->title, param->name, COLOR_YELLOW);
    init_text(&wififm->text, &wififm->info[0], COLOR_YELLOW);

    if (!wififm->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory for item view");
            return -1;
        }
        wififm->iv = iv;
    }

    iv = wififm->iv;
    iv->set_title(iv, &wififm->title);
    iv->set_items(iv, wifi_items, 0);
    iv->set_text(iv, &wififm->text);
    /*
        tv = &wififm->tv;
        ui_init_textview(tv, wifi_key_handler, (void*)wififm);
        tv->set(tv, "Wi-Fi", &wififm->info[0]);
        tv->set_btn(tv, "Fail", "Pass", "Back");
        tv->run(tv);
    */
    /* initialize thread condition */
    wififm->exit_thd = false;
    wififm->result = false;
    wififm->renew = true;
    pthread_create(&wififm->update_thd, NULL, wifi_update_thread, priv);

    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_RENEW:
            wififm->renew = true;
            break;

        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                wififm->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                wififm->mod->test_result = FTM_TEST_FAIL;
            }

            exit = true;
            break;
        }

        if (exit) {
            wififm->exit_thd = true;
            break;
        }
    } while (1);
    pthread_join(wififm->update_thd, NULL);

    FM_WIFI_deinit();

    return 0;
}
Example #10
0
int fmtx_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct fmtx_factory *fmtx = (struct fmtx_factory *)priv;
    struct textview *tv;
    struct itemview *iv;

    LOGD("%s\n", __FUNCTION__);

    memset(&fmtx->info[0], 0, sizeof(fmtx->info));
    memset(&fmtx->info[0], '\n', 10);

    init_text(&fmtx->title, param->name, COLOR_YELLOW);
    init_text(&fmtx->text, &fmtx->info[0], COLOR_YELLOW);

    /* show text view */
    if (!fmtx->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD("No memory for item view");
            return -1;
        }
        fmtx->iv = iv;
    }

    iv = fmtx->iv;
    iv->set_title(iv, &fmtx->title);
    iv->set_items(iv, fmtx_items, 0);
    iv->set_text(iv, &fmtx->text);
	 #ifdef MTK_AUDIO
    Common_Audio_init();
	 #endif

    /* initialize thread condition */
    read_preferred_freq();
    fmtx->exit_thd = false;
    fmtx->result = false;
    pthread_create(&fmtx->update_thd, NULL, fmtx_update_thread, priv);

    /* process procedure */
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_FREQ0:
            g_txsetfreq = 1;
            g_txfreq_item = 0;
            break;
        case ITEM_FREQ1:
            g_txsetfreq = 1;
            g_txfreq_item = 1;
            break;
        case ITEM_FREQ2:
            g_txsetfreq = 1;
            g_txfreq_item = 2;
            break;
        case ITEM_FREQ3:
            g_txsetfreq = 1;
            g_txfreq_item = 3;
            break;
        case ITEM_FREQ4:
            g_txsetfreq = 1;
            g_txfreq_item = 4;
            break;
        case ITEM_FREQ5:
            g_txsetfreq = 1;
            g_txfreq_item = 5;
            break;
        case ITEM_FREQ6:
            g_txsetfreq = 1;
            g_txfreq_item = 6;
            break;
        case ITEM_FREQ7:
            g_txsetfreq = 1;
            g_txfreq_item = 7;
            break;
        case ITEM_FREQ8:
            g_txsetfreq = 1;
            g_txfreq_item = 8;
            break;
        case ITEM_FREQ9:
            g_txsetfreq = 1;
            g_txfreq_item = 9;
            break;
        case ITEM_PASS:
        case ITEM_FAIL:
//      case ITEM_RETURN:
            if (chosen == ITEM_PASS) {
                fmtx->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                fmtx->mod->test_result = FTM_TEST_FAIL;
            }
            g_txsetfreq = 0;        
            exit = true;
            break;
        }

        if (exit) {
            fmtx->exit_thd = true;
            break;
        }
    } while (1);
    pthread_join(fmtx->update_thd, NULL);
	 #ifdef MTK_AUDIO
    Common_Audio_deinit();
	 #endif

    return 0;
}
Example #11
0
int nfc_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct nfc_desc *nfc = (struct nfc_desc *)priv;
    struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&nfc->title, param->name, COLOR_YELLOW);
    init_text(&nfc->text, &nfc->info[0], COLOR_YELLOW);
    
    nfc->exit_thd = false;
    
      if (!nfc->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        nfc->iv = iv;
    }  
 
 
     iv = nfc->iv;
    iv->set_title(iv, &nfc->title);
    iv->set_items(iv, nfc_items, 0);
    iv->set_text(iv, &nfc->text);
    
    pthread_create(&nfc->update_thd, NULL, nfc_update_iv_thread, priv);
    
    i4TestItem = -1;
    do {
        chosen = iv->run(iv, &exit);
        LOGD(TAG "%s, chosen = %d\n", __FUNCTION__, chosen);
        switch (chosen) {
        case ITEM_1:
        	   i4TestItem = ITEM_1;
             ;
            break;
        #if 0
        case ITEM_2:
        	   i4TestItem = ITEM_2;
             ;
            break;
        #endif
        case ITEM_3:
        	   i4TestItem = ITEM_3;
             ;
            break;
        case ITEM_4:
        	   i4TestItem = ITEM_4;
             ;
            break;
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                nfc->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                nfc->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit) {
            nfc->exit_thd = true;
            LOGD(TAG "%s, nfc->exit_thd = true\n", __FUNCTION__);
            break;
        }        
    } while (1);
    pthread_join(nfc->update_thd, NULL);
       
    
    return 0;
}
Example #12
0
int hdmi_entry(struct ftm_param *param, void *priv)
{
    bool exit = false;
    hdmi_module *hdmi = (hdmi_module *)priv;
    struct itemview *iv;

    LOGD(TAG "hdmi_entry\n");

     /* show text view */
    if (!hdmi->itm_view) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory for item view");
            return -1;
        }
        hdmi->itm_view = iv;
    }

    iv = hdmi->itm_view;

    //init item view
    memset(&hdmi->info[0], 0, sizeof(hdmi->info));
    memset(&hdmi->info[0], '\n', 10);
    init_text(&hdmi->title, param->name, COLOR_YELLOW);
    init_text(&hdmi->text, &hdmi->info[0], COLOR_YELLOW);

    iv->set_title(iv, &hdmi->title);
    iv->set_items(iv, hdmi_item, 0);
    iv->set_text(iv, &hdmi->text);

    //iv->redraw(iv);

    if(hdmi_enable())
    {
        LOGD(TAG "hdmi test fail\n");
        //hdmi->text.color = COLOR_RED;
        sprintf(hdmi->info, "HDMI "uistr_fail"\n");
    }
    else
    {
        LOGD(TAG "hdmi test pass\n");
        //hdmi->text.color = COLOR_GREEN;
        sprintf(hdmi->info, "HDMI "uistr_pass"\n");
    }

    while(!exit)
    {
        switch(iv->run(iv, NULL))
        {
        case ITEM_PASS:
            hdmi->module->test_result = FTM_TEST_PASS;
            exit = true;
            break;
        case ITEM_FAIL:
            hdmi->module->test_result = FTM_TEST_FAIL;
            exit = true;
            break;
        case -1:
            exit = true;
            break;
        default:
            break;
        }
    }

    //hdmi_disable();

    return 0;
}
Example #13
0
int headset_PhoneTest_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct headset *hds = (struct headset *)priv;
    struct textview *tv;
    struct itemview *iv;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    headset_phonetest_state = 0;

    if (!hds->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    iv->set_items(iv, headset_items_auto, 0);
    iv->set_text(iv, &hds->text);
    iv->start_menu(iv, 0);
    iv->redraw(iv);

    Common_Audio_init();

    memset(hds->info, 0, sizeof(hds->info) / sizeof(*(hds->info)));
    hds->recordDevice = BUILTIN_MIC;

    pthread_create(&hds->hRecordThread, NULL, Audio_Record_thread, priv);

    int    play_time = 3000;// 3s
    hds->mod->test_result = FTM_TEST_FAIL;
    ALOGD("start play and freq check");
    //----- Test CH1
    EarphoneTest(1);
    EarphoneTestLR(1);
    for (int i = 0; i < 100 ; i ++)
    {
        usleep(play_time * 10);
    }
    //----- Delay 0.5s
    headset_phonetest_state = 1;
    EarphoneTest(0);
    for (int i = 0; i < 100 ; i ++)
    {
        usleep(500 * 10);
    }
    //----- Test CH2
    EarphoneTest(1);
    EarphoneTestLR(0);
    for (int i = 0; i < 100 ; i ++)
    {
        if (strstr(hds->info, "Check freq pass"))
        {
            hds->mod->test_result = FTM_TEST_PASS;
            ALOGD("Check freq pass");
            //break;
        }
        usleep(play_time * 10);
    }
    EarphoneTest(0);
    ALOGD("stop play and freq check");
    if (hds->mod->test_result == FTM_TEST_FAIL)
    {
        ALOGD("Check freq fail");
    }

    headset_phonetest_state = 2;

    pthread_join(hds->hRecordThread, NULL);
    Common_Audio_deinit();

    LOGD(TAG "%s: End\n", __FUNCTION__);

    return 0;
}
Example #14
0
//#else
int mAudio_headset_manual_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    char *inputType = NULL;
    struct headset *hds = (struct headset *)priv;
    struct textview *tv;
    struct itemview *iv;
    int privChosen = -1;
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    headset_update_info(hds, hds->info);

    hds->exit_thd = false;

    if (!hds->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    if (get_is_ata() == 0)
    {
        iv->set_items(iv, headset_items, 0);
    }
    else
    {
        iv->set_items(iv, headset_items_ex, 0);
    }
    iv->set_text(iv, &hds->text);

    Common_Audio_init();

    pthread_create(&hds->headset_update_thd, NULL, headset_update_iv_thread, priv);

    inputType = ftm_get_prop("Audio.Manual.InputType");
    if (inputType != NULL && (atoi(inputType) == 0 || atoi(inputType) == 1 || atoi(inputType) == 2 || atoi(inputType) == 3))
    {
        // @ input != NULL, PC command control mode
        ALOGD("Audio.Manual.InputType = %s", inputType);

        iv->redraw(iv);

        PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
        usleep(20000);
        if (atoi(inputType) == 1)
        {
            ALOGD("Set Mic1 on");
            PhoneMic_EarphoneLR_Loopback(MIC1_ON);
        }
        else if (atoi(inputType) == 2)
        {
            ALOGD("Set Mic2 on");
            PhoneMic_EarphoneLR_Loopback(MIC2_ON);
        }
        else if (atoi(inputType) == 3)
        {
            ALOGD("Set headset Mic on");
            HeadsetMic_EarphoneLR_Loopback(1, 1);
        }

        hds->exit_thd = true;
        pthread_join(hds->headset_update_thd, NULL);
        hds->mod->test_result = FTM_TEST_PASS;

        if (atoi(inputType) == 0)
        {
            ALOGD("Audio Deinit");
            Common_Audio_deinit();
        }

    }
    else
    {
        // Original manual operating mode
        do
        {
            chosen = iv->run(iv, &exit);
            switch (chosen)
            {
                case ITEM_RINGTONE:
                    if (!hds->avail || privChosen == ITEM_RINGTONE)
                    {
                        break;
                    }
                    if (privChosen == ITEM_HEADSET_MIC && hds->Headset_mic)
                    {
                        HeadsetMic_EarphoneLR_Loopback(0, 1);
                    }
                    usleep(20000);
                    EarphoneTest(1);
                    privChosen = ITEM_RINGTONE;
                    break;
                case ITEM_MIC1:
                    if (!hds->avail || privChosen == ITEM_MIC1)
                    {
                        break;
                    }
                    if (privChosen == ITEM_RINGTONE)
                    {
                        EarphoneTest(0);
                    }
                    else if (privChosen == ITEM_MIC2)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC2_OFF);
                    }
                    else if (privChosen == ITEM_HEADSET_MIC)
                    {
                        HeadsetMic_EarphoneLR_Loopback(0, 1);
                    }

                    usleep(20000);
                    PhoneMic_EarphoneLR_Loopback(MIC1_ON);
                    privChosen = ITEM_MIC1;
                    break;
                case ITEM_MIC2:
                    if (!hds->avail || privChosen == ITEM_MIC2)
                    {
                        break;
                    }
                    if (privChosen == ITEM_RINGTONE)
                    {
                        EarphoneTest(0);
                    }
                    else if (privChosen == ITEM_MIC1)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
                    }
                    else if (privChosen == ITEM_HEADSET_MIC)
                    {
                        HeadsetMic_EarphoneLR_Loopback(0, 1);
                    }

                    usleep(20000);
                    PhoneMic_EarphoneLR_Loopback(MIC2_ON);
                    privChosen = ITEM_MIC2;
                    break;
                case ITEM_HEADSET_MIC:
                    if (!hds->avail || privChosen == ITEM_HEADSET_MIC || !hds->Headset_mic)
                    {
                        break;
                    }
                    if (privChosen == ITEM_RINGTONE)
                    {
                        EarphoneTest(0);
                    }
                    else if (privChosen == ITEM_MIC1)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
                    }
                    else if (privChosen == ITEM_MIC2)
                    {
                        PhoneMic_EarphoneLR_Loopback(MIC2_OFF);
                    }
                    usleep(20000);
                    HeadsetMic_EarphoneLR_Loopback(1, 1);
                    privChosen = ITEM_HEADSET_MIC;
                    break;
                case ITEM_PASS:
                case ITEM_FAIL:
                    if (chosen == ITEM_PASS)
                    {
                        hds->mod->test_result = FTM_TEST_PASS;
                    }
                    else if (chosen == ITEM_FAIL)
                    {
                        hds->mod->test_result = FTM_TEST_FAIL;
                    }
                    exit = true;
                    break;
            }

            if (exit)
            {
                hds->exit_thd = true;
                break;
            }
        }
        while (1);

        if (privChosen == ITEM_RINGTONE)
        {
            EarphoneTest(0);
        }
        if (privChosen == ITEM_MIC1)
        {
            PhoneMic_EarphoneLR_Loopback(MIC1_OFF);
        }
        if (privChosen == ITEM_MIC2)
        {
            PhoneMic_EarphoneLR_Loopback(MIC2_OFF);
        }
        if (privChosen == ITEM_HEADSET_MIC)
        {
            HeadsetMic_EarphoneLR_Loopback(0, 1);
        }

        pthread_join(hds->headset_update_thd, NULL);

        Common_Audio_deinit();
    }

    return 0;
}
Example #15
0
int emmc_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
	int index = 0;
    bool exit = false;
    struct emmc *mc = (struct emmc *)priv;
    struct itemview *iv;
    struct statfs stat;
	
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&mc->title, param->name, COLOR_YELLOW);
    init_text(&mc->text, &mc->info[0], COLOR_YELLOW);   

    emmc_update_info(mc, mc->info);

    mc->exit_thd = false;

    if (!mc->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        mc->iv = iv;
    }
    
    iv = mc->iv;
    iv->set_title(iv, &mc->title);
    iv->set_items(iv, emmc_items, 0);
    iv->set_text(iv, &mc->text);
    iv->redraw(iv);
    
	emmc_update_iv_thread(priv);
    //pthread_create(&mc->update_thd, NULL, emmc_update_iv_thread, priv);
    /*do {
      chosen = iv->run(iv, &exit);
      switch (chosen) {
      case ITEM_PASS:
      case ITEM_FAIL:
      if (chosen == ITEM_PASS) {
      mc->mod->test_result = FTM_TEST_PASS;
      } else if (chosen == ITEM_FAIL) {
      mc->mod->test_result = FTM_TEST_FAIL;
      }           
      exit = true;
      break;
      }

      if (exit) {
      mc->exit_thd = true;
      break;
      }        
      } while (1);*/
    //pthread_join(mc->update_thd, NULL);

    if (g_test_result_emmc > 0) {
        mc->mod->test_result = FTM_TEST_PASS;
    }
    else {
        mc->mod->test_result = FTM_TEST_FAIL;
    }


    return 0;
}
Example #16
0
int gps_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    char *pTimeout=NULL;
    int chosen;
    bool exit = false;
    struct gps_desc *gps = (struct gps_desc *)priv;
    struct itemview *iv;
	pTimeout = ftm_get_prop("GPS.TIMEOUT");
	if(pTimeout != NULL )
	{
		timeout=atoi(pTimeout);
		LOGD(TAG "timeout value is %d\n", timeout);	
	}
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&gps->title, param->name, COLOR_YELLOW);
    init_text(&gps->text, &gps->info[0], COLOR_YELLOW);
    
    gps_update_info(gps, gps->info);
   
    gps->exit_thd = false;

    if (!gps->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        gps->iv = iv;
    }
    
    iv = gps->iv;
    iv->set_title(iv, &gps->title);
    iv->set_items(iv, gps_items, 0);
    iv->set_text(iv, &gps->text);
    
	iv->start_menu(iv,0);
    pthread_create(&gps->update_thd, NULL, gps_update_iv_thread, priv);
    int wait_time = 10;
    int init_try_time = 0;
    while(!init_flag && wait_time)
    {
    	LOGD(TAG" init_flag = %d, try time = %d\n", init_flag, ++init_try_time);
    	sleep(1);
    	--wait_time;	
    }
    init_flag = 0;
    wait_time = 10;
    init_try_time = 0;
    LOGD(TAG" init_flag = %d\n", init_flag);
	iv->redraw(iv);
    do{
        //Auto test: only CTTFF
        cttff = 1;
        do{
            usleep(1000000); //check status per sec
            LOGD(TAG"after %d sec from test starting, we still can not see any SV\n", ttff);
        }while(ttff <= timeout && !ttff_check_res);

        if(ttff_check_res == 1){
            LOGD(TAG"Test pass"); 
            gps->mod->test_result = FTM_TEST_PASS;
	      }else{
            LOGD(TAG"Test fail");
            gps->mod->test_result = FTM_TEST_FAIL;		
        }
		if(unlink("/data/misc/mtkgps.dat")!=0 )
			LOGD(TAG "unlink mtkgps.dat error, error is %s\n", strerror(errno));
		    ttff_check_res = 0;

     }while(0);
     
    gps->exit_thd = true;
    LOGD(TAG "%s, gps->exit_thd = true\n", __FUNCTION__);    
#if 0
    do {
        chosen = iv->run(iv, &exit);
        LOGD(TAG "%s, chosen = %d\n", __FUNCTION__, chosen);
        switch (chosen) {
        case ITEM_HTTFF:
            httff = 1;
            break;
        case ITEM_CTTFF:
            cttff = 1;
            break;
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                gps->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                gps->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit) {
            gps->exit_thd = true;
            LOGD(TAG "%s, gps->exit_thd = true\n", __FUNCTION__);
            break;
        }        
    } while (1);
#endif
    pthread_join(gps->update_thd, NULL);

    return 0;
}
Example #17
0
int vibrator_manual_entry(struct ftm_param *param, void *priv)
{
	int chosen;
	bool exit = false;
	struct itemview *iv;
	text_t    title;
	char* vibr_time = NULL;
	struct ftm_module *mod = (struct ftm_module *)priv;

	LOGD("%s\n", __FUNCTION__);

	vibrator_test_exit = false;

	iv = ui_new_itemview();
	if (!iv) {
		LOGD("No memory");
		return -1;
	}
        init_text(&title, param->name, COLOR_YELLOW);

	iv->set_title(iv, &title);
	iv->set_items(iv, items, 0);

	vibr_time = ftm_get_prop("Vibrator_Last_Time");
	LOGD("%s: get vibrator last time=%s!\n", __FUNCTION__, vibr_time);
	if(vibr_time != NULL)
	{
		vibrator_time = (uint32_t)atoi(vibr_time);
		LOGD("%s: get vibrator last time=%d!\n", __FUNCTION__, vibrator_time);
	}
	else
	{
		LOGD("%s: get vibrator last time fail!\n", __FUNCTION__);
	}
//#if defined(MTK_VIBSPK_SUPPORT)
    if (IsFTMSupportVibSpk())
     Common_Audio_init();
//#endif
	pthread_create(&vibrator_thread, NULL, update_vibrator_thread, priv);
	
	iv->start_menu(iv, 0);
	iv->redraw(iv);
	do {
		if(param->test_type == FTM_MANUAL_ITEM){
		chosen = iv->run(iv, &exit);
		switch (chosen) {
		case ITEM_PASS:
		case ITEM_FAIL:
			if (chosen == ITEM_PASS) {
				mod->test_result = FTM_TEST_PASS;
			} else if (chosen == ITEM_FAIL) {
				mod->test_result = FTM_TEST_FAIL;
			}
			exit = true;
			break;
		}

		if (exit) {
			vibrator_test_exit = true;
			break;
		}
		}
		else{
			if(vibrator_test_exit)
				break;
		}
	} while (1);
	//pthread_join(vibrator_thread, NULL);

//    #if defined(MTK_VIBSPK_SUPPORT)
    if (IsFTMSupportVibSpk())
    Common_Audio_deinit();
//    #endif

	return 0;
}
Example #18
0
int vibrator_autotest_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct mVibrator *mc = (struct mVibrator *)priv;
    struct textview *tv;
    struct itemview *iv;

    ALOGD(TAG "%s\n", __FUNCTION__);
    init_text(&mc->title, param->name, COLOR_YELLOW);
    init_text(&mc->text, "", COLOR_YELLOW);
    init_text(&mc->left_btn, uistr_key_fail, COLOR_YELLOW);
    init_text(&mc->center_btn, uistr_key_pass, COLOR_YELLOW);
    init_text(&mc->right_btn, uistr_key_back, COLOR_YELLOW);
    
    // init Audio
    Common_Audio_init();
    mc->exit_thd = false;
    vibrator_test_exit = false;

    // ui start
    if (!mc->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            ALOGD(TAG "No memory");
            return -1;
        }
        mc->iv = iv;
    }
    
    iv = mc->iv;
    iv->set_title(iv, &mc->title);
    iv->set_items(iv, items_auto, 0);
    iv->set_text(iv, &mc->text);
	iv->start_menu(iv,0);
    iv->redraw(iv);

    memset(mc->info, 0, sizeof(mc->info) / sizeof(*(mc->info)));
    mc->i4Playtime = 5*1000;//ms         //read_preferred_ringtone_time() = 5
    mc->recordDevice = WIRED_HEADSET;
    pthread_create(&mc->hHeadsetThread, NULL, update_vibrator_thread, priv);
    pthread_create(&mc->hRecordThread, NULL, Audio_Record_thread, priv);
    
    int    play_time = mc->i4Playtime;
    mc->mod->test_result = FTM_TEST_FAIL;

    int i;
    for(i = 0; i < 100 ; i ++)
    {
      //ALOGD("check mc info:%d",i);
      if (strstr(mc->info, "Check freq pass")) 
      {      
          mc->mod->test_result = FTM_TEST_PASS;
          ALOGD("Check freq pass");
          break;
      }
      usleep(play_time * 10);
    }

    if(mc->mod->test_result == FTM_TEST_FAIL)
       ALOGD("Check freq fail");

    if(mc->mod->test_result == FTM_TEST_PASS)
        usleep(2000000);

    mc->exit_thd = true;
    vibrator_test_exit = true;
	
    pthread_join(mc->hRecordThread, NULL);
    pthread_join(mc->hHeadsetThread, NULL);
    Common_Audio_deinit();
    
    LOGD(TAG "%s: End\n", __FUNCTION__);
    return 0;
}
Example #19
0
int battery_entry(struct ftm_param *param, void *priv)
{
	char *ptr;
	int chosen;
	bool exit = false;
	struct batteryFTM *batt = (struct batteryFTM *)priv;
	struct textview *tv;    
	struct itemview *iv;
	//auto test
	int temp_v_bat=0;
	int temp_v_chr=0;

	LOGD(TAG "%s\n", __FUNCTION__);
	if(FTM_AUTO_ITEM  == param->test_type)
	{
		gBatteryAutoTest = 1;
	}
	else
	{
		gBatteryAutoTest = 0;
	}
	LOGD(TAG "AutoMode=%d, %s\n", gBatteryAutoTest, __FUNCTION__);
	init_text(&batt->title, param->name, COLOR_YELLOW);
	init_text(&batt->text, &batt->info[0], COLOR_YELLOW);
	init_text(&batt->left_btn, "Fail", COLOR_YELLOW);
	init_text(&batt->center_btn, "Pass", COLOR_YELLOW);
	init_text(&batt->right_btn, "Back", COLOR_YELLOW);
	
	battery_update_info(batt, batt->info);
	
	/* show text view */
	batt->exit_thd = false;

	if (!batt->iv) {
		iv = ui_new_itemview();
		if (!iv) {
			LOGD(TAG "No memory");
			return -1;
		}
		batt->iv = iv;
	}
  
	iv = batt->iv;
	iv->set_title(iv, &batt->title);
	if (gBatteryAutoTest) {
		iv->set_items(iv, battery_items_auto, 0);
	} else {
		iv->set_items(iv, battery_items_manual, 0);
	}
	iv->set_text(iv, &batt->text);
	iv->start_menu(iv,0);

	if (gBatteryAutoTest) {
	iv->redraw(iv);

	return_data.battery.current = 0;
	return_data.battery.voltage = 0;

    //check charger voltage, if no charger, return fail
    temp_v_chr = get_v_charger();
  if(temp_v_chr < AUTO_TEST_VCHR_VALUE)
  {
    LOGD(TAG "[FTM_BAT 0] %d < %d => no charger, return fail\n", temp_v_chr, AUTO_TEST_VCHR_VALUE);		
    batt->mod->test_result = FTM_TEST_FAIL;
    return 0;
  }

	//auto test - V_bat
	temp_v_bat = get_v_bat_sen();
        return_data.battery.voltage = temp_v_bat;
	if(temp_v_bat < AUTO_TEST_VBAT_VALUE)
	{
		LOGD(TAG "[FTM_BAT 1] %d,%d,%d\n", 
			temp_v_bat, 
			AUTO_TEST_VBAT_VALUE, AUTO_TEST_THD_VALUE);
		
		batt->mod->test_result = FTM_TEST_FAIL;
		return 0;
	}
	if(temp_v_bat > AUTO_TEST_THD_VALUE)
	{
		LOGD(TAG "[FTM_BAT 2] %d,%d,%d\n", 
			temp_v_bat, 
			AUTO_TEST_VBAT_VALUE, AUTO_TEST_THD_VALUE);
    
	    batt->mod->test_result = FTM_TEST_FAIL;		
		return 0;
	}
  
#ifdef FEATURE_FTM_VBAT_TEMP_CHECK
    //auto test - V bat temp	
    temp_v_bat_temp = get_v_bat_temp();
    if(temp_v_bat_temp < AUTO_TEST_VBAT_TEMP_MIN || temp_v_bat_temp > AUTO_TEST_VBAT_TEMP_MAX)
    {
       LOGD(TAG "[FTM_BAT 5] VBatTemp = %d , return fail\n", temp_v_chr);		
        batt->mod->test_result = FTM_TEST_FAIL;
    return 0;
}
#endif
  
    batt->mod->test_result = FTM_TEST_PASS;		
    return 0;

	} else {
    pthread_create(&batt->batt_update_thd, NULL, battery_update_iv_thread, priv);
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                batt->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                batt->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit) {
            batt->exit_thd = true;
            break;
        }        
    } while (1);
    pthread_join(batt->batt_update_thd, NULL);
	}	

    return 0;
}
Example #20
0
int flash_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct nand_info *flash = (struct nand_info *)priv;
    //struct textview *tv;
    struct itemview *iv;
    /* for time evaluations */
    struct timeval tv1, tv2;

    /* reset the read/write test result */
    flash->base_rw_test_result = false;
    
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&flash->title, param->name, COLOR_YELLOW);
    init_text(&flash->text, &flash->info[0], COLOR_YELLOW);

    /* Check if the data partition is mounted or not */
    if(!check_root_path_mounted(DATA_PARTITION))
    {
        /* Get the manf id and dev id */
        read_device_info(flash, CMD_LINE_PATH);
    
        gettimeofday(&tv1, NULL);
        flash->teststart = tv1.tv_sec * 1000000 + tv1.tv_usec;

        /* Start the basic read/write tests */
        flash->base_rw_test_result = flash_basic_rw(flash, DATA_PARTITION);
        
        gettimeofday(&tv2, NULL);
        flash->testend = tv2.tv_sec * 1000000 + tv2.tv_usec;

        /* Delete the test temp file */
        remove(flash->test_file_path);
    } else
    {
        LOGD(TAG "%s partition is not mounted !", DATA_PARTITION);
    }
    
    flash_update_info(flash, flash->info);
   
    flash->exit_thd = false;  

    /* Create a itemview */
    if (!flash->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        flash->iv = iv;
    }
    
    iv = flash->iv;
    iv->set_title(iv, &flash->title);
    iv->set_items(iv, flash_items, 0);
    iv->set_text(iv, &flash->text);
    iv->redraw(iv);
    usleep(1000000);      
    /* Create a thread to update screen */
    //pthread_create(&flash->update_thd, NULL, flash_update_thread, priv);
    //do
    //{
    //    chosen = iv->run(iv, &exit);
    //    switch (chosen)
    //    {
    //    case ITEM_PASS:
    //    case ITEM_FAIL:
    //    default:
    //        /* report test results */
    //        if (flash->base_rw_test_result == true)
    //        {
    //          flash->mod->test_result = FTM_TEST_PASS;
    //        }
    //        else
    //        {
    //          flash->mod->test_result = FTM_TEST_FAIL;
    //        }                       
    //        exit = true;
    //        break;
    //    }
    //    
    //    if (exit)
    //    {
    //        /* mark for exit update thread */
    //        flash->exit_thd = true;
    //        break;
    //    }        
    //}
    //while (1);
    //pthread_join(flash->update_thd, NULL); 
    if (flash->base_rw_test_result == true)            
    {                                                  
      flash->mod->test_result = FTM_TEST_PASS;         
    }                                                  
    else                                               
    {                                                  
      flash->mod->test_result = FTM_TEST_FAIL;         
    }                                                  
        
    return 0;
}
Example #21
0
int mcard_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    int index = 0;
    bool exit_val = false;
    struct mcard_array *ma = (struct mcard_array *)priv;
    struct itemview *iv;
    struct statfs stat;
#ifdef MTK_EMMC_SUPPORT
        pid_t pid;
#endif

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&ma->title, param->name, COLOR_YELLOW);
    init_text(&ma->text, &ma->info[0], COLOR_YELLOW);

#if defined(MTK_MULTI_STORAGE_SUPPORT) && !defined(MTK_FAT_ON_NAND)
        mcard_update_info_multi_storage(ma, ma->info,0);
#else
        mcard_update_info(ma->mcard[0],ma->info);
#endif

    ma->isFormatting = false;
    ma->exit_thd = false;

    if (!ma->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        ma->iv = iv;
    }

    iv = ma->iv;
    iv->set_title(iv, &ma->title);
    iv->set_items(iv, mcard_items, 0);
    iv->set_text(iv, &ma->text);
    iv->redraw(iv);

    pthread_create(&ma->update_thd, NULL, mcard_update_iv_thread, priv);
#if 0
    do {
        chosen = iv->run(iv, &exit_val);
        switch (chosen) {
#if defined(MTK_EMMC_SUPPORT) && !defined(MTK_SHARED_SDCARD)
            case ITEM_FORMAT_EMMC_FAT:
                #if defined(MTK_MULTI_STORAGE_SUPPORT) && !defined(MTK_FAT_ON_NAND)
                    mcard_update_info_multi_storage(ma,ma->info,0);
                #else
                    mcard_update_info(ma->mcard[0], ma->info);
                #endif

                ma->isFormatting = true;
                if (ma->mcard[0]->mounted) {
                    if (mcard_umount(ma->mcard[0]->mntpnt)) {
                        LOGE(TAG"eMMC: umount %s fails: %d (%s)\n", ma->mcard[0]->mntpnt, errno, strerror(errno));
                        ma->mcard[0]->format_stat = uistr_info_emmc_format_stat_fail;
                        ma->isFormatting = false;
                        break;
                    }
                    else {
                       LOGD(TAG"eMMC: umount %s sucessfully \n", ma->mcard[0]->mntpnt);
                       ma->mcard[0]->mounted  = false;
                       ma->mcard[0]->checksum = -1;
                    }
                }

                if ((pid = fork()) < 0)
                {
                    LOGE(TAG"eMMC: fork fails: %d (%s)\n", errno, strerror(errno));
                    ma->mcard[0]->format_stat = uistr_info_emmc_format_stat_fail;
                    ma->isFormatting = false;
                    break;
                }
                else if (pid == 0)  /*child process*/
                {
                    int err;
                    char fat_partition_path[64];
                    int partition_idx;

                    ma->mcard[0]->format_stat = uistr_info_emmc_format_stat_start;


                    sprintf(fat_partition_path, "/emmc@fat");
                    err = execl("/system/bin/newfs_msdos", "newfs_msdos", fat_partition_path, NULL);
                    exit(-3) ;
                }
                else  /*parent process*/
                {
                    int child_stat ;
                    waitpid(pid, &child_stat, 0) ;
                    sync() ;
                    if (WIFEXITED(child_stat) && (WEXITSTATUS(child_stat) == 0)) {
                        LOGD(TAG"eMMC: pid = %d\n", pid);
                        ma->mcard[0]->format_stat = uistr_info_emmc_format_stat_success;
                    }
                    else {
                        LOGD(TAG"eMMC: execl error: %s\n", strerror(errno));
                        ma->mcard[0]->format_stat = uistr_info_emmc_format_stat_fail;
                    }

#if defined(MTK_MULTI_STORAGE_SUPPORT) && !defined(MTK_FAT_ON_NAND)
                    mcard_update_info_multi_storage(ma,ma->info,0);
#else
                    mcard_update_info(ma->mcard[0], ma->info);
#endif
                }
                ma->isFormatting = false;
                break;
#endif
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                ma->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                ma->mod->test_result = FTM_TEST_FAIL;
            }

#if defined(MTK_EMMC_SUPPORT)
            ma->mcard[0]->format_stat = NULL;
#endif
            exit_val = true;
            break;
        }

        if (exit_val) {
            ma->exit_thd = true;
            break;
        }
    } while (1);
#endif
    pthread_join(ma->update_thd, NULL);
    if (g_test_result > 0) {
        ma->mod->test_result = FTM_TEST_PASS;
    } else {
        ma->mod->test_result = FTM_TEST_FAIL;
    }

    return 0;
}
Example #22
0
int battery_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct batteryFTM *batt = (struct batteryFTM *)priv;
    struct textview *tv;    
	struct itemview *iv;
	//auto test
	int temp=0;
	int temp_v_bat=0;
	int temp_chr_cuttent=0;
	int temp_v_chr=0;
	int temp_v_bat_temp=0;
	unsigned long i=0;
	unsigned long i_loop_time=100;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&batt->title, param->name, COLOR_YELLOW);
    init_text(&batt->text, &batt->info[0], COLOR_YELLOW);
    init_text(&batt->left_btn, "Fail", COLOR_YELLOW);
    init_text(&batt->center_btn, "Pass", COLOR_YELLOW);
    init_text(&batt->right_btn, "Back", COLOR_YELLOW);

    battery_update_info(batt, batt->info);

    /* show text view */
    batt->exit_thd = false;     

#if 0
    pthread_create(&batt->batt_update_thd, NULL, battery_update_thread, priv);

    tv = &batt->tv;
    ui_init_textview(tv, battery_key_handler, (void*)batt);
    tv->set_title(tv, &batt->title);
    tv->set_text(tv, &batt->text);
    tv->set_btn(tv, &batt->left_btn, &batt->center_btn, &batt->right_btn);
    tv->run(tv);

    pthread_join(batt->batt_update_thd, NULL);
#else
	if (!batt->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        batt->iv = iv;
    }
    
    iv = batt->iv;
    iv->set_title(iv, &batt->title);
    iv->set_items(iv, battery_items, 0);
    iv->set_text(iv, &batt->text);
	iv->start_menu(iv,0);

    #if 1
	iv->redraw(iv);


	return_data.battery.current = 0;
	return_data.battery.voltage = 0;

  //auto test - if no charger, return fail

   #ifdef FEATURE_FTM_VBAT_TEMP_CHECK
   //auto test - V bat temp	
   temp_v_bat_temp = get_v_bat_temp();
   if(temp_v_bat_temp < AUTO_TEST_VBAT_TEMP_MIN || temp_v_bat_temp > AUTO_TEST_VBAT_TEMP_MAX)
   {
     LOGD(TAG "[FTM_BAT 5] VBatTemp = %d , return fail\n", temp_v_chr);		
     batt->mod->test_result = FTM_TEST_FAIL;
     return 0;
   }
   #endif
  
  temp_v_chr = get_v_charger();  
  if(temp_v_chr < AUTO_TEST_VCHR_VALUE)
  {
    LOGD(TAG "[FTM_BAT 0] %d < %d => no charger, return fail\n", temp_v_chr, AUTO_TEST_VCHR_VALUE);		
    batt->mod->test_result = FTM_TEST_FAIL;
    return 0;
  }

	//auto test - V_bat
	temp_v_bat = get_v_bat_sen();
	return_data.battery.voltage = temp_v_bat;
	if(temp_v_bat < AUTO_TEST_VBAT_VALUE)
	{
		LOGD(TAG "[FTM_BAT 1] %d,%d,%d,%d,%d,%d,%d\n", 
			temp_v_bat, temp_chr_cuttent, i, i_loop_time, 
			AUTO_TEST_VBAT_VALUE, AUTO_TEST_THD_VALUE, AUTO_TEST_CHR_CURRENT_VALUE);
		
	    batt->mod->test_result = FTM_TEST_FAIL;
		return 0;
	}
	if(temp_v_bat > AUTO_TEST_THD_VALUE)
	{
		LOGD(TAG "[FTM_BAT 2] %d,%d,%d,%d,%d,%d,%d\n", 
			temp_v_bat, temp_chr_cuttent, i, i_loop_time, 
			AUTO_TEST_VBAT_VALUE, AUTO_TEST_THD_VALUE, AUTO_TEST_CHR_CURRENT_VALUE);
    
		//ignore I_charging test because the battery is full, no charging current
	    batt->mod->test_result = FTM_TEST_PASS;		
		return 0;
	}

	//auto test - I_charging
	for(i=0 ; i<i_loop_time ; i++)
	{
		temp_chr_cuttent = get_charging_current();
		return_data.battery.current = temp_chr_cuttent;
		
		if(temp_chr_cuttent > AUTO_TEST_CHR_CURRENT_VALUE)
			break;
	}	
	
	
	if(i >= i_loop_time)
	{
		LOGD(TAG "[FTM_BAT 3] %d,%d,%d,%d,%d,%d,%d\n", 
			temp_v_bat, temp_chr_cuttent, i, i_loop_time, 
			AUTO_TEST_VBAT_VALUE, AUTO_TEST_THD_VALUE, AUTO_TEST_CHR_CURRENT_VALUE);
		
	    batt->mod->test_result = FTM_TEST_FAIL;
		return 0;
	}
	else
	{
		LOGD(TAG "[FTM_BAT 4] %d,%d,%d,%d,%d,%d,%d\n", 
			temp_v_bat, temp_chr_cuttent, i, i_loop_time, 
			AUTO_TEST_VBAT_VALUE, AUTO_TEST_THD_VALUE, AUTO_TEST_CHR_CURRENT_VALUE);
		
		batt->mod->test_result = FTM_TEST_PASS;
		return 0;
	}	


	#else
    pthread_create(&batt->batt_update_thd, NULL, battery_update_iv_thread, priv);
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
		case ITEM_AC_CHARGER:
			set_Charger_Current(AC_CHARGER_CURRENT);
			break;
		case ITEM_USB_CHARGER:	
			set_Charger_Current(USB_CHARGER_CURRENT);
			break;
			
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                batt->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                batt->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit) {
            batt->exit_thd = true;
            break;
        }        
    } while (1);
    pthread_join(batt->batt_update_thd, NULL);
#endif	
	//do nothing
#endif	

    return 0;
}
Example #23
0
int headset_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct headset *hds = (struct headset *)priv;
    struct textview *tv;
    struct itemview *iv;
    int privChosen = -1;
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&hds->title, param->name, COLOR_YELLOW);
    init_text(&hds->text, &hds->info[0], COLOR_YELLOW);
    init_text(&hds->left_btn, "Fail", COLOR_YELLOW);
    init_text(&hds->center_btn, "Pass", COLOR_YELLOW);
    init_text(&hds->right_btn, "Back", COLOR_YELLOW);

    headset_update_info(hds, hds->info);

    hds->exit_thd = false;

    if (!hds->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            LOGD(TAG "No memory");
            return -1;
        }
        hds->iv = iv;
    }

    iv = hds->iv;
    iv->set_title(iv, &hds->title);
    iv->set_items(iv, headset_items, 0);
    iv->set_text(iv, &hds->text);

    Common_Audio_init();

    pthread_create(&hds->headset_update_thd, NULL, headset_update_iv_thread, priv);
    do
    {
        chosen = iv->run(iv, &exit);
        switch (chosen)
        {
            case ITEM_RINGTONE:
                if (!hds->avail || privChosen == ITEM_RINGTONE)
                {
                    break;
                }
                if (privChosen == ITEM_HEADSET_MIC && hds->Headset_mic)
                {
                    HeadsetMic_EarphoneLR_Loopback(0, 1);
                }
                usleep(20000);
                EarphoneTest(1);
                privChosen = ITEM_RINGTONE;
                break;
            case ITEM_HEADSET_MIC:
                if (!hds->avail || privChosen == ITEM_HEADSET_MIC || !hds->Headset_mic)
                {
                    break;
                }
                if (privChosen == ITEM_RINGTONE)
                {
                    EarphoneTest(0);
                }
                usleep(20000);
                HeadsetMic_EarphoneLR_Loopback(1, 1);
                privChosen = ITEM_HEADSET_MIC;
                break;
            case ITEM_PASS:
            case ITEM_FAIL:
                if (chosen == ITEM_PASS)
                {
                    hds->mod->test_result = FTM_TEST_PASS;
                }
                else if (chosen == ITEM_FAIL)
                {
                    hds->mod->test_result = FTM_TEST_FAIL;
                }
                exit = true;
                break;
        }

        if (exit)
        {
            hds->exit_thd = true;
            break;
        }
    }
    while (1);

    if (privChosen == ITEM_RINGTONE)
    {
        EarphoneTest(0);
    }
    if (privChosen == ITEM_HEADSET_MIC)
    {
        HeadsetMic_EarphoneLR_Loopback(0, 1);
    }

    pthread_join(hds->headset_update_thd, NULL);

    Common_Audio_deinit();

    return 0;
}
Example #24
0
/*---------------------------------------------------------------------------*/
int alsps_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    struct lps_data *dat = (struct lps_data *)priv;
    struct textview *tv;
    struct itemview *iv;
    struct statfs stat;
    int err;

    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&dat->title, param->name, COLOR_YELLOW);
    init_text(&dat->text, &dat->info[0], COLOR_YELLOW);
    init_text(&dat->left_btn, uistr_info_sensor_fail, COLOR_YELLOW);
    init_text(&dat->center_btn, uistr_info_sensor_pass, COLOR_YELLOW);
    init_text(&dat->right_btn, uistr_info_sensor_back, COLOR_YELLOW);
       
    snprintf(dat->info, sizeof(dat->info), uistr_info_sensor_initializing);
    dat->exit_thd = false;  


    if (!dat->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        dat->iv = iv;
    }
    iv = dat->iv;
    iv->set_title(iv, &dat->title);
    iv->set_items(iv, alsps_items, 0);
    iv->set_text(iv, &dat->text);
    if(get_is_ata() == 1){
        support_ata = true;
    }
    
    pthread_create(&dat->update_thd, NULL, alsps_update_iv_thread, priv);
    do {
        if(!support_ata){
        chosen = iv->run(iv, &thread_exit);
        switch (chosen) {
        case ITEM_PASS:
        case ITEM_FAIL:
            if (chosen == ITEM_PASS) {
                dat->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_FAIL) {
                dat->mod->test_result = FTM_TEST_FAIL;
            }           
            thread_exit = true;          
            break;
        }
        }
        iv->redraw(iv);
        
        pthread_mutex_lock (&alsps_mutex);
        if (thread_exit) {
            dat->exit_thd = true;
        pthread_mutex_unlock (&alsps_mutex);
            break;
        }else{
        
            pthread_mutex_unlock (&alsps_mutex);
            usleep(50000);
        }
    } while (1);
    pthread_join(dat->update_thd, NULL);

    return 0;
}
Example #25
0
static int hotknot_entry(struct ftm_param *param, void *priv)
{
	int i, err, num = 0;
	int x = 0, y = CHAR_HEIGHT;
	bool exit=false;
	static char buf[128];
	struct hotknot *keys = (struct hotknot *)priv;
	struct itemview *iv = NULL;
	int chosen = -1;


	err = 0;
	
    DEBUG("%s, %d\n", __FUNCTION__, __LINE__);


	init_text(&keys->title, param->name, COLOR_YELLOW);
    init_text(&keys->text, &keys->info[0], COLOR_YELLOW);	

	if (!keys->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        keys->iv = iv;
    }else{
		iv = keys->iv;
    }  

    
	//ui_init_textview(tv, hotknot_handler, (void*)keys);
	DEBUG("%s, %d, iv:0x%x, iv->set_title:0x%x, title:0x%x\n", __FUNCTION__, __LINE__, iv,iv->set_title, &keys->title);
    iv->set_title(iv, &keys->title);
	DEBUG("%s, %d\n", __FUNCTION__, __LINE__);

	iv->set_items(iv, hotknot_items, 0);
	DEBUG("%s, %d\n", __FUNCTION__, __LINE__);
	iv->set_text(iv, &keys->text);
	DEBUG("%s, %d\n", __FUNCTION__, __LINE__);

    err = pthread_create(&keys->update_thd, NULL, hotknot_handler, priv);
    DEBUG("%s, %d\n", __FUNCTION__, __LINE__);
    TestItem_hotknot = -1;
	keys->exit_thd = false;
    do {
        chosen = iv->run(iv, &exit);
        DEBUG("%s, exit = %d\n", __FUNCTION__, exit);
        DEBUG("%s, chosen = %d\n", __FUNCTION__, chosen);
        switch (chosen) {
        case ITEM_HOTKNOT_MASTER:
        	   TestItem_hotknot = ITEM_HOTKNOT_MASTER;
			   DEBUG("[%s]TestItem_hotknot = %d\n", __FUNCTION__, TestItem_hotknot);
            break;

        case ITEM_HOTKNOT_SLAVE:
        	   TestItem_hotknot = ITEM_HOTKNOT_SLAVE;
			   DEBUG("[%s]TestItem_hotknot = %d\n", __FUNCTION__, TestItem_hotknot);
            break;
        case ITEM_HOTKNOT_PASS:
        case ITEM_HOTKNOT_FAIL:
            if (chosen == ITEM_HOTKNOT_PASS) {
				TestItem_hotknot = ITEM_HOTKNOT_PASS;
                keys->mod->test_result = FTM_TEST_PASS;
            } else if (chosen == ITEM_HOTKNOT_FAIL) {
            	TestItem_hotknot = ITEM_HOTKNOT_FAIL;
                keys->mod->test_result = FTM_TEST_FAIL;
            }

			usleep(1000*1000);
			memset(keys->info, '\n', INFO_SIZE);
			sprintf(keys->info, "%s\n",uistr_info_hotknot_info);
			iv->redraw(iv);  
			usleep(1000*1000);
				
            exit = true;
            break;
        }
        
        if (exit) {
            keys->exit_thd = true;
            LOGD(TAG "%s, nfc->exit_thd = true\n", __FUNCTION__);
            break;
        }        
        
        usleep(100000); // wake up every 0.1sec		
    } while (1);
    pthread_join(keys->update_thd, NULL);


	return 0;
}
Example #26
0
int sigtest_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen, i;
    bool exit = false;
    struct sigtest *st = (struct sigtest *)priv;
    struct itemview *iv;
    int ret;
    const char *pret;
	int test_result_temp = FTM_TEST_PASS;
    char dev_node1[32];
    char dev_node2[32];
    char dev_node5[32];
    LOGD(TAG "%s\n", __FUNCTION__);

if(is_support_modem(1)){

    snprintf(dev_node1, 32, "%s", ccci_get_node_name(USR_FACTORY_DATA, MD_SYS1));
    st->fd_atmd = openDeviceWithDeviceName(dev_node1);
    
    if (-1 == st->fd_atmd) {
				LOGD(TAG "Fail to open CCCI interface\n");
				return 0;
    }
	for (i = 0; i<30; i++) usleep(50000); //sleep 1s wait for modem bootup

}

if(is_support_modem(2)){

    snprintf(dev_node2, 32, "%s", ccci_get_node_name(USR_FACTORY_DATA, MD_SYS2));
    st->fd_atmd2 = openDeviceWithDeviceName(dev_node2);
    
    if (-1 == st->fd_atmd2) {
				LOGD(TAG "Fail to open CCCI interface\n");
				return 0;
    }
	for (i = 0; i<30; i++) usleep(50000); //sleep 1s wait for modem bootup

}

#if defined(MTK_EXTERNAL_MODEM_SLOT) && !defined(EVDO_DT_SUPPORT)
        #if defined(PURE_AP_USE_EXTERNAL_MODEM)
            st->fd_atmd_dt = openDeviceWithDeviceName("/dev/ttyUSB1");
        #else
	        st->fd_atmd_dt = openDeviceWithDeviceName("/dev/ttyMT0");
        #endif
		//st->fd_atmd_dt= openDeviceWithDeviceName(CCCI_MODEM_MT6252);
		if (-1 == st->fd_atmd_dt) {
					LOGD(TAG "Fail to open CCCI interface\n");
					return 0;
		}
	for (i = 0; i<30; i++) usleep(50000); //sleep 1s wait for modem bootup
#endif

    if(is_support_modem(5)){

        snprintf(dev_node5, 32, "%s", ccci_get_node_name(USR_FACTORY_DATA, MD_SYS5));
        st->fd_atmd5 = openDeviceWithDeviceName(dev_node5);
        
        if (-1 == st->fd_atmd5) {
				LOGD(TAG "Fail to open /dev/eemcs_mux interface\n");
				return 0;
        }
	    for (i = 0; i<30; i++) usleep(50000); //sleep 1s wait for modem bootup

    }

	for (i = 0; i<50; i++) usleep(50000); //sleep 1s wait for modem bootup

if(is_support_modem(1)){
	ExitFlightMode (st->fd_atmd, TRUE);
}


if(is_support_modem(2)){
	ExitFlightMode_DualTalk (st->fd_atmd2, TRUE);
}

#if defined(MTK_EXTERNAL_MODEM_SLOT) && !defined(EVDO_DT_SUPPORT)
	ExitFlightMode_DualTalk(st->fd_atmd_dt, TRUE);
#endif

    for (i = 0; i<30; i++) usleep(50000); //sleep 1s wait for modem bootup

    if(is_support_modem(5)){
    	ExitFlightMode (st->fd_atmd5, TRUE);
    }

    init_text(&st->title, param->name, COLOR_YELLOW);
    init_text(&st->text, &st->info[0], COLOR_YELLOW);   

 
    memset(&st->info[0], 0, sizeof(st->info));
    sprintf(st->info, "%s\n", uistr_info_emergency_call_testing);
    st->exit_thd = false;

    if (!st->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGD(TAG "No memory");
            return -1;
        }
        st->iv = iv;
    }
    
    iv = st->iv;
    iv->set_title(iv, &st->title);
    iv->set_items(iv, sigtest_items, 0);
    iv->set_text(iv, &st->text); 
	iv->start_menu(iv,0);

	iv->redraw(iv);

#if 0
    do {
        chosen = iv->run(iv, &exit);
        switch (chosen) {
#ifdef MTK_DT_SUPPORT
			  case ITEM_CALL_FOR_MODEM_75:
					pret = dial112(st->fd_atmd);
					if(!strcmp(pret, "OK")) {
		                 LOGD(TAG "Dial 112 Success\n");
		                 sprintf(st->info, "%s\n", "Dial 112 Success!\n");
		           }
					else {
						LOGD(TAG "Dial 112 Fail\n");
						sprintf(st->info, "%s\n", "Dial 112 Fail!\n");
					}
					iv->redraw(iv);
					break;

			  case ITEM_CALL_FOR_MODEM_52:
					pret = dial112(st->fd_atmd2);
					if(!strcmp(pret, "OK")) {
		                 LOGD(TAG "Dial 112 Success\n");
		                 sprintf(st->info, "%s\n", "Dial 112 Success!\n");
		           }
					else {
						LOGD(TAG "Dial 112 Fail\n");
						sprintf(st->info, "%s\n", "Dial 112 Fail!\n");
					}
					iv->redraw(iv);
					break;
#else
            case ITEM_EMG_CALL:
               	   LOGD(TAG "Come to EMG Call...\n");

//mtk70828
				   sprintf(st->info, "%s\n", "Dial 112 on going ...!\n");
				   iv->redraw(iv);
//mtk70828
		           pret = dial112(st->fd_atmd);
		           if(!strcmp(pret, "OK")) {
		                 LOGD(TAG "Dial 112 Success\n");
		                 sprintf(st->info, "%s\n", "Dial 112 Success!\n");
		           }
					else {
						LOGD(TAG "Dial 112 Fail\n");
						sprintf(st->info, "%s\n", "Dial 112 Fail!\n");
					}
					iv->redraw(iv);
                             
                break;
#endif
            case ITEM_PASS:
            case ITEM_FAIL:
                if (chosen == ITEM_PASS) {
                    st->mod->test_result = FTM_TEST_PASS;
                } else if (chosen == ITEM_FAIL) {
                    st->mod->test_result = FTM_TEST_FAIL;
                }          
                exit = true;
                break;
        }
        
        if (exit) {
            st->exit_thd = true;
            // Need to add ATH command else the loop back test will have noise.
			ExitFlightMode (st->fd_atmd, FALSE);
				
#ifdef MTK_DT_SUPPORT
	ExitFlightMode_DualTalk (st->fd_atmd2, FALSE);
#endif
            break;
        }        
    } while (1);
#endif

if(is_support_modem(1)){
	LOGD(TAG "Come to EMG Call IN MTK_ENABLE_MD1\n");
	pret = dial112(st->fd_atmd);
	if(!strcmp(pret, "OK"))
	{
		LOGD(TAG "Dial 112 Success\n");
		sprintf(st->info, "%s\n", uistr_info_emergency_call_success_in_modem1);
		st->mod->test_result = FTM_TEST_PASS;
		test_result_temp = FTM_TEST_PASS;
	}
	else 
	{
		LOGD(TAG "Dial 112 Fail IN MTK_ENABLE_MD1\n");
		sprintf(st->info, "%s\n", uistr_info_emergency_call_fail_in_modem1);
		st->mod->test_result = FTM_TEST_FAIL;
		test_result_temp = FTM_TEST_FAIL;
	}
	ExitFlightMode (st->fd_atmd, FALSE);
    closeDevice(st->fd_atmd);
    iv->redraw(iv);
}


if(is_support_modem(2)){
	LOGD(TAG "Come to EMG Call\n");
		pret = dial112(st->fd_atmd2);
		if(!strcmp(pret, "OK"))
		{
			LOGD(TAG "Dial 112 Success\n");
			sprintf(st->info, "%s\n", uistr_info_emergency_call_success_in_modem2);
			if(test_result_temp == FTM_TEST_PASS)
			{
				st->mod->test_result = FTM_TEST_PASS;
			}
			else
			{
				st->mod->test_result = FTM_TEST_FAIL;
			}
		}
		else 
		{
			LOGD(TAG "Dial 112 Fail in MTK_ENABLE_MD2\n");
			sprintf(st->info, "%s\n", uistr_info_emergency_call_fail_in_modem2);
			st->mod->test_result = FTM_TEST_FAIL;
		}
		ExitFlightMode (st->fd_atmd2, FALSE);
		
	closeDevice (st->fd_atmd2);
    iv->redraw(iv);
}


#if defined(MTK_EXTERNAL_MODEM_SLOT) && !defined(EVDO_DT_SUPPORT)
		LOGD(TAG "Come to EMG Call\n");
			pret = dial112(st->fd_atmd_dt);
			if(!strcmp(pret, "OK"))
			{
				LOGD(TAG "Dial 112 Success\n");
				sprintf(st->info, "%s\n", uistr_info_emergency_call_success_in_modem2);
				if(test_result_temp == FTM_TEST_PASS)
			    {
	    			st->mod->test_result = FTM_TEST_PASS;
		    	}
		    	else
		    	{
				    st->mod->test_result = FTM_TEST_FAIL;
		    	}
			}
			else 
			{
				LOGD(TAG "Dial 112 Fail in MTK_ENABLE_MD2\n");
				sprintf(st->info, "%s\n", uistr_info_emergency_call_fail_in_modem2);
				st->mod->test_result = FTM_TEST_FAIL;
			}
			ExitFlightMode (st->fd_atmd_dt, FALSE);
			
		closeDevice (st->fd_atmd_dt);
        iv->redraw(iv);
#endif

	

   if(is_support_modem(5)){
	 LOGD(TAG "Come to EMG Call IN MTK_ENABLE_MD5\n");
	 pret = dial112(st->fd_atmd5);
	 if(!strcmp(pret, "OK"))
	 {
		LOGD(TAG "Dial 112 Success\n");
		sprintf(st->info, "%s\n", uistr_info_emergency_call_success_in_modem5);
		st->mod->test_result = FTM_TEST_PASS;
		test_result_temp = FTM_TEST_PASS;
	 }
	 else 
	 {
		LOGD(TAG "Dial 112 Fail IN MTK_ENABLE_MD5\n");
		sprintf(st->info, "%s\n", uistr_info_emergency_call_fail_in_modem5);
		st->mod->test_result = FTM_TEST_FAIL;
		test_result_temp = FTM_TEST_FAIL;
	 }
	 ExitFlightMode (st->fd_atmd5, FALSE);
     closeDevice(st->fd_atmd5);
     iv->redraw(iv);
   }	

    return 0;
}
Example #27
0
int clear_flash_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct nand_info *flash = (struct nand_info *)priv;
    struct textview *tv = &flash->tv;
    struct itemview *iv;
    struct timeval tv1, tv2;

    flash->erase_result = false;
    
    LOGD(TAG "%s\n", __FUNCTION__);

    init_text(&flash->title, param->name, COLOR_YELLOW);
    init_text(&flash->text, &flash->info[0], COLOR_YELLOW);

    clear_flash_update_info(flash, flash->info);

    flash->exit_clr_thd = false;  

#if 0
    if (!flash->iv) 
    {
        iv = ui_new_itemview();
        if (!iv) 
        {
            LOGD(TAG "No memory");
            return -1;
        }
        flash->iv = iv;
    }
#endif
    ui_init_textview(tv, flash_key_handler, (void*)flash);
#if 0    
    iv = flash->iv;
    iv->set_title(iv, &flash->title);
    iv->set_items(iv, clear_flash_items, 0);
    iv->set_text(iv, &flash->text);
#endif
    tv->set_title(tv, &flash->title);
    tv->set_text(tv, &flash->text);
    
    pthread_create(&flash->update_thd, NULL, clear_flash_update_thread, priv);
#if 0    
    do
    {
        chosen = iv->run(iv, &exit);
        switch (chosen)
        {
        case ITEM_PASS:
        case ITEM_FAIL:
              if (chosen == ITEM_PASS)
              {
                flash->mod->test_result = FTM_TEST_PASS;
              } else if (chosen == ITEM_FAIL)
              {
                flash->mod->test_result = FTM_TEST_FAIL;
            }           
            exit = true;
            break;
        }
        
        if (exit)
        {
            flash->exit_clr_thd = true;
            break;
        }        
    }
    while (1);
#endif
    LOGD(TAG "Start the NAND flash erase operations !\n");

    gettimeofday(&tv1, NULL);
    flash->teststart = tv1.tv_sec * 1000000 + tv1.tv_usec;
    
    flash->erase_result = format_root_device(DATA_PARTITION);
    
    gettimeofday(&tv2, NULL);
    flash->testend = tv2.tv_sec * 1000000 + tv2.tv_usec;
    
    LOGD(TAG "Finish the NAND flash erase operations !\n");
    
    flash->exit_clr_thd = true;
    
    pthread_join(flash->update_thd, NULL); 

    sync();
    reboot(RB_AUTOBOOT); 

    return 0;
}
Example #28
0
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
int strobe_entry(struct ftm_param *param, void *priv)
{
	FTM_CAMERA_DBG("strobe_entry %d\n",__LINE__);
    int chosen;
    bool exit = false;
    struct camera *cam = (struct camera *)priv;
    struct textview *tv = NULL ;
    struct itemview *iv = NULL ;
    static int isTestDone = 0;

    init_text(&cam ->title, param->name, COLOR_YELLOW);
    init_text(&cam ->text, &cam->info[0], COLOR_YELLOW);
    if (!cam->iv)
    {
        iv = ui_new_itemview();
        if (!iv)
        {
            FTM_CAMERA_DBG("No memory");
            return -1;
        }
        cam->iv = iv;
    }
    iv = cam->iv;
    iv->set_title(iv, &cam->title);

    //menu_items[0].id = ITEM_STROBE_TEST;
    //menu_items[0].name = uistr_strobe_test;
    //menu_items[1].id = -1;
    //menu_items[1].name = NULL;



    menu_items[0].id = ITEM_PASS;
    menu_items[0].name = uistr_pass;
    menu_items[1].id = ITEM_FAIL;
    menu_items[1].name = uistr_fail;
    menu_items[2].id = -1;
    menu_items[2].name = NULL;

    iv->set_items(iv, menu_items, 0);
    iv->set_text(iv, &cam->text);

    pthread_t strobeTestTh;
    pthread_create(&strobeTestTh, NULL, strobe_test_thread, cam);
	cam->cmd = ITEM_NULL;
	cam->isExit = 0;
	cam->isTestDone = isTestDone;

    if(isTestDone == 0)
    {
        cam->cmd = ITEM_STROBE_TEST;
        acdkIFInit();
        isTestDone=1;
    }

	while(1)
	{
		/*if(cam->isTestDone==1)
		{
			menu_items[1].id = ITEM_PASS;
	    	menu_items[1].name = uistr_pass;
	    	menu_items[2].id = ITEM_FAIL;
	    	menu_items[2].name = uistr_fail;
	    	menu_items[3].id = -1;
	    	menu_items[3].name = NULL;
	    	iv->set_items(iv, menu_items, 0);
  		}*/
		chosen = iv->run(iv, &exit);
		switch (chosen)
		{
			//case ITEM_STROBE_TEST:
			//	cam->cmd = ITEM_STROBE_TEST;
			//	acdkIFInit();
			//	isTestDone=1;
			//break;
			case ITEM_PASS:
				cam->cmd = ITEM_NULL;
				if(cam->isTestDone)
				{
				    cam->mod->test_result = FTM_TEST_PASS;
				    exit = true;
				}
				else
				{
				    memset(cam->info, 0, 1024);
				    sprintf(cam->info, "Not test done !! \n");
				    iv->set_text(iv, &cam->text);
				    iv->redraw(iv);
				}
				break;
			case ITEM_FAIL:
				cam->cmd = ITEM_NULL;
				if(cam->isTestDone)
				{
				    cam->mod->test_result = FTM_TEST_FAIL;
				    exit = true;
				}
				else
				{
				    memset(cam->info, 0, 1024);
				    sprintf(cam->info, "Not test done !! \n");
				    iv->set_text(iv, &cam->text);
				    iv->redraw(iv);
				}
			break;
		}
		if(exit)
		{
			isTestDone = cam->isTestDone;
			cam->cmd = ITEM_NULL;
			cam->isExit = true;
            isTestDone = 0;
            MDK_DeInit();
            MDK_Close();
			break;
		}
		usleep(30000);
	}
FTM_CAMERA_DBG("strobe_entry %d\n",__LINE__);
    pthread_join(strobeTestTh, NULL);
FTM_CAMERA_DBG("strobe_entry %d\n",__LINE__);
    return 0;
}
Example #29
0
int irtx_led_entry(struct ftm_param *param, void *priv)
{
    int chosen = -1;
    bool exit = false;
    struct irtx_led_stu *irtxledstu = (struct irtx_led_stu *)priv;
    struct itemview *iv;
    bool auto_pass = false;

    LOGD(TAG "%s: Start\n", __FUNCTION__);

    strcpy(irtxledstu->info, "");
    init_text(&irtxledstu->title, param->name, COLOR_YELLOW);
    init_text(&irtxledstu->text, &irtxledstu->info[0], COLOR_YELLOW);

    if (!irtxledstu->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            LOGE(TAG "%s - ui_new_itemview fail! err:%d\n", __FUNCTION__, errno);
            return -1;
        }
        irtxledstu->iv = iv;
    }
    
    iv = irtxledstu->iv;
    iv->set_title(iv, &irtxledstu->title);
    iv->set_text(iv, &irtxledstu->text);

    LOGE(TAG "param->test_type:%d\n", param->test_type);
    if (FTM_MANUAL_ITEM == param->test_type) {
        iv->set_items(iv, irtx_led_test_items, 0);
    } else {
        iv->set_items(iv, irtx_led_auto_test_items, 0);
        iv->start_menu(iv,0);
        iv->redraw(iv);
    }

    LOGE(TAG "%s - do\n", __FUNCTION__);

    irtxledstu->exit_thread = false;
    irtxledstu->test_done = true;
    pthread_create(&irtxledstu->update_thread, NULL, irtx_led_test_update_thread, priv);

    LOGE(TAG "%s - do1\n", __FUNCTION__);
    if (FTM_MANUAL_ITEM == param->test_type) {
        do {
            LOGE(TAG "%s - do3\n", __FUNCTION__);

            chosen = iv->run(iv, &exit);
            LOGD(TAG "%s -chosen = %d\n", __FUNCTION__, chosen);

            irtxledstu->mod->test_result = FTM_TEST_FAIL;
            
            switch (chosen) {
                case ITEM_ENABLE_IRTX_LED:
                    // irtx_led_test_pre_set(true);
                    LOGD(TAG "%s: ITEM_ENABLE_IRTX_LED\n", __FUNCTION__);
                    // irtx_led_test_update_info(irtxledstu, irtxledstu->info);
                    // iv->redraw(iv);
                    irtxledstu->test_case = ITEM_ENABLE_IRTX_LED;
                    irtxledstu->test_done = false;
                    break;

                case ITEM_DISABLE_IRTX_LED:
                    // irtx_led_test_pre_set(false);
                    LOGD(TAG "%s: ITEM_DISABLE_IRTX_LED\n", __FUNCTION__);
                    // irtx_led_test_update_info(irtxledstu, irtxledstu->info);
                    // iv->redraw(iv);
                    irtxledstu->test_case = ITEM_DISABLE_IRTX_LED;
                    irtxledstu->test_done = false;
                    break;

                case ITEM_PASS:
                    irtxledstu->mod->test_result = FTM_TEST_PASS;

                case ITEM_FAIL:
                default:
                    irtxledstu->exit_thread = true;
                    irtxledstu->test_done = true;
                    exit = true;
                    break;
            }

            if (exit) {
                irtxledstu->exit_thread = true;
                LOGD(TAG "%s -irtxledstu->exit_thread is true.\n", __FUNCTION__);
                break;
            }
            usleep(1000000);
        }while (1);
    }else if (FTM_AUTO_ITEM == param->test_type) {
        // Auto test
        char *ptmp = NULL;
        memset(irtxledstu->info, 0, sizeof(irtxledstu->info) / sizeof(*(irtxledstu->info)));
        irtxledstu->test_case = ITEM_ENABLE_IRTX_LED;
        irtxledstu->test_done = false;
        while ((strlen(irtxledstu->info) == 0) || (!strstr(irtxledstu->info, "ioctl"))) {
            LOGD(TAG "%s -Auto test ITEM_ENABLE_IRTX_LED test_steps:%d\n", __FUNCTION__, test_steps);
            usleep(200000);
        }

        LOGD(TAG "%s -Auto test ITEM_ENABLE_IRTX_LED test result:%d\n", __FUNCTION__, test_steps);
        LOGD(TAG "%s -begin redraw\n", __FUNCTION__);
        iv->redraw(iv);
        LOGD(TAG "%s -end redraw\n", __FUNCTION__);

        if (test_steps == 2) {
            irtxledstu->test_case = ITEM_DISABLE_IRTX_LED;
            irtxledstu->test_done = false;
            ptmp = strstr(irtxledstu->info, "ioctl"); // first ioctl
            ptmp += strlen("ioctl");

            while ((!strstr(ptmp, "ioctl"))) {
                LOGD(TAG "%s -Auto test ITEM_DISABLE_IRTX_LED test_steps:%d\n", __FUNCTION__, test_steps);
                usleep(200000);
                ptmp = strstr(irtxledstu->info, "ioctl"); // first ioctl
                ptmp += strlen("ioctl");
            }
            
            LOGD(TAG "%s -Auto test ITEM_DISABLE_IRTX_LED test result:%d\n", __FUNCTION__, test_steps);
            LOGD(TAG "%s -begin redraw\n", __FUNCTION__);
            iv->redraw(iv);
            usleep(1000000);
            LOGD(TAG "%s -end redraw\n", __FUNCTION__);

            if (test_steps == 2) {
                auto_pass == true;
            }
        }

        irtxledstu->exit_thread = true;
        irtxledstu->test_done = true;
    }

    pthread_join(irtxledstu->update_thread, NULL);

    if (FTM_AUTO_ITEM == param->test_type) {
        if (auto_pass) {
            irtxledstu->mod->test_result = FTM_TEST_PASS;
        } else {
            irtxledstu->mod->test_result = FTM_TEST_FAIL;
        }
    }

    LOGD(TAG "%s Exist.\n", __FUNCTION__);
     return 0;
}
Example #30
0
/*---------------------------------------------------------------------------*/
int ps_cali_entry(struct ftm_param *param, void *priv)
{
    char *ptr;
    int chosen;
    bool exit = false;
    struct lps_data *dat = (struct lps_data *)priv;
    struct textview *tv;
    struct itemview *iv;
    struct statfs stat;
    int err,op;

    FLPLOGD(TAG "%s\n", __FUNCTION__);

    init_text(&dat->title, param->name, COLOR_YELLOW);
    init_text(&dat->text, &dat->info[0], COLOR_YELLOW);
    init_text(&dat->left_btn, "Fail", COLOR_YELLOW);
    init_text(&dat->center_btn, "Pass", COLOR_YELLOW);
    init_text(&dat->right_btn, "Back", COLOR_YELLOW);

    snprintf(dat->info, sizeof(dat->info), "初始化...\n");
    dat->exit_thd = false;
    bUpToDate = false; 

    if (!dat->iv) {
        iv = ui_new_itemview();
        if (!iv) {
            FLPLOGD(TAG "No memory");
            return -1;
        }
        dat->iv = iv;
    }
    iv = dat->iv;
    iv->set_title(iv, &dat->title);
    iv->set_items(iv, ps_cali_items, 0);
    iv->set_text(iv, &dat->text);

    pthread_create(&dat->update_thd, NULL, ps_update_iv_thread, priv);
    do {
        chosen = iv->run(iv, &exit);

        pthread_mutex_lock(&dat->lps.evtmutex);
        op = dat->lps.pending_op;
        pthread_mutex_unlock(&dat->lps.evtmutex);
        if ((chosen != ITEM_EXIT) && (op != PS_OP_NONE))   /*some OP is pending*/
            continue;

        switch (chosen) {
        case ITEM_CLEAR:
            pthread_mutex_lock(&dat->lps.evtmutex);
            dat->lps.pending_op = PS_OP_CLEAR;
            FLPLOGD("chosen clear: %d\n", dat->lps.pending_op);
            pthread_mutex_unlock(&dat->lps.evtmutex);
	    break;
        case ITEM_DOCALI:
            pthread_mutex_lock(&dat->lps.evtmutex);
            dat->lps.pending_op = PS_OP_CALI_PRE;
            dat->lps.cali_delay = 50;  //50ms
            dat->lps.cali_num   = 20;  //Use 20 samples
            FLPLOGD("chosen DOCALI\n");
            pthread_mutex_unlock(&dat->lps.evtmutex);
	    break;
        case ITEM_EXIT:
            exit = true;
            break;
        }

        if (exit) {
            dat->exit_thd = true;
            break;
        }
    } while (1);
    pthread_join(dat->update_thd, NULL);

    return 0;
}