Loading src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java +10 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 */ Loading Loading @@ -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; } Loading Loading @@ -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); Loading @@ -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; Loading @@ -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(); Loading tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -76,8 +76,6 @@ public class DataUsageSummaryPreferenceControllerTest { @Mock private DataUsageController mDataUsageController; @Mock private DataUsageInfoController mDataInfoController; @Mock private DataUsageSummaryPreference mSummaryPreference; @Mock private NetworkPolicyEditor mPolicyEditor; Loading @@ -96,6 +94,8 @@ public class DataUsageSummaryPreferenceControllerTest { @Mock private ConnectivityManager mConnectivityManager; private DataUsageInfoController mDataInfoController; private FakeFeatureFactory mFactory; private Activity mActivity; private Context mContext; Loading @@ -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); Loading Loading
src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java +10 −7 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 */ Loading Loading @@ -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; } Loading Loading @@ -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); Loading @@ -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; Loading @@ -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(); Loading
tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -76,8 +76,6 @@ public class DataUsageSummaryPreferenceControllerTest { @Mock private DataUsageController mDataUsageController; @Mock private DataUsageInfoController mDataInfoController; @Mock private DataUsageSummaryPreference mSummaryPreference; @Mock private NetworkPolicyEditor mPolicyEditor; Loading @@ -96,6 +94,8 @@ public class DataUsageSummaryPreferenceControllerTest { @Mock private ConnectivityManager mConnectivityManager; private DataUsageInfoController mDataInfoController; private FakeFeatureFactory mFactory; private Activity mActivity; private Context mContext; Loading @@ -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); Loading