shill: cellular: Update online portal from M[V]NO information.
This CL refactors the code-paths that set the online portal property of cellular
service. In particular, it
(1) Removes |CellularService::OLP| class, as it is no longer used extensively.
This class is moved to |CellularOperatorInfo| so that it can still be used
by the remaining code that uses |CellularOperatorInfo|, and will go away
completely in a follow up CL.
(2) Adds |OnOperatorChanged| to the |CellularCapability*| hierarchy as a hook
to trigger updates whenever network operator information changes.
(3) Adds |UpdateServiceOLP| to the |CellularCapability*| hierarchy to be called
from |OnOperatorChanged|. This consolidates the code paths that update the
OLP property of |CellularService|.
(4) Updates |CellularCapabilityUniversal| and |CellularCapabilityUniversalCDMA|
to use the information from MobileOperatorInfo objects to modify the OLP.
(5) Updates |CellularCapabilityCDMA| to use the hooks in (2) and (3) to update
the OLP.
BUG=chromium:352243
TEST=Run shill unit-tests.
Test activation flow on e362, gobi3k GSM/CDMA.
CQ-DEPEND=CL:198597
Change-Id: I10e16144165aafcfc564e1e68a80cce08635163e
Reviewed-on: https://chromium-review.googlesource.com/197770
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Commit-Queue: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/cellular_capability_universal_cdma.cc b/cellular_capability_universal_cdma.cc
index 09f7967..43af14a 100644
--- a/cellular_capability_universal_cdma.cc
+++ b/cellular_capability_universal_cdma.cc
@@ -169,7 +169,7 @@
if (!modem_info()->cellular_operator_info())
return false;
- const CellularService::OLP *olp =
+ const CellularOperatorInfo::OLP *olp =
modem_info()->cellular_operator_info()->GetOLPBySID(UintToString(sid_));
if (!olp)
return false;
@@ -190,7 +190,6 @@
UpdateServingOperator();
HandleNewActivationStatus(MM_CDMA_ACTIVATION_ERROR_NONE);
UpdatePendingActivationState();
- UpdateOLP();
}
void CellularCapabilityUniversalCDMA::UpdateServiceActivationStateProperty() {
@@ -206,36 +205,32 @@
cellular()->service()->SetActivationState(activation_state);
}
-void CellularCapabilityUniversalCDMA::UpdateOLP() {
+void CellularCapabilityUniversalCDMA::UpdateServiceOLP() {
SLOG(Cellular, 2) << __func__;
- const CellularOperatorInfo *cellular_operator_info =
- modem_info()->cellular_operator_info();
- if (!cellular_operator_info)
+ // In this case, the Home Provider is trivial. All information comes from the
+ // Serving Operator.
+ if (!cellular()->serving_operator_info()->IsMobileNetworkOperatorKnown()) {
return;
+ }
- string sid_string = UintToString(sid_);
- const CellularOperatorInfo::CellularOperator *cellular_operator =
- cellular_operator_info->GetCellularOperatorBySID(sid_string);
- if (!cellular_operator)
+ const vector<MobileOperatorInfo::OnlinePortal> &olp_list =
+ cellular()->serving_operator_info()->olp_list();
+ if (olp_list.empty()) {
return;
+ }
- const CellularService::OLP *result =
- cellular_operator_info->GetOLPBySID(sid_string);
- if (!result)
- return;
-
- CellularService::OLP olp;
- olp.CopyFrom(*result);
- string post_data = olp.GetPostData();
+ if (olp_list.size() > 1) {
+ SLOG(Cellular, 1) << "Found multiple online portals. Choosing the first.";
+ }
+ string post_data = olp_list[0].post_data;
ReplaceSubstringsAfterOffset(&post_data, 0, "${esn}", cellular()->esn());
- ReplaceSubstringsAfterOffset(&post_data, 0, "${mdn}",
- GetMdnForOLP(*cellular_operator));
+ ReplaceSubstringsAfterOffset(
+ &post_data, 0, "${mdn}",
+ GetMdnForOLP(cellular()->serving_operator_info()));
ReplaceSubstringsAfterOffset(&post_data, 0, "${meid}", cellular()->meid());
ReplaceSubstringsAfterOffset(&post_data, 0, "${oem}", "GOG2");
- olp.SetPostData(post_data);
- if (cellular()->service().get())
- cellular()->service()->SetOLP(olp);
+ cellular()->service()->SetOLP(olp_list[0].url, olp_list[0].method, post_data);
}
void CellularCapabilityUniversalCDMA::GetProperties() {
@@ -356,7 +351,7 @@
cellular()->service()->SetActivationState(
GetActivationStateString(activation_state_));
cellular()->service()->set_error(GetActivationErrorString(error));
- UpdateOLP();
+ UpdateServiceOLP();
}
// static