@Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case VoiceCommandListener.ACTION_MAIN_VOICE_UI:
       mVoiceUI.handleAsyncVoiceMessage((VoiceMessage) msg.obj);
       break;
     case VoiceCommandListener.ACTION_MAIN_VOICE_TRAINING:
       mVoiceTraining.handleAsyncVoiceMessage((VoiceMessage) msg.obj);
       break;
     case VoiceCommandListener.ACTION_MAIN_VOICE_RECOGNIZE:
       mVoiceRecognize.handleAsyncVoiceMessage((VoiceMessage) msg.obj);
       break;
     case VoiceCommandListener.ACTION_MAIN_VOICE_CONTACTS:
       mVoiceContacts.handleAsyncVoiceMessage((VoiceMessage) msg.obj);
       break;
     case VoiceCommandListener.ACTION_VOICE_CONTACTS_NAME:
       handleAsyncContactsMsg((String[]) msg.obj);
       break;
     case VoiceCommandBusiness.ACTION_MAIN_VOICE_SERVICE:
     case VoiceCommandBusiness.ACTION_MAIN_VOICE_BROADCAST:
       mVoiceServiceInternal.handleAsyncVoiceMessage((VoiceMessage) msg.obj);
       break;
     default:
       // do nothing
       break;
   }
 }
 /*
  * Send message to native via JNICommandAdapter
  */
 @Override
 public int dispatchMessageDown(VoiceMessage message) {
   // TODO Auto-generated method stub
   int errorid = VoiceCommandListener.VOICE_NO_ERROR;
   switch (message.mMainAction) {
     case VoiceCommandListener.ACTION_MAIN_VOICE_UI:
       errorid = mVoiceUI.handleSyncVoiceMessage(message);
       break;
     case VoiceCommandListener.ACTION_MAIN_VOICE_TRAINING:
       errorid = mVoiceTraining.handleSyncVoiceMessage(message);
       break;
     case VoiceCommandListener.ACTION_MAIN_VOICE_RECOGNIZE:
       errorid = mVoiceRecognize.handleSyncVoiceMessage(message);
       break;
     case VoiceCommandBusiness.ACTION_MAIN_VOICE_SERVICE:
       errorid = mVoiceServiceInternal.handleSyncVoiceMessage(message);
       break;
     case VoiceCommandListener.ACTION_MAIN_VOICE_CONTACTS:
       errorid = mVoiceContacts.handleSyncVoiceMessage(message);
       break;
     default:
       // do nothing here
       break;
   }
   return errorid;
 }
 /*
  * Send all contacts name to next dispatcher
  *
  * @param contactsNameList contacts name list
  */
 public void handleAsyncContactsMsg(String[] contactsNames) {
   VoiceMessage message = new VoiceMessage();
   message.mMainAction = VoiceCommandListener.ACTION_MAIN_VOICE_CONTACTS;
   message.mSubAction = VoiceCommandListener.ACTION_VOICE_CONTACTS_NAME;
   Bundle bundle = DataPackage.packageSendInfo(contactsNames, null);
   message.mExtraData = bundle;
   mVoiceContacts.handleAsyncVoiceMessage(message);
 }
 @Override
 public int dispatchMessageUp(VoiceMessage message) {
   // TODO Auto-generated method stub
   int errorid = VoiceCommandListener.VOICE_NO_ERROR;
   switch (message.mMainAction) {
     case VoiceCommandBusiness.ACTION_MAIN_VOICE_SERVICE:
       if (message.mSubAction == VoiceCommandBusiness.ACTION_VOICE_SERVICE_SELFEXIT) {
         mService.mContext.unregisterReceiver(mHeadsetPlugReceiver);
         mVoiceContacts.handleDataRelease();
       }
       errorid = mVoiceServiceInternal.handleSyncVoiceMessage(message);
       break;
     default:
       errorid = mUpDispatcher.dispatchMessageUp(message);
       break;
   }
   return errorid;
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   VoiceMessage msg = new VoiceMessage();
   msg.mMainAction = VoiceCommandBusiness.ACTION_MAIN_VOICE_BROADCAST;
   if (intent.getIntExtra("state", 0) == 0) {
     msg.mSubAction = VoiceCommandBusiness.ACTION_VOICE_BROADCAST_HEADSETPLUGOUT;
   } else {
     msg.mSubAction = VoiceCommandBusiness.ACTION_VOICE_BROADCAST_HEADSETPLUGIN;
   }
   mVoiceServiceInternal.handleSyncVoiceMessage(msg);
 }