use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryUtils method smearScreenBatterySipper.
/**
* Smear the screen on power usage among {@code sippers}, based on ratio of foreground activity
* time.
*/
@VisibleForTesting
void smearScreenBatterySipper(List<BatterySipper> sippers, BatterySipper screenSipper) {
long totalActivityTimeMs = 0;
final SparseLongArray activityTimeArray = new SparseLongArray();
for (int i = 0, size = sippers.size(); i < size; i++) {
final BatteryStats.Uid uid = sippers.get(i).uidObj;
if (uid != null) {
final long timeMs = getProcessTimeMs(StatusType.SCREEN_USAGE, uid, BatteryStats.STATS_SINCE_CHARGED);
activityTimeArray.put(uid.getUid(), timeMs);
totalActivityTimeMs += timeMs;
}
}
if (totalActivityTimeMs >= 10 * DateUtils.MINUTE_IN_MILLIS) {
if (screenSipper == null) {
Log.e(TAG, "screen sipper is null even when app screen time is not zero");
return;
}
final double screenPowerMah = screenSipper.totalPowerMah;
for (int i = 0, size = sippers.size(); i < size; i++) {
final BatterySipper sipper = sippers.get(i);
sipper.totalPowerMah += screenPowerMah * activityTimeArray.get(sipper.getUid(), 0) / totalActivityTimeMs;
}
}
}
use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PowerUsageSummary method initFeatureProvider.
@VisibleForTesting
void initFeatureProvider() {
final Context context = getContext();
mPowerFeatureProvider = FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
}
use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PowerUsageSummary method updateHeaderPreference.
@VisibleForTesting
void updateHeaderPreference(BatteryInfo info) {
final Context context = getContext();
if (context == null) {
return;
}
final BatteryMeterView batteryView = (BatteryMeterView) mBatteryLayoutPref.findViewById(R.id.battery_header_icon);
final TextView timeText = (TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent);
final TextView summary1 = (TextView) mBatteryLayoutPref.findViewById(R.id.summary1);
if (info.remainingLabel == null) {
summary1.setText(info.statusLabel);
} else {
summary1.setText(info.remainingLabel);
}
batteryView.setCharging(!info.discharging);
batteryView.setPowerSave(mPowerManager.isPowerSaveMode());
startBatteryHeaderAnimationIfNecessary(batteryView, timeText, mBatteryLevel, info.batteryLevel);
}
use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RenameMobileNetworkDialogFragment method populateView.
@VisibleForTesting
protected void populateView(View view) {
mNameView = view.findViewById(R.id.name_edittext);
final SubscriptionInfo info = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
if (info == null) {
Log.w(TAG, "got null SubscriptionInfo for mSubId:" + mSubId);
return;
}
final CharSequence displayName = info.getDisplayName();
mNameView.setText(displayName);
if (!TextUtils.isEmpty(displayName)) {
mNameView.setSelection(displayName.length());
}
mColorSpinner = view.findViewById(R.id.color_spinner);
final ColorAdapter adapter = new ColorAdapter(getContext(), R.layout.dialog_mobile_network_color_picker_item, mColors);
mColorSpinner.setAdapter(adapter);
for (int i = 0; i < mColors.length; i++) {
if (mColors[i].getColor() == info.getIconTint()) {
mColorSpinner.setSelection(i);
break;
}
}
final TextView operatorName = view.findViewById(R.id.operator_name_value);
final ServiceState serviceState = mTelephonyManager.getServiceStateForSubscriber(mSubId);
operatorName.setText(serviceState.getOperatorAlphaLong());
final TextView phoneTitle = view.findViewById(R.id.number_label);
phoneTitle.setVisibility(info.isOpportunistic() ? View.GONE : View.VISIBLE);
final TextView phoneNumber = view.findViewById(R.id.number_value);
final String formattedNumber = DeviceInfoUtils.getFormattedPhoneNumber(getContext(), info);
phoneNumber.setText(BidiFormatter.getInstance().unicodeWrap(formattedNumber, TextDirectionHeuristics.LTR));
}
use of androidx.annotation.VisibleForTesting in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class RoamingPreferenceController method isDialogNeeded.
@VisibleForTesting
boolean isDialogNeeded() {
final boolean isRoamingEnabled = mTelephonyManager.isDataRoamingEnabled();
final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
// Need dialog if we need to turn on roaming and the roaming charge indication is allowed
if (!isRoamingEnabled && (carrierConfig == null || !carrierConfig.getBoolean(CarrierConfigManager.KEY_DISABLE_CHARGE_INDICATION_BOOL))) {
return true;
}
return false;
}
Aggregations