LOG_INFO("privilege[%s] allowed", privilege.c_str());
}
-void util::throwIfFeatureNotSupported(const std::string& feature)
+static bool __isFeatureSupported(const std::string& feature)
{
bool supported = false;
+ if (system_info_get_platform_bool(feature.c_str(), &supported) != SYSTEM_INFO_ERROR_NONE) {
+ LOG_ERROR("failed to system_info_get_platform_bool(%s)", feature.c_str());
+ return false;
+ }
- if (system_info_get_platform_bool(feature.c_str(), &supported) != SYSTEM_INFO_ERROR_NONE)
- throw MediaTransporterException(MTPR_ERROR_INVALID_OPERATION,
- "failed to system_info_get_platform_bool(" + feature + ")");
+ LOG_INFO("feature[%s] supported[%d]", feature.c_str(), supported);
+ return supported;
+}
- if (!supported)
+void util::throwIfFeatureNotSupported(const std::string& feature)
+{
+ if (!__isFeatureSupported(feature))
throw MediaTransporterException(MTPR_ERROR_NOT_SUPPORTED,
"[" + feature + "] not supported");
-
- LOG_INFO("feature[%s] supported", feature.c_str());
}
void util::throwIfNetworkFeaturesNotSupported()
{
- try {
- throwIfFeatureNotSupported(MTPR_FEATURE_NETWORK_WIFI);
- throwIfFeatureNotSupported(MTPR_FEATURE_NETWORK_TELE);
- throwIfFeatureNotSupported(MTPR_FEATURE_NETWORK_ETH);
- } catch (const MediaTransporterException& e) {
- throw MediaTransporterException(MTPR_ERROR_NOT_SUPPORTED, e.what());
- }
+ if (!(__isFeatureSupported(MTPR_FEATURE_NETWORK_WIFI) ||
+ __isFeatureSupported(MTPR_FEATURE_NETWORK_TELE) ||
+ __isFeatureSupported(MTPR_FEATURE_NETWORK_ETH)))
+ throw MediaTransporterException(MTPR_ERROR_NOT_SUPPORTED,
+ "One of the network feature (WIFI/TELE/ETH) must be supported");
}