Loading src/com/android/documentsui/services/FileOperationService.java +10 −7 Original line number Original line Diff line number Diff line Loading @@ -52,9 +52,11 @@ public class FileOperationService extends Service implements Job.Listener { private static final int DEFAULT_DELAY = 0; private static final int DEFAULT_DELAY = 0; private static final int MAX_DELAY = 10 * 1000; // ten seconds private static final int MAX_DELAY = 10 * 1000; // ten seconds private static final int POOL_SIZE = 2; // "pool size", not *max* "pool size". private static final int NOTIFICATION_ID_PROGRESS = 0; private static final int NOTIFICATION_ID_FAILURE = 1; public static final String TAG = "FileOperationService"; public static final String TAG = "FileOperationService"; private static final int POOL_SIZE = 2; // "pool size", not *max* "pool size". public static final String EXTRA_JOB_ID = "com.android.documentsui.JOB_ID"; public static final String EXTRA_JOB_ID = "com.android.documentsui.JOB_ID"; public static final String EXTRA_DELAY = "com.android.documentsui.DELAY"; public static final String EXTRA_DELAY = "com.android.documentsui.DELAY"; Loading Loading @@ -209,7 +211,7 @@ public class FileOperationService extends Service implements Job.Listener { // interactivity for the user in case the copy loop is stalled. // interactivity for the user in case the copy loop is stalled. // Try to cancel it even if we don't have a job id...in case there is some sad // Try to cancel it even if we don't have a job id...in case there is some sad // orphan notification. // orphan notification. mNotificationManager.cancel(jobId, 0); mNotificationManager.cancel(jobId, NOTIFICATION_ID_PROGRESS); // TODO: Guarantee the job is being finalized // TODO: Guarantee the job is being finalized } } Loading Loading @@ -286,7 +288,7 @@ public class FileOperationService extends Service implements Job.Listener { @Override @Override public void onStart(Job job) { public void onStart(Job job) { if (DEBUG) Log.d(TAG, "onStart: " + job.id); if (DEBUG) Log.d(TAG, "onStart: " + job.id); mNotificationManager.notify(job.id, 0, job.getSetupNotification()); mNotificationManager.notify(job.id, NOTIFICATION_ID_PROGRESS, job.getSetupNotification()); } } @Override @Override Loading @@ -294,7 +296,7 @@ public class FileOperationService extends Service implements Job.Listener { if (DEBUG) Log.d(TAG, "onFinished: " + job.id); if (DEBUG) Log.d(TAG, "onFinished: " + job.id); // Dismiss the ongoing copy notification when the copy is done. // Dismiss the ongoing copy notification when the copy is done. mNotificationManager.cancel(job.id, 0); mNotificationManager.cancel(job.id, NOTIFICATION_ID_PROGRESS); synchronized (mRunning) { synchronized (mRunning) { deleteJob(job); deleteJob(job); Loading @@ -304,7 +306,8 @@ public class FileOperationService extends Service implements Job.Listener { @Override @Override public void onProgress(CopyJob job) { public void onProgress(CopyJob job) { if (DEBUG) Log.d(TAG, "onProgress: " + job.id); if (DEBUG) Log.d(TAG, "onProgress: " + job.id); mNotificationManager.notify(job.id, 0, job.getProgressNotification()); mNotificationManager.notify( job.id, NOTIFICATION_ID_PROGRESS, job.getProgressNotification()); } } @Override @Override Loading @@ -312,8 +315,8 @@ public class FileOperationService extends Service implements Job.Listener { if (DEBUG) Log.d(TAG, "onFailed: " + job.id); if (DEBUG) Log.d(TAG, "onFailed: " + job.id); checkArgument(job.failed()); checkArgument(job.failed()); Log.e(TAG, "Job failed on files: " + job.failedFiles.size() + "."); Log.e(TAG, "Job failed on files: " + job.failedFiles.size() + "."); mNotificationManager.notify(job.id, 0, job.getFailureNotification()); mNotificationManager.notify(job.id, NOTIFICATION_ID_FAILURE, job.getFailureNotification()); onFinished(job); // failed jobs don't call finished, so we do. onFinished(job); // Failed jobs don't call finished, so we do. } } private static final class JobRecord { private static final class JobRecord { Loading Loading
src/com/android/documentsui/services/FileOperationService.java +10 −7 Original line number Original line Diff line number Diff line Loading @@ -52,9 +52,11 @@ public class FileOperationService extends Service implements Job.Listener { private static final int DEFAULT_DELAY = 0; private static final int DEFAULT_DELAY = 0; private static final int MAX_DELAY = 10 * 1000; // ten seconds private static final int MAX_DELAY = 10 * 1000; // ten seconds private static final int POOL_SIZE = 2; // "pool size", not *max* "pool size". private static final int NOTIFICATION_ID_PROGRESS = 0; private static final int NOTIFICATION_ID_FAILURE = 1; public static final String TAG = "FileOperationService"; public static final String TAG = "FileOperationService"; private static final int POOL_SIZE = 2; // "pool size", not *max* "pool size". public static final String EXTRA_JOB_ID = "com.android.documentsui.JOB_ID"; public static final String EXTRA_JOB_ID = "com.android.documentsui.JOB_ID"; public static final String EXTRA_DELAY = "com.android.documentsui.DELAY"; public static final String EXTRA_DELAY = "com.android.documentsui.DELAY"; Loading Loading @@ -209,7 +211,7 @@ public class FileOperationService extends Service implements Job.Listener { // interactivity for the user in case the copy loop is stalled. // interactivity for the user in case the copy loop is stalled. // Try to cancel it even if we don't have a job id...in case there is some sad // Try to cancel it even if we don't have a job id...in case there is some sad // orphan notification. // orphan notification. mNotificationManager.cancel(jobId, 0); mNotificationManager.cancel(jobId, NOTIFICATION_ID_PROGRESS); // TODO: Guarantee the job is being finalized // TODO: Guarantee the job is being finalized } } Loading Loading @@ -286,7 +288,7 @@ public class FileOperationService extends Service implements Job.Listener { @Override @Override public void onStart(Job job) { public void onStart(Job job) { if (DEBUG) Log.d(TAG, "onStart: " + job.id); if (DEBUG) Log.d(TAG, "onStart: " + job.id); mNotificationManager.notify(job.id, 0, job.getSetupNotification()); mNotificationManager.notify(job.id, NOTIFICATION_ID_PROGRESS, job.getSetupNotification()); } } @Override @Override Loading @@ -294,7 +296,7 @@ public class FileOperationService extends Service implements Job.Listener { if (DEBUG) Log.d(TAG, "onFinished: " + job.id); if (DEBUG) Log.d(TAG, "onFinished: " + job.id); // Dismiss the ongoing copy notification when the copy is done. // Dismiss the ongoing copy notification when the copy is done. mNotificationManager.cancel(job.id, 0); mNotificationManager.cancel(job.id, NOTIFICATION_ID_PROGRESS); synchronized (mRunning) { synchronized (mRunning) { deleteJob(job); deleteJob(job); Loading @@ -304,7 +306,8 @@ public class FileOperationService extends Service implements Job.Listener { @Override @Override public void onProgress(CopyJob job) { public void onProgress(CopyJob job) { if (DEBUG) Log.d(TAG, "onProgress: " + job.id); if (DEBUG) Log.d(TAG, "onProgress: " + job.id); mNotificationManager.notify(job.id, 0, job.getProgressNotification()); mNotificationManager.notify( job.id, NOTIFICATION_ID_PROGRESS, job.getProgressNotification()); } } @Override @Override Loading @@ -312,8 +315,8 @@ public class FileOperationService extends Service implements Job.Listener { if (DEBUG) Log.d(TAG, "onFailed: " + job.id); if (DEBUG) Log.d(TAG, "onFailed: " + job.id); checkArgument(job.failed()); checkArgument(job.failed()); Log.e(TAG, "Job failed on files: " + job.failedFiles.size() + "."); Log.e(TAG, "Job failed on files: " + job.failedFiles.size() + "."); mNotificationManager.notify(job.id, 0, job.getFailureNotification()); mNotificationManager.notify(job.id, NOTIFICATION_ID_FAILURE, job.getFailureNotification()); onFinished(job); // failed jobs don't call finished, so we do. onFinished(job); // Failed jobs don't call finished, so we do. } } private static final class JobRecord { private static final class JobRecord { Loading