Loading src/com/android/documentsui/services/FileOperationService.java +7 −4 Original line number Diff line number Diff line Loading @@ -183,12 +183,12 @@ public class FileOperationService extends Service implements Job.Listener { return; } mWakeLock.acquire(); assert (job != null); if (DEBUG) Log.d(TAG, "Scheduling job " + job.id + "."); Future<?> future = getExecutorService(operation.getOpType()).submit(job); mRunning.put(jobId, new JobRecord(job, future)); mWakeLock.acquire(); } } Loading Loading @@ -245,6 +245,11 @@ public class FileOperationService extends Service implements Job.Listener { assert(record != null); record.job.cleanup(); mWakeLock.release(); if (!mWakeLock.isHeld()) { mWakeLock = null; } if (mRunning.isEmpty()) { shutdown(); } Loading @@ -256,8 +261,6 @@ public class FileOperationService extends Service implements Job.Listener { */ private void shutdown() { if (DEBUG) Log.d(TAG, "Shutting down. Last serviceId was " + mLastServiceId); mWakeLock.release(); mWakeLock = null; // Turns out, for us, stopSelfResult always returns false in tests, // so we can't guard executor shutdown. For this reason we move Loading tests/common/com/android/documentsui/testing/TestScheduledExecutorService.java +5 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static junit.framework.Assert.fail; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.Delayed; Loading Loading @@ -137,8 +138,11 @@ public class TestScheduledExecutorService implements ScheduledExecutorService { } public void runAll() { for (TestFuture future : scheduled) { final Iterator<TestFuture> iter = scheduled.iterator(); while (iter.hasNext()) { TestFuture future = iter.next(); future.runnable.run(); iter.remove(); } } Loading tests/unit/com/android/documentsui/services/FileOperationServiceTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -90,10 +90,16 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi @Override protected void tearDown() { // Release all possibly held wake lock here mExecutor.runAll(); mDeletionExecutor.runAll(); // There are lots of progress notifications generated in this test case. // Dismiss all of them here. while (mHandler.hasScheduledMessage()) { mHandler.dispatchAllMessages(); } } public void testRunsCopyJobs() throws Exception { startService(createCopyIntent(newArrayList(ALPHA_DOC), BETA_DOC)); Loading Loading
src/com/android/documentsui/services/FileOperationService.java +7 −4 Original line number Diff line number Diff line Loading @@ -183,12 +183,12 @@ public class FileOperationService extends Service implements Job.Listener { return; } mWakeLock.acquire(); assert (job != null); if (DEBUG) Log.d(TAG, "Scheduling job " + job.id + "."); Future<?> future = getExecutorService(operation.getOpType()).submit(job); mRunning.put(jobId, new JobRecord(job, future)); mWakeLock.acquire(); } } Loading Loading @@ -245,6 +245,11 @@ public class FileOperationService extends Service implements Job.Listener { assert(record != null); record.job.cleanup(); mWakeLock.release(); if (!mWakeLock.isHeld()) { mWakeLock = null; } if (mRunning.isEmpty()) { shutdown(); } Loading @@ -256,8 +261,6 @@ public class FileOperationService extends Service implements Job.Listener { */ private void shutdown() { if (DEBUG) Log.d(TAG, "Shutting down. Last serviceId was " + mLastServiceId); mWakeLock.release(); mWakeLock = null; // Turns out, for us, stopSelfResult always returns false in tests, // so we can't guard executor shutdown. For this reason we move Loading
tests/common/com/android/documentsui/testing/TestScheduledExecutorService.java +5 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static junit.framework.Assert.fail; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.Delayed; Loading Loading @@ -137,8 +138,11 @@ public class TestScheduledExecutorService implements ScheduledExecutorService { } public void runAll() { for (TestFuture future : scheduled) { final Iterator<TestFuture> iter = scheduled.iterator(); while (iter.hasNext()) { TestFuture future = iter.next(); future.runnable.run(); iter.remove(); } } Loading
tests/unit/com/android/documentsui/services/FileOperationServiceTest.java +7 −1 Original line number Diff line number Diff line Loading @@ -90,10 +90,16 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi @Override protected void tearDown() { // Release all possibly held wake lock here mExecutor.runAll(); mDeletionExecutor.runAll(); // There are lots of progress notifications generated in this test case. // Dismiss all of them here. while (mHandler.hasScheduledMessage()) { mHandler.dispatchAllMessages(); } } public void testRunsCopyJobs() throws Exception { startService(createCopyIntent(newArrayList(ALPHA_DOC), BETA_DOC)); Loading