package com.tcl.factory.view;

import android.view.KeyEvent;

import com.tcl.factory.bsp.TV;
import com.tcl.factory.bsp.TVDefine;
import com.tcl.factory.def.DEFS;
import com.tcl.factory.thirdparty.ThirdParty;


public class PModeOtherMenu extends SubMenu {
    public static String MenuInfos_PModeOtherMenu[][] = {
            {"Project Info", ""},
            {"NVM 种子标志", "OFF"},
            {"Panel Rotate", ""},
            {"Flip-Mirror", "OFF"},
//	{"DONGLE Upgrade",">"},
    };

    public static int FreQuenceArray[] =
            {0, 339, 474};

    public PModeOtherMenu() {
        menuInfos = MenuInfos_PModeOtherMenu;
        menuLabel = "Factory\\Other";
        super.setTAG();
        updateMenuInfos();
    }

    public void KeyEvent(int keyCode, int pos) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
            case KeyEvent.KEYCODE_DPAD_RIGHT: {
                switch (pos) {
                    case 0:
                        setProjectID(keyCode);
                        break;
                    case 1:
                        makeNvmDate(keyCode);
                        break;
                    case 2:
                        super.StatusHandler(TVDefine.PanelRotate);
                        break;
                    case 3:
                        ThirdParty.setDeviceIDString("ab84b2d8d00d726414aaba17605dea839d6c7aa7");
                        break;
                    //		case 4:
                    //			upgradeRC71(keyCode);break;
                }
            }
            break;
            default:
                break;
        }
    }

//	public void upgradeRC71(int keyCode)
//	{
//		//rc71
////		USBUpgradeDialog usbUpgradeDialog = new USBUpgradeDialog(ThirdParty.mContext);
////		usbUpgradeDialog.show();
////		usbUpgradeDialog.UpgradeDialogConfirm();
//		//rc65
//		USBUpgradeRC65Dialog usbUpgradeDialog = new USBUpgradeRC65Dialog(ThirdParty.mContext);
//		usbUpgradeDialog.show();
//		usbUpgradeDialog.UpgradeDialogConfirm();
//	}

    private void makeNvmDate(int keyCode) {
        TV.writeV(TVDefine.NVM, 0x210, 0xff);
        TV.writeV(TVDefine.NVM, 0x211, 0xff);   //edid init !!
        TV.writeV(TVDefine.CityID, 0);  //default city
        TV.writeV(TVDefine.AreaFrequence, FreQuenceArray[0]);  //default value main fre
        TV.writeS(TVDefine.NonStandardMode, DEFS.Disable); //NonstandardStatus -->off
        TV.writeV(TVDefine.PowerMode, 1);//power mode on
        TV.writeS(TVDefine.PMode, DEFS.Enable);
        menuInfos[1][1] = "����ɣ��밴ң�عػ�";
    }

    /* (non-Javadoc)
     * Factory
     */
    @Override
    public void updateMenuInfos() {
        // TODO Auto-generated method stub
        super.updateValueInfo(TVDefine.ProjectID, 0);
        super.updateStatusInfo(TVDefine.PanelRotate, 3);
    }

    /* (non-Javadoc)
     * Factory
     */
    @Override
    public void enterSubMenu(int pos) {
        // TODO Auto-generated method stub
        super.enterSubMenu(pos);

        if (pos == 0) MainMenu.mSubMenu = new PModeProjectInfoMenu();
    }
}

