use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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);
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class HighUsageTip method log.
@Override
public void log(Context context, MetricsFeatureProvider metricsFeatureProvider) {
metricsFeatureProvider.action(context, SettingsEnums.ACTION_HIGH_USAGE_TIP, mState);
for (int i = 0, size = mHighUsageAppList.size(); i < size; i++) {
final AppInfo appInfo = mHighUsageAppList.get(i);
metricsFeatureProvider.action(context, SettingsEnums.ACTION_HIGH_USAGE_TIP_LIST, appInfo.packageName);
}
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictAppTip method toString.
@Override
public String toString() {
final StringBuilder stringBuilder = new StringBuilder(super.toString());
stringBuilder.append(" {");
for (int i = 0, size = mRestrictAppList.size(); i < size; i++) {
final AppInfo appInfo = mRestrictAppList.get(i);
stringBuilder.append(" " + appInfo.toString() + " ");
}
stringBuilder.append('}');
return stringBuilder.toString();
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RestrictedAppDetails method refreshUi.
@VisibleForTesting
void refreshUi() {
mRestrictedAppListGroup.removeAll();
final Context context = getPrefContext();
final SparseLongArray timestampArray = mBatteryDatabaseManager.queryActionTime(AnomalyDatabaseHelper.ActionType.RESTRICTION);
final long now = System.currentTimeMillis();
for (int i = 0, size = mAppInfos.size(); i < size; i++) {
final CheckBoxPreference checkBoxPreference = new AppCheckBoxPreference(context);
final AppInfo appInfo = mAppInfos.get(i);
try {
final ApplicationInfo applicationInfo = mPackageManager.getApplicationInfoAsUser(appInfo.packageName, 0, /* flags */
UserHandle.getUserId(appInfo.uid));
checkBoxPreference.setChecked(mBatteryUtils.isForceAppStandbyEnabled(appInfo.uid, appInfo.packageName));
checkBoxPreference.setTitle(mPackageManager.getApplicationLabel(applicationInfo));
checkBoxPreference.setIcon(Utils.getBadgedIcon(mIconDrawableFactory, mPackageManager, appInfo.packageName, UserHandle.getUserId(appInfo.uid)));
checkBoxPreference.setKey(getKeyFromAppInfo(appInfo));
checkBoxPreference.setOnPreferenceChangeListener((pref, value) -> {
final BatteryTipDialogFragment fragment = createDialogFragment(appInfo, (Boolean) value);
fragment.setTargetFragment(this, 0);
fragment.show(getFragmentManager(), TAG);
return false;
});
final long timestamp = timestampArray.get(appInfo.uid, TIME_NULL);
if (timestamp != TIME_NULL) {
checkBoxPreference.setSummary(getString(R.string.restricted_app_time_summary, StringUtil.formatRelativeTime(context, now - timestamp, false)));
}
final CharSequence test = checkBoxPreference.getSummaryOn();
mRestrictedAppListGroup.addPreference(checkBoxPreference);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Can't find package: " + appInfo.packageName);
}
}
}
use of com.android.settings.fuelgauge.batterytip.AppInfo in project android_packages_apps_Settings by omnirom.
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);
}
Aggregations