package com.tcl.factory.view;
import android.view.KeyEvent;

import com.tcl.factory.bsp.TCL;
import com.tcl.factory.bsp.TV;
import com.tcl.factory.bsp.TVDefine;
import com.tcl.factory.def.DEFS;
import com.tcl.factory.thirdparty.ThirdParty;
import android.os.SystemProperties;
 
public class DModeOtherMenu extends SubMenu
{
	public static  String MenuInfos_DModeOtherMenu[][]={
		{"TestPattern",">"},
		{"UartEnable",""},
		{"ScreenPixel",""},
		{"DeviceID",""},
		{"",""},
		{"MAC",""},
		{"SN",""},
		{"RegisterCode",""},
		{"HuanID",""},
		{"ClientType",""},
		{"ReadEepromToUSB",">"},
		{"WatchDog","OFF"},
		{"ADB","OFF"},
	};
	public DModeOtherMenu()
	{
		super.menuInfos=MenuInfos_DModeOtherMenu;
		super.menuLabel = "Main menu\\Other";
		super.setTAG();
		updateMenuInfos();
	}
	
	private boolean adbStatus = true;
	public void KeyEvent(int keyCode,int pos)
	{
		switch(keyCode)
		{
		case KeyEvent.KEYCODE_DPAD_LEFT:
		case KeyEvent.KEYCODE_DPAD_RIGHT:
		{
			switch(pos)
			{
			case 0: {
				//goto TestPattern
				TV.writeS(TVDefine.PMode, DEFS.Enable);
				TCL.setKeyCodeTestStatus(true);
				break;
			}
			case 1:
				if(!ThirdParty.mFactoryAdapter.getUartStatus()) {
					ThirdParty.mFactoryAdapter.openSerialPort();
					SystemProperties.set("persist.sys.logd.level", "V");
				}
				else {
					ThirdParty.mFactoryAdapter.closeSerialPort();
					SystemProperties.set("persist.sys.logd.level", "S");
				}
				break;
			case 10:
				TCL.readEepromTest();
				break;
			case 11:
				super.StatusHandler(TVDefine.WatchDog) ; break;
			case 12:
				if(adbStatus) {
					ThirdParty.setAdbdStatus(false);
				} else {
					ThirdParty.setAdbdStatus(true);
				}
				break;
			}
		}
		break;
		default:
			break;
		}
	}
 
	@Override
	public void updateMenuInfos() {
		if(ThirdParty.mFactoryAdapter.getUartStatus())	
			menuInfos[1][1]="ON"; 
		else 
			menuInfos[1][1]="OFF";
		
//		{
//			short[] ret = ThirdParty.getPanelPixelShort((short)10, (short)10, (short)50);
//			if(ret.length>=3) {
//				menuInfos[2][1] = ""+(ret[0])+"/"+(ret[1])+"/"+(ret[2]);
//			}
//		}
		
		menuInfos[4][1] = ""+ThirdParty.getDeviceIDString();
		menuInfos[5][1] = ""+ThirdParty.getMACAddressString();
		menuInfos[6][1] = ""+ThirdParty.getSNString();
		menuInfos[7][1] = ""+ThirdParty.getRegiterCodeString();
		menuInfos[8][1] = ""+ThirdParty.getUserID();
		menuInfos[9][1] = ""+ThirdParty.getClientType();
		
		super.updateStatusInfo(TVDefine.WatchDog, 11);
		adbStatus = ThirdParty.getAdbdStatus();
		if(adbStatus) {
			menuInfos[12][1]="ON"; 
		} else {
			menuInfos[12][1]="OFF"; 
		}
	}

	/* (non-Javadoc)
	 * Factory
	 */
	@Override
	public void enterSubMenu(int pos) {
		// TODO Auto-generated method stub
		
		super.enterSubMenu(pos);
	}
	
	//hexdump -e '16/1 " 0x%02X,"'  HDCP.bin
//	private short[] HDCP_BIN = {
//			 0x2F, 0x64, 0x3D, 0xA2, 0xE4, 0x47, 0x5D, 0x40, 0x46, 0x1A, 0x22, 0x4D, 0x63, 0x75, 0x50, 0x40, 
//			 0x1B, 0x2B, 0x3D, 0x22, 0x44, 0x23, 0x01, 0x0D, 0x71, 0x58, 0x3A, 0x59, 0x78, 0x22, 0x41, 0x71,
//			 0x57, 0x00, 0x50, 0x62, 0x7F, 0x08, 0x37, 0x22, 0x1E, 0x5B, 0x02, 0x4A, 0x6B, 0x5A, 0x2F, 0x6F, 
//			 0x2C, 0x5F, 0x1F, 0x36, 0x40, 0x75, 0x4A, 0x76, 0x1A, 0x4B, 0x44, 0x45, 0x63, 0x48, 0x2E, 0x08, 
//			 0x03, 0x1A, 0x06, 0x6F, 0x7B, 0x4B, 0x24, 0x19, 0x58, 0x64, 0x60, 0x50, 0x18, 0x6E, 0x57, 0x05, 
//			 0x2C, 0x77, 0x5F, 0x0C, 0x2A, 0x3B, 0x16, 0x6A, 0x06, 0x1D, 0x53, 0x05, 0x4B, 0x61, 0x62, 0x38, 
//			 0x4B, 0x47, 0x2B, 0x4D, 0x13, 0x79, 0x1F, 0x51, 0x1C, 0x64, 0x4B, 0x5E, 0x64, 0x39, 0x5E, 0x3C, 
//			 0x40, 0x46, 0x79, 0x52, 0x4E, 0x58, 0x31, 0x61, 0x1A, 0x78, 0x3B, 0x45, 0x57, 0x18, 0x48, 0x0E, 
//			 0x32, 0x61, 0x57, 0x3E, 0x33, 0x21, 0x35, 0x65, 0x33, 0x2B, 0x73, 0x62, 0x2F, 0x1D, 0x75, 0x21, 
//			 0x20, 0x24, 0x2C, 0x2F, 0x63, 0x01, 0x4E, 0x57, 0x3D, 0x30, 0x79, 0x77, 0x12, 0x16, 0x67, 0x1F, 
//			 0x0B, 0x59, 0x02, 0x70, 0x7A, 0x30, 0x30, 0x70, 0x21, 0x48, 0x75, 0x34, 0x76, 0x3C, 0x00, 0x57, 
//			 0x6E, 0x63, 0x11, 0x1E, 0x17, 0x6C, 0x1A, 0x23, 0x7A, 0x63, 0x0D, 0x74, 0x08, 0x7D, 0x42, 0x12, 
//			 0x1A, 0x02, 0x28, 0x3D, 0x4C, 0x4E, 0x52, 0x77, 0x28, 0x3D, 0x6E, 0x4C, 0x20, 0x0D, 0x0B, 0x55, 
//			 0x5B, 0x3C, 0x6F, 0x4A, 0x11, 0x35, 0x40, 0x57, 0x26, 0x17, 0x2B, 0x38, 0x05, 0x05, 0x70, 0x1D, 
//			 0x1E, 0x0B, 0x4A, 0x70, 0x6B, 0x79, 0x5E, 0x07, 0x61, 0x2A, 0x13, 0x3F, 0x28, 0x18, 0x57, 0x6A, 
//			 0x54, 0x22, 0x1C, 0x4A, 0x2C, 0x0B, 0x19, 0x55, 0x7E, 0x79, 0x27, 0x2A, 0x3D, 0x75, 0x3C, 0x4E, 
//			 0x46, 0x58, 0x4A, 0x15, 0x55, 0x14, 0x51, 0x4D, 0x52, 0x7E, 0x18, 0x70, 0x4B, 0x72, 0x12, 0x64, 
//			 0x1C, 0x26, 0x7D, 0x0C, 0x16, 0x27, 0x2A, 0x3F, 0x00, 0x77, 0x28, 0x7F, 0x02, 0x41, 0x61, 0x40, 
//			 0x48, 0x4B, 0x07, 0x11, 0x5B, 0x22, 0x6E, 0x30, 0x68, 0x6B, 0x2F, 0x40, 0x01, 0x0F, 0x3C, 0x72, 
//			 0x33, 0x0A, 0x21, 0x7C, 0x23, 0x3F, 0x04, 0x3F, 0x08, 0x41, 0x2F, 0x5F, 0x04, 0x2B, 0x19, 0x15, 
//			 0x31, 0x2F, 0x74, 0x0A, 0x45
//	};
	
}
