Allow developer to always force allowing automatic updates (#2266)

By default, if the SUAllowsAutomaticUpdates Info.plist key is not specified, the update alert option to allow automatic downloading/installing of updates will only be shown if automatic checking of updates is enabled. However, the developer can now override this by setting SUAllowsAutomaticUpdates to true in Info.plist which indicates the option should be available even if automatic checking of updates is not enabled.
This commit is contained in:
Zorg authored and GitHub committed 2022-09-16 20:41:08 -07:00
1 parent 83cc66b988
commit 005392963f
3 files changed
+25 -2

No files matched your search

+6
View File
@@ -31,6 +31,12 @@ SU_EXPORT @interface SPUUpdaterSettings : NSObject
*/
@property (readonly, nonatomic) NSTimeInterval updateCheckInterval;
/**
* Indicates whether or not automatically downloading updates is allowed to be turned on by the user.
* If this value is nil, the developer has not explicitly specified this option.
*/
@property (readonly, nonatomic, nullable) NSNumber *allowsAutomaticUpdatesOption;
/**
* Indicates whether or not automatically downloading updates is allowed to be turned on by the user.
*/
+7 -1
View File
@@ -52,9 +52,15 @@
}
// For allowing automatic downloaded updates to be turned on or off
- (BOOL)allowsAutomaticUpdates
- (NSNumber * _Nullable)allowsAutomaticUpdatesOption
{
NSNumber *developerAllowsAutomaticUpdates = [self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey];
return [developerAllowsAutomaticUpdates isKindOfClass:[NSNumber class]] ? developerAllowsAutomaticUpdates : nil;
}
- (BOOL)allowsAutomaticUpdates
{
NSNumber *developerAllowsAutomaticUpdates = [self allowsAutomaticUpdatesOption];
return (developerAllowsAutomaticUpdates == nil || developerAllowsAutomaticUpdates.boolValue);
}
+12 -1
View File
@@ -98,7 +98,18 @@ static NSString *const SUUpdateAlertTouchBarIndentifier = @"" SPARKLE_BUNDLE_IDE
_didBecomeKeyBlock = [didBecomeKeyBlock copy];
SPUUpdaterSettings *updaterSettings = [[SPUUpdaterSettings alloc] initWithHostBundle:host.bundle];
_allowsAutomaticUpdates = updaterSettings.allowsAutomaticUpdates && updaterSettings.automaticallyChecksForUpdates && !item.informationOnlyUpdate;
BOOL allowsAutomaticUpdates;
NSNumber *allowsAutomaticUpdatesOption = updaterSettings.allowsAutomaticUpdatesOption;
if (item.informationOnlyUpdate) {
allowsAutomaticUpdates = NO;
} else if (allowsAutomaticUpdatesOption == nil) {
allowsAutomaticUpdates = updaterSettings.automaticallyChecksForUpdates;
} else {
allowsAutomaticUpdates = allowsAutomaticUpdatesOption.boolValue;
}
_allowsAutomaticUpdates = allowsAutomaticUpdates;
[self setShouldCascadeWindows:NO];
} else {
assert(false);