Merge "Do not use warning or limit to display "X B left" above usage bar" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-04-05 21:36:59 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 9 deletions

View File

@@ -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.support.v7.preference.Preference;
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 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
* -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 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
void setPlanValues(int dataPlanCount, long dataPlanSize, long dataPlanUse) {
mDataplanCount = dataPlanCount;
mDataplanSize = dataPlanSize;
mDataBarSize = dataPlanSize;
mDataplanUse = dataPlanUse;
}
@@ -237,13 +238,13 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
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 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
// 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 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
mDataplanCount = plans.size();
mDataplanSize = primaryPlan.getDataLimitBytes();
if (unlimited(mDataplanSize)) {
mDataplanSize = 0L;
mDataplanSize = -1L;
}
mDataBarSize = mDataplanSize;
mDataplanUse = primaryPlan.getDataUsageBytes();
RecurrenceRule rule = primaryPlan.getCycleRule();

View File

@@ -76,8 +76,6 @@ public class DataUsageSummaryPreferenceControllerTest {
@Mock
private DataUsageController mDataUsageController;
@Mock
private DataUsageInfoController mDataInfoController;
@Mock
private DataUsageSummaryPreference mSummaryPreference;
@Mock
private NetworkPolicyEditor mPolicyEditor;
@@ -96,6 +94,8 @@ public class DataUsageSummaryPreferenceControllerTest {
@Mock
private ConnectivityManager mConnectivityManager;
private DataUsageInfoController mDataInfoController;
private FakeFeatureFactory mFactory;
private Activity mActivity;
private Context mContext;
@@ -113,6 +113,7 @@ public class DataUsageSummaryPreferenceControllerTest {
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);