Skip to content

Commit e0df9c8

Browse files
committed
Minor updates and README
1 parent 9b685c4 commit e0df9c8

2 files changed

Lines changed: 41 additions & 24 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ log stream --debug --info --predicate 'subsystem contains "nl.root3.support"'
391391
```
392392

393393
## Known issues
394+
* All available software updates (minor and major) are shown in the menu bar icon and the macOS version info item, even when the update is deferred using a Restrictions Configuration Profile from MDM. macOS collects all available updates in `/Library/Preferences/com.apple.SoftwareUpdate.plist` regardless of any deferral configurations. Only major OS updates can be hidden using the `HideMajorUpdates` key for macOS 12.3 and later.
394395
* Buttons may keep a hovered state when mouse cursor moves fast: FB8212902 (**resolved in macOS Monterey**)
395396
* When Jamf Connect is used as password type, clicking "Change Now" does not allow the user to open the Jamf Connect change password window, but instead triggers an alert. Jamf Connect does not support a URL Scheme for opening the Change Password window. Please upvote this feature request: https://ideas.jamf.com/ideas/JN-I-16087
396397

src/Support/ComputerInfo.swift

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -541,45 +541,61 @@ class ComputerInfo: ObservableObject {
541541

542542
// MARK: - Get Array of RecommendedUpdates from com.apple.SoftwareUpdate
543543
func getRecommendedUpdates() {
544+
544545
logger.debug("Checking RecommendedUpdates for macOS updates and versions...")
545546

547+
// Set UserDefaults to com.apple.SoftwareUpdate
546548
let userDefaultsSoftwareUpdates = UserDefaults(suiteName: "com.apple.SoftwareUpdate")
549+
550+
// Create empty array for RecommendedUpdates UserDefaults data
547551
let recommendedUpdates = userDefaultsSoftwareUpdates?.array(forKey: "RecommendedUpdates") ?? []
548552

553+
// Create empty array for decoded RecommendedUpdates UserDefaults data
549554
var decodedItems: [SoftwareUpdateModel] = []
550555

551556
// Reset major version updates to 0
552557
majorVersionUpdates = 0
553558

554-
do {
555-
// Convert UserDefaults to JSON data
556-
let data = try JSONSerialization.data(withJSONObject: recommendedUpdates, options: [])
559+
// Move decoding of RecommendedUpdates to background thread
560+
DispatchQueue.global().async {
557561

558-
// Decode JSON data
559-
let decoder = JSONDecoder()
560-
decodedItems = try decoder.decode([SoftwareUpdateModel].self, from: data)
561-
logger.debug("Successfully decoded RecommendedUpdates...")
562+
do {
563+
// Convert UserDefaults to JSON data
564+
let data = try JSONSerialization.data(withJSONObject: recommendedUpdates, options: [])
565+
566+
// Decode JSON data
567+
let decoder = JSONDecoder()
568+
decodedItems = try decoder.decode([SoftwareUpdateModel].self, from: data)
569+
self.logger.debug("Successfully decoded RecommendedUpdates...")
570+
571+
} catch {
572+
self.logger.error("Error getting RecommendedUpdates...")
573+
}
562574

563-
} catch {
564-
logger.error("Error getting RecommendedUpdates...")
565-
}
566-
567-
logger.debug("\(decodedItems.count) updates found")
568-
569-
// Loop through all available updates and decrease number of updates when available macOS version is higher than current major version
570-
for item in decodedItems {
571-
if item.displayName.contains("macOS") {
572-
if let version = item.displayVersion?.components(separatedBy: ".")[0] {
573-
logger.debug("macOS update found: \(item.displayName, privacy: .public)")
574-
if Int(version) ?? 0 > systemVersionMajor {
575-
logger.debug("macOS version \(version, privacy: .public) is higher than the current macOS version, update will be hidden when DeferMajorVersions is enabled")
576-
majorVersionUpdates += 1
575+
self.logger.debug("\(decodedItems.count) updates found")
576+
577+
// Loop through all available updates and decrease number of updates when available macOS version is higher than current major version
578+
for item in decodedItems {
579+
// Filter updates with "macOS" in Display Name
580+
if item.displayName.contains("macOS") {
581+
// Get digits from Display Version separated by a dot to get the major version
582+
if let version = item.displayVersion?.components(separatedBy: ".")[0] {
583+
self.logger.debug("macOS update found: \(item.displayName, privacy: .public)")
584+
// Convert to integer and compare with current major OS version. If higher, increase number of major OS updates
585+
if Int(version) ?? 0 > self.systemVersionMajor {
586+
self.logger.debug("macOS version \(version, privacy: .public) is higher than the current macOS version, update will be hidden when DeferMajorVersions is enabled")
587+
// Back to the main thread to publish values
588+
DispatchQueue.main.async {
589+
self.majorVersionUpdates += 1
590+
}
591+
}
592+
} else {
593+
self.logger.error("Error getting macOS version from \(item.displayName)")
577594
}
595+
// Report but ignore any non-macOS updates, such as application updates
578596
} else {
579-
logger.error("Error getting macOS version from \(item.displayName)")
597+
self.logger.debug("\(item.displayName) is not a macOS update")
580598
}
581-
} else {
582-
logger.debug("\(item.displayName) is not a macOS update")
583599
}
584600
}
585601
}

0 commit comments

Comments
 (0)