コード例 #1
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;
  }