CHECK_EXIST(args, "domainName", out)
CHECK_EXIST(args, "id", out)
+ const auto status = NetworkBearerSelectionManager::GetInstance()->getCellularState();
+
+ if (!status) {
+ LogAndReportError(status, &out, ("Failed to request route to host"));
+ return;
+ }
+
const std::string& domainName = args.get("domainName").get<std::string>();
const int listenerId = static_cast<int>(args.get("id").get<double>());
}
}
+common::PlatformResult NetworkBearerSelectionManager::getCellularState() {
+
+ connection_cellular_state_e state;
+
+ int ret = connection_get_cellular_state(m_connection_handle_, &state);
+
+ if (ret != CONNECTION_ERROR_NONE) {
+ LoggerE("Fail to get connection state. %d", ret);
+ return common::PlatformResult(GetNBSErrorCode(ret),
+ "Fail to get connection state.");
+ }
+
+ if (state == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) {
+ LoggerE("Network cellular have no service. %d", state);
+ return common::PlatformResult(common::ErrorCode::NOT_SUPPORTED_ERR,
+ "Fail to get connection state.");
+ }
+ return common::PlatformResult(common::ErrorCode::NO_ERROR);
+}
+
+
void NetworkBearerSelectionManager::requestRouteToHost(
const std::string& domain_name) {
LoggerD("NetworkBearerSelectionManager::requestRouteToHost");
return nullptr;
}
+common::ErrorCode NetworkBearerSelectionManager::GetNBSErrorCode(int error_code) {
+
+ common::ErrorCode error = common::ErrorCode::UNKNOWN_ERR;
+
+ switch (error_code) {
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ error = common::ErrorCode::UNKNOWN_ERR;
+ break;
+ case CONNECTION_ERROR_NOT_SUPPORTED:
+ error = common::ErrorCode::NOT_SUPPORTED_ERR;
+ break;
+ default:
+ error = common::ErrorCode::UNKNOWN_ERR;
+ break;
+ }
+
+ return error;
+}
+
} // namespace networkbearerselection
} // namespace extension
common::PlatformResult releaseRouteToHost(const std::string& domain_name,
const ReleaseReplyCallback& reply_cb);
+ common::PlatformResult getCellularState();
+
static NetworkBearerSelectionManager* GetInstance();
NetworkBearerSelectionManager(const NetworkBearerSelectionManager&) = delete;
void makeErrorCallback(const std::string& domain_name, const char* info);
void makeErrorCallback(const std::string& domain_name,
const std::string& info);
+ common::ErrorCode GetNBSErrorCode(int error_code);
void makeDisconnectCallback(const std::string& domain_name);
void destroyProfileHandle();
RequestEventPtr getRequestEvent(NetworkBearerSelectionRequestEvent* event);