From aa4fea64cf6c95c6a4c0884c299eb6fc4d84346a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 3 Dec 2018 08:56:31 -0500 Subject: [PATCH 1/2] Improve Profiles Debug UI. --- .../ViewControllers/DebugUI/DebugUIProfile.swift | 5 +++++ SignalMessaging/profiles/OWSProfileManager.m | 1 + .../src/Network/WebSockets/OWSWebSocket.m | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIProfile.swift b/Signal/src/ViewControllers/DebugUI/DebugUIProfile.swift index ce718ddaa..5377de584 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIProfile.swift +++ b/Signal/src/ViewControllers/DebugUI/DebugUIProfile.swift @@ -35,6 +35,11 @@ class DebugUIProfile: DebugUIPage { OWSTableItem(title: "Log User Profiles") { profileManager.logUserProfiles() }, + OWSTableItem(title: "Log Profile Key") { + let localProfileKey = profileManager.localProfileKey() + Logger.info("localProfileKey: \(localProfileKey.keyData.hexadecimalString)") + profileManager.logUserProfiles() + }, OWSTableItem(title: "Regenerate Profile/ProfileKey") { profileManager.regenerateLocalProfile() }, diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 87648e85c..7c2534de1 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -851,6 +851,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error); { OWSUserProfile *userProfile = self.localUserProfile; [userProfile clearWithProfileKey:[OWSAES256Key generateRandomKey] dbConnection:self.dbConnection completion:nil]; + [self.tsAccountManager updateAccountAttributes]; } - (void)addUserToProfileWhitelist:(NSString *)recipientId diff --git a/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m b/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m index ea06c5272..eef3e96ab 100644 --- a/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m +++ b/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m @@ -741,6 +741,17 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O } } +- (dispatch_queue_t)serialQueue +{ + static dispatch_queue_t _serialQueue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _serialQueue = dispatch_queue_create("org.signal.websocket", DISPATCH_QUEUE_SERIAL); + }); + + return _serialQueue; +} + - (void)processWebSocketRequestMessage:(WebSocketProtoWebSocketRequestMessage *)message { OWSAssertIsOnMainThread(); @@ -756,7 +767,7 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O __block OWSBackgroundTask *_Nullable backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__]; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + dispatch_async(self.serialQueue, ^{ BOOL success = NO; @try { NSData *_Nullable decryptedPayload = From 4ea920e89f250884e3d37fc185cc9eebcc69086a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 3 Dec 2018 08:46:58 -0500 Subject: [PATCH 2/2] Add explicit feature flag for backup. --- .../AppSettings/AppSettingsViewController.m | 14 +------------- Signal/src/util/OWSBackup.h | 2 ++ Signal/src/util/OWSBackup.m | 9 +++++++++ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index d376dd3de..8108ce847 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -193,20 +193,8 @@ actionBlock:^{ [weakSelf showAdvanced]; }]]; - // Show backup UI in debug builds OR if backup has already been enabled. - // - // NOTE: Backup format is not yet finalized and backups are not yet - // properly encrypted, so these debug backups should only be - // done on test devices and will not be usable if/when we ship - // backup to production. - // - // TODO: Always show backup when we go to production. BOOL isBackupEnabled = [OWSBackup.sharedManager isBackupEnabled]; - BOOL showBackup = isBackupEnabled; - SUPPRESS_DEADSTORE_WARNING(showBackup); -#ifdef DEBUG - showBackup = YES; -#endif + BOOL showBackup = (OWSBackup.isFeatureEnabled && isBackupEnabled); if (showBackup) { [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BACKUP", @"Label for the backup view in app settings.") diff --git a/Signal/src/util/OWSBackup.h b/Signal/src/util/OWSBackup.h index ddcdb2552..7ce526b2e 100644 --- a/Signal/src/util/OWSBackup.h +++ b/Signal/src/util/OWSBackup.h @@ -44,6 +44,8 @@ typedef NS_ENUM(NSUInteger, OWSBackupState) { @property (nonatomic, readonly, nullable) NSString *backupExportDescription; @property (nonatomic, readonly, nullable) NSNumber *backupExportProgress; ++ (BOOL)isFeatureEnabled; + - (BOOL)isBackupEnabled; - (void)setIsBackupEnabled:(BOOL)value; diff --git a/Signal/src/util/OWSBackup.m b/Signal/src/util/OWSBackup.m index 27651eedb..22c05dade 100644 --- a/Signal/src/util/OWSBackup.m +++ b/Signal/src/util/OWSBackup.m @@ -107,6 +107,11 @@ NS_ASSUME_NONNULL_BEGIN }); } ++ (BOOL)isFeatureEnabled +{ + return NO; +} + #pragma mark - Backup Export - (void)tryToExportBackup @@ -251,6 +256,10 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssertIsOnMainThread(); + if (!OWSBackup.isFeatureEnabled) { + return; + } + // Start or abort a backup export if neccessary. if (!self.shouldHaveBackupExport && self.backupExportJob) { [self.backupExportJob cancel];