Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76e2a5a1 authored by Dmitry Dementyev's avatar Dmitry Dementyev Committed by Android (Google) Code Review
Browse files

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

parents 2fa848da d8c138bb
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -128,18 +128,14 @@ public class RecoverableKeyStoreManager {
    public static synchronized RecoverableKeyStoreManager
            getInstance(Context context) {
        if (mInstance == null) {
            RecoverableKeyStoreDb db;
            RecoverableKeyStoreDb db = RecoverableKeyStoreDb.newInstance(context);
            RemoteLockscreenValidationSessionStorage lockscreenCheckSessions;
            if (FeatureFlagUtils.isEnabled(context,
                    FeatureFlagUtils.SETTINGS_ENABLE_LOCKSCREEN_TRANSFER_API)) {
                // TODO(b/254335492): Remove flag check when feature is launched.
                db = RecoverableKeyStoreDb.newInstance(context, 7);
                lockscreenCheckSessions = new RemoteLockscreenValidationSessionStorage();
            } else {
                db = RecoverableKeyStoreDb.newInstance(context);
                lockscreenCheckSessions = null;
            }

            PlatformKeyManager platformKeyManager;
            ApplicationKeyStorage applicationKeyStorage;
            try {
+0 −12
Original line number Diff line number Diff line
@@ -78,18 +78,6 @@ public class RecoverableKeyStoreDb {
        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) {
        this.mKeyStoreDbHelper = keyStoreDbHelper;
        this.mTestOnlyInsecureCertificateHelper = new TestOnlyInsecureCertificateHelper();
+2 −12
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ class RecoverableKeyStoreDbHelper extends SQLiteOpenHelper {
    private static final String TAG = "RecoverableKeyStoreDbHp";

    // v6 - added user id serial number.
    static final int DATABASE_VERSION = 6;
    // v7 - added bad guess counter for remote LSKF check;
    static final int DATABASE_VERSION_7 = 7;
    private static final String DATABASE_NAME = "recoverablekeystore.db";
@@ -118,23 +117,14 @@ class RecoverableKeyStoreDbHelper extends SQLiteOpenHelper {
        super(context, DATABASE_NAME, null, getDbVersion(context));
    }

    RecoverableKeyStoreDbHelper(Context context, int version) {
        super(context, DATABASE_NAME, null, version);
    }

    private static int getDbVersion(Context context) {
        // TODO(b/254335492): Update to version 7 and clean up code.
        return DATABASE_VERSION;
        return DATABASE_VERSION_7;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        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_RECOVERY_SERVICE_METADATA_ENTRY);
        db.execSQL(SQL_CREATE_ROOT_OF_TRUST_ENTRY);
    }
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public class RecoverableKeyStoreDbHelperTest {
    @Before
    public void setUp() throws Exception {
        Context context = InstrumentationRegistry.getTargetContext();
        mDatabaseHelper = new RecoverableKeyStoreDbHelper(context, 7);
        mDatabaseHelper = new RecoverableKeyStoreDbHelper(context);
        mDatabase = SQLiteDatabase.create(null);
    }

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

    @After