Refactor anomaly detection
This cl refactor it so: 1. AnomayLoader could create its own BatteryStatsHelper if needed. 2. AnomalyDetector could detect the anomaly with a target package name 3. Remove FeatureProvider in AnomalyLoader and use AnomalyDetectionPolicy instead With this cl, we could add anomaly detection to battery usage page more easily. Bug: 36924669 Test: RunSettingsRoboTests Change-Id: I1ee09701de8b5c8855f44e447813760285794c89
This commit is contained in:
@@ -41,6 +41,7 @@ import java.util.List;
|
||||
* Utils for battery operation
|
||||
*/
|
||||
public class BatteryUtils {
|
||||
public static final int UID_NULL = -1;
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({StatusType.FOREGROUND,
|
||||
StatusType.BACKGROUND,
|
||||
@@ -274,6 +275,22 @@ public class BatteryUtils {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find package uid from package name
|
||||
*
|
||||
* @param packageName used to find the uid
|
||||
* @return uid for packageName, or {@link #UID_NULL} if exception happens or
|
||||
* {@code packageName} is null
|
||||
*/
|
||||
public int getPackageUid(String packageName) {
|
||||
try {
|
||||
return packageName == null ? UID_NULL : mPackageManager.getPackageUid(packageName,
|
||||
PackageManager.GET_META_DATA);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return UID_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
public long convertUsToMs(long timeUs) {
|
||||
return timeUs / 1000;
|
||||
}
|
||||
|
Reference in New Issue
Block a user