6ccbe4f151820edc162c2a9864202b51ca62c3ea
[platform/core/connectivity/stc-manager.git] / src / monitor / stc-emulator.c
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <stdio.h>
18 #include <system_info.h>
19
20 #include "stc-emulator.h"
21 #include "stc-manager-util.h"
22
23 static gboolean stc_is_emulated = FALSE;
24
25 static gboolean __stc_emulator_check_env(void)
26 {
27         int ret;
28         char *model = NULL;
29
30         ret = system_info_get_platform_string("tizen.org/system/model_name", &model);
31         if (ret != SYSTEM_INFO_ERROR_NONE) {
32                 STC_LOGE("Failed to get system information(%d)", ret); //LCOV_EXCL_LINE
33                 return FALSE; //LCOV_EXCL_LINE
34         }
35
36         if (model && strncmp(model, "Emulator", strlen("Emulator")) == 0) {
37                 g_free(model); //LCOV_EXCL_LINE
38                 return TRUE; //LCOV_EXCL_LINE
39         }
40
41         g_free(model); //LCOV_EXCL_LINE
42         return FALSE; //LCOV_EXCL_LINE
43 }
44
45 gboolean stc_emulator_is_emulated(void)
46 {
47         return stc_is_emulated;
48 }
49
50 void stc_emulator_check_environment(void)
51 {
52         stc_is_emulated = __stc_emulator_check_env();
53
54         STC_LOGD("Emulation environment : %s",
55                 stc_is_emulated ? "It's emulated" : "Not emulated");
56 }
57