Search in sources :

Example 1 with AppInfo

use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HighUsageDetectorTest method testDetect_containsHighUsageApp_tipVisibleAndSorted.

@Test
public void testDetect_containsHighUsageApp_tipVisibleAndSorted() {
    doReturn(true).when(mDataParser).isDeviceHeavilyUsed();
    final HighUsageTip highUsageTip = (HighUsageTip) mHighUsageDetector.detect();
    assertThat(highUsageTip.isVisible()).isTrue();
    // Contain two appInfo and large one comes first
    final List<AppInfo> appInfos = highUsageTip.getHighUsageAppList();
    assertThat(appInfos).containsExactly(mLowAppInfo, mHighAppInfo);
    assertThat(appInfos.get(0)).isEqualTo(mHighAppInfo);
}
Also used : HighUsageTip(com.android.settings.fuelgauge.batterytip.tips.HighUsageTip) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) Test(org.junit.Test)

Example 2 with AppInfo

use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
}
Also used : Parcel(android.os.Parcel) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) Test(org.junit.Test)

Example 3 with AppInfo

use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
}
Also used : AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) Before(org.junit.Before)

Example 4 with AppInfo

use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BackgroundActivityPreferenceController method showDialog.

@VisibleForTesting
void showDialog(boolean restricted) {
    final AppInfo appInfo = new AppInfo.Builder().setUid(mUid).setPackageName(mTargetPackage).build();
    BatteryTip tip = restricted ? new UnrestrictAppTip(BatteryTip.StateType.NEW, appInfo) : new RestrictAppTip(BatteryTip.StateType.NEW, appInfo);
    final BatteryTipDialogFragment dialogFragment = BatteryTipDialogFragment.newInstance(tip, mFragment.getMetricsCategory());
    dialogFragment.setTargetFragment(mFragment, 0);
    dialogFragment.show(mFragment.getFragmentManager(), TAG);
}
Also used : BatteryTipDialogFragment(com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment) RestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) UnrestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 5 with AppInfo

use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RestrictedAppDetails method onBatteryTipHandled.

@Override
public void onBatteryTipHandled(BatteryTip batteryTip) {
    final AppInfo appInfo;
    final boolean isRestricted = batteryTip instanceof RestrictAppTip;
    if (isRestricted) {
        appInfo = ((RestrictAppTip) batteryTip).getRestrictAppList().get(0);
    } else {
        appInfo = ((UnrestrictAppTip) batteryTip).getUnrestrictAppInfo();
    }
    CheckBoxPreference preference = (CheckBoxPreference) mRestrictedAppListGroup.findPreference(getKeyFromAppInfo(appInfo));
    if (preference != null) {
        preference.setChecked(isRestricted);
    }
}
Also used : CheckBoxPreference(androidx.preference.CheckBoxPreference) AppCheckBoxPreference(com.android.settings.widget.AppCheckBoxPreference) RestrictAppTip(com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo)

Aggregations

AppInfo (com.android.settings.fuelgauge.batterytip.AppInfo)15 Test (org.junit.Test)5 Parcel (android.os.Parcel)2 VisibleForTesting (androidx.annotation.VisibleForTesting)2 CheckBoxPreference (androidx.preference.CheckBoxPreference)2 BatteryTipDialogFragment (com.android.settings.fuelgauge.batterytip.BatteryTipDialogFragment)2 RestrictAppTip (com.android.settings.fuelgauge.batterytip.tips.RestrictAppTip)2 UnrestrictAppTip (com.android.settings.fuelgauge.batterytip.tips.UnrestrictAppTip)2 AppCheckBoxPreference (com.android.settings.widget.AppCheckBoxPreference)2 Before (org.junit.Before)2 Context (android.content.Context)1 Intent (android.content.Intent)1 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 Bundle (android.os.Bundle)1 SparseLongArray (android.util.SparseLongArray)1 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)1 HighUsageTip (com.android.settings.fuelgauge.batterytip.tips.HighUsageTip)1 ArrayList (java.util.ArrayList)1