diff options
author | Ben Kwa <kenobi@google.com> | 2015-05-27 09:18:53 -0700 |
---|---|---|
committer | Ben Kwa <kenobi@google.com> | 2015-05-27 09:19:28 -0700 |
commit | 7c0ade56f38c61055e7d35a5e077d4f6f005b5bd (patch) | |
tree | 1e915b9ab2baccaacf3c1d19273547d6d43d254b /packages | |
parent | 327c364113c18c9d5a05df0c912b65788461da41 (diff) | |
download | frameworks_base-7c0ade56f38c61055e7d35a5e077d4f6f005b5bd.zip frameworks_base-7c0ade56f38c61055e7d35a5e077d4f6f005b5bd.tar.gz frameworks_base-7c0ade56f38c61055e7d35a5e077d4f6f005b5bd.tar.bz2 |
Ensure that the copy notification is always cancelable.
If the CopyService dies or is stopped for whatever reason, the cached
"current" job ID will go to null. In that case, the cancel intent will
be ignored, and the copy notification can never be dismissed. Adding a
null check to the handleCancel method of CopyService fixes this.
BUG=21365043
Change-Id: I0615328f6033a313fec79f8b63291c7f7373ea0f
Diffstat (limited to 'packages')
-rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/CopyService.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java index 6e050c6..506ec58 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java +++ b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java @@ -173,8 +173,6 @@ public class CopyService extends IntentService { .setAutoCancel(true); mNotificationManager.notify(mJobId, 0, errorBuilder.build()); } - - // TODO: Display a toast if the copy was cancelled. } } @@ -306,13 +304,15 @@ public class CopyService extends IntentService { private void handleCancel(Intent intent) { final String cancelledId = intent.getStringExtra(EXTRA_CANCEL); // Do nothing if the cancelled ID doesn't match the current job ID. This prevents racey - // cancellation requests from affecting unrelated copy jobs. - if (Objects.equals(mJobId, cancelledId)) { + // cancellation requests from affecting unrelated copy jobs. However, if the current job ID + // is null, the service most likely crashed and was revived by the incoming cancel intent. + // In that case, always allow the cancellation to proceed. + if (Objects.equals(mJobId, cancelledId) || mJobId == null) { // Set the cancel flag. This causes the copy loops to exit. mIsCancelled = true; // Dismiss the progress notification here rather than in the copy loop. This preserves // interactivity for the user in case the copy loop is stalled. - mNotificationManager.cancel(mJobId, 0); + mNotificationManager.cancel(cancelledId, 0); } } |