/** * Helper method to stop the hardware profiling service. * * @throws ProfilingException */ private void stopBatteryService() throws ProfilingException { String command = "am startservice -a 'org.qualitune.jouleunit.android.battery.BatteryServiceStopService'"; mCoordinator.executeAdbCommand(command); mCoordinator.reportProgress("Hardware probe service stopped."); }
/** * Helper method to start the hardware profiling service. * * @throws ProfilingException */ private void startBatteryService() throws ProfilingException { mCoordinator.reportProgress("Start Battery Proc service..."); mCoordinator.startLogReading(); String command = "am startservice -a 'org.qualitune.jouleunit.android.battery.BatteryService'"; mCoordinator.executeAdbCommand(command); }
/* * (non-Javadoc) * * @see org.qualitune.jouleunit.AbstractJouleProfiler#startProfiling() */ @Override public EnergyProfile startProfiling() { try { startBatteryService(); } catch (ProfilingException e1) { mCoordinator.reportError("Error during start of profiling service: " + e1.getMessage()); return null; } mProcessor = new BatteryLogLineProcessor(this); mCoordinator.startLogReading(); mCoordinator.logOutputReceiver.addLogLineProcessor(mProcessor); return super.startProfiling(); }
/* * (non-Javadoc) * * @see org.qualitune.jouleunit.AbstractJouleProfiler#endProfiling() */ @Override public EnergyProfile endProfiling() { EnergyProfile result = super.endProfiling(); if (null != mProcessor && null != mCoordinator.logOutputReceiver) { mCoordinator.logOutputReceiver.removeLogLineProcessor(mProcessor); mProcessor = null; } // no else. try { stopBatteryService(); } catch (ProfilingException e) { mCoordinator.reportError("Error during termination of profiling service: " + e.getMessage()); } return result; }