Clean up unused DataUsageSummary.formatUsage
Bug: 321861088 Flag: EXEMPT bug fix Test: atest DataUsageSummaryTest Change-Id: Idea8401a81d738272a8f7b23d22c1fbd3feb6903
This commit is contained in:
@@ -22,12 +22,7 @@ import android.os.Bundle;
|
||||
import android.os.UserManager;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.text.BidiFormatter;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.text.style.RelativeSizeSpan;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -211,34 +206,6 @@ public class DataUsageSummary extends DashboardFragment {
|
||||
updateState();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static CharSequence formatUsage(Context context, String template, long usageLevel) {
|
||||
final float LARGER_SIZE = 1.25f * 1.25f; // (1/0.8)^2
|
||||
final float SMALLER_SIZE = 1.0f / LARGER_SIZE; // 0.8^2
|
||||
return formatUsage(context, template, usageLevel, LARGER_SIZE, SMALLER_SIZE);
|
||||
}
|
||||
|
||||
static CharSequence formatUsage(Context context, String template, long usageLevel,
|
||||
float larger, float smaller) {
|
||||
final int FLAGS = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
|
||||
|
||||
final Formatter.BytesResult usedResult = Formatter.formatBytes(context.getResources(),
|
||||
usageLevel, Formatter.FLAG_CALCULATE_ROUNDED | Formatter.FLAG_IEC_UNITS);
|
||||
final SpannableString enlargedValue = new SpannableString(usedResult.value);
|
||||
enlargedValue.setSpan(new RelativeSizeSpan(larger), 0, enlargedValue.length(), FLAGS);
|
||||
|
||||
final SpannableString amountTemplate = new SpannableString(
|
||||
context.getString(com.android.internal.R.string.fileSizeSuffix)
|
||||
.replace("%1$s", "^1").replace("%2$s", "^2"));
|
||||
final CharSequence formattedUsage = TextUtils.expandTemplate(amountTemplate,
|
||||
enlargedValue, usedResult.units);
|
||||
|
||||
final SpannableString fullTemplate = new SpannableString(template);
|
||||
fullTemplate.setSpan(new RelativeSizeSpan(smaller), 0, fullTemplate.length(), FLAGS);
|
||||
return TextUtils.expandTemplate(fullTemplate,
|
||||
BidiFormatter.getInstance().unicodeWrap(formattedUsage.toString()));
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
for (int i = 1; i < screen.getPreferenceCount(); i++) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package com.android.settings.datausage;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
@@ -92,15 +90,6 @@ public class DataUsageSummaryTest {
|
||||
doNothing().when(mDataUsageSummary).addWifiSection();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void formatUsage_shouldLookLikeFormatFileSize() {
|
||||
final long usage = 2147483648L; // 2GB
|
||||
final String formattedUsage =
|
||||
DataUsageSummary.formatUsage(mContext, "^1", usage).toString();
|
||||
final CharSequence formattedInIECUnit = DataUsageUtils.formatDataUsage(mContext, usage);
|
||||
assertThat(formattedUsage).isEqualTo(formattedInIECUnit);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowSubscriptionManager.class)
|
||||
public void configuration_withSim_shouldShowMobileAndWifi() {
|
||||
|
||||
Reference in New Issue
Block a user