use of com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryFixSliceTest method updateBatteryTipAvailabilityCache_hasImportantTip_shouldReturnTrue.
@Test
public void updateBatteryTipAvailabilityCache_hasImportantTip_shouldReturnTrue() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
ShadowBatteryTipLoader.setBatteryTips(tips);
BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
assertThat(BatteryFixSlice.isBatteryTipAvailableFromCache(mContext)).isTrue();
}
use of com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip in project android_packages_apps_Settings by omnirom.
the class EarlyWarningDetector method detect.
@Override
public BatteryTip detect() {
final Intent batteryBroadcast = mContext.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
final boolean discharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
final boolean powerSaveModeOn = mPowerManager.isPowerSaveMode();
final boolean earlyWarning = mPowerUsageFeatureProvider.getEarlyWarningSignal(mContext, EarlyWarningDetector.class.getName()) || mPolicy.testBatterySaverTip;
final int state = powerSaveModeOn ? BatteryTip.StateType.INVISIBLE : mPolicy.batterySaverTipEnabled && discharging && earlyWarning ? BatteryTip.StateType.NEW : BatteryTip.StateType.INVISIBLE;
return new EarlyWarningTip(state, powerSaveModeOn);
}
use of com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip in project android_packages_apps_Settings by omnirom.
the class BatteryFixSliceTest method getSlice_unimportantSlice_shouldSkip.
@Test
public void getSlice_unimportantSlice_shouldSkip() {
final List<BatteryTip> tips = new ArrayList<>();
final List<AppInfo> appList = new ArrayList<>();
appList.add(new AppInfo.Builder().setPackageName("com.android.settings").setScreenOnTimeMs(10000L).build());
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false));
tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false));
tips.add(new HighUsageTip(1000L, appList));
ShadowBatteryTipLoader.setBatteryTips(tips);
BatteryFixSlice.refreshBatteryTips(mContext);
final Slice slice = mSlice.getSlice();
assertThat(SliceMetadata.from(mContext, slice).isErrorSlice()).isTrue();
}
Aggregations