Merge "Remove unnecessary flag check from RecoverableKeystoreDb." into udc-dev

This commit is contained in:
Dmitry Dementyev
2023-05-09 15:36:10 +00:00
committed by Android (Google) Code Review
5 changed files with 5 additions and 31 deletions

View File

@@ -128,18 +128,14 @@ public class RecoverableKeyStoreManager {
public static synchronized RecoverableKeyStoreManager public static synchronized RecoverableKeyStoreManager
getInstance(Context context) { getInstance(Context context) {
if (mInstance == null) { if (mInstance == null) {
RecoverableKeyStoreDb db; RecoverableKeyStoreDb db = RecoverableKeyStoreDb.newInstance(context);
RemoteLockscreenValidationSessionStorage lockscreenCheckSessions; RemoteLockscreenValidationSessionStorage lockscreenCheckSessions;
if (FeatureFlagUtils.isEnabled(context, if (FeatureFlagUtils.isEnabled(context,
FeatureFlagUtils.SETTINGS_ENABLE_LOCKSCREEN_TRANSFER_API)) { FeatureFlagUtils.SETTINGS_ENABLE_LOCKSCREEN_TRANSFER_API)) {
// TODO(b/254335492): Remove flag check when feature is launched.
db = RecoverableKeyStoreDb.newInstance(context, 7);
lockscreenCheckSessions = new RemoteLockscreenValidationSessionStorage(); lockscreenCheckSessions = new RemoteLockscreenValidationSessionStorage();
} else { } else {
db = RecoverableKeyStoreDb.newInstance(context);
lockscreenCheckSessions = null; lockscreenCheckSessions = null;
} }
PlatformKeyManager platformKeyManager; PlatformKeyManager platformKeyManager;
ApplicationKeyStorage applicationKeyStorage; ApplicationKeyStorage applicationKeyStorage;
try { try {

View File

@@ -78,18 +78,6 @@ public class RecoverableKeyStoreDb {
return new RecoverableKeyStoreDb(helper); return new RecoverableKeyStoreDb(helper);
} }
/**
* A new instance, storing the database in the user directory of {@code context}.
*
* @hide
*/
public static RecoverableKeyStoreDb newInstance(Context context, int version) {
RecoverableKeyStoreDbHelper helper = new RecoverableKeyStoreDbHelper(context, version);
helper.setWriteAheadLoggingEnabled(true);
helper.setIdleConnectionTimeout(IDLE_TIMEOUT_SECONDS);
return new RecoverableKeyStoreDb(helper);
}
private RecoverableKeyStoreDb(RecoverableKeyStoreDbHelper keyStoreDbHelper) { private RecoverableKeyStoreDb(RecoverableKeyStoreDbHelper keyStoreDbHelper) {
this.mKeyStoreDbHelper = keyStoreDbHelper; this.mKeyStoreDbHelper = keyStoreDbHelper;
this.mTestOnlyInsecureCertificateHelper = new TestOnlyInsecureCertificateHelper(); this.mTestOnlyInsecureCertificateHelper = new TestOnlyInsecureCertificateHelper();

View File

@@ -34,7 +34,6 @@ class RecoverableKeyStoreDbHelper extends SQLiteOpenHelper {
private static final String TAG = "RecoverableKeyStoreDbHp"; private static final String TAG = "RecoverableKeyStoreDbHp";
// v6 - added user id serial number. // v6 - added user id serial number.
static final int DATABASE_VERSION = 6;
// v7 - added bad guess counter for remote LSKF check; // v7 - added bad guess counter for remote LSKF check;
static final int DATABASE_VERSION_7 = 7; static final int DATABASE_VERSION_7 = 7;
private static final String DATABASE_NAME = "recoverablekeystore.db"; private static final String DATABASE_NAME = "recoverablekeystore.db";
@@ -118,23 +117,14 @@ class RecoverableKeyStoreDbHelper extends SQLiteOpenHelper {
super(context, DATABASE_NAME, null, getDbVersion(context)); super(context, DATABASE_NAME, null, getDbVersion(context));
} }
RecoverableKeyStoreDbHelper(Context context, int version) {
super(context, DATABASE_NAME, null, version);
}
private static int getDbVersion(Context context) { private static int getDbVersion(Context context) {
// TODO(b/254335492): Update to version 7 and clean up code. return DATABASE_VERSION_7;
return DATABASE_VERSION;
} }
@Override @Override
public void onCreate(SQLiteDatabase db) { public void onCreate(SQLiteDatabase db) {
db.execSQL(SQL_CREATE_KEYS_ENTRY); db.execSQL(SQL_CREATE_KEYS_ENTRY);
if (db.getVersion() == 6) { // always false
db.execSQL(SQL_CREATE_USER_METADATA_ENTRY);
} else {
db.execSQL(SQL_CREATE_USER_METADATA_ENTRY_FOR_V7); db.execSQL(SQL_CREATE_USER_METADATA_ENTRY_FOR_V7);
}
db.execSQL(SQL_CREATE_RECOVERY_SERVICE_METADATA_ENTRY); db.execSQL(SQL_CREATE_RECOVERY_SERVICE_METADATA_ENTRY);
db.execSQL(SQL_CREATE_ROOT_OF_TRUST_ENTRY); db.execSQL(SQL_CREATE_ROOT_OF_TRUST_ENTRY);
} }

View File

@@ -104,7 +104,7 @@ public class RecoverableKeyStoreDbHelperTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
Context context = InstrumentationRegistry.getTargetContext(); Context context = InstrumentationRegistry.getTargetContext();
mDatabaseHelper = new RecoverableKeyStoreDbHelper(context, 7); mDatabaseHelper = new RecoverableKeyStoreDbHelper(context);
mDatabase = SQLiteDatabase.create(null); mDatabase = SQLiteDatabase.create(null);
} }

View File

@@ -67,7 +67,7 @@ public class RecoverableKeyStoreDbTest {
public void setUp() { public void setUp() {
Context context = InstrumentationRegistry.getTargetContext(); Context context = InstrumentationRegistry.getTargetContext();
mDatabaseFile = context.getDatabasePath(DATABASE_FILE_NAME); mDatabaseFile = context.getDatabasePath(DATABASE_FILE_NAME);
mRecoverableKeyStoreDb = RecoverableKeyStoreDb.newInstance(context, 7); mRecoverableKeyStoreDb = RecoverableKeyStoreDb.newInstance(context);
} }
@After @After