Distinguish initiated vs scheduled updates for allowing interaction

This commit is contained in:
Zorg committed 2016-08-21 15:58:33 -04:00
1 parent 6a8680464b
commit b1fa9efa24
2 files changed
+45 -11

No files matched your search

+19 -8
View File
@@ -434,7 +434,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
updaterDelegate:strongSelf.delegate];
}
[strongSelf checkForUpdatesWithDriver:updateDriver installerInProgress:installerIsRunning];
BOOL preventsInstallerInteraction;
if ([strongSelf.delegate respondsToSelector:@selector(updaterShouldAllowInstallerInteractionForScheduledChecks:)]) {
preventsInstallerInteraction = ![strongSelf.delegate updaterShouldAllowInstallerInteractionForScheduledChecks:strongSelf];
} else {
preventsInstallerInteraction = NO;
}
[strongSelf checkForUpdatesWithDriver:updateDriver installerInProgress:installerIsRunning preventsInstallerInteraction:preventsInstallerInteraction];
});
}];
}
@@ -461,7 +468,14 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
dispatch_async(dispatch_get_main_queue(), ^{
SPUUpdater *strongSelf = weakSelf;
if (strongSelf != nil) {
[strongSelf checkForUpdatesWithDriver:theUpdateDriver installerInProgress:installerInProgress];
BOOL preventsInstallerInteraction;
if ([strongSelf.delegate respondsToSelector:@selector(updaterShouldAllowInstallerInteractionForInitiatedChecks:)]) {
preventsInstallerInteraction = ![strongSelf.delegate updaterShouldAllowInstallerInteractionForInitiatedChecks:strongSelf];
} else {
preventsInstallerInteraction = NO;
}
[strongSelf checkForUpdatesWithDriver:theUpdateDriver installerInProgress:installerInProgress preventsInstallerInteraction:preventsInstallerInteraction];
}
});
}];
@@ -483,13 +497,13 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
dispatch_async(dispatch_get_main_queue(), ^{
SPUUpdater *strongSelf = weakSelf;
if (strongSelf != nil) {
[strongSelf checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithHost:strongSelf.host updater:strongSelf updaterDelegate:strongSelf.delegate] installerInProgress:installerInProgress];
[strongSelf checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithHost:strongSelf.host updater:strongSelf updaterDelegate:strongSelf.delegate] installerInProgress:installerInProgress preventsInstallerInteraction:NO];
}
});
}];
}
- (void)checkForUpdatesWithDriver:(id <SUUpdateDriver> )d installerInProgress:(BOOL)installerInProgress
- (void)checkForUpdatesWithDriver:(id <SUUpdateDriver> )d installerInProgress:(BOOL)installerInProgress preventsInstallerInteraction:(BOOL)preventsInstallerInteraction
{
if (self.driver != nil) {
return;
@@ -551,10 +565,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
} else if (self.resumableUpdate != nil) {
[self.driver resumeDownloadedUpdate:(SUDownloadedUpdate * _Nonnull)self.resumableUpdate completion:completionBlock];
} else {
BOOL allowsInstallerInteraction =
(![self.delegate respondsToSelector:@selector(updaterShouldAllowInstallerInteraction:)] || [self.delegate updaterShouldAllowInstallerInteraction:self]);
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders] preventingInstallerInteraction:!allowsInstallerInteraction completion:completionBlock];
[self.driver checkForUpdatesAtAppcastURL:theFeedURL withUserAgent:[self userAgentString] httpHeaders:[self httpHeaders] preventingInstallerInteraction:preventsInstallerInteraction completion:completionBlock];
}
} else {
// I think this is really unlikely to occur but better be safe
+26 -3
View File
@@ -232,19 +232,42 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
- (nullable id<SUVersionComparison>)versionComparatorForUpdater:(SPUUpdater *)updater;
/*!
Returns whether or not the updater should allow interaction with its installer
Returns whether or not the updater should allow interaction from the installer for scheduled checks
Use this to override the default behavior which is to allow interaction with the installer.
This method applies to updates started in the background
If interaction is allowed, then an authorization prompt may show up to the user if they do
not curently have sufficient privileges to perform the installation of the new update.
On the other hand, if interaction is not allowed, then an installation may fail if the user does not
have sufficient privileges to perform the installation.
have sufficient privileges to perform the installation. In this case, the feed and update may not even be downloaded.
Note this has no effect if the update has already been downloaded in the background silently and ready to be resumed.
\param updater The updater instance.
*/
- (BOOL)updaterShouldAllowInstallerInteraction:(SPUUpdater *)updater;
- (BOOL)updaterShouldAllowInstallerInteractionForScheduledChecks:(SPUUpdater *)updater;
/*!
Returns whether or not the updater should allow interaction from the installer for user initiated checks
Use this to override the default behavior which is to allow interaction with the installer.
This method applies to updates started from -[SPUUpdater checkForUpdates]
If interaction is allowed, then an authorization prompt may show up to the user if they do
not curently have sufficient privileges to perform the installation of the new update.
On the other hand, if interaction is not allowed, then an installation may fail if the user does not
have sufficient privileges to perform the installation. In this case, the feed and update may not even be downloaded.
Note this has no effect if the update has already been downloaded in the background silently and ready to be resumed.
\param updater The updater instance.
*/
- (BOOL)updaterShouldAllowInstallerInteractionForInitiatedChecks:(SPUUpdater *)updater;
/*!
Returns the decryption password (if any) which is used to extract the update archive DMG.