package com.tcl.factory.view;

/*
 * 
 * Date:2014.02.16
 * add by yangms
 * 工厂串口bluetooth相关*/
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.tcl.factory.def.BlueTooth3DSync;
//import com.broadcom.bt.bt3dsync.Bluetooth3DSync;
import com.tcl.factory.bsp.TCL;
import com.tcl.factory.bsp.TVDefine;
import com.tcl.factory.thirdparty.ThirdParty;

public class Bluetooth3DReceiver extends BroadcastReceiver{

	private static final String TAG = "Bluetooth3DReceiver";
	@Override
	public void onReceive(Context context, Intent intent) {
		// TODO Auto-generated method stub
		String action = intent.getAction();
		BlueTooth3DSync blueTooth3DSync = new BlueTooth3DSync(); 
		Log.v(TAG, "onReceive() Action:" + action);
		TCL.implemetThirdPartyIsntance(context);
		if(blueTooth3DSync.ACTION_ON_FRAME_PERIOD_CHANGED.equals(action))
		{
			TVDefine.status_3d=true;
			TVDefine.period = intent.getIntExtra(blueTooth3DSync.EXTRA_FRAME_PERIOD, -1);
			//Log.v(TAG, "3d 模式: period:"+TVDefine.period);
			
			//0,1,2
			ThirdParty.setBluetooth3dSyncStatus(TCL.getBluetoothvsync()[0]);
			// 0,1
			ThirdParty.setBluetooth3dWorkStatus(TCL.getBluetoothsync()[0]);
			
		}else if(blueTooth3DSync.ACTION_ON_ASSOC_NOTIFICATION.equals(action))
		{
			Log.v(TAG, "蓝牙对码状:"+TVDefine.bluetoothstatus);
			TVDefine.bluetoothstatus=true;
			
			BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
			if (device != null)
			{
				Log.d(TAG,"ON_ASSOC_NOTIFICATION for "+ device.getAddress());
			}
			//0,1,2
			ThirdParty.setBluetooth3dSyncStatus(TCL.getBluetoothvsync()[0]);
			// 0,1
			ThirdParty.setBluetooth3dWorkStatus(TCL.getBluetoothsync()[0]);
		}
	}

}
