Loading src/com/android/documentsui/services/CopyJob.java +6 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import static com.android.documentsui.services.FileOperationService.EXTRA_OPERAT import static com.android.documentsui.services.FileOperationService.MESSAGE_FINISH; import static com.android.documentsui.services.FileOperationService.MESSAGE_PROGRESS; import static com.android.documentsui.services.FileOperationService.OPERATION_COPY; import static com.android.documentsui.util.FlagUtils.isVisualSignalsFlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.app.Notification; Loading Loading @@ -1054,7 +1055,11 @@ class CopyJob extends ResolvedResourcesJob { } protected void update(Builder builder, Function<Long, String> messageFormatter) { // When the flag is enabled, updateEstimatedRemainingTime() is already called // elsewhere at the same time, so only call it when the flag is disabled. if (!isVisualSignalsFlagEnabled()) { updateEstimateRemainingTime(); } final double completed = getProgress(); builder.setProgress(100, (int) (completed * 100), false); Loading src/com/android/documentsui/services/FileOperationService.java +10 −1 Original line number Diff line number Diff line Loading @@ -614,7 +614,16 @@ public class FileOperationService extends Service implements Job.Listener { var progress = new ArrayList<JobProgress>(); synchronized (mJobs) { for (JobRecord rec : mJobs.values()) { progress.add(rec.job.getJobProgress()); var job = rec.job; progress.add(job.getJobProgress()); // Only job in set up state has progress bar if (job.getState() == Job.STATE_SET_UP) { notificationManager.notify( mForegroundJob == job ? null : job.id, NOTIFICATION_ID_PROGRESS, job.getProgressNotification()); } } } Intent intent = new Intent(); Loading tests/common/com/android/documentsui/services/TestNotificationManager.java +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.documentsui.services; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import android.app.Notification; Loading Loading @@ -74,7 +73,7 @@ class TestNotificationManager { return null; } private boolean hasNotification(int id, String jobId) { boolean hasNotification(int id, String jobId) { if (mNotifications.get(id) == null) { return false; } Loading tests/functional/com/android/documentsui/services/FileOperationServiceTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -109,8 +109,6 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi assertNull(mService.features); mService.features = features; mService.mVisualSignalsEnabled = false; } @Override Loading Loading @@ -265,26 +263,37 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi public void testRunsInForeground_MultipleJobs() throws Exception { startService(createCopyIntent(Arrays.asList(ALPHA_DOC), BETA_DOC)); startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC)); Job job2 = mCopyJobs.get(1); mExecutor.run(0); mForegroundManager.assertInForeground(); mHandler.dispatchAllMessages(); while (mTestNotificationManager.hasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id)) { mHandler.dispatchNextMessage(); } mForegroundManager.assertInForeground(); } public void testFinishesInBackground_MultipleJobs() throws Exception { startService(createCopyIntent(Arrays.asList(ALPHA_DOC), BETA_DOC)); startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC)); Job job2 = mCopyJobs.get(1); mExecutor.run(0); mForegroundManager.assertInForeground(); mHandler.dispatchAllMessages(); while (mTestNotificationManager.hasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id)) { mHandler.dispatchNextMessage(); } mForegroundManager.assertInForeground(); mExecutor.run(0); mHandler.dispatchAllMessages(); while (mTestNotificationManager.hasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, null)) { mHandler.dispatchNextMessage(); } mForegroundManager.assertInBackground(); } Loading Loading
src/com/android/documentsui/services/CopyJob.java +6 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import static com.android.documentsui.services.FileOperationService.EXTRA_OPERAT import static com.android.documentsui.services.FileOperationService.MESSAGE_FINISH; import static com.android.documentsui.services.FileOperationService.MESSAGE_PROGRESS; import static com.android.documentsui.services.FileOperationService.OPERATION_COPY; import static com.android.documentsui.util.FlagUtils.isVisualSignalsFlagEnabled; import static com.android.documentsui.util.Material3Config.getRes; import android.app.Notification; Loading Loading @@ -1054,7 +1055,11 @@ class CopyJob extends ResolvedResourcesJob { } protected void update(Builder builder, Function<Long, String> messageFormatter) { // When the flag is enabled, updateEstimatedRemainingTime() is already called // elsewhere at the same time, so only call it when the flag is disabled. if (!isVisualSignalsFlagEnabled()) { updateEstimateRemainingTime(); } final double completed = getProgress(); builder.setProgress(100, (int) (completed * 100), false); Loading
src/com/android/documentsui/services/FileOperationService.java +10 −1 Original line number Diff line number Diff line Loading @@ -614,7 +614,16 @@ public class FileOperationService extends Service implements Job.Listener { var progress = new ArrayList<JobProgress>(); synchronized (mJobs) { for (JobRecord rec : mJobs.values()) { progress.add(rec.job.getJobProgress()); var job = rec.job; progress.add(job.getJobProgress()); // Only job in set up state has progress bar if (job.getState() == Job.STATE_SET_UP) { notificationManager.notify( mForegroundJob == job ? null : job.id, NOTIFICATION_ID_PROGRESS, job.getProgressNotification()); } } } Intent intent = new Intent(); Loading
tests/common/com/android/documentsui/services/TestNotificationManager.java +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.documentsui.services; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import android.app.Notification; Loading Loading @@ -74,7 +73,7 @@ class TestNotificationManager { return null; } private boolean hasNotification(int id, String jobId) { boolean hasNotification(int id, String jobId) { if (mNotifications.get(id) == null) { return false; } Loading
tests/functional/com/android/documentsui/services/FileOperationServiceTest.java +14 −5 Original line number Diff line number Diff line Loading @@ -109,8 +109,6 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi assertNull(mService.features); mService.features = features; mService.mVisualSignalsEnabled = false; } @Override Loading Loading @@ -265,26 +263,37 @@ public class FileOperationServiceTest extends ServiceTestCase<FileOperationServi public void testRunsInForeground_MultipleJobs() throws Exception { startService(createCopyIntent(Arrays.asList(ALPHA_DOC), BETA_DOC)); startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC)); Job job2 = mCopyJobs.get(1); mExecutor.run(0); mForegroundManager.assertInForeground(); mHandler.dispatchAllMessages(); while (mTestNotificationManager.hasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id)) { mHandler.dispatchNextMessage(); } mForegroundManager.assertInForeground(); } public void testFinishesInBackground_MultipleJobs() throws Exception { startService(createCopyIntent(Arrays.asList(ALPHA_DOC), BETA_DOC)); startService(createCopyIntent(Arrays.asList(GAMMA_DOC), DELTA_DOC)); Job job2 = mCopyJobs.get(1); mExecutor.run(0); mForegroundManager.assertInForeground(); mHandler.dispatchAllMessages(); while (mTestNotificationManager.hasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, job2.id)) { mHandler.dispatchNextMessage(); } mForegroundManager.assertInForeground(); mExecutor.run(0); mHandler.dispatchAllMessages(); while (mTestNotificationManager.hasNotification( FileOperationService.NOTIFICATION_ID_PROGRESS, null)) { mHandler.dispatchNextMessage(); } mForegroundManager.assertInBackground(); } Loading