use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
the class UnrestrictAppTipTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME).build();
mBatteryTip = new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
the class HighUsageTipTest method testParcelable.
@Test
public void testParcelable() {
Parcel parcel = Parcel.obtain();
mBatteryTip.writeToParcel(parcel, mBatteryTip.describeContents());
parcel.setDataPosition(0);
final HighUsageTip parcelTip = new HighUsageTip(parcel);
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Higher battery usage");
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
assertThat(parcelTip.getLastFullChargeTimeMs()).isEqualTo(LAST_FULL_CHARGE_TIME);
assertThat(parcelTip.mHighUsageAppList).isNotNull();
assertThat(parcelTip.mHighUsageAppList.size()).isEqualTo(1);
final AppInfo app = parcelTip.mHighUsageAppList.get(0);
assertThat(app.packageName).isEqualTo(PACKAGE_NAME);
assertThat(app.screenOnTimeMs).isEqualTo(SCREEN_TIME);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
the class RestrictAppTipTest method parcelable.
@Test
public void parcelable() {
Parcel parcel = Parcel.obtain();
mNewBatteryTip.writeToParcel(parcel, mNewBatteryTip.describeContents());
parcel.setDataPosition(0);
final RestrictAppTip parcelTip = new RestrictAppTip(parcel);
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.APP_RESTRICTION);
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
final AppInfo app = parcelTip.getRestrictAppList().get(0);
assertThat(app.packageName).isEqualTo(PACKAGE_NAME);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
the class UnrestrictAppActionTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final AppInfo appInfo = new AppInfo.Builder().setUid(UID_1).setPackageName(PACKAGE_NAME_1).build();
mFeatureFactory = FakeFeatureFactory.setupForTest();
mUnrestrictAppAction = new UnrestrictAppAction(RuntimeEnvironment.application, new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo));
mUnrestrictAppAction.mBatteryUtils = mBatteryUtils;
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
the class RestrictAppAction method handlePositiveAction.
/**
* Handle the action when user clicks positive button
*/
@Override
public void handlePositiveAction(int metricsKey) {
final List<AppInfo> appInfos = mRestrictAppTip.getRestrictAppList();
for (int i = 0, size = appInfos.size(); i < size; i++) {
final AppInfo appInfo = appInfos.get(i);
final String packageName = appInfo.packageName;
// Force app standby, then app can't run in the background
mBatteryUtils.setForceAppStandby(appInfo.uid, packageName, AppOpsManager.MODE_IGNORED);
if (CollectionUtils.isEmpty(appInfo.anomalyTypes)) {
// Only log context if there is no anomaly type
mMetricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_TIP_RESTRICT_APP, metricsKey, packageName, 0);
} else {
for (int type : appInfo.anomalyTypes) {
mMetricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_TIP_RESTRICT_APP, metricsKey, packageName, type);
}
}
}
mBatteryDatabaseManager.updateAnomalies(appInfos, AnomalyDatabaseHelper.State.HANDLED);
}
Aggregations