work/workmanager/src/main/java/androidx/work/impl/Processor.java
public synchronized boolean stopAndCancelWork(String id) {
        Log.d(TAG, String.format("Processor cancelling %s", id));
        mCancelledIds.add(id);
        WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id);
        if (wrapper != null) {
            wrapper.interrupt(true);
            Log.d(TAG, String.format("WorkerWrapper cancelled for %s", id));
            return true;
        }
        Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id));
        return false;
    }
/**
     * Stops a unit of work and marks it as cancelled.
     *
     * @param id The work id to stop and cancel
     * @return {@code true} if the work was stopped successfully
     */
Stops a unit of work and marks it as cancelled.
@param id The work id to stop and cancel
@return  true if the work was stopped successfully
Stops a unit of work and marks it as cancelled . @param id The work id to stop and cancel @return true if the work was stopped successfully
public synchronized boolean stopAndCancelWork(String id) {
        Log.d(TAG, String.format("Processor cancelling %s", id));
        mCancelledIds.add(id);
        WorkerWrapper wrapper = mEnqueuedWorkMap.remove(id);
        if (wrapper != null) {
            wrapper.interrupt(true);
            Log.d(TAG, String.format("WorkerWrapper cancelled for %s", id));
            return true;
        }
        Log.d(TAG, String.format("WorkerWrapper could not be found for %s", id));
        return false;
    }
public synchronized boolean stopAndCancelWork ( String id ) { Log . d ( TAG , String . format ( "Processor cancelling %s" , id ) ) ; mCancelledIds . add ( id ) ; WorkerWrapper wrapper = mEnqueuedWorkMap . remove ( id ) ; if ( wrapper != null ) { wrapper . interrupt ( true ) ; Log . d ( TAG , String . format ( "WorkerWrapper cancelled for %s" , id ) ) ; return true ; } Log . d ( TAG , String . format ( "WorkerWrapper could not be found for %s" , id ) ) ; return false ; }
Stops a unit of work and marks it as cancelled.
Stops a unit of work and marks it as cancelled .