Add test for anomaly detection in P
Lot of tests have been added already, this CL adds the missing tests after robolectric upgrade. Also add UID_NULL check in AnomalyDetectionJobService. It is almost impossible to happen however we better catch it. Bug: 73172999 Test: RunSettingsRoboTests Change-Id: I950537efb166b0900393df1321ca64151b43e906
This commit is contained in:
@@ -59,9 +59,11 @@ import java.util.concurrent.TimeUnit;
|
||||
/** A JobService to store anomaly data to anomaly database */
|
||||
public class AnomalyDetectionJobService extends JobService {
|
||||
private static final String TAG = "AnomalyDetectionService";
|
||||
private static final int UID_NULL = 0;
|
||||
private static final int STATSD_UID_FILED = 1;
|
||||
private static final int ON = 1;
|
||||
@VisibleForTesting
|
||||
static final int UID_NULL = -1;
|
||||
@VisibleForTesting
|
||||
static final int STATSD_UID_FILED = 1;
|
||||
|
||||
@VisibleForTesting
|
||||
static final long MAX_DELAY_MS = TimeUnit.MINUTES.toMillis(30);
|
||||
@@ -143,7 +145,8 @@ public class AnomalyDetectionJobService extends JobService {
|
||||
: Settings.Global.getInt(contentResolver,
|
||||
Settings.Global.APP_AUTO_RESTRICTION_ENABLED, ON) == ON;
|
||||
final String packageName = batteryUtils.getPackageName(uid);
|
||||
if (!isSystemUid(uid) && !powerWhitelistBackend.isSysWhitelistedExceptIdle(
|
||||
if (uid != UID_NULL && !isSystemUid(uid)
|
||||
&& !powerWhitelistBackend.isSysWhitelistedExceptIdle(
|
||||
packageManager.getPackagesForUid(uid))) {
|
||||
boolean anomalyDetected = true;
|
||||
if (anomalyInfo.anomalyType
|
||||
@@ -191,7 +194,6 @@ public class AnomalyDetectionJobService extends JobService {
|
||||
*/
|
||||
@VisibleForTesting
|
||||
int extractUidFromStatsDimensionsValue(StatsDimensionsValue statsDimensionsValue) {
|
||||
//TODO(b/73172999): Add robo test for this method
|
||||
if (statsDimensionsValue == null) {
|
||||
return UID_NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user