Posts

Post not yet marked as solved
2 Replies
921 Views
IOPSCopyPowerSourcesInfo → kIOPSBatteryHealthKey returning incorrect value Background: I write software to monitor computer system health. I'm having problems getting battery health information on my new M2 notebook. Given the following Objective-C program: #include <Foundation/NSObjCRuntime.h> #include <IOKit/ps/IOPSKeys.h> #include <IOKit/ps/IOPowerSources.h> #include <assert.h> int main() { CFTypeRef psInfo = IOPSCopyPowerSourcesInfo(); assert(psInfo != NULL); CFArrayRef list = IOPSCopyPowerSourcesList(psInfo); assert(list != NULL); long count = CFArrayGetCount(list); for(long i = 0; i < count; i++) { CFDictionaryRef ps = IOPSGetPowerSourceDescription( psInfo, CFArrayGetValueAtIndex(list, i)); assert(ps != NULL); CFStringRef deviceName = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSNameKey)); assert(deviceName != NULL); CFStringRef serialNumber = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSHardwareSerialNumberKey)); assert(serialNumber != NULL); CFStringRef health = (CFStringRef)CFDictionaryGetValue( ps, CFSTR(kIOPSBatteryHealthKey)); assert(health != NULL); NSLog(@"\nName=\"%@\"\nSerialNumber=\"%@\"\n" "BatteryHealth=\"%@\"\n", (__bridge NSString*)deviceName, (__bridge NSString*)serialNumber, (__bridge NSString*)health); } CFRelease(list); CFRelease(psInfo); return 0; } and looking at the IOPSKeys.h header, I expect to get one of "Poor", "Fair", or "Good" for the value of kIOPSBatteryHealthKey. https://opensource.apple.com/source/IOKitUser/IOKitUser-1845.81.1/ps.subproj/IOPSKeys.h.auto.html Instead, on my 2022 M2 Macbook Air running 13.2.1 (22D68), I get the following output: Name="InternalBattery-0" SerialNumber="F8Y2422145S10X2A7" BatteryHealth="Check Battery" At the same time, the "System Information app says "Condition: Normal". Am I missing something? This seems to be a bug, right? Should I look into filing a Technical Support Incident?
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
In https://support.apple.com/guide/mac-help/configuration-profiles-standardize-settings-mh35561/mac, Apple says View an installed configuration profile: On your Mac, choose Apple menu → System Settings, click Privacy and Security in the sidebar, then click Profiles on the right. (You may need to scroll down.) Select a profile in the Profiles list to view information about it. Is there a way to get this information on the command line or via an API? I would like to include a dump of all of this info in my debug logs of my application, so that I know when it misbehaves whether or not the system permissions were set correctly.
Posted Last updated
.