Upgrade the anomaly database.

Add one column for the table. Since the database is not offically
used, we can just simply delete and recreate it.

Bug: 72385333
Test: Build
Change-Id: If999dbccbf168b05f98af5ab389c9e2cbb5ad2e8
This commit is contained in:
jackqdyulei
2018-02-12 16:14:48 -08:00
parent 4f6d667ac4
commit ea153abe27

View File

@@ -19,10 +19,14 @@ package com.android.settings.fuelgauge.batterytip;
import android.content.Context; import android.content.Context;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.support.annotation.IntDef;
import android.util.Log; import android.util.Log;
import com.android.settings.fuelgauge.anomaly.Anomaly; import com.android.settings.fuelgauge.anomaly.Anomaly;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/** /**
* Database controls the anomaly logging(e.g. packageName, anomalyType and time) * Database controls the anomaly logging(e.g. packageName, anomalyType and time)
*/ */
@@ -30,7 +34,17 @@ public class AnomalyDatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = "BatteryDatabaseHelper"; private static final String TAG = "BatteryDatabaseHelper";
private static final String DATABASE_NAME = "battery_settings.db"; private static final String DATABASE_NAME = "battery_settings.db";
private static final int DATABASE_VERSION = 1; private static final int DATABASE_VERSION = 2;
@Retention(RetentionPolicy.SOURCE)
@IntDef({State.NEW,
State.HANDLED,
State.AUTO_HANDLED})
public @interface State {
int NEW = 0;
int HANDLED = 1;
int AUTO_HANDLED = 2;
}
public interface Tables { public interface Tables {
String TABLE_ANOMALY = "anomaly"; String TABLE_ANOMALY = "anomaly";
@@ -46,6 +60,11 @@ public class AnomalyDatabaseHelper extends SQLiteOpenHelper {
* @see Anomaly.AnomalyType * @see Anomaly.AnomalyType
*/ */
String ANOMALY_TYPE = "anomaly_type"; String ANOMALY_TYPE = "anomaly_type";
/**
* The state of the anomaly app
* @see State
*/
String ANOMALY_STATE = "anomaly_state";
/** /**
* The time when anomaly happens * The time when anomaly happens
*/ */
@@ -59,6 +78,8 @@ public class AnomalyDatabaseHelper extends SQLiteOpenHelper {
" TEXT, " + " TEXT, " +
AnomalyColumns.ANOMALY_TYPE + AnomalyColumns.ANOMALY_TYPE +
" INTEGER, " + " INTEGER, " +
AnomalyColumns.ANOMALY_STATE +
" INTEGER, " +
AnomalyColumns.TIME_STAMP_MS + AnomalyColumns.TIME_STAMP_MS +
" INTEGER)"; " INTEGER)";