Merge "Surface metered networks as "Mobile hotspots."" into jb-dev

This commit is contained in:
Jeff Sharkey
2012-05-29 15:01:33 -07:00
committed by Android (Google) Code Review
3 changed files with 20 additions and 15 deletions

View File

@@ -104,7 +104,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
@@ -2164,15 +2163,19 @@ public class DataUsageSummary extends Fragment {
final boolean hasEthernet = conn.isNetworkSupported(TYPE_ETHERNET);
final long ethernetBytes;
try {
ethernetBytes = mStatsSession.getSummaryForNetwork(
NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
.getTotalBytes();
} catch (RemoteException e) {
throw new RuntimeException(e);
if (mStatsSession != null) {
try {
ethernetBytes = mStatsSession.getSummaryForNetwork(
NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
.getTotalBytes();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
} else {
ethernetBytes = 0;
}
// suppress ethernet unless traffic has occurred
// only show ethernet when both hardware present and traffic has occurred
return hasEthernet && ethernetBytes > 0;
}

View File

@@ -41,6 +41,8 @@ import com.android.settings.SettingsPreferenceFragment;
*/
public class DataUsageMeteredSettings extends SettingsPreferenceFragment {
private static final boolean SHOW_MOBILE_CATEGORY = false;
private NetworkPolicyManager mPolicyManager;
private WifiManager mWifiManager;
@@ -70,7 +72,7 @@ public class DataUsageMeteredSettings extends SettingsPreferenceFragment {
}
private void updateNetworks(Context context) {
if (hasReadyMobileRadio(context)) {
if (SHOW_MOBILE_CATEGORY && hasReadyMobileRadio(context)) {
mMobileCategory.removeAll();
mMobileCategory.addPreference(buildMobilePref(context));
} else {