Search in sources :

Example 6 with EarlyWarningTip

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();
}
Also used : EarlyWarningTip(com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip) ArrayList(java.util.ArrayList) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) Test(org.junit.Test)

Example 7 with EarlyWarningTip

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);
}
Also used : EarlyWarningTip(com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent)

Example 8 with EarlyWarningTip

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();
}
Also used : EarlyWarningTip(com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip) HighUsageTip(com.android.settings.fuelgauge.batterytip.tips.HighUsageTip) Slice(androidx.slice.Slice) ArrayList(java.util.ArrayList) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) LowBatteryTip(com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) Test(org.junit.Test)

Aggregations

EarlyWarningTip (com.android.settings.fuelgauge.batterytip.tips.EarlyWarningTip)8 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)6 LowBatteryTip (com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 Slice (androidx.slice.Slice)4 Intent (android.content.Intent)2 IntentFilter (android.content.IntentFilter)2 Config (org.robolectric.annotation.Config)2 AppInfo (com.android.settings.fuelgauge.batterytip.AppInfo)1 HighUsageTip (com.android.settings.fuelgauge.batterytip.tips.HighUsageTip)1