Source:
<code>private void runTearDown(Throwable exception) throws DeviceNotAvailableException { List<IMultiTargetPreparer> cleanerList = new ArrayList<>(mMultiPreparers); Collections.reverse(cleanerList); for (IMultiTargetPreparer multiCleaner : cleanerList) { if (multiCleaner.isDisabled() || multiCleaner.isTearDownDisabled()) { continue; } CLog.d("Running teardown <START> Multi <END> cleaner: %s", multiCleaner.getClass().getSimpleName()); multiCleaner.tearDown(mModuleInvocationContext, exception); } for (int i = 0; i < mModuleInvocationContext.getDeviceConfigNames().size(); i++) { String deviceName = mModuleInvocationContext.getDeviceConfigNames().get(i); ITestDevice device = mModuleInvocationContext.getDevice(deviceName); if (i >= mPreparersPerDevice.size()) { CLog.d( "Main configuration has more devices than the module configuration. '%s' " + "will not run any tear down.", deviceName); continue; } List<ITargetPreparer> preparers = mPreparersPerDevice.get(deviceName); if (preparers == null) { CLog.w( "Module configuration devices mismatch the main configuration " + "(Missing device '%s'), resolving preparers by index.", deviceName); String key = new ArrayList<>(mPreparersPerDevice.keySet()).get(i); preparers = mPreparersPerDevice.get(key); } ListIterator<ITargetPreparer> itr = preparers.listIterator(preparers.size()); while (itr.hasPrevious()) { ITargetPreparer preparer = itr.previous(); if (preparer instanceof ITargetCleaner) { ITargetCleaner cleaner = (ITargetCleaner) preparer; if (cleaner.isDisabled() || cleaner.isTearDownDisabled()) { CLog.d("%s has been disabled. skipping.", cleaner); continue; } RecoveryMode origMode = null; try { if (exception != null && exception instanceof DeviceNotAvailableException) { origMode = device.getRecoveryMode(); device.setRecoveryMode(RecoveryMode.NONE); } cleaner.tearDown( device, mModuleInvocationContext.getBuildInfo(deviceName), exception); } finally { if (origMode != null) { device.setRecoveryMode(origMode); } } } } } }</code><technical_language>m</technical_language>

Target:
private void runTearDown(Throwable exception) throws DeviceNotAvailableException { List<IMultiTargetPreparer> cleanerList = new ArrayList<>(mMultiPreparers); Collections.reverse(cleanerList); for (IMultiTargetPreparer multiCleaner : cleanerList) { if (multiCleaner.isDisabled() || multiCleaner.isTearDownDisabled()) { continue; } CLog.d("Running teardown multi cleaner: %s", multiCleaner.getClass().getSimpleName()); multiCleaner.tearDown(mModuleInvocationContext, exception); } for (int i = 0; i < mModuleInvocationContext.getDeviceConfigNames().size(); i++) { String deviceName = mModuleInvocationContext.getDeviceConfigNames().get(i); ITestDevice device = mModuleInvocationContext.getDevice(deviceName); if (i >= mPreparersPerDevice.size()) { CLog.d( "Main configuration has more devices than the module configuration. '%s' " + "will not run any tear down.", deviceName); continue; } List<ITargetPreparer> preparers = mPreparersPerDevice.get(deviceName); if (preparers == null) { CLog.w( "Module configuration devices mismatch the main configuration " + "(Missing device '%s'), resolving preparers by index.", deviceName); String key = new ArrayList<>(mPreparersPerDevice.keySet()).get(i); preparers = mPreparersPerDevice.get(key); } ListIterator<ITargetPreparer> itr = preparers.listIterator(preparers.size()); while (itr.hasPrevious()) { ITargetPreparer preparer = itr.previous(); if (preparer instanceof ITargetCleaner) { ITargetCleaner cleaner = (ITargetCleaner) preparer; if (cleaner.isDisabled() || cleaner.isTearDownDisabled()) { CLog.d("%s has been disabled. skipping.", cleaner); continue; } RecoveryMode origMode = null; try { if (exception != null && exception instanceof DeviceNotAvailableException) { origMode = device.getRecoveryMode(); device.setRecoveryMode(RecoveryMode.NONE); } cleaner.tearDown( device, mModuleInvocationContext.getBuildInfo(deviceName), exception); } finally { if (origMode != null) { device.setRecoveryMode(origMode); } } } } } }