code: public synchronized void update() {
      SYSTEM_POWER_STATUS status = new SYSTEM_POWER_STATUS();
      Kernel32.INSTANCE.GetSystemPowerStatus(status);
  
      switch (status.ACLineStatus) {
      case 0: // battery
        allow(!requireAC
            && (status.BatteryLifePercent < 0 || status.BatteryLifePercent >= minBatteryLifePercent));
        break;
  
      case 1:  // A/C
      default:
        allow((status.BatteryFlag & 0x8) == 0 // not charging
            || (status.BatteryLifePercent < 0 || status.BatteryLifePercent >= minBatteryLifePercentWhileCharging));
        break;
  
      }
    }
docs: Updates the state of this <code>CourtesyMonitor</code>.