Search in sources :

Example 86 with VisibleForTesting

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;
        }
    }
}
Also used : BatterySipper(com.android.internal.os.BatterySipper) SparseLongArray(android.util.SparseLongArray) BatteryStats(android.os.BatteryStats) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 87 with VisibleForTesting

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);
}
Also used : Context(android.content.Context) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 88 with VisibleForTesting

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);
}
Also used : Context(android.content.Context) TextView(android.widget.TextView) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 89 with VisibleForTesting

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));
}
Also used : ServiceState(android.telephony.ServiceState) SubscriptionInfo(android.telephony.SubscriptionInfo) TextView(android.widget.TextView) Paint(android.graphics.Paint) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 90 with VisibleForTesting

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;
}
Also used : PersistableBundle(android.os.PersistableBundle) VisibleForTesting(androidx.annotation.VisibleForTesting)

Aggregations

VisibleForTesting (androidx.annotation.VisibleForTesting)385 Intent (android.content.Intent)36 ArrayList (java.util.ArrayList)36 Context (android.content.Context)34 Bundle (android.os.Bundle)30 Uri (android.net.Uri)18 View (android.view.View)18 Preference (androidx.preference.Preference)18 TextView (android.widget.TextView)16 SubSettingLauncher (com.android.settings.core.SubSettingLauncher)16 MetricsFeatureProvider (com.android.settingslib.core.instrumentation.MetricsFeatureProvider)16 SuppressLint (android.annotation.SuppressLint)15 Activity (android.app.Activity)14 RemoteException (android.os.RemoteException)14 SubscriptionInfo (android.telephony.SubscriptionInfo)12 ImageView (android.widget.ImageView)12 BluetoothDevice (android.bluetooth.BluetoothDevice)11 ComponentName (android.content.ComponentName)11 Drawable (android.graphics.drawable.Drawable)11 SharedPreferences (android.content.SharedPreferences)10