We need to know if the DB password is accessible *before* we init the db

So method can't be *on* the instance.

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent dd1aa26827
commit a45ab9fe40

@ -1,9 +1,5 @@
//
// TSStorageManager.h
// TextSecureKit
//
// Created by Frederic Jacobs on 27/10/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSStorageKeys.h"
@ -21,9 +17,17 @@ extern NSString *const TSUIDatabaseConnectionDidUpdateNotification;
@interface TSStorageManager : NSObject
+ (instancetype)sharedManager;
/**
* Returns NO if:
*
* - Keychain is locked because device has just been restarted.
* - Password could not be retrieved because of a keychain error.
*/
+ (BOOL)isDatabasePasswordAccessible;
- (void)setupDatabase;
- (void)deleteThreadsAndMessages;
- (BOOL)databasePasswordAccessible;
- (void)resetSignalStorage;
- (YapDatabase *)database;

@ -1,6 +1,4 @@
//
// TSStorageManager.m
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
@ -23,7 +21,8 @@
NSString *const TSUIDatabaseConnectionDidUpdateNotification = @"TSUIDatabaseConnectionDidUpdateNotification";
NSString *const TSStorageManagerExceptionNameDatabasePasswordInaccessible = @"TSStorageManagerExceptionNameDatabasePasswordInaccessible";
NSString *const TSStorageManagerExceptionNameDatabasePasswordInaccessibleWhileBackgrounded = @"TSStorageManagerExceptionNameDatabasePasswordInaccessibleWhileBackgrounded";
NSString *const TSStorageManagerExceptionNameDatabasePasswordInaccessibleWhileBackgrounded =
@"TSStorageManagerExceptionNameDatabasePasswordInaccessibleWhileBackgrounded";
NSString *const TSStorageManagerExceptionNameDatabasePasswordUnwritable = @"TSStorageManagerExceptionNameDatabasePasswordUnwritable";
NSString *const TSStorageManagerExceptionNameNoDatabase = @"TSStorageManagerExceptionNameNoDatabase";
@ -271,7 +270,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass";
return databasePath;
}
- (BOOL)databasePasswordAccessible
+ (BOOL)isDatabasePasswordAccessible
{
[SAMKeychain setAccessibilityType:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly];
NSError *error;

Loading…
Cancel
Save