Async Task Running even when conditions are not met

I am badly stuck in a problem. This is my code:

public class ScreenContextSensor extends Service {

  private static final String TAG = ScreenContextSensor.class.getSimpleName();
    @Override
    public void onCreate() {
        super.onCreate();
        Log.d("Check", "onCreate, Thread name" + Thread.currentThread().getName());

    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {

        boolean screenOff = intent.getBooleanExtra("screen_state", false);
        boolean screenUnLock = intent.getBooleanExtra("lock_state", false);
        if(screenOff)
        {
            Log.d("Check", "Screen is OFF");
            if(!screenUnLock)
            {
                Log.d("Check", "Screen is Locked");
            }
            else
            {
                Log.d("Check", "Screen is not Locked");
                    new LockedWhenSleep().execute(screenUnLock);
            }
        }

        else
        {
            Log.d("Check", "Screen is ON");
            if(!screenUnLock)
            {
                Log.d("Check", "Screen is Locked");
            }
            else
            {
                Log.d("Check", "Screen is not Locked");

            }
        }

        Log.i(TAG, "onStartCommand, Thread name" + Thread.currentThread().getName());

        return START_STICKY;
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {

        Log.i(TAG, "onBind, Thread name" + Thread.currentThread().getName());

        return null;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    private class LockedWhenSleep extends AsyncTask<Boolean, Void, Void> {

        @Override
        protected Void doInBackground(Boolean... booleans) {

            boolean screenUnLock = booleans[0];
            try {
                boolean checkState = true;
                while (checkState) {
                    if (screenUnLock) {
                        Log.d("Check", "Screen is Now Locked\n");
                        checkState = false;
                    }
                }
            } catch (Exception e) {
                Log.d("LOG", e.getMessage());
            }
            return null;
        }
    }
}

The Async task above should only run if the condition: screenOff and Screen is not Locked is true. Then after sometime, when the screen locks itself (lets say after 5 sec) then, the log: "Screen is now locked" should show. But my Async task is showing "Screen is now locked" as soon as the above two conditions are met. But it must only show when the phone actually locks itself.

Where am I going wrong?