Merge "Remove PowerUsageFeatureProvider.isAnomalyDetectionEnabled" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
74a350f9c9
@@ -62,11 +62,6 @@ public interface PowerUsageFeatureProvider {
|
||||
*/
|
||||
boolean isPowerAccountingToggleEnabled();
|
||||
|
||||
/**
|
||||
* Check whether the anomaly detection is enabled
|
||||
*/
|
||||
boolean isAnomalyDetectionEnabled();
|
||||
|
||||
/**
|
||||
* Returns an improved prediction for battery time remaining.
|
||||
*/
|
||||
@@ -87,12 +82,6 @@ public interface PowerUsageFeatureProvider {
|
||||
*/
|
||||
long getTimeRemainingEstimate(Cursor cursor);
|
||||
|
||||
/**
|
||||
* Check whether a specific anomaly detector is enabled
|
||||
*/
|
||||
//TODO(b/62096650): remove this method and use AnomalyDetectionPolicy instead
|
||||
boolean isAnomalyDetectorEnabled(@Anomaly.AnomalyType int type);
|
||||
|
||||
/**
|
||||
* Checks whether debugging should be enabled for battery estimates.
|
||||
* @return
|
||||
|
@@ -88,11 +88,6 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnomalyDetectionEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEnhancedBatteryPrediction(Context context) {
|
||||
return -1;
|
||||
@@ -113,11 +108,6 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnomalyDetectorEnabled(@Anomaly.AnomalyType int type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnhancedEstimateDebugString(String timeRemaining) {
|
||||
return null;
|
||||
|
@@ -63,6 +63,7 @@ import com.android.settings.display.AutoBrightnessPreferenceController;
|
||||
import com.android.settings.display.BatteryPercentagePreferenceController;
|
||||
import com.android.settings.display.TimeoutPreferenceController;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyDialogFragment.AnomalyDialogListener;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyLoader;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalySummaryPreferenceController;
|
||||
@@ -661,11 +662,16 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
|
||||
@VisibleForTesting
|
||||
void initAnomalyDetectionIfPossible() {
|
||||
if (mPowerFeatureProvider.isAnomalyDetectionEnabled()) {
|
||||
if (getAnomalyDetectionPolicy().isAnomalyDetectionEnabled()) {
|
||||
getLoaderManager().initLoader(ANOMALY_LOADER, Bundle.EMPTY, mAnomalyLoaderCallbacks);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
AnomalyDetectionPolicy getAnomalyDetectionPolicy() {
|
||||
return new AnomalyDetectionPolicy(getContext());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
BatterySipper findBatterySipperByType(List<BatterySipper> usageList, DrainType type) {
|
||||
for (int i = 0, size = usageList.size(); i < size; i++) {
|
||||
|
@@ -51,7 +51,7 @@ public class AnomalyDetectionPolicy {
|
||||
* @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
|
||||
* @see #KEY_ANOMALY_DETECTION_ENABLED
|
||||
*/
|
||||
public final boolean anomalyDetectionEnabled;
|
||||
final boolean anomalyDetectionEnabled;
|
||||
|
||||
/**
|
||||
* {@code true} if wakelock anomaly detection is enabled
|
||||
@@ -59,7 +59,7 @@ public class AnomalyDetectionPolicy {
|
||||
* @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
|
||||
* @see #KEY_WAKELOCK_DETECTION_ENABLED
|
||||
*/
|
||||
public final boolean wakeLockDetectionEnabled;
|
||||
final boolean wakeLockDetectionEnabled;
|
||||
|
||||
/**
|
||||
* {@code true} if wakeup alarm detection is enabled
|
||||
@@ -67,7 +67,7 @@ public class AnomalyDetectionPolicy {
|
||||
* @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
|
||||
* @see #KEY_WAKEUP_ALARM_DETECTION_ENABLED
|
||||
*/
|
||||
public final boolean wakeupAlarmDetectionEnabled;
|
||||
final boolean wakeupAlarmDetectionEnabled;
|
||||
|
||||
/**
|
||||
* {@code true} if bluetooth scanning detection is enabled
|
||||
@@ -75,7 +75,7 @@ public class AnomalyDetectionPolicy {
|
||||
* @see Settings.Global#ANOMALY_DETECTION_CONSTANTS
|
||||
* @see #KEY_BLUETOOTH_SCAN_THRESHOLD
|
||||
*/
|
||||
public final boolean bluetoothScanDetectionEnabled;
|
||||
final boolean bluetoothScanDetectionEnabled;
|
||||
|
||||
/**
|
||||
* Threshold for wakelock time in milli seconds
|
||||
@@ -132,6 +132,10 @@ public class AnomalyDetectionPolicy {
|
||||
30 * DateUtils.MINUTE_IN_MILLIS);
|
||||
}
|
||||
|
||||
public boolean isAnomalyDetectionEnabled() {
|
||||
return anomalyDetectionEnabled;
|
||||
}
|
||||
|
||||
public boolean isAnomalyDetectorEnabled(@Anomaly.AnomalyType int type) {
|
||||
switch (type) {
|
||||
case Anomaly.AnomalyType.WAKE_LOCK:
|
||||
|
@@ -39,6 +39,7 @@ import com.android.internal.os.BatteryStatsHelper;
|
||||
import com.android.internal.os.BatteryStatsImpl;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.fuelgauge.anomaly.AnomalyDetectionPolicy;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.Utils;
|
||||
@@ -151,6 +152,8 @@ public class PowerUsageSummaryTest {
|
||||
private PreferenceScreen mPreferenceScreen;
|
||||
@Mock
|
||||
private PreferenceGroup mAppListGroup;
|
||||
@Mock
|
||||
private AnomalyDetectionPolicy mAnomalyDetectionPolicy;
|
||||
|
||||
private List<BatterySipper> mUsageList;
|
||||
private Context mRealContext;
|
||||
@@ -463,9 +466,9 @@ public class PowerUsageSummaryTest {
|
||||
|
||||
@Test
|
||||
public void testInitAnomalyDetectionIfPossible_detectionEnabled_init() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isAnomalyDetectionEnabled()).thenReturn(
|
||||
true);
|
||||
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
||||
doReturn(mAnomalyDetectionPolicy).when(mFragment).getAnomalyDetectionPolicy();
|
||||
when(mAnomalyDetectionPolicy.isAnomalyDetectionEnabled()).thenReturn(true);
|
||||
|
||||
mFragment.initAnomalyDetectionIfPossible();
|
||||
|
||||
|
Reference in New Issue
Block a user