Added check emulator environment 85/135185/2 accepted/tizen/unified/20170622.104910 submit/tizen/20170621.080105
authorhyunuktak <hyunuk.tak@samsung.com>
Wed, 21 Jun 2017 06:48:07 +0000 (15:48 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Wed, 21 Jun 2017 07:05:51 +0000 (16:05 +0900)
Change-Id: Ied3e0a4abe59f93445aa46c8a44868f52c82876c
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
packaging/stc-manager.spec
src/CMakeLists.txt
src/monitor/include/stc-application-lifecycle.h [changed mode: 0644->0755]
src/monitor/include/stc-default-connection.h [changed mode: 0644->0755]
src/monitor/include/stc-emulator.h [new file with mode: 0755]
src/monitor/include/stc-monitor.h [changed mode: 0644->0755]
src/monitor/stc-emulator.c [new file with mode: 0755]
src/monitor/stc-monitor.c
src/stc-manager.c

index 7247da5..f9ff828 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-manager
 Summary:    STC(Smart Traffic Control) manager
-Version:    0.0.16
+Version:    0.0.17
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
@@ -19,6 +19,7 @@ BuildRequires:  pkgconfig(gio-unix-2.0)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(vconf)
+BuildRequires:  pkgconfig(capi-system-info)
 
 %if %{?enable_database} == YES
 BuildRequires: pkgconfig(sqlite3)
index 4173f82..736cec3 100644 (file)
@@ -6,6 +6,7 @@ SET(REQUIRES_LIST ${REQUIRES_LIST}
        gio-unix-2.0
        dlog
        vconf
+       capi-system-info
        )
 
 IF("${ENABLE_DATABASE}" STREQUAL "YES")
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/src/monitor/include/stc-emulator.h b/src/monitor/include/stc-emulator.h
new file mode 100755 (executable)
index 0000000..8e06f7c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __STC_EMULATOR_H__
+#define __STC_EMULATOR_H__
+
+#include <glib.h>
+
+gboolean stc_emulator_is_emulated(void);
+void stc_emulator_check_environment(void);
+
+#endif /* __STC_EMULATOR_H__ */
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/src/monitor/stc-emulator.c b/src/monitor/stc-emulator.c
new file mode 100755 (executable)
index 0000000..80bc170
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <system_info.h>
+
+#include "stc-emulator.h"
+#include "stc-manager-util.h"
+
+static gboolean stc_is_emulated = FALSE;
+
+static gboolean __stc_emulator_check_env(void)
+{
+       int ret;
+       char *model = NULL;
+
+       ret = system_info_get_platform_string("tizen.org/system/model_name", &model);
+       if (ret != SYSTEM_INFO_ERROR_NONE) {
+               STC_LOGE("Failed to get system information(%d)", ret);
+               return FALSE;
+       }
+
+       if (model && strncmp(model, "Emulator", strlen("Emulator")) == 0) {
+               g_free(model);
+               return TRUE;
+       }
+
+       g_free(model);
+       return FALSE;
+}
+
+gboolean stc_emulator_is_emulated(void)
+{
+       return stc_is_emulated;
+}
+
+void stc_emulator_check_environment(void)
+{
+       stc_is_emulated = __stc_emulator_check_env();
+
+       STC_LOGD("Emulation environment : %s",
+               stc_is_emulated ? "It's emulated" : "Not emulated");
+}
+
index 32d2a8a..835e29f 100755 (executable)
@@ -895,7 +895,7 @@ static gboolean __process_contr_reply(GIOChannel *source,
 
        ret = read_netlink(sock,
                           &ans, sizeof(struct genl));
-       STC_LOGD("Counter data received ret [%d]", ret);
+       /* STC_LOGD("Counter data received ret [%d]", ret); */
        if (ret == 0)
                goto out;
 
@@ -918,7 +918,7 @@ static gboolean __update_contr_cb(void *user_data)
                stc->carg->sock = stc_monitor_get_counter_socket();
        }
 
-       STC_LOGD("Get all counters");
+       /* STC_LOGD("Get all counters"); */
        nfacct_send_get_all(stc->carg);
 
        /* we need to continue the timer */
index 69349ae..6af6b7b 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 #include "stc-manager.h"
+#include "stc-emulator.h"
 #include "stc-statistics.h"
 #include "stc-restriction.h"
 #include "stc-manager-gdbus.h"
@@ -98,13 +99,16 @@ gint32 main(gint32 argc, gchar *argv[])
        g_type_init();
 #endif
 
-       g_stc = __stc_manager_init();
-       if (!g_stc)
-               goto fail;
-
        /* Crate the GLIB main loop */
        main_loop = g_main_loop_new(NULL, FALSE);
-       g_stc->main_loop = main_loop;
+
+       stc_emulator_check_environment();
+       if (stc_emulator_is_emulated() == FALSE) {
+               g_stc = __stc_manager_init();
+               if (!g_stc)
+                       goto fail;
+               g_stc->main_loop = main_loop;
+       }
 
        /* Run the main loop */
        g_main_loop_run(main_loop);
@@ -112,7 +116,8 @@ gint32 main(gint32 argc, gchar *argv[])
        ret = 0;
 
 fail:
-       __stc_manager_deinit();
+       if (stc_emulator_is_emulated() == FALSE)
+               __stc_manager_deinit();
 
        if (main_loop)
                g_main_loop_unref(main_loop);