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

am: eff9d43739

Change-Id: I8af506c4d7be28f8b5a966f2d4f38aeb13994b85
This commit is contained in:
Jan Nordqvist
2018-04-05 15:18:18 -07:00
committed by android-build-merger
2 changed files with 13 additions and 9 deletions

View File

@@ -17,7 +17,6 @@
package com.android.settings.datausage; package com.android.settings.datausage;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.NetworkPolicyManager; import android.net.NetworkPolicyManager;
@@ -27,7 +26,6 @@ import android.support.v7.preference.Preference;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionPlan; import android.telephony.SubscriptionPlan;
import android.telephony.TelephonyManager;
import android.text.BidiFormatter; import android.text.BidiFormatter;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
@@ -91,6 +89,8 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
* -1 if no information is available. * -1 if no information is available.
*/ */
private long mDataplanSize; 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. */ /** The number of bytes used since the start of the cycle. */
private long mDataplanUse; private long mDataplanUse;
/** The starting time of the billing cycle in ms since the epoch */ /** 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) { void setPlanValues(int dataPlanCount, long dataPlanSize, long dataPlanUse) {
mDataplanCount = dataPlanCount; mDataplanCount = dataPlanCount;
mDataplanSize = dataPlanSize; mDataplanSize = dataPlanSize;
mDataBarSize = dataPlanSize;
mDataplanUse = dataPlanUse; mDataplanUse = dataPlanUse;
} }
@@ -237,13 +238,13 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
summaryPreference.setUsageNumbers(mDataplanUse, mDataplanSize, mHasMobileData); summaryPreference.setUsageNumbers(mDataplanUse, mDataplanSize, mHasMobileData);
if (mDataplanSize <= 0) { if (mDataBarSize <= 0) {
summaryPreference.setChartEnabled(false); summaryPreference.setChartEnabled(false);
} else { } else {
summaryPreference.setChartEnabled(true); summaryPreference.setChartEnabled(true);
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */), summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
Formatter.formatFileSize(mContext, mDataplanSize)); Formatter.formatFileSize(mContext, mDataBarSize));
summaryPreference.setProgress(mDataplanUse / (float) mDataplanSize); summaryPreference.setProgress(mDataplanUse / (float) mDataBarSize);
} }
summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName, summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
mDataplanCount, mManageSubscriptionIntent); mDataplanCount, mManageSubscriptionIntent);
@@ -262,7 +263,8 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
// reset data before overwriting // reset data before overwriting
mCarrierName = null; mCarrierName = null;
mDataplanCount = 0; mDataplanCount = 0;
mDataplanSize = mDataInfoController.getSummaryLimit(info); mDataplanSize = -1L;
mDataBarSize = mDataInfoController.getSummaryLimit(info);
mDataplanUse = info.usageLevel; mDataplanUse = info.usageLevel;
mCycleStart = info.cycleStart; mCycleStart = info.cycleStart;
mCycleEnd = info.cycleEnd; mCycleEnd = info.cycleEnd;
@@ -278,8 +280,9 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
mDataplanCount = plans.size(); mDataplanCount = plans.size();
mDataplanSize = primaryPlan.getDataLimitBytes(); mDataplanSize = primaryPlan.getDataLimitBytes();
if (unlimited(mDataplanSize)) { if (unlimited(mDataplanSize)) {
mDataplanSize = 0L; mDataplanSize = -1L;
} }
mDataBarSize = mDataplanSize;
mDataplanUse = primaryPlan.getDataUsageBytes(); mDataplanUse = primaryPlan.getDataUsageBytes();
RecurrenceRule rule = primaryPlan.getCycleRule(); RecurrenceRule rule = primaryPlan.getCycleRule();

View File

@@ -77,8 +77,6 @@ public class DataUsageSummaryPreferenceControllerTest {
@Mock @Mock
private DataUsageController mDataUsageController; private DataUsageController mDataUsageController;
@Mock @Mock
private DataUsageInfoController mDataInfoController;
@Mock
private DataUsageSummaryPreference mSummaryPreference; private DataUsageSummaryPreference mSummaryPreference;
@Mock @Mock
private NetworkPolicyEditor mPolicyEditor; private NetworkPolicyEditor mPolicyEditor;
@@ -97,6 +95,8 @@ public class DataUsageSummaryPreferenceControllerTest {
@Mock @Mock
private ConnectivityManager mConnectivityManager; private ConnectivityManager mConnectivityManager;
private DataUsageInfoController mDataInfoController;
private FakeFeatureFactory mFactory; private FakeFeatureFactory mFactory;
private Activity mActivity; private Activity mActivity;
private Context mContext; private Context mContext;
@@ -114,6 +114,7 @@ public class DataUsageSummaryPreferenceControllerTest {
when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class))) when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class)))
.thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY); .thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY);
ShadowEntityHeaderController.setUseMock(mHeaderController); ShadowEntityHeaderController.setUseMock(mHeaderController);
mDataInfoController = new DataUsageInfoController();
mActivity = spy(Robolectric.buildActivity(Activity.class).get()); mActivity = spy(Robolectric.buildActivity(Activity.class).get());
when(mActivity.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager); when(mActivity.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);