Search in sources :

Example 11 with AppInfo

use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.

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 12 with AppInfo

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

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

Example 13 with AppInfo

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

the class RestrictedAppDetailsTest method startRestrictedAppDetails_startWithCorrectData.

@Test
public void startRestrictedAppDetails_startWithCorrectData() {
    final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
    doAnswer(invocation -> {
        // Get the intent in which it has the app info bundle
        mIntent = captor.getValue();
        return true;
    }).when(mContext).startActivity(captor.capture());
    RestrictedAppDetails.startRestrictedAppDetails(mFragment, mRestrictedAppDetails.mAppInfos);
    final Bundle bundle = mIntent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
    // Verify the bundle has the correct info
    final List<AppInfo> appInfos = bundle.getParcelableArrayList(RestrictedAppDetails.EXTRA_APP_INFO_LIST);
    assertThat(appInfos).containsExactly(mAppInfo);
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) Test(org.junit.Test)

Example 14 with AppInfo

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

the class BatteryDatabaseManagerTest method updateAnomalies_updateSuccessfully.

@Test
public void updateAnomalies_updateSuccessfully() {
    mBatteryDatabaseManager.insertAnomaly(UID_NEW, PACKAGE_NAME_NEW, TYPE_NEW, AnomalyDatabaseHelper.State.NEW, NOW);
    mBatteryDatabaseManager.insertAnomaly(UID_OLD, PACKAGE_NAME_OLD, TYPE_OLD, AnomalyDatabaseHelper.State.NEW, NOW);
    final AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME_OLD).build();
    final List<AppInfo> updateAppInfos = new ArrayList<>();
    updateAppInfos.add(appInfo);
    // Change state of PACKAGE_NAME_OLD to handled
    mBatteryDatabaseManager.updateAnomalies(updateAppInfos, AnomalyDatabaseHelper.State.HANDLED);
    // The state of PACKAGE_NAME_NEW is still new
    List<AppInfo> newAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE, AnomalyDatabaseHelper.State.NEW);
    assertThat(newAppInfos).containsExactly(mNewAppInfo);
    // The state of PACKAGE_NAME_OLD is changed to handled
    List<AppInfo> handledAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE, AnomalyDatabaseHelper.State.HANDLED);
    assertThat(handledAppInfos).containsExactly(mOldAppInfo);
}
Also used : ArrayList(java.util.ArrayList) AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo) Test(org.junit.Test)

Example 15 with AppInfo

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

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

Aggregations

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