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

Commit 4b94e073 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Data usage label width, locking, Wi-Fi fixes." into ics-mr1

parents 6519c610 bdf98e84
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settings;

import static android.net.ConnectivityManager.TYPE_ETHERNET;
import static android.net.ConnectivityManager.TYPE_MOBILE;
import static android.net.ConnectivityManager.TYPE_WIFI;
import static android.net.ConnectivityManager.TYPE_WIMAX;
import static android.net.NetworkPolicy.LIMIT_DISABLED;
import static android.net.NetworkPolicy.WARNING_DISABLED;
@@ -143,7 +144,7 @@ import libcore.util.Objects;
 */
public class DataUsageSummary extends Fragment {
    private static final String TAG = "DataUsage";
    private static final boolean LOGD = true;
    private static final boolean LOGD = false;

    // TODO: remove this testing code
    private static final boolean TEST_ANIM = false;
@@ -343,6 +344,7 @@ public class DataUsageSummary extends Fragment {

        mChart = (ChartDataUsageView) mHeader.findViewById(R.id.chart);
        mChart.setListener(mChartListener);
        mChart.bindNetworkPolicy(null);

        {
            // bind app detail controls
@@ -430,7 +432,7 @@ public class DataUsageSummary extends Fragment {
        mMenuDataRoaming.setChecked(getDataRoaming());

        mMenuRestrictBackground = menu.findItem(R.id.data_usage_menu_restrict_background);
        mMenuRestrictBackground.setVisible(!appDetailMode);
        mMenuRestrictBackground.setVisible(hasMobileRadio(context) && !appDetailMode);
        mMenuRestrictBackground.setChecked(getRestrictBackground());

        final MenuItem split4g = menu.findItem(R.id.data_usage_menu_split_4g);
@@ -759,7 +761,8 @@ public class DataUsageSummary extends Fragment {
        updateDetailData();

        if (NetworkPolicyManager.isUidValidForPolicy(context, primaryUid)
                && !getRestrictBackground() && isBandwidthControlEnabled()) {
                && !getRestrictBackground() && isBandwidthControlEnabled()
                && hasMobileRadio(context)) {
            setPreferenceTitle(mAppRestrictView, R.string.data_usage_app_restrict_background);
            if (hasLimitedNetworks()) {
                setPreferenceSummary(mAppRestrictView,
@@ -2042,10 +2045,7 @@ public class DataUsageSummary extends Fragment {

        final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
                Context.CONNECTIVITY_SERVICE);

        // mobile devices should have MOBILE network tracker regardless of
        // connection status.
        return conn.getNetworkInfo(TYPE_MOBILE) != null;
        return conn.isNetworkSupported(TYPE_MOBILE);
    }

    /**
@@ -2064,9 +2064,7 @@ public class DataUsageSummary extends Fragment {
        final TelephonyManager telephony = (TelephonyManager) context.getSystemService(
                Context.TELEPHONY_SERVICE);

        // WiMAX devices should have WiMAX network tracker regardless of
        // connection status.
        final boolean hasWimax = conn.getNetworkInfo(TYPE_WIMAX) != null;
        final boolean hasWimax = conn.isNetworkSupported(TYPE_WIMAX);
        final boolean hasLte = telephony.getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE;
        return hasWimax || hasLte;
    }
@@ -2079,7 +2077,9 @@ public class DataUsageSummary extends Fragment {
            return SystemProperties.get(TEST_RADIOS_PROP).contains("wifi");
        }

        return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI);
        final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        return conn.isNetworkSupported(TYPE_WIFI);
    }

    /**
@@ -2092,7 +2092,7 @@ public class DataUsageSummary extends Fragment {

        final ConnectivityManager conn = (ConnectivityManager) context.getSystemService(
                Context.CONNECTIVITY_SERVICE);
        return conn.getNetworkInfo(TYPE_ETHERNET) != null;
        return conn.isNetworkSupported(TYPE_ETHERNET);
    }

    /**
+2 −2
Original line number Diff line number Diff line
@@ -39,14 +39,14 @@ public class UidDetailProvider {
        mUidDetailCache = new SparseArray<UidDetail>();
    }

    public void clearCache() {
    public synchronized void clearCache() {
        mUidDetailCache.clear();
    }

    /**
     * Resolve best descriptive label for the given UID.
     */
    public UidDetail getUidDetail(int uid, boolean blocking) {
    public synchronized UidDetail getUidDetail(int uid, boolean blocking) {
        final UidDetail cached = mUidDetailCache.get(uid);
        if (cached != null) {
            return cached;
+24 −7
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.text.DynamicLayout;
import android.text.Layout;
import android.text.Layout.Alignment;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
@@ -60,7 +61,9 @@ public class ChartSweepView extends View {

    private int mFollowAxis;

    private int mLabelSize;
    private int mLabelMinSize;
    private float mLabelSize;

    private int mLabelTemplateRes;
    private int mLabelColor;

@@ -89,6 +92,8 @@ public class ChartSweepView extends View {
    private static final int MODE_DRAG = 1;
    private static final int MODE_LABEL = 2;

    private static final int LARGE_WIDTH = 1024;

    private long mDragInterval = 1;

    public interface OnSweepListener {
@@ -121,7 +126,7 @@ public class ChartSweepView extends View {
        setFollowAxis(a.getInt(R.styleable.ChartSweepView_followAxis, -1));
        setNeighborMargin(a.getDimensionPixelSize(R.styleable.ChartSweepView_neighborMargin, 0));

        setLabelSize(a.getDimensionPixelSize(R.styleable.ChartSweepView_labelSize, 0));
        setLabelMinSize(a.getDimensionPixelSize(R.styleable.ChartSweepView_labelSize, 0));
        setLabelTemplate(a.getResourceId(R.styleable.ChartSweepView_labelTemplate, 0));
        setLabelColor(a.getColor(R.styleable.ChartSweepView_labelColor, Color.BLUE));

@@ -231,8 +236,8 @@ public class ChartSweepView extends View {
        mFollowAxis = followAxis;
    }

    public void setLabelSize(int size) {
        mLabelSize = size;
    public void setLabelMinSize(int minSize) {
        mLabelMinSize = minSize;
        invalidateLabelTemplate();
    }

@@ -258,7 +263,7 @@ public class ChartSweepView extends View {

            mLabelTemplate = new SpannableStringBuilder(template);
            mLabelLayout = new DynamicLayout(
                    mLabelTemplate, paint, mLabelSize, Alignment.ALIGN_RIGHT, 1f, 0f, false);
                    mLabelTemplate, paint, LARGE_WIDTH, Alignment.ALIGN_RIGHT, 1f, 0f, false);
            invalidateLabel();

        } else {
@@ -289,20 +294,26 @@ public class ChartSweepView extends View {
        float labelOffset = 0;
        if (mFollowAxis == VERTICAL) {
            if (mValidAfterDynamic != null) {
                mLabelSize = Math.max(getLabelWidth(this), getLabelWidth(mValidAfterDynamic));
                margin = getLabelTop(mValidAfterDynamic) - getLabelBottom(this);
                if (margin < 0) {
                    labelOffset = margin / 2;
                }
            } else if (mValidBeforeDynamic != null) {
                mLabelSize = Math.max(getLabelWidth(this), getLabelWidth(mValidBeforeDynamic));
                margin = getLabelTop(this) - getLabelBottom(mValidBeforeDynamic);
                if (margin < 0) {
                    labelOffset = -margin / 2;
                }
            } else {
                mLabelSize = getLabelWidth(this);
            }
        } else {
            // TODO: implement horizontal labels
        }

        mLabelSize = Math.max(mLabelSize, mLabelMinSize);

        // when offsetting label, neighbor probably needs to offset too
        if (labelOffset != mLabelOffset) {
            mLabelOffset = labelOffset;
@@ -692,11 +703,13 @@ public class ChartSweepView extends View {
        if (isEnabled() && mLabelLayout != null) {
            final int count = canvas.save();
            {
                canvas.translate(mContentOffset.left, mContentOffset.top + mLabelOffset);
                final float alignOffset = mLabelSize - LARGE_WIDTH;
                canvas.translate(
                        mContentOffset.left + alignOffset, mContentOffset.top + mLabelOffset);
                mLabelLayout.draw(canvas);
            }
            canvas.restoreToCount(count);
            labelSize = mLabelSize;
            labelSize = (int) mLabelSize;
        } else {
            labelSize = 0;
        }
@@ -724,4 +737,8 @@ public class ChartSweepView extends View {
    public static float getLabelBottom(ChartSweepView view) {
        return getLabelTop(view) + view.mLabelLayout.getHeight();
    }

    public static float getLabelWidth(ChartSweepView view) {
        return Layout.getDesiredWidth(view.mLabelLayout.getText(), view.mLabelLayout.getPaint());
    }
}