mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
[NTOS:PO] Set SystemBatteriesPresent when having a battery device in the system
This is (at least) used by powercfg.cpl to know if it needs to display some additional pages.
This commit is contained in:
parent
dff8b93ee2
commit
9e43518da5
2 changed files with 22 additions and 0 deletions
|
@ -159,6 +159,7 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
|
|||
BOOLEAN Arrival;
|
||||
ULONG Caps;
|
||||
NTSTATUS Status;
|
||||
POP_POLICY_DEVICE_TYPE DeviceType = (POP_POLICY_DEVICE_TYPE)(ULONG_PTR)Context;
|
||||
|
||||
DPRINT("PopAddRemoveSysCapsCallback(%p %p)\n",
|
||||
NotificationStructure, Context);
|
||||
|
@ -175,6 +176,12 @@ PopAddRemoveSysCapsCallback(IN PVOID NotificationStructure,
|
|||
else
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
if (Arrival && DeviceType == PolicyDeviceBattery)
|
||||
{
|
||||
PopCapabilities.SystemBatteriesPresent = TRUE;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (Arrival)
|
||||
{
|
||||
DPRINT("Arrival of %wZ\n", Notification->SymbolicLinkName);
|
||||
|
|
|
@ -423,6 +423,18 @@ PoInitSystem(IN ULONG BootPhase)
|
|||
PopAddRemoveSysCapsCallback,
|
||||
(PVOID)(ULONG_PTR)PolicyDeviceSystemButton,
|
||||
&NotificationEntry);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return FALSE;
|
||||
|
||||
/* Register battery notification */
|
||||
Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange,
|
||||
PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES,
|
||||
(PVOID)&GUID_DEVICE_BATTERY,
|
||||
IopRootDeviceNode->PhysicalDeviceObject->DriverObject,
|
||||
PopAddRemoveSysCapsCallback,
|
||||
(PVOID)(ULONG_PTR)PolicyDeviceBattery,
|
||||
&NotificationEntry);
|
||||
|
||||
return NT_SUCCESS(Status);
|
||||
}
|
||||
|
||||
|
@ -824,7 +836,10 @@ NtPowerInformation(IN POWER_INFORMATION_LEVEL PowerInformationLevel,
|
|||
/* Just zero the struct (and thus set BatteryState->BatteryPresent = FALSE) */
|
||||
RtlZeroMemory(BatteryState, sizeof(SYSTEM_BATTERY_STATE));
|
||||
BatteryState->EstimatedTime = MAXULONG;
|
||||
BatteryState->BatteryPresent = PopCapabilities.SystemBatteriesPresent;
|
||||
// BatteryState->AcOnLine = TRUE;
|
||||
// BatteryState->MaxCapacity = ;
|
||||
// BatteryState->RemainingCapacity = ;
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue