Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ba9a27b authored by Ben Kwa's avatar Ben Kwa Committed by Android Git Automerger
Browse files

am 7a3b2012: Merge "Ensure that the copy notification is always cancelable." into mnc-dev

* commit '7a3b2012ea4d079a50edb8aa101a353830219d29':
  Ensure that the copy notification is always cancelable.
parents 7d5d0624 c562179e
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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);
        }
    }