Fix DataUsageSummary non-indexable keys
Indexing in DataUsage was not conventional, since it blocked adding XML based on current sim status rather than indexing everything and changing non-indexabe keys. Manual merge for: ag/2631595 Change-Id: I7bb3cdb0f11772bbaefb6c21c61eb63bd0b17c7e Fixes: 64193449 Test: robotests
This commit is contained in:
@@ -54,13 +54,19 @@ import java.util.List;
|
||||
public class DataPlanUsageSummary extends DataUsageBase implements Indexable {
|
||||
|
||||
public static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
|
||||
public static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
|
||||
private static final String KEY_DATA_PLAN_USAGE = "data_plan_usage";
|
||||
public static final String KEY_DATA_PLAN_USAGE = "data_plan_usage";
|
||||
|
||||
private static final String KEY_STATUS_HEADER = "status_header";
|
||||
private static final String KEY_LIMIT_SUMMARY = "plan_summary";
|
||||
private static final String KEY_MOBILE_USAGE_TITLE = "data_usage_mobile_category";
|
||||
private static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
|
||||
public static final String KEY_STATUS_HEADER = "status_header";
|
||||
public static final String KEY_LIMIT_SUMMARY = "plan_summary";
|
||||
|
||||
// Mobile data keys
|
||||
public static final String KEY_MOBILE_USAGE_TITLE = "data_usage_mobile_category";
|
||||
public static final String KEY_MOBILE_DATA_USAGE_TOGGLE = "data_usage_enable";
|
||||
|
||||
// Wifi keys
|
||||
public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
|
||||
public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
|
||||
public static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
|
||||
|
||||
private DataUsageController mDataUsageController;
|
||||
private DataUsageInfoController mDataInfoController;
|
||||
@@ -364,19 +370,17 @@ public class DataPlanUsageSummary extends DataUsageBase implements Indexable {
|
||||
boolean enabled) {
|
||||
List<SearchIndexableResource> resources = new ArrayList<>();
|
||||
SearchIndexableResource resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_plan_usage;
|
||||
resource.xmlResId = R.xml.data_usage;
|
||||
resources.add(resource);
|
||||
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_plan_usage_cell_data_preference_screen;
|
||||
resources.add(resource);
|
||||
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_wifi;
|
||||
resources.add(resource);
|
||||
|
||||
if (DataUsageUtils.hasMobileData(context)) {
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_plan_usage_cell_data_preference_screen;
|
||||
resources.add(resource);
|
||||
}
|
||||
if (DataUsageUtils.hasWifiRadio(context)) {
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_wifi;
|
||||
resources.add(resource);
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
@@ -384,12 +388,16 @@ public class DataPlanUsageSummary extends DataUsageBase implements Indexable {
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
|
||||
if (DataUsageUtils.hasMobileData(context)) {
|
||||
keys.add(KEY_RESTRICT_BACKGROUND);
|
||||
if (!DataUsageUtils.hasMobileData(context)) {
|
||||
keys.add(KEY_MOBILE_USAGE_TITLE);
|
||||
keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE);
|
||||
}
|
||||
if (DataUsageUtils.hasWifiRadio(context)) {
|
||||
|
||||
if (!DataUsageUtils.hasWifiRadio(context)) {
|
||||
keys.add(KEY_WIFI_DATA_USAGE);
|
||||
keys.add(KEY_NETWORK_RESTRICTIONS);
|
||||
}
|
||||
|
||||
keys.add(KEY_WIFI_USAGE_TITLE);
|
||||
|
||||
return keys;
|
||||
|
@@ -69,12 +69,21 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs
|
||||
static final boolean LOGD = false;
|
||||
|
||||
public static final String KEY_RESTRICT_BACKGROUND = "restrict_background";
|
||||
public static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
|
||||
|
||||
private static final String KEY_STATUS_HEADER = "status_header";
|
||||
private static final String KEY_LIMIT_SUMMARY = "limit_summary";
|
||||
private static final String KEY_MOBILE_USAGE_TITLE = "mobile_category";
|
||||
private static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
|
||||
|
||||
// Mobile data keys
|
||||
public static final String KEY_MOBILE_USAGE_TITLE = "mobile_category";
|
||||
public static final String KEY_MOBILE_DATA_USAGE_TOGGLE = "data_usage_enable";
|
||||
public static final String KEY_MOBILE_DATA_USAGE = "cellular_data_usage";
|
||||
public static final String KEY_MOBILE_BILLING_CYCLE = "billing_preference";
|
||||
|
||||
// Wifi keys
|
||||
public static final String KEY_WIFI_USAGE_TITLE = "wifi_category";
|
||||
public static final String KEY_WIFI_DATA_USAGE = "wifi_data_usage";
|
||||
public static final String KEY_NETWORK_RESTRICTIONS = "network_restrictions";
|
||||
|
||||
|
||||
private DataUsageController mDataUsageController;
|
||||
private DataUsageInfoController mDataInfoController;
|
||||
@@ -381,16 +390,14 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs
|
||||
resource.xmlResId = R.xml.data_usage;
|
||||
resources.add(resource);
|
||||
|
||||
if (DataUsageUtils.hasMobileData(context)) {
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_cellular;
|
||||
resources.add(resource);
|
||||
}
|
||||
if (DataUsageUtils.hasWifiRadio(context)) {
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_wifi;
|
||||
resources.add(resource);
|
||||
}
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_cellular;
|
||||
resources.add(resource);
|
||||
|
||||
resource = new SearchIndexableResource(context);
|
||||
resource.xmlResId = R.xml.data_usage_wifi;
|
||||
resources.add(resource);
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
@@ -398,12 +405,19 @@ public class DataUsageSummary extends DataUsageBase implements Indexable, DataUs
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
|
||||
if (DataUsageUtils.hasMobileData(context)) {
|
||||
keys.add(KEY_RESTRICT_BACKGROUND);
|
||||
if (!DataUsageUtils.hasMobileData(context)) {
|
||||
keys.add(KEY_MOBILE_USAGE_TITLE);
|
||||
keys.add(KEY_MOBILE_DATA_USAGE_TOGGLE);
|
||||
keys.add(KEY_MOBILE_DATA_USAGE);
|
||||
keys.add(KEY_MOBILE_BILLING_CYCLE);
|
||||
}
|
||||
if (DataUsageUtils.hasWifiRadio(context)) {
|
||||
|
||||
if (!DataUsageUtils.hasWifiRadio(context)) {
|
||||
keys.add(KEY_WIFI_DATA_USAGE);
|
||||
keys.add(KEY_NETWORK_RESTRICTIONS);
|
||||
}
|
||||
|
||||
// This title is named Wifi, and will confuse users.
|
||||
keys.add(KEY_WIFI_USAGE_TITLE);
|
||||
|
||||
return keys;
|
||||
|
@@ -39,7 +39,7 @@ public final class DataUsageUtils {
|
||||
* Returns whether device has mobile data.
|
||||
* TODO: This is the opposite to Utils.isWifiOnly(), it should be refactored into 1 method.
|
||||
*/
|
||||
static boolean hasMobileData(Context context) {
|
||||
public static boolean hasMobileData(Context context) {
|
||||
ConnectivityManager connectivityManager = ConnectivityManager.from(context);
|
||||
return connectivityManager != null && connectivityManager
|
||||
.isNetworkSupported(ConnectivityManager.TYPE_MOBILE);
|
||||
|
Reference in New Issue
Block a user