Do not use warning or limit to display "X B left" above usage bar
Bug: 70950124
Test: manual
Test: make RunSettingsRoboTests
Change-Id: I46f4f5f1cf6092038e49beaafe5aa6a19ffb0aa1
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 44e5cf2..ccceae3 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.datausage;
import android.app.Activity;
-import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.net.NetworkPolicyManager;
@@ -27,7 +26,6 @@
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionPlan;
-import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.Spannable;
import android.text.SpannableString;
@@ -91,6 +89,8 @@
* -1 if no information is available.
*/
private long mDataplanSize;
+ /** The "size" of the data usage bar, i.e. the amount of data its rhs end represents */
+ private long mDataBarSize;
/** The number of bytes used since the start of the cycle. */
private long mDataplanUse;
/** The starting time of the billing cycle in ms since the epoch */
@@ -171,6 +171,7 @@
void setPlanValues(int dataPlanCount, long dataPlanSize, long dataPlanUse) {
mDataplanCount = dataPlanCount;
mDataplanSize = dataPlanSize;
+ mDataBarSize = dataPlanSize;
mDataplanUse = dataPlanUse;
}
@@ -237,13 +238,13 @@
summaryPreference.setUsageNumbers(mDataplanUse, mDataplanSize, mHasMobileData);
- if (mDataplanSize <= 0) {
+ if (mDataBarSize <= 0) {
summaryPreference.setChartEnabled(false);
} else {
summaryPreference.setChartEnabled(true);
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
- Formatter.formatFileSize(mContext, mDataplanSize));
- summaryPreference.setProgress(mDataplanUse / (float) mDataplanSize);
+ Formatter.formatFileSize(mContext, mDataBarSize));
+ summaryPreference.setProgress(mDataplanUse / (float) mDataBarSize);
}
summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
mDataplanCount, mManageSubscriptionIntent);
@@ -262,7 +263,8 @@
// reset data before overwriting
mCarrierName = null;
mDataplanCount = 0;
- mDataplanSize = mDataInfoController.getSummaryLimit(info);
+ mDataplanSize = -1L;
+ mDataBarSize = mDataInfoController.getSummaryLimit(info);
mDataplanUse = info.usageLevel;
mCycleStart = info.cycleStart;
mCycleEnd = info.cycleEnd;
@@ -278,8 +280,9 @@
mDataplanCount = plans.size();
mDataplanSize = primaryPlan.getDataLimitBytes();
if (unlimited(mDataplanSize)) {
- mDataplanSize = 0L;
+ mDataplanSize = -1L;
}
+ mDataBarSize = mDataplanSize;
mDataplanUse = primaryPlan.getDataUsageBytes();
RecurrenceRule rule = primaryPlan.getCycleRule();
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
index 67caed4..6092357 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -76,8 +76,6 @@
@Mock
private DataUsageController mDataUsageController;
@Mock
- private DataUsageInfoController mDataInfoController;
- @Mock
private DataUsageSummaryPreference mSummaryPreference;
@Mock
private NetworkPolicyEditor mPolicyEditor;
@@ -96,6 +94,8 @@
@Mock
private ConnectivityManager mConnectivityManager;
+ private DataUsageInfoController mDataInfoController;
+
private FakeFeatureFactory mFactory;
private Activity mActivity;
private Context mContext;
@@ -113,6 +113,7 @@
when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class)))
.thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY);
ShadowEntityHeaderController.setUseMock(mHeaderController);
+ mDataInfoController = new DataUsageInfoController();
mActivity = spy(Robolectric.buildActivity(Activity.class).get());
when(mActivity.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);