- This is for Tizen 4.0.
: Tizen 4.0 Configurability and Build Blocks require
to remove all profile-depending build options in spec files.
(No More profile macros)
- It is recommended to distinguish features/profiles at runtime.
unless it incurs too much overhead, which requires you to
create multiple binaries and subpackages.
- When SR-ing this commit, maintainers need to create JIRA-TRE issue of
Add net-config-profile_tv for TV profile
patchset5: code style update
Change-Id: I8641e53861df320698a6fba0dca1dd0ebcffeaa6
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
SET(SRCS ${SRCS} src/utils/network-accessibility.c)
ENDIF(TIZEN_CAPTIVE_PORTAL)
-IF(TIZEN_TV)
- ADD_DEFINITIONS(-DTIZEN_TV)
-ENDIF(TIZEN_TV)
-
IF(TIZEN_WEARABLE)
ADD_DEFINITIONS(-DTIZEN_WEARABLE)
ENDIF(TIZEN_WEARABLE)
-IF(TIZEN_TELEPHONY_ENABLE)
- ADD_DEFINITIONS(-DTIZEN_TELEPHONY_ENABLE)
-ENDIF(TIZEN_TELEPHONY_ENABLE)
-
-IF(TIZEN_NTP_ENABLE)
- ADD_DEFINITIONS(-DTIZEN_NTP_ENABLE)
-ENDIF(TIZEN_NTP_ENABLE)
-
-IF(TIZEN_WLAN_BOARD_SPRD)
- ADD_DEFINITIONS(-DTIZEN_WLAN_BOARD_SPRD)
-ENDIF(TIZEN_WLAN_BOARD_SPRD)
-
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(pkgs REQUIRED
dlog
}
#endif
+typedef enum {
+ TIZEN_PROFILE_UNKNOWN = 0,
+ TIZEN_PROFILE_MOBILE = 0x1,
+ TIZEN_PROFILE_WEARABLE = 0x2,
+ TIZEN_PROFILE_TV = 0x4,
+ TIZEN_PROFILE_IVI = 0x8,
+ TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+extern tizen_profile_t _get_tizen_profile();
+
+#define TIZEN_TELEPHONY_ENABLE (_get_tizen_profile() == TIZEN_PROFILE_MOBILE)
+#define TIZEN_WLAN_BOARD_SPRD (_get_tizen_profile() == TIZEN_PROFILE_MOBILE)
+#define TIZEN_TV (_get_tizen_profile() == TIZEN_PROFILE_TV)
+#define TIZEN_NTP_ENABLE (_get_tizen_profile() == TIZEN_PROFILE_IVI)
+
#endif /* __NETCONFIG_UTIL_H__ */
gboolean handle_load_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
gboolean handle_remove_p2p_driver(Wifi *wifi, GDBusMethodInvocation *context);
-#if defined TIZEN_TV
- void __netconfig_set_ether_macaddr();
-#endif
+void __netconfig_set_ether_macaddr();
#ifdef __cplusplus
}
void __netconfig_wifi_connect_reply(GObject *source_object, GAsyncResult *res,
gpointer user_data);
-#if defined TIZEN_WLAN_BOARD_SPRD
int wifi_firmware_download(void);
-#endif
-
void wifi_object_create_and_init(void);
void wifi_object_deinit(void);
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
+Provides: %{name}-profile_common = %{version}-%{release}
+Provides: %{name}-profile_mobile = %{version}-%{release}
+Provides: %{name}-profile_wearable = %{version}-%{release}
+Provides: %{name}-profile_ivi = %{version}-%{release}
%define upgrade_script_path /usr/share/upgrade/scripts
%description
TIZEN Network Configuration service
+%package profile_tv
+Summary: net-config extension for TV profile
+Requires: %{name} = %{version}-%{release}
+%description profile_tv
+TIZEN Network Configuration service extension for Tizen TV profile.
+
+
%prep
%setup -q
+# NOTE: the following macros are undefined.
+# PLEASE DO NOT USE model_build_features in the future with Tizen 4.0+.
+#{?model_build_feature_wlan_concurrent_mode}
+#{?model_build_feature_wlan_p2p_disable}
+#{?model_build_feature_network_tethering_disable}
+#{?model_build_feature_wlan_wearable}
+# In case, we have commercializing team using such unwelcomed
+# macros in their productin build, we are keeping those.
+# However, it is recommended to remove all if/endif with model_build_feature
+
+# NOTE: Are we really going to make "mobile" == "SPRD"?
+
%build
cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DTIZEN_WLAN_PASSPOINT=1 \
%if ! 0%{?model_build_feature_network_tethering_disable}
-DTIZEN_TETHERING_ENABLE=1 \
%endif
-%if "%{profile}" == "mobile"
- -DTIZEN_TELEPHONY_ENABLE=1 \
- -DTIZEN_WLAN_BOARD_SPRD=1 \
-%else
-%if "%{profile}" == "tv"
- -DTIZEN_TV=1 \
-%endif
-%endif
-%if "%{profile}" == "ivi"
- -DTIZEN_NTP_ENABLE=1 \
-%endif
%if 0%{?model_build_feature_wlan_wearable} == 1
-DTIZEN_WEARABLE=1 \
-DTIZEN_CAPTIVE_PORTAL=1 \
mkdir -p %{buildroot}%{_unitdir}
%endif
-%if "%{profile}" == "tv"
-cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_libdir}/systemd/system/net-config.service
+cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_libdir}/systemd/system/net-config.service.tv
mkdir -p %{buildroot}%{_libdir}/udev/rules.d/
cp resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules %{buildroot}%{_libdir}/udev/rules.d/99-wifiusb-dev.rules
%if "%{?_lib}" == "lib64"
-cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_unitdir}/net-config.service
+cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_unitdir}/net-config.service.tv
%endif
-%else
cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_libdir}/systemd/system/net-config.service
%if "%{?_lib}" == "lib64"
cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_unitdir}/net-config.service
%endif
-%endif
mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/
ln -s ../net-config.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/net-config.service
%attr(644,root,root) %{_unitdir}/multi-user.target.wants/net-config.service
%endif
%{_datadir}/license/net-config
-%if "%{profile}" == "tv"
-%attr(644,root,root) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
-%endif
%if 0%{?model_build_feature_wlan_wearable} == 1
%attr(700,root,root) /usr/system/RestoreDir/softreset/network_softreset.sh
%endif
%{upgrade_script_path}/500.netconfig_upgrade.sh
+%post profile_tv
+mv %{_libdir}/systemd/system/net-config.service.tv %{_libdir}/systemd/system/net-config.service
+%if "%{?_lib}" == "lib64"
+mv %{_unitdir}/net-config.service.tv %{_unitdir}/net-config.service
+%endif
+%files profile_tv
+%attr(644,root,root) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%attr(644,root,root) %{_libdir}/systemd/system/net-config.service.tv
+%if "%{?_lib}" == "lib64"
+%attr(644,root,root) %{_unitdir}/net-config.service.tv
+%endif
#include <system_info.h>
#include "log.h"
+#include "util.h"
#include "wifi.h"
#include "netdbus.h"
#include "emulator.h"
register_gdbus_signal();
connman_register_agent();
-#if defined TIZEN_TV
- __netconfig_set_ether_macaddr();
-#endif
+ if (TIZEN_TV)
+ __netconfig_set_ether_macaddr();
}
static void _objects_deinit(void)
netconfig_error_init();
-#if defined TIZEN_NTP_ENABLE
- netconfig_clock_init();
-#endif
+ if (TIZEN_NTP_ENABLE)
+ netconfig_clock_init();
/* If its environment uses Emulator, network configuration is set by emulator default */
emulator_test_and_start();
/* For device policy manager */
netconfig_dpm_init();
-#if defined TIZEN_WLAN_BOARD_SPRD
- wifi_firmware_download();
-#endif
+ if (TIZEN_WLAN_BOARD_SPRD)
+ wifi_firmware_download();
/*In case no emulator, set the ETH0 Mac address*/
-#if defined TIZEN_TV
- if (emulator_is_emulated() == FALSE)
+ if (TIZEN_TV && emulator_is_emulated() == FALSE)
__netconfig_set_ether_macaddr();
-#endif
if (!system_info_get_platform_bool(ETHERNET_FEATURE, ðernet_feature_supported)) {
if (ethernet_feature_supported == TRUE) {
netconfig_dpm_deinit();
-#if defined TIZEN_NTP_ENABLE
- netconfig_clock_deinit();
-#endif
+ if (TIZEN_NTP_ENABLE)
+ netconfig_clock_deinit();
/*remove the Timer*/
#include <bundle_internal.h>
#include <eventsystem.h>
#include <tzplatform_config.h>
+#include <system_info.h>
#include "log.h"
#include "util.h"
g_free(mac_lower_str);
fclose(file);
}
+
+tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ char *profileName;
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+ switch (*profileName) {
+ case 'm':
+ case 'M':
+ profile = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: // common or unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
gchar *tmp = NULL;
gchar mac[13] = { 0, };
gint i = 0, j = 0;
-#if defined TIZEN_TV
- FILE *fp = NULL;
- char buf[WIFI_MAC_ADD_LENGTH + 1];
- if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
- fp = fopen(WIFI_MAC_ADD_PATH, "r");
-
- if (fp == NULL) {
- ERR("Failed to open file %s\n", WIFI_MAC_ADD_PATH);
- *mac_address = NULL;
- return FALSE;
- }
- if (fgets(buf, sizeof(buf), fp) == NULL) {
- ERR("Failed to get MAC info from %s\n", WIFI_MAC_ADD_PATH);
- *mac_address = NULL;
- fclose(fp);
- return FALSE;
- }
- tmp_mac = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1);
- if (tmp_mac == NULL) {
- ERR("malloc() failed");
- *mac_address = NULL;
+ if (TIZEN_TV) {
+ FILE *fp = NULL;
+ char buf[WIFI_MAC_ADD_LENGTH + 1];
+ if (0 == access(WIFI_MAC_ADD_PATH, F_OK))
+ fp = fopen(WIFI_MAC_ADD_PATH, "r");
+
+ if (fp == NULL) {
+ ERR("Failed to open file %s\n", WIFI_MAC_ADD_PATH);
+ *mac_address = NULL;
+ return FALSE;
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ ERR("Failed to get MAC info from %s\n", WIFI_MAC_ADD_PATH);
+ *mac_address = NULL;
+ fclose(fp);
+ return FALSE;
+ }
+ tmp_mac = (char *)g_try_malloc0(WIFI_MAC_ADD_LENGTH + 1);
+ if (tmp_mac == NULL) {
+ ERR("malloc() failed");
+ *mac_address = NULL;
+ fclose(fp);
+ return FALSE;
+ }
+ g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1);
fclose(fp);
- return FALSE;
- }
- g_strlcpy(tmp_mac, buf, WIFI_MAC_ADD_LENGTH + 1);
- fclose(fp);
-#else
- tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
- if (tmp_mac == NULL) {
- ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
- *mac_address = NULL;
- return FALSE;
+ } else {
+ tmp_mac = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+ if (tmp_mac == NULL) {
+ ERR("vconf_get_str(WIFI_BSSID_ADDRESS) Failed");
+ *mac_address = NULL;
+ return FALSE;
+ }
}
-#endif
tmp = g_ascii_strdown(tmp_mac, (gssize)strlen(tmp_mac));
g_free(tmp_mac);
while (tmp && tmp[i]) {
#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
#define WLAN_IFACE_NAME "wlan0"
-#if defined(TIZEN_TV)
-#define WLAN_P2P_IFACE_NAME "p2p0"
-#else /* defined(TIZEN_TV) */
-#define WLAN_P2P_IFACE_NAME "wlan0"
-#endif /* defined(TIZEN_TV) */
+#define WLAN_P2P_IFACE_NAME_TV "p2p0"
+#define WLAN_P2P_IFACE_NAME_COMMON "wlan0"
+#define WLAN_P2P_IFACE_NAME ((TIZEN_TV) ? (WLAN_P2P_IFACE_NAME_TV) : (WLAN_P2P_IFACE_NAME_COMMON))
static int __netconfig_sta_firmware_start(void)
{
#define WLAN_MAC_ADDR_MAX 20
#define VCONF_WIFI_BSSID_ADDRESS "db/wifi/bssid_address"
-#if defined TIZEN_TV
#define ETH_MAC_ADDR_SIZE 6
#define VCONF_ETH_MAC_ADDRESS "db/dnet/mac_address"
#define NET_EXEC_PATH "/sbin/ifconfig"
#define OS_RANDOM_FILE "/dev/urandom"
-#endif
static gboolean connman_wifi_technology_state = FALSE;
static gboolean wifi_firmware_recovery_mode = FALSE;
prev_state = new_state;
}
-#if defined TIZEN_TELEPHONY_ENABLE
static void _tapi_noti_sim_status_cb(TapiHandle *handle, const char *noti_id,
void *data, void *user_data)
{
done:
vconf_ignore_key_changed(VCONFKEY_TELEPHONY_READY, __netconfig_telephony_ready_changed_cb);
}
-#endif
int wifi_power_driver_and_supplicant(gboolean enable)
{
/* Update the last Wi-Fi power state */
netconfig_vconf_get_int(VCONF_WIFI_LAST_POWER_STATE, &wifi_last_power_state);
if (wifi_last_power_state > VCONFKEY_WIFI_OFF) {
-#if defined TIZEN_TELEPHONY_ENABLE
- int telephony_ready = 0;
- netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_READY, &telephony_ready);
- if (telephony_ready == 0) {
- DBG("Telephony API is not initialized yet");
- vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY,
- __netconfig_telephony_ready_changed_cb, NULL);
- } else {
- if (netconfig_tapi_check_sim_state() == FALSE)
- DBG("SIM is not initialized yet");
+ if (TIZEN_TELEPHONY_ENABLE) {
+ int telephony_ready = 0;
+ netconfig_vconf_get_bool(VCONFKEY_TELEPHONY_READY, &telephony_ready);
+ if (telephony_ready == 0) {
+ DBG("Telephony API is not initialized yet");
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY,
+ __netconfig_telephony_ready_changed_cb, NULL);
+ } else {
+ if (netconfig_tapi_check_sim_state() == FALSE)
+ DBG("SIM is not initialized yet");
+ }
}
-#endif
DBG("Turn Wi-Fi on automatically");
#if defined TIZEN_WEARABLE
wifi_power_on_wearable(TRUE);
return TRUE;
}
-#if defined TIZEN_WLAN_BOARD_SPRD
- wifi_firmware_download();
-#endif
+ if (TIZEN_WLAN_BOARD_SPRD)
+ wifi_firmware_download();
#if defined TIZEN_WEARABLE
err = wifi_power_on_wearable(device_picker_test);
return TRUE;
}
-#if defined TIZEN_TV
static int __netconfig_get_random_mac(unsigned char *mac_buf, int mac_len)
{
DBG("Generate Random Mac address of ethernet");
g_free(mac_addr);
}
-#endif
return TRUE;
}
-#if defined TIZEN_TV
static void __interface_wps_cancel_result(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
return reply;
}
-#endif
gboolean netconfig_iface_wifi_request_wps_cancel(Wifi *wifi, GDBusMethodInvocation **context)
{
-#if defined TIZEN_TV
- DBG("Received WPS PBC Cancel Request");
- g_return_val_if_fail(wifi != NULL, FALSE);
- return __netconfig_wifi_invoke_wps_cancel();
-#else
- /*Not supported for mobile and Wearable profile*/
- return FALSE;
-#endif
+ if (TIZEN_TV) {
+ DBG("Received WPS PBC Cancel Request");
+ g_return_val_if_fail(wifi != NULL, FALSE);
+ return __netconfig_wifi_invoke_wps_cancel();
+ } else {
+ /*Not supported for mobile and Wearable profile*/
+ return FALSE;
+ }
}
#include "wifi-config.h"
#include "wifi-tdls.h"
-#if defined TIZEN_WLAN_BOARD_SPRD
#define SPRD_CP2_FIRMWARE_PATH "/usr/bin/cp2-downloader"
static int is_wifi_firmware_downloaded = FALSE;
-#endif
static Wifi *wifi_object = NULL;
static NetConnmanAgent *connman_agent_object = NULL;
return;
}
-#if defined TIZEN_WLAN_BOARD_SPRD
int wifi_firmware_download(void)
{
int rv = 0;
return 0;
}
-#endif
void wifi_object_create_and_init(void)
{