Add auto restriction for excessive background
If it is excessive bg anomaly and auto restriction is on, then restrict the anomaly in receiver and store it in database. Also in this cl we move the anomaly logic to a JobService, so all works are done in a background thread and won't interfere the main thread. Bug: 72385333 Test: RunSettingsRoboTests && Will add auto restriction test once robo framework is updated(b/73172999) Change-Id: Id0ec5fb449ce26bf19a292bcbe63838d621cfd8e
This commit is contained in:
@@ -60,18 +60,19 @@ public class BatteryDatabaseManager {
|
||||
|
||||
/**
|
||||
* Insert an anomaly log to database.
|
||||
*
|
||||
* @param packageName the package name of the app
|
||||
* @param type the type of the anomaly
|
||||
* @param timestampMs the time when it is happened
|
||||
* @param packageName the package name of the app
|
||||
* @param type the type of the anomaly
|
||||
* @param anomalyState the state of the anomaly
|
||||
* @param timestampMs the time when it is happened
|
||||
*/
|
||||
public synchronized void insertAnomaly(String packageName, int type, long timestampMs) {
|
||||
public synchronized void insertAnomaly(String packageName, int type, int anomalyState,
|
||||
long timestampMs) {
|
||||
try (SQLiteDatabase db = mDatabaseHelper.getWritableDatabase()) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(PACKAGE_NAME, packageName);
|
||||
values.put(ANOMALY_TYPE, type);
|
||||
values.put(ANOMALY_STATE, anomalyState);
|
||||
values.put(TIME_STAMP_MS, timestampMs);
|
||||
values.put(ANOMALY_STATE, AnomalyDatabaseHelper.State.NEW);
|
||||
db.insert(TABLE_ANOMALY, null, values);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user