2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file wrt_global_settings.cpp
19 * @author Pawel Sikorski(p.sikorski@samsung.com)
20 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
26 #include <sys/utsname.h>
27 #include <dpl/utils/wrt_global_settings.h>
29 namespace GlobalSettings {
32 const char* MACHINE_NAME_EMUL = "emulated"; // "arch_emulated"
36 MACHINE_TYPE_EMULATOR,
52 bool initializeGlobalSettings();
53 bool initHelper = initializeGlobalSettings();
55 MachineType getMachineType()
57 // get current machine name
60 if ((!u.machine) || (0 == strlen(u.machine))) {
61 return MACHINE_TYPE_UNKNOWN;
63 // If current machine is emul,
64 // machine name include "<arch>_emulated"
65 std::string machine = u.machine;
66 // find "emulated" string in the u.machine
67 if (std::string::npos != machine.find(MACHINE_NAME_EMUL)) {
68 return MACHINE_TYPE_EMULATOR;
70 return MACHINE_TYPE_TARGET;
75 return MACHINE_TYPE_UNKNOWN;
78 bool initializeGlobalSettings()
82 // ignore environment variables if this flag is not set
83 #ifdef GLOBAL_SETTINGS_CONTROL
84 const char *env = getenv("WRT_TEST_MODE");
85 gSettings.testMode = (env != NULL && 0 == strncmp(env, "1", 1));
86 // TODO other settings initialization
89 gSettings.isEmulator = (MACHINE_TYPE_EMULATOR == getMachineType());
94 bool TestModeEnabled()
96 return gSettings.testMode;
101 return gSettings.isEmulator;