Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow developer to always force allowing automatic updates #2266

Merged
merged 1 commit into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Sparkle/SPUUpdaterSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
8 changes: 7 additions & 1 deletion Sparkle/SPUUpdaterSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ - (NSTimeInterval)updateCheckInterval
}

// 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);
}

Expand Down
13 changes: 12 additions & 1 deletion Sparkle/SUUpdateAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ - (instancetype)initWithAppcastItem:(SUAppcastItem *)item state:(SPUUserUpdateSt
_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);
Expand Down