Data plan usage summary fragment.

Change-Id: I2d928d1b5313b723450c8f5a45ff944b99dc3d5d
Note: These changes are required for Data balance UI.
Bug: 62349208
Test: make RunSettingsRoboTests -j40
This commit is contained in:
Rajeev Kumar
2017-07-14 19:40:56 -07:00
parent 4b351b4ca1
commit e19cd4828e
9 changed files with 734 additions and 40 deletions

View File

@@ -58,6 +58,12 @@ import com.android.settingslib.net.DataUsageController;
import java.util.ArrayList;
import java.util.List;
/**
* Settings preference fragment that displays data usage summary.
*
* This class in deprecated use {@link DataPlanUsageSummary}.
*/
@Deprecated
public class DataUsageSummary extends DataUsageBase implements Indexable, DataUsageEditController {
static final boolean LOGD = false;
@@ -311,36 +317,6 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs
updateState();
}
/**
* Test if device has an ethernet network connection.
*/
public boolean hasEthernet(Context context) {
if (DataUsageUtils.TEST_RADIOS) {
return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("ethernet");
}
final ConnectivityManager conn = ConnectivityManager.from(context);
final boolean hasEthernet = conn.isNetworkSupported(TYPE_ETHERNET);
final long ethernetBytes;
try {
INetworkStatsSession statsSession = services.mStatsService.openSession();
if (statsSession != null) {
ethernetBytes = statsSession.getSummaryForNetwork(
NetworkTemplate.buildTemplateEthernet(), Long.MIN_VALUE, Long.MAX_VALUE)
.getTotalBytes();
TrafficStats.closeQuietly(statsSession);
} else {
ethernetBytes = 0;
}
} catch (RemoteException e) {
throw new RuntimeException(e);
}
// only show ethernet when both hardware present and traffic has occurred
return hasEthernet && ethernetBytes > 0;
}
@VisibleForTesting
void updateNetworkRestrictionSummary(NetworkRestrictionsPreference preference) {
if (preference == null) {