Remove LockInteractionController.

This commit is contained in:
Matthew Chen 2019-01-08 11:25:03 -05:00
parent 517458dc63
commit c0922fc2c0
10 changed files with 7 additions and 204 deletions

View file

@ -186,12 +186,10 @@
34AC09EE211B39B100997B47 /* EditContactShareNameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D0211B39B000997B47 /* EditContactShareNameViewController.swift */; };
34AC09EF211B39B100997B47 /* ViewControllerUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D1211B39B000997B47 /* ViewControllerUtils.m */; };
34AC09F0211B39B100997B47 /* AttachmentApprovalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D2211B39B000997B47 /* AttachmentApprovalViewController.swift */; };
34AC09F1211B39B100997B47 /* LockInteractionController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D3211B39B000997B47 /* LockInteractionController.h */; settings = {ATTRIBUTES = (Public, ); }; };
34AC09F2211B39B100997B47 /* OWSViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D4211B39B000997B47 /* OWSViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
34AC09F3211B39B100997B47 /* NewNonContactConversationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D5211B39B100997B47 /* NewNonContactConversationViewController.m */; };
34AC09F4211B39B100997B47 /* SelectThreadViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D6211B39B100997B47 /* SelectThreadViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
34AC09F5211B39B100997B47 /* SharingThreadPickerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09D7211B39B100997B47 /* SharingThreadPickerViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
34AC09F6211B39B100997B47 /* LockInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D8211B39B100997B47 /* LockInteractionController.m */; };
34AC09F7211B39B100997B47 /* MediaMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09D9211B39B100997B47 /* MediaMessageView.swift */; };
34AC09F8211B39B100997B47 /* CountryCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34AC09DA211B39B100997B47 /* CountryCodeViewController.m */; };
34AC09F9211B39B100997B47 /* CountryCodeViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 34AC09DB211B39B100997B47 /* CountryCodeViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -854,12 +852,10 @@
34AC09D0211B39B000997B47 /* EditContactShareNameViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditContactShareNameViewController.swift; sourceTree = "<group>"; };
34AC09D1211B39B000997B47 /* ViewControllerUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewControllerUtils.m; sourceTree = "<group>"; };
34AC09D2211B39B000997B47 /* AttachmentApprovalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentApprovalViewController.swift; sourceTree = "<group>"; };
34AC09D3211B39B000997B47 /* LockInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LockInteractionController.h; sourceTree = "<group>"; };
34AC09D4211B39B000997B47 /* OWSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSViewController.h; sourceTree = "<group>"; };
34AC09D5211B39B100997B47 /* NewNonContactConversationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewNonContactConversationViewController.m; sourceTree = "<group>"; };
34AC09D6211B39B100997B47 /* SelectThreadViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectThreadViewController.h; sourceTree = "<group>"; };
34AC09D7211B39B100997B47 /* SharingThreadPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharingThreadPickerViewController.h; sourceTree = "<group>"; };
34AC09D8211B39B100997B47 /* LockInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LockInteractionController.m; sourceTree = "<group>"; };
34AC09D9211B39B100997B47 /* MediaMessageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaMessageView.swift; sourceTree = "<group>"; };
34AC09DA211B39B100997B47 /* CountryCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CountryCodeViewController.m; sourceTree = "<group>"; };
34AC09DB211B39B100997B47 /* CountryCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CountryCodeViewController.h; sourceTree = "<group>"; };
@ -2061,8 +2057,6 @@
34AC09DB211B39B100997B47 /* CountryCodeViewController.h */,
34AC09DA211B39B100997B47 /* CountryCodeViewController.m */,
34AC09D0211B39B000997B47 /* EditContactShareNameViewController.swift */,
34AC09D3211B39B000997B47 /* LockInteractionController.h */,
34AC09D8211B39B100997B47 /* LockInteractionController.m */,
34AC09D9211B39B100997B47 /* MediaMessageView.swift */,
34AC09C9211B39AF00997B47 /* MessageApprovalViewController.swift */,
34AC09CC211B39B000997B47 /* ModalActivityIndicatorViewController.swift */,
@ -2630,7 +2624,6 @@
346129951FD1E30000532771 /* OWSDatabaseMigration.h in Headers */,
34B6D27420F664C900765BE2 /* OWSUnreadIndicator.h in Headers */,
34AC09E4211B39B100997B47 /* ScreenLockViewController.h in Headers */,
34AC09F1211B39B100997B47 /* LockInteractionController.h in Headers */,
346129B41FD1F7E800532771 /* OWSProfileManager.h in Headers */,
342950892124CB0A0000B063 /* OWSSearchBar.h in Headers */,
346941A1215D2EE400B5BFAD /* Theme.h in Headers */,
@ -3345,7 +3338,6 @@
34AC0A1F211B39EA00997B47 /* AvatarImageView.swift in Sources */,
3466087220E550F400AFFE73 /* ConversationStyle.swift in Sources */,
3478506B1FD9B78A007B8332 /* NoopCallMessageHandler.swift in Sources */,
34AC09F6211B39B100997B47 /* LockInteractionController.m in Sources */,
346129AD1FD1F34E00532771 /* ImageCache.swift in Sources */,
452C7CA72037628B003D51A5 /* Weak.swift in Sources */,
34D5872F208E2C4200D2255A /* OWS109OutgoingMessageState.m in Sources */,

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "Environment.h"
@ -15,7 +15,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) OWSContactsManager *contactsManager;
@property (nonatomic) OWSPreferences *preferences;
@property (nonatomic) OWSSounds *sounds;
@property (nonatomic) LockInteractionController *lockInteractionController;
@property (nonatomic) OWSWindowManager *windowManager;
@end

View file

@ -1,11 +1,10 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "MockEnvironment.h"
#import "OWSBackup.h"
#import "OWSWindowManager.h"
#import <SignalMessaging/LockInteractionController.h>
#import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/SignalMessaging-Swift.h>
@ -28,14 +27,12 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: We should probably mock this out.
OWSAudioSession *audioSession = [OWSAudioSession new];
LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault];
OWSPreferences *preferences = [OWSPreferences new];
OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage];
id<OWSProximityMonitoringManager> proximityMonitoringManager = [OWSProximityMonitoringManagerImpl new];
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
self = [super initWithAudioSession:audioSession
lockInteractionController:lockInteractionController
preferences:preferences
proximityMonitoringManager:proximityMonitoringManager
sounds:sounds

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>
@ -20,7 +20,6 @@ FOUNDATION_EXPORT const unsigned char SignalMessagingVersionString[];
#import <SignalMessaging/CountryCodeViewController.h>
#import <SignalMessaging/DebugLogger.h>
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/LockInteractionController.h>
#import <SignalMessaging/NSAttributedString+OWS.h>
#import <SignalMessaging/NewNonContactConversationViewController.h>
#import <SignalMessaging/OWSAnyTouchGestureRecognizer.h>

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "AppSetup.h"
@ -92,11 +92,9 @@ NS_ASSUME_NONNULL_BEGIN
OWSAudioSession *audioSession = [OWSAudioSession new];
OWSSounds *sounds = [[OWSSounds alloc] initWithPrimaryStorage:primaryStorage];
id<OWSProximityMonitoringManager> proximityMonitoringManager = [OWSProximityMonitoringManagerImpl new];
LockInteractionController *lockInteractionController = [[LockInteractionController alloc] initDefault];
OWSWindowManager *windowManager = [[OWSWindowManager alloc] initDefault];
[Environment setShared:[[Environment alloc] initWithAudioSession:audioSession
lockInteractionController:lockInteractionController
preferences:preferences
proximityMonitoringManager:proximityMonitoringManager
sounds:sounds

View file

@ -1,10 +1,9 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import <SignalServiceKit/SSKEnvironment.h>
@class LockInteractionController;
@class OWSAudioSession;
@class OWSContactsManager;
@class OWSPreferences;
@ -26,7 +25,6 @@
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithAudioSession:(OWSAudioSession *)audioSession
lockInteractionController:(LockInteractionController *)lockInteractionController
preferences:(OWSPreferences *)preferences
proximityMonitoringManager:(id<OWSProximityMonitoringManager>)proximityMonitoringManager
sounds:(OWSSounds *)sounds
@ -34,7 +32,6 @@
@property (nonatomic, readonly) OWSAudioSession *audioSession;
@property (nonatomic, readonly) OWSContactsManager *contactsManager;
@property (nonatomic, readonly) LockInteractionController *lockInteractionController;
@property (nonatomic, readonly) id<OWSProximityMonitoringManager> proximityMonitoringManager;
@property (nonatomic, readonly) OWSPreferences *preferences;
@property (nonatomic, readonly) OWSSounds *sounds;

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "Environment.h"
@ -13,7 +13,6 @@ static Environment *sharedEnvironment = nil;
@property (nonatomic) OWSAudioSession *audioSession;
@property (nonatomic) OWSContactsManager *contactsManager;
@property (nonatomic) LockInteractionController *lockInteractionController;
@property (nonatomic) OWSPreferences *preferences;
@property (nonatomic) id<OWSProximityMonitoringManager> proximityMonitoringManager;
@property (nonatomic) OWSSounds *sounds;
@ -50,7 +49,6 @@ static Environment *sharedEnvironment = nil;
}
- (instancetype)initWithAudioSession:(OWSAudioSession *)audioSession
lockInteractionController:(LockInteractionController *)lockInteractionController
preferences:(OWSPreferences *)preferences
proximityMonitoringManager:(id<OWSProximityMonitoringManager>)proximityMonitoringManager
sounds:(OWSSounds *)sounds
@ -62,14 +60,12 @@ static Environment *sharedEnvironment = nil;
}
OWSAssertDebug(audioSession);
OWSAssertDebug(lockInteractionController);
OWSAssertDebug(preferences);
OWSAssertDebug(proximityMonitoringManager);
OWSAssertDebug(sounds);
OWSAssertDebug(windowManager);
_audioSession = audioSession;
_lockInteractionController = lockInteractionController;
_preferences = preferences;
_proximityMonitoringManager = proximityMonitoringManager;
_sounds = sounds;

View file

@ -1,10 +1,9 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "VersionMigrations.h"
#import "Environment.h"
#import "LockInteractionController.h"
#import "OWSDatabaseMigrationRunner.h"
#import "SignalKeyingStorage.h"
#import <SignalServiceKit/AppContext.h>
@ -86,7 +85,6 @@ NS_ASSUME_NONNULL_BEGIN
if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.1.70"] && [self.tsAccountManager isRegistered]) {
[self clearVideoCache];
[self blockingAttributesUpdate];
}
if ([self isVersion:previousVersion atLeast:@"2.0.0" andLessThan:@"2.3.0"] && [self.tsAccountManager isRegistered]) {
@ -135,49 +133,6 @@ NS_ASSUME_NONNULL_BEGIN
}
}
#pragma mark - Update Account Attributes
+ (void)blockingAttributesUpdate
{
LIControllerBlockingOperation blockingOperation = ^BOOL(void) {
[[NSUserDefaults appUserDefaults] setObject:@YES forKey:NEEDS_TO_REGISTER_ATTRIBUTES];
__block dispatch_semaphore_t sema = dispatch_semaphore_create(0);
__block BOOL success;
TSRequest *request = [OWSRequestFactory updateAttributesRequest];
[[TSNetworkManager sharedManager] makeRequest:request
success:^(NSURLSessionDataTask *task, id responseObject) {
success = YES;
dispatch_semaphore_signal(sema);
}
failure:^(NSURLSessionDataTask *task, NSError *error) {
if (!IsNSErrorNetworkFailure(error)) {
OWSProdError([OWSAnalyticsEvents errorUpdateAttributesRequestFailed]);
}
success = NO;
OWSLogError(@"Updating attributess failed with error: %@", error.description);
dispatch_semaphore_signal(sema);
}];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
return success;
};
LIControllerRetryBlock retryBlock = [LockInteractionController defaultNetworkRetry];
[LockInteractionController performBlock:blockingOperation
completionBlock:^{
[[NSUserDefaults appUserDefaults] removeObjectForKey:NEEDS_TO_REGISTER_ATTRIBUTES];
OWSLogWarn(@"Successfully updated attributes.");
}
retryBlock:retryBlock
usesNetwork:YES];
}
#pragma mark Upgrading to 2.3.0
// We removed bloom filter contact discovery. Clean up any local bloom filter data.

View file

@ -1,22 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
@interface LockInteractionController : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initDefault NS_DESIGNATED_INITIALIZER;
typedef void (^LIControllerCompletionBlock)(void);
typedef BOOL (^LIControllerBlockingOperation)(void);
typedef void (^LIControllerRetryBlock)(
LIControllerBlockingOperation operationBlock, LIControllerCompletionBlock completionBlock);
+ (void)performBlock:(LIControllerBlockingOperation)blockingOperation
completionBlock:(LIControllerCompletionBlock)completionBlock
retryBlock:(LIControllerRetryBlock)retryBlock
usesNetwork:(BOOL)networkFlag;
+ (LIControllerRetryBlock)defaultNetworkRetry;
@end

View file

@ -1,108 +0,0 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "LockInteractionController.h"
#import "Environment.h"
#import <SignalServiceKit/AppContext.h>
@interface LockInteractionController ()
@property (nonatomic) UIAlertController *alertController;
@end
#pragma mark -
@implementation LockInteractionController
+ (instancetype)sharedController
{
OWSAssertDebug(Environment.shared.lockInteractionController);
return Environment.shared.lockInteractionController;
}
- (instancetype)initDefault {
self = [super init];
if (!self) {
return self;
}
OWSAssertIsOnMainThread();
OWSSingletonAssert();
return self;
}
+ (void)performBlock:(LIControllerBlockingOperation)blockingOperation
completionBlock:(LIControllerCompletionBlock)completionBlock
retryBlock:(LIControllerRetryBlock)retryBlock
usesNetwork:(BOOL)networkFlag
{
if (networkFlag) {
[CurrentAppContext() setNetworkActivityIndicatorVisible:networkFlag];
}
LockInteractionController *sharedController = [LockInteractionController sharedController];
sharedController.alertController =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"Upgrading Signal ...", nil)
message:nil
preferredStyle:UIAlertControllerStyleAlert];
[CurrentAppContext().frontmostViewController presentViewController:sharedController.alertController
animated:YES
completion:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
BOOL success = blockingOperation();
dispatch_async(dispatch_get_main_queue(), ^{
[sharedController.alertController
dismissViewControllerAnimated:YES
completion:^{
if (networkFlag) {
[CurrentAppContext() setNetworkActivityIndicatorVisible:NO];
}
if (!success) {
retryBlock(blockingOperation, completionBlock);
} else {
completionBlock();
}
}];
});
});
}
+ (LIControllerRetryBlock)defaultNetworkRetry
{
LIControllerRetryBlock retryBlock = ^void(
LIControllerBlockingOperation blockingOperation, LIControllerCompletionBlock completionBlock) {
UIAlertController *retryController =
[UIAlertController alertControllerWithTitle:@"Upgrading Signal failed"
message:@"An network error occured while upgrading, please check "
@"your connectivity and try again."
preferredStyle:UIAlertControllerStyleAlert];
[retryController
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"REGISTER_FAILED_TRY_AGAIN", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[self performBlock:blockingOperation
completionBlock:completionBlock
retryBlock:[LockInteractionController defaultNetworkRetry]
usesNetwork:YES];
}]];
[CurrentAppContext().frontmostViewController presentViewController:retryController animated:YES completion:nil];
};
return retryBlock;
}
@end