Change initMobileTabTag to use subInfoList

Also add additional debug.

Bug: 18364932
Change-Id: I836b751a443635efcfb9987bb3b91f55c4dff9d6
This commit is contained in:
Wink Saville
2014-12-02 17:12:08 -08:00
parent 91177d1c16
commit fcec91f475

View File

@@ -761,20 +761,25 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
mDataEnabledSupported = isOwner; mDataEnabledSupported = isOwner;
mDisableAtLimitSupported = true; mDisableAtLimitSupported = true;
// TODO: remove mobile tabs when SIM isn't ready // TODO: remove mobile tabs when SIM isn't ready probably by
// TODO: using SubscriptionManager.getActiveSubscriptionInfoList.
if (LOGD) Log.d(TAG, "updateBody() isMobileTab=" + isMobileTab(currentTab));
if (isMobileTab(currentTab)) { if (isMobileTab(currentTab)) {
if (LOGD) Log.d(TAG, "updateBody() mobile tab");
setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_mobile); setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_mobile);
setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_mobile_limit); setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_mobile_limit);
mTemplate = buildTemplateMobileAll(getActiveSubscriberId(context,getSubId(currentTab))); mTemplate = buildTemplateMobileAll(getActiveSubscriberId(context,getSubId(currentTab)));
mDataEnabledSupported = isMobileDataAvailable(getSubId(currentTab)); mDataEnabledSupported = isMobileDataAvailable(getSubId(currentTab));
} else if (TAB_3G.equals(currentTab)) { } else if (TAB_3G.equals(currentTab)) {
if (LOGD) Log.d(TAG, "updateBody() 3g tab");
setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_3g); setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_3g);
setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_3g_limit); setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_3g_limit);
// TODO: bind mDataEnabled to 3G radio state // TODO: bind mDataEnabled to 3G radio state
mTemplate = buildTemplateMobile3gLower(getActiveSubscriberId(context)); mTemplate = buildTemplateMobile3gLower(getActiveSubscriberId(context));
} else if (TAB_4G.equals(currentTab)) { } else if (TAB_4G.equals(currentTab)) {
if (LOGD) Log.d(TAG, "updateBody() 4g tab");
setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_4g); setPreferenceTitle(mDataEnabledView, R.string.data_usage_enable_4g);
setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_4g_limit); setPreferenceTitle(mDisableAtLimitView, R.string.data_usage_disable_4g_limit);
// TODO: bind mDataEnabled to 4G radio state // TODO: bind mDataEnabled to 4G radio state
@@ -782,17 +787,20 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
} else if (TAB_WIFI.equals(currentTab)) { } else if (TAB_WIFI.equals(currentTab)) {
// wifi doesn't have any controls // wifi doesn't have any controls
if (LOGD) Log.d(TAG, "updateBody() wifi tab");
mDataEnabledSupported = false; mDataEnabledSupported = false;
mDisableAtLimitSupported = false; mDisableAtLimitSupported = false;
mTemplate = buildTemplateWifiWildcard(); mTemplate = buildTemplateWifiWildcard();
} else if (TAB_ETHERNET.equals(currentTab)) { } else if (TAB_ETHERNET.equals(currentTab)) {
// ethernet doesn't have any controls // ethernet doesn't have any controls
if (LOGD) Log.d(TAG, "updateBody() ethernet tab");
mDataEnabledSupported = false; mDataEnabledSupported = false;
mDisableAtLimitSupported = false; mDisableAtLimitSupported = false;
mTemplate = buildTemplateEthernet(); mTemplate = buildTemplateEthernet();
} else { } else {
if (LOGD) Log.d(TAG, "updateBody() unknown tab");
throw new IllegalStateException("unknown tab: " + currentTab); throw new IllegalStateException("unknown tab: " + currentTab);
} }
@@ -1389,12 +1397,15 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
@Deprecated @Deprecated
private boolean isMobilePolicySplit() { private boolean isMobilePolicySplit() {
final Context context = getActivity(); final Context context = getActivity();
boolean retVal;
if (hasReadyMobileRadio(context)) { if (hasReadyMobileRadio(context)) {
final TelephonyManager tele = TelephonyManager.from(context); final TelephonyManager tele = TelephonyManager.from(context);
return mPolicyEditor.isMobilePolicySplit(getActiveSubscriberId(context)); retVal = mPolicyEditor.isMobilePolicySplit(getActiveSubscriberId(context));
} else { } else {
return false; retVal = false;
} }
if (LOGD) Log.d(TAG, "isMobilePolicySplit: retVal=" + retVal);
return retVal;
} }
@Deprecated @Deprecated
@@ -1402,6 +1413,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
final Context context = getActivity(); final Context context = getActivity();
if (hasReadyMobileRadio(context)) { if (hasReadyMobileRadio(context)) {
final TelephonyManager tele = TelephonyManager.from(context); final TelephonyManager tele = TelephonyManager.from(context);
if (LOGD) Log.d(TAG, "setMobilePolicySplit: split=" + split);
mPolicyEditor.setMobilePolicySplit(getActiveSubscriberId(context), split); mPolicyEditor.setMobilePolicySplit(getActiveSubscriberId(context), split);
} }
} }
@@ -1409,12 +1421,16 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
private static String getActiveSubscriberId(Context context) { private static String getActiveSubscriberId(Context context) {
final TelephonyManager tele = TelephonyManager.from(context); final TelephonyManager tele = TelephonyManager.from(context);
final String actualSubscriberId = tele.getSubscriberId(); final String actualSubscriberId = tele.getSubscriberId();
return SystemProperties.get(TEST_SUBSCRIBER_PROP, actualSubscriberId); String retVal = SystemProperties.get(TEST_SUBSCRIBER_PROP, actualSubscriberId);
if (LOGD) Log.d(TAG, "getActiveSubscriberId=" + retVal + " actualSubscriberId=" + actualSubscriberId);
return retVal;
} }
private static String getActiveSubscriberId(Context context, int subId) { private static String getActiveSubscriberId(Context context, int subId) {
final TelephonyManager tele = TelephonyManager.from(context); final TelephonyManager tele = TelephonyManager.from(context);
return tele.getSubscriberId(subId); String retVal = tele.getSubscriberId(subId);
if (LOGD) Log.d(TAG, "getActiveSubscriberId=" + retVal + " subId=" + subId);
return retVal;
} }
private DataUsageChartListener mChartListener = new DataUsageChartListener() { private DataUsageChartListener mChartListener = new DataUsageChartListener() {
@@ -2367,14 +2383,23 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
SubscriptionManager.from(context).getActiveSubscriptionInfoList(); SubscriptionManager.from(context).getActiveSubscriptionInfoList();
// No activated Subscriptions // No activated Subscriptions
if (subInfoList == null) { if (subInfoList == null) {
if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfoList=null");
return false; return false;
} }
// require both supported network and ready SIM // require both supported network and ready SIM
boolean isReady = true; boolean isReady = true;
for (SubscriptionInfo subInfo : subInfoList) { for (SubscriptionInfo subInfo : subInfoList) {
isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY; isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY;
if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo);
} }
return conn.isNetworkSupported(TYPE_MOBILE) && isReady; boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
if (LOGD) {
Log.d(TAG, "hasReadyMobileRadio:"
+ " conn.isNetworkSupported(TYPE_MOBILE)="
+ conn.isNetworkSupported(TYPE_MOBILE)
+ " isReady=" + isReady);
}
return retVal;
} }
/* /*
@@ -2390,7 +2415,11 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
final int slotId = SubscriptionManager.getSlotId(subId); final int slotId = SubscriptionManager.getSlotId(subId);
final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY; final boolean isReady = tele.getSimState(slotId) == SIM_STATE_READY;
return conn.isNetworkSupported(TYPE_MOBILE) && isReady; boolean retVal = conn.isNetworkSupported(TYPE_MOBILE) && isReady;
if (LOGD) Log.d(TAG, "hasReadyMobileRadio: subId=" + subId
+ " conn.isNetworkSupported(TYPE_MOBILE)=" + conn.isNetworkSupported(TYPE_MOBILE)
+ " isReady=" + isReady);
return retVal;
} }
/** /**
@@ -2616,6 +2645,8 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
mTabHost.addTab(buildTabSpec(mMobileTagMap.get(subInfo.getSubscriptionId()), mTabHost.addTab(buildTabSpec(mMobileTagMap.get(subInfo.getSubscriptionId()),
subInfo.getDisplayName())); subInfo.getDisplayName()));
} }
} else {
if (LOGD) Log.d(TAG, "addMobileTab: subInfoList is null");
} }
} }
@@ -2640,17 +2671,13 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
* @return The map or null if no activated subscription * @return The map or null if no activated subscription
*/ */
private Map<Integer, String> initMobileTabTag(List<SubscriptionInfo> subInfoList) { private Map<Integer, String> initMobileTabTag(List<SubscriptionInfo> subInfoList) {
final Context context = getActivity();
Map<Integer, String> map = null; Map<Integer, String> map = null;
if (subInfoList != null) { if (subInfoList != null) {
String mobileTag; String mobileTag;
map = new HashMap<Integer, String>(); map = new HashMap<Integer, String>();
for (int i = 0; i < mTelephonyManager.getSimCount(); i++) { for (SubscriptionInfo subInfo : subInfoList) {
final SubscriptionInfo subInfo = Utils.findRecordBySlotId(context, i); mobileTag = TAB_MOBILE + String.valueOf(subInfo.getSubscriptionId());
mobileTag = TAB_MOBILE + i; map.put(subInfo.getSubscriptionId(), mobileTag);
if (subInfo != null) {
map.put(subInfo.getSubscriptionId(), mobileTag);
}
} }
} }
return map; return map;