@ -63,6 +63,9 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
[ logger addLoggingCallback : ^( NSString * category , id details , NSUInteger index ) {
[ logger addLoggingCallback : ^( NSString * category , id details , NSUInteger index ) {
} ] ;
} ] ;
/ / XXX - careful when moving this . It must happen before we initialize TSStorageManager .
[ self verifyDBKeysAvailableBeforeBackgroundLaunch ] ;
/ / Setting up environment
/ / Setting up environment
[ Environment setCurrent : [ Release releaseEnvironmentWithLogging : logger ] ] ;
[ Environment setCurrent : [ Release releaseEnvironmentWithLogging : logger ] ] ;
@ -88,7 +91,6 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
#elif RELEASE
#elif RELEASE
loggingIsEnabled = Environment . preferences . loggingIsEnabled ;
loggingIsEnabled = Environment . preferences . loggingIsEnabled ;
#endif
#endif
[ self verifyBackgroundBeforeKeysAvailableLaunch ] ;
if ( loggingIsEnabled ) {
if ( loggingIsEnabled ) {
[ DebugLogger . sharedLogger enableFileLogging ] ;
[ DebugLogger . sharedLogger enableFileLogging ] ;
@ -378,31 +380,23 @@ static NSString *const kURLHostVerifyPrefix = @"verify";
}
}
/ * *
/ * *
* Signal requires an iPhone to be unlocked after reboot to be able to access keying material .
* The user must unlock the device once after reboot before the database encryption key can be accessed .
* /
* /
- ( void ) verifyBackgroundBeforeKeysAvailableLaunch {
- ( void ) verifyDBKeysAvailableBeforeBackgroundLaunch
if ( [ self applicationIsActive ] ) {
{
if ( UIApplication . sharedApplication . applicationState != UIApplicationStateBackground ) {
return ;
return ;
}
}
if ( ![ [ TSStorageManager sharedManager ] d atabasePasswordAccessible] ) {
if ( [ TSStorageManager isD atabasePasswordAccessible] ) {
UILocalNotification * notification = [ [ UILocalNotification alloc ] init ] ;
UILocalNotification * notification = [ [ UILocalNotification alloc ] init ] ;
notification . alertBody = NSLocalizedString ( @ "PHONE_NEEDS_UNLOCK ", nil ) ;
notification . alertBody = NSLocalizedString ( @ "PHONE_NEEDS_UNLOCK ", nil ) ;
[ [ UIApplication sharedApplication ] presentLocalNotificationNow : notification ] ;
[ [ UIApplication sharedApplication ] presentLocalNotificationNow : notification ] ;
DDLogInfo ( @ "%@ exiting because we are in the background and the database password is not accessible.", self.tag);
exit ( 0 ) ;
exit ( 0 ) ;
}
}
}
}
- ( BOOL ) applicationIsActive {
UIApplication * app = [ UIApplication sharedApplication ] ;
if ( app . applicationState == UIApplicationStateActive ) {
return YES ;
}
return NO ;
}
#pragma mark - Logging
#pragma mark - Logging
+ ( NSString * ) tag
+ ( NSString * ) tag