/** * @param prefs * @return */ public static ArrayList<ObdCommand> getObdCommands(SharedPreferences prefs) { ArrayList<ObdCommand> cmds = ObdConfig.getCommands(); ArrayList<ObdCommand> ucmds = new ArrayList<>(); for (int i = 0; i < cmds.size(); i++) { ObdCommand cmd = cmds.get(i); boolean selected = prefs.getBoolean(cmd.getName(), true); if (selected) ucmds.add(cmd); } return ucmds; }
/** * */ private void queueCommands() { if (isServiceBound) { for (ObdCommand Command : ObdConfig.getCommands()) { if (prefs.getBoolean(Command.getName(), true)) service.queueJob(new ObdCommandJob(Command)); } } }
Log.d(TAG, "Job state is NEW. Run it.."); job.setState(ObdCommandJobState.RUNNING); Log.d(TAG, job.getCommand().getName()); job.getCommand().run(new ByteArrayInputStream("41 00 00 00>41 00 00 00>41 00 00 00>".getBytes()), new ByteArrayOutputStream()); } else {
public void stateUpdate(final ObdCommandJob job) { final String cmdName = job.getCommand().getName(); String cmdResult = ""; final String cmdID = LookUpCommand(cmdName); if (job.getState().equals(ObdCommandJob.ObdCommandJobState.EXECUTION_ERROR)) { cmdResult = job.getCommand().getResult(); if (cmdResult != null && isServiceBound) { obdStatusTextView.setText(cmdResult.toLowerCase()); } } else if (job.getState().equals(ObdCommandJob.ObdCommandJobState.BROKEN_PIPE)) { if (isServiceBound) stopLiveData(); } else if (job.getState().equals(ObdCommandJob.ObdCommandJobState.NOT_SUPPORTED)) { cmdResult = getString(R.string.status_obd_no_support); } else { cmdResult = job.getCommand().getFormattedResult(); if(isServiceBound) obdStatusTextView.setText(getString(R.string.status_obd_data)); } if (vv.findViewWithTag(cmdID) != null) { TextView existingTV = (TextView) vv.findViewWithTag(cmdID); existingTV.setText(cmdResult); } else addTableRow(cmdID, cmdName, cmdResult); commandResult.put(cmdID, cmdResult); updateTripStatistic(job, cmdID); }