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

Commit 7d424b6c authored by John Spurlock's avatar John Spurlock
Browse files

On db upgrade, reset ringer mode to normal.

When users upgrade to L, don't restore into a state that would force
zen mode to follow suit.  A user's first encounter with zen mode
should be via the UI.

Bug:16826161
Change-Id: I4eb63dce37d88f3a91b5034b3393eed2b768562c
parent fbc3f198
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
    // database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
    // is properly propagated through your change.  Not doing so will result in a loss of user
    // settings.
    private static final int DATABASE_VERSION = 110;
    private static final int DATABASE_VERSION = 111;

    private Context mContext;
    private int mUserHandle;
@@ -1770,6 +1770,24 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            upgradeVersion = 110;
        }

        if (upgradeVersion < 111) {
            // reset ringer mode, so it doesn't force zen mode to follow
            if (mUserHandle == UserHandle.USER_OWNER) {
                db.beginTransaction();
                SQLiteStatement stmt = null;
                try {
                    stmt = db.compileStatement("INSERT OR REPLACE INTO global(name,value)"
                            + " VALUES(?,?);");
                    loadSetting(stmt, Settings.Global.MODE_RINGER, AudioManager.RINGER_MODE_NORMAL);
                    db.setTransactionSuccessful();
                } finally {
                    db.endTransaction();
                    if (stmt != null) stmt.close();
                }
            }
            upgradeVersion = 111;
        }

        // *** Remember to update DATABASE_VERSION above!

        if (upgradeVersion != currentVersion) {