Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.documentsui.services; |
| 18 | |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 19 | import static com.android.documentsui.DocumentsApplication.acquireUnstableProviderOrThrow; |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 20 | import static com.android.documentsui.services.FileOperationService.EXTRA_CANCEL; |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 21 | import static com.android.documentsui.services.FileOperationService.EXTRA_DIALOG_TYPE; |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 22 | import static com.android.documentsui.services.FileOperationService.EXTRA_JOB_ID; |
| 23 | import static com.android.documentsui.services.FileOperationService.EXTRA_OPERATION; |
| 24 | import static com.android.documentsui.services.FileOperationService.EXTRA_SRC_LIST; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 25 | import static com.android.documentsui.services.FileOperationService.OPERATION_UNKNOWN; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 26 | |
| 27 | import android.annotation.DrawableRes; |
| 28 | import android.annotation.PluralsRes; |
| 29 | import android.app.Notification; |
| 30 | import android.app.Notification.Builder; |
| 31 | import android.app.PendingIntent; |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 32 | import android.content.ContentProviderClient; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 33 | import android.content.ContentResolver; |
| 34 | import android.content.Context; |
| 35 | import android.content.Intent; |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 36 | import android.net.Uri; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 37 | import android.os.Parcelable; |
| 38 | import android.os.RemoteException; |
| 39 | import android.provider.DocumentsContract; |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 40 | import android.util.Log; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 41 | |
| 42 | import com.android.documentsui.FilesActivity; |
Ben Kwa | d5b2af1 | 2016-01-28 16:39:57 -0800 | [diff] [blame] | 43 | import com.android.documentsui.Metrics; |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 44 | import com.android.documentsui.OperationDialogFragment; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 45 | import com.android.documentsui.R; |
| 46 | import com.android.documentsui.Shared; |
| 47 | import com.android.documentsui.model.DocumentInfo; |
| 48 | import com.android.documentsui.model.DocumentStack; |
| 49 | import com.android.documentsui.services.FileOperationService.OpType; |
| 50 | |
| 51 | import java.util.ArrayList; |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 52 | import java.util.HashMap; |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 53 | import java.util.List; |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 54 | import java.util.Map; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 55 | |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 56 | /** |
| 57 | * A mashup of work item and ui progress update factory. Used by {@link FileOperationService} |
| 58 | * to do work and show progress relating to this work. |
| 59 | */ |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 60 | abstract public class Job implements Runnable { |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 61 | private static final String TAG = "Job"; |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 62 | |
| 63 | static final String INTENT_TAG_WARNING = "warning"; |
| 64 | static final String INTENT_TAG_FAILURE = "failure"; |
| 65 | static final String INTENT_TAG_PROGRESS = "progress"; |
| 66 | static final String INTENT_TAG_CANCEL = "cancel"; |
| 67 | |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 68 | final Context service; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 69 | final Context appContext; |
| 70 | final Listener listener; |
| 71 | |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 72 | final @OpType int operationType; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 73 | final String id; |
| 74 | final DocumentStack stack; |
| 75 | |
| 76 | final ArrayList<DocumentInfo> failedFiles = new ArrayList<>(); |
| 77 | final Notification.Builder mProgressBuilder; |
| 78 | |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 79 | private final Map<String, ContentProviderClient> mClients = new HashMap<>(); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 80 | private volatile boolean mCanceled; |
| 81 | |
| 82 | /** |
| 83 | * A simple progressable job, much like an AsyncTask, but with support |
| 84 | * for providing various related notification, progress and navigation information. |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 85 | * @param operationType |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 86 | * |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 87 | * @param service The service context in which this job is running. |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 88 | * @param appContext The context of the invoking application. This is usually |
| 89 | * just {@code getApplicationContext()}. |
| 90 | * @param listener |
| 91 | * @param id Arbitrary string ID |
| 92 | * @param stack The documents stack context relating to this request. This is the |
| 93 | * destination in the Files app where the user will be take when the |
| 94 | * navigation intent is invoked (presumably from notification). |
| 95 | */ |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 96 | Job(Context service, Context appContext, Listener listener, |
| 97 | @OpType int operationType, String id, DocumentStack stack) { |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 98 | |
Steve McKay | a1f7680 | 2016-02-25 13:34:03 -0800 | [diff] [blame] | 99 | assert(operationType != OPERATION_UNKNOWN); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 100 | |
| 101 | this.service = service; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 102 | this.appContext = appContext; |
| 103 | this.listener = listener; |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 104 | this.operationType = operationType; |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 105 | |
| 106 | this.id = id; |
| 107 | this.stack = stack; |
| 108 | |
| 109 | mProgressBuilder = createProgressBuilder(); |
| 110 | } |
| 111 | |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 112 | @Override |
| 113 | public final void run() { |
| 114 | listener.onStart(this); |
| 115 | try { |
| 116 | start(); |
Tomasz Mikolajewski | 0fa97e8 | 2016-02-18 16:45:44 +0900 | [diff] [blame] | 117 | } catch (RuntimeException e) { |
| 118 | // No exceptions should be thrown here, as all calls to the provider must be |
| 119 | // handled within Job implementations. However, just in case catch them here. |
| 120 | Log.e(TAG, "Operation failed due to an unhandled runtime exception.", e); |
Ben Kwa | d5b2af1 | 2016-01-28 16:39:57 -0800 | [diff] [blame] | 121 | Metrics.logFileOperationErrors(service, operationType, failedFiles); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 122 | } finally { |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 123 | listener.onFinished(this); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 124 | } |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 125 | } |
| 126 | |
Tomasz Mikolajewski | 0fa97e8 | 2016-02-18 16:45:44 +0900 | [diff] [blame] | 127 | abstract void start(); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 128 | |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 129 | abstract Notification getSetupNotification(); |
| 130 | // TODO: Progress notification for deletes. |
| 131 | // abstract Notification getProgressNotification(long bytesCopied); |
| 132 | abstract Notification getFailureNotification(); |
| 133 | |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 134 | abstract Notification getWarningNotification(); |
| 135 | |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 136 | Uri getDataUriForIntent(String tag) { |
| 137 | return Uri.parse(String.format("data,%s-%s", tag, id)); |
| 138 | } |
| 139 | |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 140 | ContentProviderClient getClient(DocumentInfo doc) throws RemoteException { |
| 141 | ContentProviderClient client = mClients.get(doc.authority); |
| 142 | if (client == null) { |
| 143 | // Acquire content providers. |
| 144 | client = acquireUnstableProviderOrThrow( |
| 145 | getContentResolver(), |
| 146 | doc.authority); |
| 147 | |
| 148 | mClients.put(doc.authority, client); |
| 149 | } |
| 150 | |
Steve McKay | a1f7680 | 2016-02-25 13:34:03 -0800 | [diff] [blame] | 151 | assert(client != null); |
| 152 | return client; |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | final void cleanup() { |
| 156 | for (ContentProviderClient client : mClients.values()) { |
| 157 | ContentProviderClient.releaseQuietly(client); |
| 158 | } |
| 159 | } |
| 160 | |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 161 | final void cancel() { |
| 162 | mCanceled = true; |
Ben Kwa | d5b2af1 | 2016-01-28 16:39:57 -0800 | [diff] [blame] | 163 | Metrics.logFileOperationCancelled(service, operationType); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | final boolean isCanceled() { |
| 167 | return mCanceled; |
| 168 | } |
| 169 | |
| 170 | final ContentResolver getContentResolver() { |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 171 | return service.getContentResolver(); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | void onFileFailed(DocumentInfo file) { |
| 175 | failedFiles.add(file); |
| 176 | } |
| 177 | |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 178 | final boolean hasFailures() { |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 179 | return !failedFiles.isEmpty(); |
| 180 | } |
| 181 | |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 182 | boolean hasWarnings() { |
| 183 | return false; |
| 184 | } |
| 185 | |
Tomasz Mikolajewski | db87543 | 2016-02-23 15:12:54 +0900 | [diff] [blame] | 186 | final void deleteDocument(DocumentInfo doc, DocumentInfo parent) throws ResourceException { |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 187 | try { |
Tomasz Mikolajewski | db87543 | 2016-02-23 15:12:54 +0900 | [diff] [blame] | 188 | if (doc.isRemoveSupported()) { |
| 189 | DocumentsContract.removeDocument(getClient(doc), doc.derivedUri, parent.derivedUri); |
| 190 | } else if (doc.isDeleteSupported()) { |
| 191 | DocumentsContract.deleteDocument(getClient(doc), doc.derivedUri); |
| 192 | } else { |
| 193 | throw new ResourceException("Unable to delete source document as the file is " + |
| 194 | "not deletable nor removable: %s.", doc.derivedUri); |
| 195 | } |
| 196 | } catch (RemoteException | RuntimeException e) { |
Tomasz Mikolajewski | 0fa97e8 | 2016-02-18 16:45:44 +0900 | [diff] [blame] | 197 | throw new ResourceException("Failed to delete file %s due to an exception.", |
| 198 | doc.derivedUri, e); |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 199 | } |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 200 | } |
| 201 | |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 202 | Notification getSetupNotification(String content) { |
Steve McKay | 7a3b811 | 2016-02-23 10:06:50 -0800 | [diff] [blame] | 203 | mProgressBuilder.setProgress(0, 0, true) |
| 204 | .setContentText(content); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 205 | return mProgressBuilder.build(); |
| 206 | } |
| 207 | |
| 208 | Notification getFailureNotification(@PluralsRes int titleId, @DrawableRes int icon) { |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 209 | final Intent navigateIntent = buildNavigateIntent(INTENT_TAG_FAILURE); |
Tomasz Mikolajewski | 748ea8c | 2016-01-22 16:22:51 +0900 | [diff] [blame] | 210 | navigateIntent.putExtra(EXTRA_DIALOG_TYPE, OperationDialogFragment.DIALOG_TYPE_FAILURE); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 211 | navigateIntent.putExtra(EXTRA_OPERATION, operationType); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 212 | navigateIntent.putParcelableArrayListExtra(EXTRA_SRC_LIST, failedFiles); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 213 | |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 214 | final Notification.Builder errorBuilder = new Notification.Builder(service) |
| 215 | .setContentTitle(service.getResources().getQuantityString(titleId, |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 216 | failedFiles.size(), failedFiles.size())) |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 217 | .setContentText(service.getString(R.string.notification_touch_for_details)) |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 218 | .setContentIntent(PendingIntent.getActivity(appContext, 0, navigateIntent, |
| 219 | PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT)) |
| 220 | .setCategory(Notification.CATEGORY_ERROR) |
| 221 | .setSmallIcon(icon) |
| 222 | .setAutoCancel(true); |
Steve McKay | 7a3b811 | 2016-02-23 10:06:50 -0800 | [diff] [blame] | 223 | |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 224 | return errorBuilder.build(); |
| 225 | } |
| 226 | |
| 227 | abstract Builder createProgressBuilder(); |
| 228 | |
| 229 | final Builder createProgressBuilder( |
| 230 | String title, @DrawableRes int icon, |
| 231 | String actionTitle, @DrawableRes int actionIcon) { |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 232 | Notification.Builder progressBuilder = new Notification.Builder(service) |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 233 | .setContentTitle(title) |
| 234 | .setContentIntent( |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 235 | PendingIntent.getActivity(appContext, 0, |
| 236 | buildNavigateIntent(INTENT_TAG_PROGRESS), 0)) |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 237 | .setCategory(Notification.CATEGORY_PROGRESS) |
| 238 | .setSmallIcon(icon) |
| 239 | .setOngoing(true); |
| 240 | |
| 241 | final Intent cancelIntent = createCancelIntent(); |
| 242 | |
| 243 | progressBuilder.addAction( |
| 244 | actionIcon, |
| 245 | actionTitle, |
| 246 | PendingIntent.getService( |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 247 | service, |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 248 | 0, |
| 249 | cancelIntent, |
| 250 | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT)); |
| 251 | |
| 252 | return progressBuilder; |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Creates an intent for navigating back to the destination directory. |
| 257 | */ |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 258 | Intent buildNavigateIntent(String tag) { |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 259 | Intent intent = new Intent(service, FilesActivity.class); |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 260 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 261 | intent.setAction(DocumentsContract.ACTION_BROWSE); |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 262 | intent.setData(getDataUriForIntent(tag)); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 263 | intent.putExtra(Shared.EXTRA_STACK, (Parcelable) stack); |
| 264 | return intent; |
| 265 | } |
| 266 | |
| 267 | Intent createCancelIntent() { |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 268 | final Intent cancelIntent = new Intent(service, FileOperationService.class); |
Tomasz Mikolajewski | cd27015 | 2016-02-01 12:01:14 +0900 | [diff] [blame] | 269 | cancelIntent.setData(getDataUriForIntent(INTENT_TAG_CANCEL)); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 270 | cancelIntent.putExtra(EXTRA_CANCEL, true); |
| 271 | cancelIntent.putExtra(EXTRA_JOB_ID, id); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 272 | return cancelIntent; |
| 273 | } |
| 274 | |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 275 | @Override |
| 276 | public String toString() { |
| 277 | return new StringBuilder() |
| 278 | .append("Job") |
| 279 | .append("{") |
| 280 | .append("id=" + id) |
| 281 | .append("}") |
| 282 | .toString(); |
| 283 | } |
| 284 | |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 285 | /** |
| 286 | * Factory class that facilitates our testing FileOperationService. |
| 287 | */ |
| 288 | static class Factory { |
| 289 | |
| 290 | static final Factory instance = new Factory(); |
| 291 | |
| 292 | Job createCopy(Context service, Context appContext, Listener listener, |
| 293 | String id, DocumentStack stack, List<DocumentInfo> srcs) { |
| 294 | return new CopyJob(service, appContext, listener, id, stack, srcs); |
| 295 | } |
| 296 | |
| 297 | Job createMove(Context service, Context appContext, Listener listener, |
Tomasz Mikolajewski | b8436af | 2016-01-25 16:20:15 +0900 | [diff] [blame] | 298 | String id, DocumentStack stack, List<DocumentInfo> srcs, |
| 299 | DocumentInfo srcParent) { |
| 300 | return new MoveJob(service, appContext, listener, id, stack, srcs, srcParent); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 301 | } |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 302 | |
| 303 | Job createDelete(Context service, Context appContext, Listener listener, |
Tomasz Mikolajewski | b8436af | 2016-01-25 16:20:15 +0900 | [diff] [blame] | 304 | String id, DocumentStack stack, List<DocumentInfo> srcs, |
| 305 | DocumentInfo srcParent) { |
| 306 | return new DeleteJob(service, appContext, listener, id, stack, srcs, srcParent); |
Steve McKay | 3564543 | 2016-01-20 15:09:35 -0800 | [diff] [blame] | 307 | } |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | /** |
| 311 | * Listener interface employed by the service that owns us as well as tests. |
| 312 | */ |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 313 | interface Listener { |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 314 | void onStart(Job job); |
Steve McKay | ecbf3c5 | 2016-01-13 17:17:39 -0800 | [diff] [blame] | 315 | void onFinished(Job job); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 316 | void onProgress(CopyJob job); |
Steve McKay | 14e827a | 2016-01-06 18:32:13 -0800 | [diff] [blame] | 317 | } |
| 318 | } |