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

Commit fe53015b authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Update default for auto-brightness." into honeycomb

parents 6c191768 f50c5113
Loading
Loading
Loading
Loading
+22 −13
Original line number Diff line number Diff line
@@ -61,7 +61,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 = 62;
    private static final int DATABASE_VERSION = 63;

    private Context mContext;

@@ -441,18 +441,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
        }

        if (upgradeVersion == 39) {
            db.beginTransaction();
            try {
                String value =
                        mContext.getResources().getBoolean(
                        R.bool.def_screen_brightness_automatic_mode) ? "1" : "0";
                db.execSQL("INSERT OR IGNORE INTO system(name,value) values('" +
                        Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');");
                db.setTransactionSuccessful();
            } finally {
                db.endTransaction();
            }

            upgradeAutoBrightness(db);
            upgradeVersion = 40;
        }

@@ -802,6 +791,12 @@ public class DatabaseHelper extends SQLiteOpenHelper {
            upgradeVersion = 62;
        }

        // Change the default for screen auto-brightness mode
        if (upgradeVersion == 62) {
            upgradeAutoBrightness(db);
            upgradeVersion = 63;
        }

        // *** Remember to update DATABASE_VERSION above!

        if (upgradeVersion != currentVersion) {
@@ -924,6 +919,20 @@ public class DatabaseHelper extends SQLiteOpenHelper {
        }
    }

    private void upgradeAutoBrightness(SQLiteDatabase db) {
        db.beginTransaction();
        try {
            String value =
                    mContext.getResources().getBoolean(
                    R.bool.def_screen_brightness_automatic_mode) ? "1" : "0";
            db.execSQL("INSERT OR REPLACE INTO system(name,value) values('" +
                    Settings.System.SCREEN_BRIGHTNESS_MODE + "','" + value + "');");
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    }

    /**
     * Loads the default set of bookmarked shortcuts from an xml file.
     *