use of com.android.settingslib.net.DataUsageController in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsagePreferenceController method init.
public void init(int subId) {
mSubId = subId;
if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
mTemplate = DataUsageUtils.getDefaultTemplate(mContext, mSubId);
boolean showDailyDataUsage = Settings.System.getInt(mContext.getContentResolver(), Settings.System.DATA_USAGE_PERIOD, 1) == 0;
final DataUsageController controller = new DataUsageController(mContext);
controller.setSubscriptionId(mSubId);
mDataUsageInfo = showDailyDataUsage ? controller.getDailyDataUsageInfo(mTemplate) : controller.getDataUsageInfo(mTemplate);
mIntent = new Intent(Settings.ACTION_MOBILE_DATA_USAGE);
mIntent.putExtra(Settings.EXTRA_NETWORK_TEMPLATE, mTemplate);
mIntent.putExtra(Settings.EXTRA_SUB_ID, mSubId);
}
}
use of com.android.settingslib.net.DataUsageController in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SettingsDumpService method dumpDataUsage.
private JSONObject dumpDataUsage(NetworkTemplate template, DataUsageController controller) throws JSONException {
JSONObject obj = new JSONObject();
DataUsageController.DataUsageInfo usage = controller.getDataUsageInfo(template);
obj.put("carrier", usage.carrier);
obj.put("start", usage.startDate);
obj.put("usage", usage.usageLevel);
obj.put("warning", usage.warningLevel);
obj.put("limit", usage.limitLevel);
return obj;
}
use of com.android.settingslib.net.DataUsageController in project android_packages_apps_Settings by omnirom.
the class DataUsagePreference method setTemplate.
@Override
public void setTemplate(NetworkTemplate template, int subId, NetworkServices services) {
mTemplate = template;
mSubId = subId;
final DataUsageController controller = getDataUsageController();
if (mTemplate.isMatchRuleMobile()) {
setTitle(R.string.app_cellular_data_usage);
} else {
final DataUsageController.DataUsageInfo usageInfo = controller.getDataUsageInfo(mTemplate);
setTitle(mTitleRes);
setSummary(getContext().getString(R.string.data_usage_template, DataUsageUtils.formatDataUsage(getContext(), usageInfo.usageLevel), usageInfo.period));
}
final long usageLevel = controller.getHistoricalUsageLevel(template);
if (usageLevel > 0L) {
setIntent(getIntent());
} else {
setIntent(null);
setEnabled(false);
}
}
use of com.android.settingslib.net.DataUsageController in project android_packages_apps_Settings by omnirom.
the class DataUsageSummaryPreferenceController method updateConfiguration.
private void updateConfiguration(Context context, int subscriptionId, SubscriptionInfo subInfo) {
final NetworkPolicyManager policyManager = context.getSystemService(NetworkPolicyManager.class);
mPolicyEditor = new NetworkPolicyEditor(policyManager);
mDataUsageController = new DataUsageController(context);
mDataUsageController.setSubscriptionId(subscriptionId);
mDataInfoController = new DataUsageInfoController();
if (subInfo != null) {
mDataUsageTemplate = R.string.cell_data_template;
mDefaultTemplate = DataUsageLib.getMobileTemplate(context, subscriptionId);
} else if (DataUsageUtils.hasWifiRadio(context)) {
mDataUsageTemplate = R.string.wifi_data_template;
mDefaultTemplate = NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL, null);
} else {
mDataUsageTemplate = R.string.ethernet_data_template;
mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, subscriptionId);
}
}
Aggregations