code: def state(self):
          
          # Check if device is disconnected.
          if not self.available:
              return STATE_UNKNOWN
          # Check if device is off.
          if not self.screen_on:
              return STATE_OFF
          # Check if screen saver is on.
          if not self.awake:
              return STATE_IDLE
          # Check if the launcher is active.
          if self.launcher or self.settings:
              return STATE_STANDBY
          # Check for a wake lock (device is playing).
          if self.wake_lock:
              return STATE_PLAYING
          # Otherwise, device is paused.
          return STATE_PAUSED
docs: Compute and return the device state.
  
          :returns: Device state.