code: public void setOnCancelListener(OnCancelListener listener) {
          synchronized (this) {
              waitForCancelFinishedLocked();
  
              if (mOnCancelListener == listener) {
                  return;
              }
              mOnCancelListener = listener;
              if (!mIsCanceled || listener == null) {
                  return;
              }
          }
          listener.onCancel();
      }
docs: Sets the cancellation listener to be called when canceled.
  
  This method is intended to be used by the recipient of a cancellation signal
  such as a database or a content provider to handle cancellation requests
  while performing a long-running operation.  This method is not intended to be
  used by applications themselves.
  
  If {@link CancellationSignal#cancel} has already been called, then the provided
  listener is invoked immediately.
  
  This method is guaranteed that the listener will not be called after it
  has been removed.
  
  @param listener The cancellation listener, or null to remove the current listener.