Search in sources :

Example 6 with AppInfo

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

the class HighUsageTip method toString.

@Override
public String toString() {
    final StringBuilder stringBuilder = new StringBuilder(super.toString());
    stringBuilder.append(" {");
    for (int i = 0, size = mHighUsageAppList.size(); i < size; i++) {
        final AppInfo appInfo = mHighUsageAppList.get(i);
        stringBuilder.append(" " + appInfo.toString() + " ");
    }
    stringBuilder.append('}');
    return stringBuilder.toString();
}
Also used : AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo)

Example 7 with AppInfo

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

the class UnrestrictAppAction method handlePositiveAction.

/**
 * Handle the action when user clicks positive button
 */
@Override
public void handlePositiveAction(int metricsKey) {
    final AppInfo appInfo = mUnRestrictAppTip.getUnrestrictAppInfo();
    // Clear force app standby, then app can run in the background
    mBatteryUtils.setForceAppStandby(appInfo.uid, appInfo.packageName, AppOpsManager.MODE_ALLOWED);
    mMetricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN, SettingsEnums.ACTION_TIP_UNRESTRICT_APP, metricsKey, appInfo.packageName, 0);
}
Also used : AppInfo(com.android.settings.fuelgauge.batterytip.AppInfo)

Example 8 with AppInfo

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

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)

Example 9 with AppInfo

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

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

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

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)

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