Source:
public StatusCheckerResult postExecutionCheck(ITestDevice device) throws DeviceNotAvailableException { if (mSystemServerProcess == null) { CLog.d("No valid system_server to be checked, skipping system checker."); return new StatusCheckerResult(CheckStatus.SUCCESS); } String message = null; ProcessInfo currSystemServerProcess = device.getProcessByName("system_server"); if (currSystemServerProcess == null) { message = "system_server is down"; } else if (currSystemServerProcess.getPid() != mSystemServerProcess.getPid() || currSystemServerProcess.getStartTime() != mSystemServerProcess.getStartTime()) { Map<Long, String> bootHistory = device.getBootHistorySince(mSystemServerProcess.getStartTime()); CLog.i("The device reboot with boot history: %s", bootHistory); if (bootHistory.isEmpty()) { message = "system_server restarted"; } else { message = "system_server restarted due to device reboot: " + bootHistory.toString(); long lastExpectedReboot = device.getLastExpectedRebootTimeMillis(); if (mModuleStartTime != null && lastExpectedReboot < mModuleStartTime) { CLog.w( "System_server restarted and Tradefed didn't trigger a reboot: " + "last expected reboot: %s, module start time: %s, " + "something went wrong.", lastExpectedReboot, mModuleStartTime); } else { return new StatusCheckerResult(CheckStatus.SUCCESS); } } } else { return new StatusCheckerResult(CheckStatus.SUCCESS); } CLog.w(message); StatusCheckerResult result = new StatusCheckerResult(CheckStatus.FAILED); result.setBugreportNeeded(true); result.setErrorMessage(message); return result; }

Target:
public StatusCheckerResult postExecutionCheck(ITestDevice device) throws DeviceNotAvailableException { if (mSystemServerProcess == null) { CLog.d( "No valid system_server process was found in preExecutionCheck, skipping system checker."); return new StatusCheckerResult(CheckStatus.SUCCESS); } String message = null; ProcessInfo currSystemServerProcess = device.getProcessByName("system_server"); if (currSystemServerProcess == null) { message = "system_server is down"; CLog.w(message); StatusCheckerResult result = new StatusCheckerResult(CheckStatus.FAILED); result.setBugreportNeeded(true); result.setErrorMessage(message); return result; } else if (currSystemServerProcess.getPid() == mSystemServerProcess.getPid() && currSystemServerProcess.getStartTime() == mSystemServerProcess.getStartTime()) { return new StatusCheckerResult(CheckStatus.SUCCESS); } Map<Long, String> bootHistory = device.getBootHistorySince(mSystemServerProcess.getStartTime()); CLog.i("The device reboot with boot history: %s", bootHistory); if (bootHistory.isEmpty()) { message = "system_server restarted"; } else { message = "system_server restarted due to device reboot: " + bootHistory.toString(); long lastExpectedReboot = device.getLastExpectedRebootTimeMillis(); if (mModuleStartTime != null && lastExpectedReboot < mModuleStartTime) { CLog.w( "System_server restarted and Tradefed didn't trigger a reboot: " + "last expected reboot: %s, module start time: %s, " + "something went wrong.", lastExpectedReboot, mModuleStartTime); } else { CLog.i("Tradefed triggered reboot detected"); return new StatusCheckerResult(CheckStatus.SUCCESS); } } CLog.w(message); StatusCheckerResult result = new StatusCheckerResult(CheckStatus.FAILED); result.setBugreportNeeded(true); result.setErrorMessage(message); return result; }