Skip to content

Commit 58cf18d

Browse files
committed
firmware: Handle devices without ALS
Devices without internal display like Mac mini, Studio and Pro do not have an ambient light sensor. The ioreg subprocess will not produce any output but return with exit status 0. Handle this gracefully. This might hide unexpected cases on devices with ALS but a simple solution without listing devices. Fixes: 766ecc0 ("Extract and store ALS calibration") Signed-off-by: Janne Grunau <[email protected]>
1 parent 48668e8 commit 58cf18d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

asahi_firmware/als.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def load(self):
1616
if ioreg.returncode != 0:
1717
log.warning("Unable to run ioreg, ambient light sensor calibration will not be saved")
1818
return
19+
if len(ioreg.stdout) == 0:
20+
log.info("ioreg without 'als' object. Possibly a device without ambient light sensor.")
21+
return
1922
tree = plistlib.loads(ioreg.stdout)
2023
try:
2124
cal_data = tree[0]["IORegistryEntryChildren"][0]["IORegistryEntryChildren"][0]["IORegistryEntryChildren"][0]["CalibrationData"]

0 commit comments

Comments
 (0)