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

Commit e03111c6 authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

DeskClock: fix alarms database to prepare m1 to m2 transition

Fix the DeskClock database helper to avoid drop all alarms when incrementing from
version 5 to version 6 (http://review.cyanogenmod.org/#/c/31623/

).
This will happen on m1 to m2 transition.

Patchset 2: Simplified version

Change-Id: I6f01b42cf93701e441a8e3d9894e1ef414ff9327
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent eaa7f7a9
Loading
Loading
Loading
Loading
+12 −13
Original line number Diff line number Diff line
@@ -61,20 +61,19 @@ class AlarmDatabaseHelper extends SQLiteOpenHelper {
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion,
            int currentVersion) {
        if (Log.LOGV) Log.v(
                "Upgrading alarms database from version " +
                oldVersion + " to " + currentVersion +
                ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS alarms");
        onCreate(db);
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int currentVersion) {
        if (Log.LOGV) Log.v("Upgrading alarms database from version " + oldVersion + " to "
                + currentVersion);

        int upgradeVersion = oldVersion;

        if (upgradeVersion == 5) {
            db.execSQL("ALTER TABLE alarms ADD incvol INTEGER;");
            db.execSQL("UPDATE alarms SET incvol=0;");
            upgradeVersion = 6;
        }

    @Override
    public void onDowngrade(SQLiteDatabase db, int oldVersion,
            int currentVersion) {
        onUpgrade(db, oldVersion, currentVersion);
        if (Log.LOGV) Log.v("Alarms database upgrade done.");
    }

    Uri commonInsert(ContentValues values) {