Add database to store anomaly data
1. Refactor HighUsageApp to AppInfo so it could be reused both in dialog and app restriction 2. Add BatteryDatabaseHelper to store the anomaly log Bug: 70570352 Test: RunSettingsRoboTests Change-Id: I900cd9746ff7f1e19bd6f3948463588b7cf72b85
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.testutils;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
|
||||
import com.android.settings.search.IndexDatabaseHelper;
|
||||
import com.android.settings.slices.SlicesDatabaseHelper;
|
||||
|
||||
@@ -28,6 +29,7 @@ public class DatabaseTestUtils {
|
||||
public static void clearDb(Context context) {
|
||||
clearSearchDb(context);
|
||||
clearSlicesDb(context);
|
||||
clearAnomalyDb(context);
|
||||
}
|
||||
|
||||
private static void clearSlicesDb(Context context) {
|
||||
@@ -45,6 +47,21 @@ public class DatabaseTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static void clearAnomalyDb(Context context) {
|
||||
AnomalyDatabaseHelper helper = AnomalyDatabaseHelper.getInstance(context);
|
||||
helper.close();
|
||||
|
||||
Field instance;
|
||||
Class clazz = AnomalyDatabaseHelper.class;
|
||||
try {
|
||||
instance = clazz.getDeclaredField("sSingleton");
|
||||
instance.setAccessible(true);
|
||||
instance.set(null, null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
private static void clearSearchDb(Context context) {
|
||||
IndexDatabaseHelper helper = IndexDatabaseHelper.getInstance(context);
|
||||
helper.close();
|
||||
|
Reference in New Issue
Block a user