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

Commit 3e720972 authored by Remi NGUYEN VAN's avatar Remi NGUYEN VAN
Browse files

Add warning comments regarding downgrades

The current downgrade code may have a bug, and at least
is not covered by enough testing.
This is fine as long as the database version does not change
(it has been the same since Q), but the schema needs to be
frozen until downgrades are properly tested.

Downgrades were not expected to be necessary, but due to
a bug in at least Q and R, applications using device-encrypted
storage may not have their device-encrypted data directory
rolled back on package rollback, so the database downgrade
code would be run.

Bug: 171340630
Change-Id: Ice41f756a1824869b95cf509361f17d083f7ecbf
Test: m
parent 7c07695f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -147,6 +147,8 @@ public class IpMemoryStoreDatabase {
    /** The SQLite DB helper */
    public static class DbHelper extends SQLiteOpenHelper {
        // Update this whenever changing the schema.
        // DO NOT CHANGE without solid testing for downgrades, and checking onDowngrade
        // below: b/171340630
        private static final int SCHEMA_VERSION = 4;
        private static final String DATABASE_FILENAME = "IpMemoryStore.db";
        private static final String TRIGGER_NAME = "delete_cascade_to_private";
@@ -202,6 +204,10 @@ public class IpMemoryStoreDatabase {
            // Downgrades always nuke all data and recreate an empty table.
            db.execSQL(NetworkAttributesContract.DROP_TABLE);
            db.execSQL(PrivateDataContract.DROP_TABLE);
            // TODO: add test for downgrades. Triggers should already be dropped
            // when the table is dropped, so this may be a bug.
            // Note that fixing this code does not affect how older versions
            // will handle downgrades.
            db.execSQL("DROP TRIGGER " + TRIGGER_NAME);
            onCreate(db);
        }