Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f59ce67 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 2c8a78a9 bdd559a1
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -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();
+3 −2
Original line number Diff line number Diff line
@@ -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);