コード例 #1
0
  /**
   * Checks if the command set already exists.
   *
   * @param pid process id
   * @param uid user id
   * @param setName command set name
   * @param featureType feature type
   * @return result
   */
  public int isSetCreatedLocked(int pid, int uid, String setName, int featureType) {

    int result = VoiceCommonState.SUCCESS;

    ProcessRecord processRecord = getProcessRecordLocked(pid, uid);
    ListenerRecord listenerRecord =
        processRecord == null ? null : processRecord.getListenerRecord(getFeatureName(featureType));

    if (processRecord == null || listenerRecord == null) {
      // Check whether is illegal process from third party application
      // Maybe third application connect service without using
      // VoiceCommandManager
      result = VoiceCommonState.PROCESS_ILLEGAL;
    } else {
      // Ask swip to check whether the set is already created
      if (!setName.equals(listenerRecord.getSetName())) {
        // First check whether the set is already selected
        String swipSet =
            ProcessRecord.getSetNameForSwip(
                processRecord.getProcssName(),
                processRecord.getPid(),
                getFeatureName(featureType),
                setName);
        result = mSwip.isSetCreated(swipSet, featureType);
      }
    }

    return result;
  }
コード例 #2
0
  /**
   * Creates a command set for commands operation.
   *
   * @param pid process id
   * @param uid user id
   * @param setName command set name
   * @param featureType feature type
   * @return result
   */
  public int createSetLocked(int pid, int uid, String setName, int featureType) {
    // TODO Auto-generated method stub

    int result = VoiceCommonState.SUCCESS;

    ProcessRecord processRecord = getProcessRecordLocked(pid, uid);
    ListenerRecord listenerRecord =
        processRecord == null ? null : processRecord.getListenerRecord(getFeatureName(featureType));

    if (listenerRecord == null) {
      // Check whether is illegal process from third party application
      // Maybe third application connect service without using
      // VoiceCommandManager
      result = VoiceCommonState.PROCESS_ILLEGAL;
    } else {

      if (setName.equals(listenerRecord.getSetName())) {
        // The setName already in used ,so don't need to ask swip
        // creating the set
        result = VoiceCommonState.SET_ALREADY_EXIST;
      } else {
        // Ask Swip whether the setName is created
        String swipSet =
            ProcessRecord.getSetNameForSwip(
                processRecord.getProcssName(),
                processRecord.getPid(),
                getFeatureName(featureType),
                setName);
        result = mSwip.createSetName(swipSet, featureType);
      }
    }

    return result;
  }
コード例 #3
0
  /**
   * Gets all command sets.
   *
   * @param pid process id
   * @param uid user id
   * @param featureType feature type
   * @return all command sets
   */
  public String[] getAllSetsLocked(int pid, int uid, int featureType) {

    String[] sets = null;
    ProcessRecord processRecord = getProcessRecordLocked(pid, uid);
    ListenerRecord listenerRecord =
        processRecord == null ? null : processRecord.getListenerRecord(getFeatureName(featureType));
    if (listenerRecord != null) {
      // Ask swip to get the sets of this process
      sets = mSwip.getAllSets(processRecord.getProcssName(), featureType);
    }
    return sets;
  }
コード例 #4
0
  /**
   * Selects a command set for setting up commands or command recognition operation.
   *
   * @param pid process id
   * @param uid user id
   * @param setName command set name
   * @param featureType feature type
   * @return result
   */
  public int selectSetLocked(int pid, int uid, String setName, int featureType) {

    int result = VoiceCommonState.SUCCESS;

    if (setName == null) {

      result = VoiceCommonState.SET_ILLEGAL;
      Log.e(TAG, "select Set fail, set name =" + setName);

    } else {

      ProcessRecord processRecord = getProcessRecordLocked(pid, uid);
      ListenerRecord listenerRecord =
          processRecord == null
              ? null
              : processRecord.getListenerRecord(getFeatureName(featureType));
      if (processRecord == null || listenerRecord == null) {
        // Check whether is illegal process from third party application
        // Maybe third application connect service without using
        // VoiceCommandManager
        result = VoiceCommonState.PROCESS_ILLEGAL;
      } else if (setName.equals(listenerRecord.getSetName())) {
        result = VoiceCommonState.SET_SELECTED;
      } else if (processRecord.isListenerOccupiedSwip(listenerRecord)) {
        // Current listenerRecord occupy the swip , can't switch set
        result = VoiceCommonState.MIC_OCCUPIED;
      } else {
        // Ask swip that is this set created
        String swipSet =
            ProcessRecord.getSetNameForSwip(
                processRecord.getProcssName(),
                processRecord.getPid(),
                getFeatureName(featureType),
                setName);
        result = mSwip.isSetCreated(swipSet, featureType);
        if (result == VoiceCommonState.SET_ALREADY_EXIST) {
          listenerRecord.setSetName(setName);
          // result = processRecord
          // .switchSwipListenerRecord(listenerRecord);
          result = VoiceCommonState.SUCCESS;
        }
      }
    }
    return result;
  }
コード例 #5
0
  /**
   * Deletes the command set.
   *
   * @param pid process id
   * @param uid user id
   * @param setName command set name
   * @param featureType feature type
   * @return result
   */
  public int deleteSetLocked(int pid, int uid, String setName, int featureType) {

    int result = VoiceCommonState.SUCCESS;

    ProcessRecord processRecord = getProcessRecordLocked(pid, uid);
    ListenerRecord listenerRecord =
        processRecord == null ? null : processRecord.getListenerRecord(getFeatureName(featureType));

    if (processRecord == null || listenerRecord == null) {
      // Check whether is illegal process from third party application
      // Maybe third application connect service without using
      // VoiceCommandManager
      result = VoiceCommonState.PROCESS_ILLEGAL;
    } else {

      if (setName.equals(listenerRecord.getSetName())) {
        if (listenerRecord == processRecord.getSwipListenerRecord()) {
          // The setName already in used ,so we need to check state
          // Swip is using the set , so we can't delete the set
          result = VoiceCommonState.SET_OCCUPIED;
        } else {
          listenerRecord.setSetName(null);
        }
      }
      // Ask swip to delete the set
      // listenerRecord.selectSet(null);
      if (result == VoiceCommonState.SUCCESS) {
        String swipSet =
            ProcessRecord.getSetNameForSwip(
                processRecord.getProcssName(),
                processRecord.getPid(),
                getFeatureName(featureType),
                setName);
        result = mSwip.deleteSetName(swipSet);
      }
    }
    return result;
  }