From f5353fc7d530209d4a3b9c7bf4d86f57d85e2c80 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 5 Dec 2017 11:35:43 -0500 Subject: [PATCH] Clean up ahead of PR. --- Signal/src/AppDelegate.m | 20 ++++++++++++++++++- .../src/Storage/TSStorageManager.h | 2 -- .../src/Storage/TSStorageManager.m | 17 ---------------- .../ShareViewController.swift | 3 --- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 847bd4f00..ff3149e79 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -131,7 +131,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; SetRandFunctionSeed(); // XXX - careful when moving this. It must happen before we initialize TSStorageManager. - [TSStorageManager verifyDBKeysAvailableBeforeBackgroundLaunch]; + [self verifyDBKeysAvailableBeforeBackgroundLaunch]; // Prevent the device from sleeping during database view async registration // (e.g. long database upgrades). @@ -192,6 +192,24 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; return YES; } + +/** + * The user must unlock the device once after reboot before the database encryption key can be accessed. + */ +- (void)verifyDBKeysAvailableBeforeBackgroundLaunch +{ + if (CurrentAppContext().isMainApp && CurrentAppContext().mainApplicationState != UIApplicationStateBackground) { + return; + } + + if (![TSStorageManager isDatabasePasswordAccessible]) { + DDLogInfo( + @"%@ exiting because we are in the background and the database password is not accessible.", self.logTag); + [DDLog flushLog]; + exit(0); + } +} + - (void)ensureIsReadyForAppExtensions { if ([OWSPreferences isReadyForAppExtensions]) { diff --git a/SignalServiceKit/src/Storage/TSStorageManager.h b/SignalServiceKit/src/Storage/TSStorageManager.h index dd2cb30a4..753408f8e 100644 --- a/SignalServiceKit/src/Storage/TSStorageManager.h +++ b/SignalServiceKit/src/Storage/TSStorageManager.h @@ -65,8 +65,6 @@ NS_ASSUME_NONNULL_BEGIN + (void)migrateToSharedData; -+ (void)verifyDBKeysAvailableBeforeBackgroundLaunch; - @end NS_ASSUME_NONNULL_END diff --git a/SignalServiceKit/src/Storage/TSStorageManager.m b/SignalServiceKit/src/Storage/TSStorageManager.m index efe740d74..84f02f176 100644 --- a/SignalServiceKit/src/Storage/TSStorageManager.m +++ b/SignalServiceKit/src/Storage/TSStorageManager.m @@ -718,23 +718,6 @@ void setDatabaseInitialized() [TSAttachmentStream deleteAttachments]; } -/** - * The user must unlock the device once after reboot before the database encryption key can be accessed. - */ -+ (void)verifyDBKeysAvailableBeforeBackgroundLaunch -{ - if (CurrentAppContext().isMainApp && CurrentAppContext().mainApplicationState != UIApplicationStateBackground) { - return; - } - - if (![TSStorageManager isDatabasePasswordAccessible]) { - DDLogInfo( - @"%@ exiting because we are in the background and the database password is not accessible.", self.logTag); - [DDLog flushLog]; - exit(0); - } -} - @end NS_ASSUME_NONNULL_END diff --git a/SignalShareExtension/ShareViewController.swift b/SignalShareExtension/ShareViewController.swift index d5eb9f979..2b2a48617 100644 --- a/SignalShareExtension/ShareViewController.swift +++ b/SignalShareExtension/ShareViewController.swift @@ -33,9 +33,6 @@ public class ShareViewController: UINavigationController, SAELoadViewDelegate { SetRandFunctionSeed() - // XXX - careful when moving this. It must happen before we initialize TSStorageManager. - TSStorageManager.verifyDBKeysAvailableBeforeBackgroundLaunch() - // TODO: // // Prevent the device from sleeping during database view async registration // // (e.g. long database upgrades).