summaryrefslogtreecommitdiff
path: root/mobile_src/Systeminfo/Systeminfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Systeminfo/Systeminfo.cpp')
-rwxr-xr-xmobile_src/Systeminfo/Systeminfo.cpp1716
1 files changed, 1716 insertions, 0 deletions
diff --git a/mobile_src/Systeminfo/Systeminfo.cpp b/mobile_src/Systeminfo/Systeminfo.cpp
new file mode 100755
index 0000000..0f33312
--- /dev/null
+++ b/mobile_src/Systeminfo/Systeminfo.cpp
@@ -0,0 +1,1716 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 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 <stddef.h>
+#include <cassert>
+#include <math.h>
+#include <Commons/Exception.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <TimeTracer.h>
+#include "Systeminfo.h"
+#include <Logger.h>
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+#define SIM_VALUE_MAX 4
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+namespace {
+
+void BatteryValueCallback(keynode_t *node, void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_BATTERY);
+ }
+}
+
+void PeripheralValueCallback(keynode_t *node, void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_PERIPHERAL);
+ }
+}
+
+void CellularNetworkValueCallback(keynode_t *node, void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_CELLULARNETWORK);
+ }
+}
+
+void DisplayValueCallback(keynode_t *node, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DISPLAY);
+ }
+}
+
+void OrientationValueVconfCallback(keynode_t *node, void *event_ptr)
+{
+ LoggerD("enter");
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DEVICE_ORIENTATION);
+ }
+}
+
+void NetworkTypeValueCallback(connection_type_e type, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_NETWORK);
+ }
+}
+
+void NetworkValueCallback(const char* ipv4_address, const char* ipv6_address, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_NETWORK_ALL);
+ }
+}
+
+void StorageValueVconfCallback(keynode_t *node, void *event_ptr)
+{
+ LoggerD("enter");
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_STORAGE);
+ }
+}
+
+static Eina_Bool StorageValueCallback(void* event_ptr)
+{
+ LoggerD("enter");
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_STORAGE);
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool CpuValueCallback(void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_CPU);
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+void OrientationValueCallback(unsigned int event_type, sensor_event_data_t *event , void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DEVICE_ORIENTATION);
+ }
+}
+
+void localeChangedCallback(runtime_info_key_e key, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_LOCALE);
+ }
+}
+
+void SimCphsValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimCphsNetName_t *cphsInfo = (TelSimCphsNetName_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ if(strlen((const char*)cphsInfo->full_name) == 0) {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, (char *)cphsInfo->full_name, event);
+ } else if (strlen((const char*)cphsInfo->short_name) == 0) {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, (char *)cphsInfo->short_name, event);
+ } else {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, NULL, event);
+ }
+ } else {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+void SimMsisdnValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimMsisdnList_t *msisdnInfo = (TelSimMsisdnList_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ systeminfo->setSimValue(SIM_MSISDN_VALUE, (char *)msisdnInfo->list[0].num, event);
+ } else {
+ systeminfo->setSimValue(SIM_MSISDN_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+void SimIccidValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimIccIdInfo_t *iccidInfo = (TelSimIccIdInfo_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ systeminfo->setSimValue(SIM_ICCID_VALUE, (char *)iccidInfo->icc_num, event);
+ } else {
+ systeminfo->setSimValue(SIM_ICCID_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+void SimSpnValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimSpn_t *spnInfo = (TelSimSpn_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ systeminfo->setSimValue(SIM_SPN_VALUE, (char *)spnInfo->spn, event);
+ } else {
+ systeminfo->setSimValue(SIM_ICCID_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+}
+
+#define STORAGE_INTERNAL_PATH "/opt/usr/media"
+#define STORAGE_SDCARD_PATH "/opt/storage/sdcard"
+#define STORAGE_USBHOST_PATH "/opt/storage/usb"
+#define DISPLAY_BRIGHTNESS_DIVIDE_VALUE 100
+#define WIFI_SIGNAL_STRENGTH_DIVIDE_VALUE 100
+#define CPU_POWER_DEVICE_VALUE 100
+
+#define RADIAN_VALUE (57.2957)
+
+enum {
+ STORAGE_TYPE_UNKNOWN = 0,
+ STORAGE_TYPE_INTERNAL = 1,
+ STORAGE_TYPE_MMC = 2,
+ STORAGE_TYPE_USBHOST = 3
+};
+
+Systeminfo::OptionalProperty Systeminfo::m_Property;
+
+Systeminfo::Systeminfo() : m_networkRegist(REGIST_NOT),
+ m_storageTimer(NULL),
+ m_cpuTimer(NULL),
+ m_sensorHandle(0),
+ m_connectionHandle(NULL)
+{
+ EventMgrPtr eventMgrPtr(new EventMgr());
+ m_EventMgrPtr = eventMgrPtr;
+ if (m_Property.IsNull()) {
+ mapProperties properties;
+ properties["BATTERY"] = BasePropertyPtr(new Battery());
+ m_Property = properties;
+ (*m_Property)["CPU"] = BasePropertyPtr(new Cpu());
+ (*m_Property)["STORAGE"] = BasePropertyPtr(new Storage());
+ (*m_Property)["DISPLAY"] = BasePropertyPtr(new Display());
+ (*m_Property)["NETWORK"] = BasePropertyPtr(new Network());
+ (*m_Property)["WIFI_NETWORK"] = BasePropertyPtr(new WifiNetwork());
+ (*m_Property)["CELLULAR_NETWORK"] = BasePropertyPtr(new CellularNetwork());
+ (*m_Property)["SIM"] = BasePropertyPtr(new SIM());
+ (*m_Property)["DEVICE_ORIENTATION"] = BasePropertyPtr(new DeviceOrientation());
+ (*m_Property)["BUILD"] = BasePropertyPtr(new Build());
+ (*m_Property)["LOCALE"] = BasePropertyPtr(new Locale());
+ (*m_Property)["PERIPHERAL"] = BasePropertyPtr(new Peripheral());
+ }
+
+ int ret = connection_create(&m_connectionHandle);
+
+ if (CONNECTION_ERROR_NONE == ret) {
+ LoggerD("Network Client registration success");
+ } else {
+ LoggerD("Network Client registration success");
+ m_connectionHandle = NULL;
+ }
+
+ m_sensorHandle = sf_connect(ACCELEROMETER_SENSOR);
+ if (m_sensorHandle < 0) {
+ LoggerD ("sensor attach fail");
+ } else {
+ LoggerD("m_sensorHandle : " << m_sensorHandle);
+ int state = sf_start(m_sensorHandle, 0);
+ if(state < 0) {
+ LoggerD("failed");
+ }
+ }
+
+ m_tapiHandle = tel_init(0);
+ if (m_tapiHandle == NULL) {
+ LoggerE ("tel init fail");
+ }
+}
+
+Systeminfo::~Systeminfo()
+{
+ int state = 0;
+ if (m_storageTimer) {
+ ecore_timer_freeze(m_storageTimer);
+ ecore_timer_del(m_storageTimer);
+ m_storageTimer = NULL;
+ }
+ if (m_cpuTimer) {
+ ecore_timer_freeze(m_cpuTimer);
+ ecore_timer_del(m_cpuTimer);
+ m_cpuTimer = NULL;
+ }
+ m_EventMgrPtr->clearAllEvent();
+
+ if(m_connectionHandle != NULL) {
+ LoggerD("Network Client deregistration success");
+ connection_destroy(m_connectionHandle);
+ } else {
+ LoggerD("Network Client deregistration failed");
+ }
+
+ if (m_tapiHandle != NULL) {
+ tel_deinit(m_tapiHandle);
+ }
+
+ state = sf_stop(m_sensorHandle);
+ LoggerD("handle 1 state = " << state);
+
+ state = sf_disconnect(m_sensorHandle);
+ LoggerD("handle state =" << state);
+}
+
+DeviceCapabilitiesPropertiesPtr Systeminfo::getCapabilities()
+{
+ LoggerD("enter");
+ DeviceCapabilitiesPropertiesPtr deviceCapabilities(new DeviceCapabilitiesProperties());
+ return deviceCapabilities;
+}
+
+void Systeminfo::get(const EventGetSysteminfoPtr& event)
+{
+ event->setTapiHandle((void*)m_tapiHandle);
+ EventRequestReceiver<EventGetSysteminfo>::PostRequest(event);
+}
+
+void Systeminfo::watch(const EventWatchSysteminfoPtr& event)
+{
+ if(event->getWatchType() == WATCH_TYPE_UNKNOWN) {
+ LoggerD("watch method is not supported");
+ event->setId(-1);
+ return;
+ }
+
+ event->setSysteminfoPtr(this);
+ event->setTapiHandle((void*)m_tapiHandle);
+ m_EventMgrPtr->addEvent(event, event->getWatchType());
+
+ EventRequestReceiver<EventWatchSysteminfo>::PostRequest(event);
+}
+
+void Systeminfo::clearWatch(const long id)
+{
+ if (id < 1) {
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+ } else {
+ int watchType = m_EventMgrPtr->getWatchType(id);
+ switch(watchType) {
+ case WATCH_TYPE_BATTERY:
+ if ((m_EventMgrPtr->getEventBatteryList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, BatteryValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, BatteryValueCallback);
+ }
+ break;
+ case WATCH_TYPE_DISPLAY:
+ if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback);
+ }
+ break;
+ case WATCH_TYPE_NETWORK:
+ if ((m_EventMgrPtr->getEventNetworkList()).size() == 1) {
+ connection_unset_type_changed_cb(m_connectionHandle);
+ }
+ break;
+ case WATCH_TYPE_WIFINETWORK:
+ if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
+ if (m_networkRegist == REGIST_WIFI) {
+ connection_unset_ip_address_changed_cb(m_connectionHandle);
+ m_networkRegist = REGIST_NOT;
+ } else if (m_networkRegist== REGIST_ALL) {
+ m_networkRegist = REGIST_CELLULAR;
+ }
+ }
+ break;
+ case WATCH_TYPE_CELLULARNETWORK:
+ if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, CellularNetworkValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_CELLID, CellularNetworkValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_LAC, CellularNetworkValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, CellularNetworkValueCallback);
+ if (m_networkRegist == REGIST_CELLULAR) {
+ connection_unset_ip_address_changed_cb(m_connectionHandle);
+ m_networkRegist = REGIST_NOT;
+ } else if (m_networkRegist== REGIST_ALL) {
+ m_networkRegist = REGIST_WIFI;
+ }
+ }
+ break;
+ case WATCH_TYPE_STORAGE:
+ if ((m_EventMgrPtr->getEventStorageList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, StorageValueVconfCallback);
+ if (m_storageTimer) {
+ ecore_timer_freeze(m_storageTimer);
+ ecore_timer_del(m_storageTimer);
+ m_storageTimer = NULL;
+ }
+ }
+ break;
+ case WATCH_TYPE_CPU:
+ if ((m_EventMgrPtr->getEventCpuList()).size() == 1) {
+ if (m_cpuTimer) {
+ ecore_timer_freeze(m_cpuTimer);
+ ecore_timer_del(m_cpuTimer);
+ m_cpuTimer = NULL;
+ }
+ }
+ break;
+ case WATCH_TYPE_DEVICE_ORIENTATION:
+ if ((m_EventMgrPtr->getEventDeviceOrientationList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, OrientationValueVconfCallback);
+ int state = sf_unregister_event(m_sensorHandle, ACCELEROMETER_EVENT_ROTATION_CHECK);
+ if (state < 0) {
+ LoggerD("sf_unregister_event fail to gather data\n");
+ }
+ }
+ break;
+ case WATCH_TYPE_LOCALE:
+ if ((m_EventMgrPtr->getEventLocaleList()).size() == 1) {
+ if (runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_LANGUAGE) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ if (runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_REGION) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ }
+ break;
+ case WATCH_TYPE_PERIPHERAL:
+ if ((m_EventMgrPtr->getEventPeripheralList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, PeripheralValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, PeripheralValueCallback);
+ }
+ break;
+ case WATCH_TYPE_UNKNOWN:
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+ break;
+ }
+ m_EventMgrPtr->removeEvent(id, watchType);
+ }
+}
+
+BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef property)
+{
+ Converter converter(context);
+ std::string l_property = converter.toString(property);
+ mapProperties::iterator it = (*m_Property).find(l_property);
+ if (it == (*m_Property).end()) {
+ LoggerE("not existing property");
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ return BasePropertyPtr(NULL);
+ }
+
+ return it->second;
+}
+
+void Systeminfo::getWatchValue(const int watchType)
+{
+ LoggerD(" watch type : " << watchType);
+
+ if (watchType == WATCH_TYPE_BATTERY) {
+ EventBatteryList eventList = m_EventMgrPtr->getEventBatteryList();
+ for (EventBatteryList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_DISPLAY) {
+ EventDisplayList eventList = m_EventMgrPtr->getEventDisplayList();
+ for (EventDisplayList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_NETWORK) {
+ EventNetworkList eventList = m_EventMgrPtr->getEventNetworkList();
+ for (EventNetworkList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_NETWORK_ALL) {
+ EventWifiNetworkList eventListWifi = m_EventMgrPtr->getEventWifiNetworkList();
+ EventWifiNetworkList eventListCellular = m_EventMgrPtr->getEventCellularNetworkList();
+ if (eventListWifi.size() > 0) {
+ for (EventWifiNetworkList::iterator it = eventListWifi.begin(); it != eventListWifi.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ }
+ if (eventListCellular.size() > 0) {
+ for (EventCellularNetworkList::iterator it = eventListCellular.begin(); it != eventListCellular.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ }
+ } else if (watchType == WATCH_TYPE_CPU) {
+ EventCpuList eventList = m_EventMgrPtr->getEventCpuList();
+ for (EventCpuList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_STORAGE) {
+ EventStorageList eventList = m_EventMgrPtr->getEventStorageList();
+ for (EventStorageList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ int storageCnt = 1;
+ int sdcardState = 0;
+ if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
+ if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+ LoggerD("mmc is mounted");
+ storageCnt++;
+ } else {
+ LoggerD("mmc is unmounted");
+ }
+ }
+ LoggerD("storage cnt : " << storageCnt);
+ (*it)->getWatchValue(storageCnt);
+ }
+ }else if (watchType == WATCH_TYPE_DEVICE_ORIENTATION) {
+ EventDeviceOrientationList eventList = m_EventMgrPtr->getEventDeviceOrientationList();
+ for (EventDeviceOrientationList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_LOCALE) {
+ EventLocaleList eventList = m_EventMgrPtr->getEventLocaleList();
+ for (EventLocaleList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_PERIPHERAL) {
+ EventPeripheralList eventList = m_EventMgrPtr->getEventPeripheralList();
+ for (EventPeripheralList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
+ EventWifiNetworkList eventListCellular = m_EventMgrPtr->getEventCellularNetworkList();
+ if (eventListCellular.size() > 0) {
+ for (EventCellularNetworkList::iterator it = eventListCellular.begin(); it != eventListCellular.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ }
+ }
+}
+
+connection_h Systeminfo::getConnectionHandle()
+{
+ return m_connectionHandle;
+}
+
+JSValueRef Systeminfo::getCpuValue(JSContextRef context)
+{
+ LoggerD("enter");
+ Converter converter(context);
+
+ CpuPropertiesPtr cpuPtr(new CpuProperties());
+ FILE *fp = NULL;
+ long long usr = 0, nice = 0, system = 0, idle = 0, cpuUsage = 0, diffIdle = 0, total = 0;
+
+ fp = fopen("/proc/stat", "r");
+ if(fp == NULL) {
+ return JSValueMakeNull(context);
+ }
+
+ if (fscanf(fp, "%*s %lld %lld %lld %lld", &usr, &system, &nice, &idle) > 0) {
+ total = usr + nice + system + idle - m_cpuInfo.usr - m_cpuInfo.nice - m_cpuInfo.system - m_cpuInfo.idle;
+ diffIdle = idle-m_cpuInfo.idle;
+ if ((total > 0LL) && (diffIdle > 0LL)) {
+ cpuUsage = diffIdle * 100LL / total;
+ cpuPtr->load = (double)cpuUsage / 100.0;
+ m_cpuInfo.usr = usr;
+ m_cpuInfo.system = system;
+ m_cpuInfo.nice = nice;
+ m_cpuInfo.idle = idle;
+ LoggerD("cpu load : " << cpuPtr->load);
+ }
+ }
+
+ fclose(fp);
+ return JSCpuInfo::createJSObject(context, cpuPtr);
+}
+
+void Systeminfo::setSimValue(const int simAttribute, char* value, const EventGetSysteminfoPtr &event)
+{
+ int ret = 0;
+ if (!value) {
+ ret = event->addSimValueCnt();
+ } else {
+ ret = event->setSimValue(simAttribute, value);
+ }
+
+ if (ret == SIM_VALUE_MAX) {
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ }
+}
+
+void Systeminfo::OnRequestReceived(const EventGetSysteminfoPtr& event)
+{
+ LoggerD("enter");
+
+ if (strcmp(event->getProperty(), (const char*)"SIM") == 0) {
+ int cardChanged = 0;
+ TelSimCardStatus_t simCardState;
+ TelSimImsiInfo_t imsi;
+ char* simState = NULL;
+
+ event->switchToManualAnswer();
+ event->setCancelAllowed(true);
+
+ if (tel_get_sim_init_info(m_tapiHandle, &simCardState, &cardChanged) == TAPI_API_SUCCESS) {
+ switch(simCardState) {
+ case TAPI_SIM_STATUS_CARD_NOT_PRESENT :
+ case TAPI_SIM_STATUS_CARD_REMOVED :
+ simState = strdup("ABSENT");
+ break;
+ case TAPI_SIM_STATUS_SIM_INITIALIZING :
+ simState = strdup("INITIALIZING");
+ break;
+ case TAPI_SIM_STATUS_SIM_INIT_COMPLETED :
+ simState = strdup("READY");
+ break;
+ case TAPI_SIM_STATUS_SIM_PIN_REQUIRED :
+ simState = strdup("PIN_REQUIRED");
+ break;
+ case TAPI_SIM_STATUS_SIM_PUK_REQUIRED :
+ simState = strdup("PUK_REQUIRED");
+ break;
+ case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED :
+ case TAPI_SIM_STATUS_CARD_BLOCKED :
+ simState = strdup("SIM_LOCKED");
+ break;
+ case TAPI_SIM_STATUS_SIM_NCK_REQUIRED :
+ case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED :
+ simState = strdup("NETWORK_LOCKED");
+ break;
+ default:
+ simState = strdup("UNKNOWN");
+ break;
+ }
+ if (simState == NULL) {
+ LoggerE("get fail sim state");
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ return;
+ }
+ event->setSimState(simState);
+ if(strcmp(simState, "READY") == 0) {
+ if (tel_get_sim_imsi(m_tapiHandle, &imsi) == TAPI_API_SUCCESS) {
+ LoggerD("mcc : " << imsi.szMcc << " mnc : " << imsi.szMnc << " msin : " << imsi.szMsin);
+ event->setSimImsi(imsi.szMcc, imsi.szMnc, imsi.szMsin);
+ } else {
+ LoggerE("get fail sim imsi");
+ }
+ SysteminfoAsyncPendingEvent *cphsPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_cphs_netname(m_tapiHandle, SimCphsValueCallback, cphsPendingEvent);
+ SysteminfoAsyncPendingEvent *msisdnPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_msisdn(m_tapiHandle, SimMsisdnValueCallback, msisdnPendingEvent);
+ SysteminfoAsyncPendingEvent *iccidPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_iccid(m_tapiHandle, SimIccidValueCallback, iccidPendingEvent);
+ SysteminfoAsyncPendingEvent *spnPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_spn(m_tapiHandle, SimSpnValueCallback, spnPendingEvent);
+ } else {
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ }
+ free(simState);
+ } else {
+ LoggerE("get fail sim state");
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ }
+ } else {
+ event->processGetValue((void *)m_connectionHandle);
+ }
+}
+
+void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
+{
+ WatchOption watchOption = event->getWatchOption();
+
+ event->switchToManualAnswer();
+ event->setCancelAllowed(true);
+
+ switch(event->getWatchType()) {
+ case WATCH_TYPE_BATTERY:
+ if ((m_EventMgrPtr->getEventBatteryList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, BatteryValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, BatteryValueCallback, (void *)this);
+ }
+ break;
+ case WATCH_TYPE_DISPLAY:
+ if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback, (void *)this);
+ }
+ break;
+ case WATCH_TYPE_NETWORK:
+ if ((m_EventMgrPtr->getEventNetworkList()).size() == 1) {
+ connection_set_type_changed_cb(m_connectionHandle, NetworkTypeValueCallback, (void *)this);
+ }
+ break;
+ case WATCH_TYPE_WIFINETWORK:
+ if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
+ if (m_networkRegist == REGIST_NOT) {
+ connection_set_ip_address_changed_cb(m_connectionHandle, NetworkValueCallback, (void *)this);
+ m_networkRegist = REGIST_WIFI;
+ } else if (m_networkRegist== REGIST_CELLULAR) {
+ m_networkRegist = REGIST_ALL;
+ }
+ }
+ break;
+ case WATCH_TYPE_CELLULARNETWORK:
+ if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, CellularNetworkValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_CELLID, CellularNetworkValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_LAC, CellularNetworkValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, CellularNetworkValueCallback, (void *)this);
+ if (m_networkRegist == REGIST_NOT) {
+ connection_set_ip_address_changed_cb(m_connectionHandle, NetworkValueCallback, (void *)this);
+ m_networkRegist = REGIST_CELLULAR;
+ } else if (m_networkRegist== REGIST_WIFI) {
+ m_networkRegist = REGIST_ALL;
+ }
+ }
+ break;
+ case WATCH_TYPE_STORAGE:
+ if ((m_EventMgrPtr->getEventStorageList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, StorageValueVconfCallback, (void *)this);
+ if (!m_storageTimer) {
+ m_storageTimer = ecore_timer_add(1, StorageValueCallback, this);
+ ecore_timer_thaw(m_storageTimer);
+ }
+ }
+ break;
+ case WATCH_TYPE_CPU:
+ if ((m_EventMgrPtr->getEventCpuList()).size() == 1) {
+ if (!m_cpuTimer) {
+ m_cpuTimer = ecore_timer_add(1, CpuValueCallback, this);
+ ecore_timer_thaw(m_cpuTimer);
+ }
+ }
+ break;
+ case WATCH_TYPE_DEVICE_ORIENTATION:
+ LoggerD("regist sensor");
+ if ((m_EventMgrPtr->getEventDeviceOrientationList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, OrientationValueVconfCallback, (void *)this);
+ int state = sf_register_event(m_sensorHandle, ACCELEROMETER_EVENT_ROTATION_CHECK, NULL, OrientationValueCallback, (void *)this);
+ if (state < 0) {
+ LoggerD("sensor_register_cb fail to gather data");
+ } else if (state == 0) {
+ LoggerD("sensor_register_cb success to gather data");
+ }
+ } else {
+ LoggerD("already regist");
+ }
+ break;
+ case WATCH_TYPE_LOCALE:
+ if ((m_EventMgrPtr->getEventLocaleList()).size() == 1) {
+ if (runtime_info_set_changed_cb(RUNTIME_INFO_KEY_REGION, localeChangedCallback, (void *)this) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ if (runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LANGUAGE, localeChangedCallback, (void *)this) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ }
+ break;
+ case WATCH_TYPE_PERIPHERAL:
+ if ((m_EventMgrPtr->getEventPeripheralList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, PeripheralValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_HDMI, PeripheralValueCallback, (void *)this);
+ }
+ break;
+ }
+ event->processGetValue();
+ event->setTimer();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+
+Systeminfo::EventMgr::EventMgr()
+{
+}
+
+Systeminfo::EventMgr::~EventMgr()
+{
+}
+
+void Systeminfo::EventMgr::clearAllEvent()
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+
+ while (!m_eventBatteryList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventBatteryList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventBatteryList.pop_front();
+ }
+ while (!m_eventDisplayList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventDisplayList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventDisplayList.pop_front();
+ }
+ while (!m_eventWifiNetworkList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventWifiNetworkList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventWifiNetworkList.pop_front();
+ }
+ while (!m_eventCelluarNetworkList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventCelluarNetworkList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventCelluarNetworkList.pop_front();
+ }
+ while (!m_eventStorageList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventStorageList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventStorageList.pop_front();
+ }
+ while (!m_eventCpuList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventCpuList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventCpuList.pop_front();
+ }
+ while (!m_eventSimList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventSimList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventSimList.pop_front();
+ }
+ while (!m_eventDeviceOrientationList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventDeviceOrientationList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventDeviceOrientationList.pop_front();
+ }
+ while (!m_eventLocaleList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventLocaleList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventLocaleList.pop_front();
+ }
+ while (!m_eventPeripheralList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventPeripheralList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventPeripheralList.pop_front();
+ }
+}
+
+void Systeminfo::EventMgr::addEvent(const EventWatchSysteminfoPtr& arg, const int watchType)
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+
+ if (watchType == WATCH_TYPE_BATTERY){
+ m_eventBatteryList.push_back(arg);
+ LoggerD("Event Battery list size=" << m_eventBatteryList.size());
+ } else if (watchType == WATCH_TYPE_DISPLAY) {
+ m_eventDisplayList.push_back(arg);
+ LoggerD("Event display list size=" << m_eventDisplayList.size());
+ } else if (watchType == WATCH_TYPE_WIFINETWORK) {
+ m_eventWifiNetworkList.push_back(arg);
+ LoggerD("Event wifi network list size=" << m_eventWifiNetworkList.size());
+ } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
+ m_eventCelluarNetworkList.push_back(arg);
+ LoggerD("Event cellular network list size=" << m_eventCelluarNetworkList.size());
+ } else if (watchType == WATCH_TYPE_STORAGE) {
+ m_eventStorageList.push_back(arg);
+ LoggerD("Event storage list size=" << m_eventStorageList.size());
+ } else if (watchType == WATCH_TYPE_CPU) {
+ m_eventCpuList.push_back(arg);
+ LoggerD("Event cpu list size=" << m_eventCpuList.size());
+ } else if (watchType == WATCH_TYPE_SIM) {
+ m_eventSimList.push_back(arg);
+ LoggerD("Event sim list size=" << m_eventSimList.size());
+ } else if (watchType == WATCH_TYPE_DEVICE_ORIENTATION) {
+ m_eventDeviceOrientationList.push_back(arg);
+ LoggerD("Event device orientation list size=" << m_eventDeviceOrientationList.size());
+ } else if (watchType == WATCH_TYPE_NETWORK) {
+ m_eventNetworkList.push_back(arg);
+ LoggerD("Event network list size=" << m_eventNetworkList.size());
+ } else if (watchType == WATCH_TYPE_LOCALE) {
+ m_eventLocaleList.push_back(arg);
+ LoggerD("Event Locale list size=" << m_eventLocaleList.size());
+ } else if (watchType == WATCH_TYPE_PERIPHERAL) {
+ m_eventPeripheralList.push_back(arg);
+ LoggerD("Event peripheral list size=" << m_eventPeripheralList.size());
+ }
+}
+
+void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+ LoggerD("Event id : " << id);
+
+ EventWatchSysteminfoPtr event(NULL);
+
+ LoggerD("trying to delete event, id=" << id);
+
+ if (watchType == WATCH_TYPE_BATTERY) {
+ for (EventBatteryList::iterator it = m_eventBatteryList.begin(); it != m_eventBatteryList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event Battery list size=" << m_eventBatteryList.size());
+ m_eventBatteryList.remove(event);
+ LoggerD( "event removed, event Battery list size=" << m_eventBatteryList.size());
+ } else if (watchType == WATCH_TYPE_DISPLAY) {
+ for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event display list size=" << m_eventDisplayList.size());
+ m_eventDisplayList.remove(event);
+ LoggerD( "event removed, event display list size=" << m_eventDisplayList.size());
+ } else if (watchType == WATCH_TYPE_WIFINETWORK) {
+ for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event wifi network list size=" << m_eventWifiNetworkList.size());
+ m_eventWifiNetworkList.remove(event);
+ LoggerD( "event removed, event wifi network list size=" << m_eventCelluarNetworkList.size());
+ } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
+ for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event cellular network list size=" << m_eventCelluarNetworkList.size());
+ m_eventCelluarNetworkList.remove(event);
+ LoggerD( "event removed, event cellular network list size=" << m_eventCelluarNetworkList.size());
+ } else if (watchType == WATCH_TYPE_STORAGE) {
+ for (EventStorageList::iterator it = m_eventStorageList.begin(); it != m_eventStorageList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event storage list size=" << m_eventStorageList.size());
+ m_eventStorageList.remove(event);
+ LoggerD( "event removed, event storage list size=" << m_eventStorageList.size());
+ } else if (watchType == WATCH_TYPE_CPU) {
+ for (EventCpuList::iterator it = m_eventCpuList.begin(); it != m_eventCpuList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event cpu list size=" << m_eventCpuList.size());
+ m_eventCpuList.remove(event);
+ LoggerD( "event removed, event cpu list size=" << m_eventCpuList.size());
+ } else if (watchType == WATCH_TYPE_SIM) {
+ for (EventSimList::iterator it = m_eventSimList.begin(); it != m_eventSimList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event sim list size=" << m_eventSimList.size());
+ m_eventSimList.remove(event);
+ LoggerD( "event removed, event sim list size=" << m_eventSimList.size());
+ } else if (watchType == WATCH_TYPE_DEVICE_ORIENTATION) {
+ for (EventDeviceOrientationList::iterator it = m_eventDeviceOrientationList.begin(); it != m_eventDeviceOrientationList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event device orientation list size=" << m_eventDeviceOrientationList.size());
+ m_eventDeviceOrientationList.remove(event);
+ LoggerD( "event removed, event device orientation list size=" << m_eventDeviceOrientationList.size());
+ } else if (watchType == WATCH_TYPE_NETWORK) {
+ for (EventNetworkList::iterator it = m_eventNetworkList.begin(); it != m_eventNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event network list size=" << m_eventNetworkList.size());
+ m_eventNetworkList.remove(event);
+ LoggerD( "event removed, event network list size=" << m_eventNetworkList.size());
+ } else if (watchType == WATCH_TYPE_LOCALE) {
+ for (EventLocaleList::iterator it = m_eventLocaleList.begin(); it != m_eventLocaleList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event Locale list size=" << m_eventLocaleList.size());
+ m_eventLocaleList.remove(event);
+ LoggerD( "event removed, event Locale list size=" << m_eventLocaleList.size());
+ } else if (watchType == WATCH_TYPE_PERIPHERAL) {
+ for (EventPeripheralList::iterator it = m_eventPeripheralList.begin(); it != m_eventPeripheralList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event peripheral list size=" << m_eventPeripheralList.size());
+ m_eventPeripheralList.remove(event);
+ LoggerD( "event removed, event peripheral list size=" << m_eventPeripheralList.size());
+ }
+}
+
+const int Systeminfo::EventMgr::getWatchType(const long id)
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+
+ EventWatchSysteminfoPtr event(NULL);
+
+ for (EventBatteryList::iterator it = m_eventBatteryList.begin(); it != m_eventBatteryList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventStorageList::iterator it = m_eventStorageList.begin(); it != m_eventStorageList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventCpuList::iterator it = m_eventCpuList.begin(); it != m_eventCpuList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventSimList::iterator it = m_eventSimList.begin(); it != m_eventSimList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventDeviceOrientationList::iterator it = m_eventDeviceOrientationList.begin(); it != m_eventDeviceOrientationList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventNetworkList::iterator it = m_eventNetworkList.begin(); it != m_eventNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventSimList::iterator it = m_eventSimList.begin(); it != m_eventSimList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventLocaleList::iterator it = m_eventLocaleList.begin(); it != m_eventLocaleList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventPeripheralList::iterator it = m_eventPeripheralList.begin(); it != m_eventPeripheralList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return WATCH_TYPE_UNKNOWN;
+ }
+
+ return event->getWatchType();
+}
+
+EventBatteryList Systeminfo::EventMgr::getEventBatteryList()
+{
+ return m_eventBatteryList;
+}
+
+EventDisplayList Systeminfo::EventMgr::getEventDisplayList()
+{
+ return m_eventDisplayList;
+}
+
+EventNetworkList Systeminfo::EventMgr::getEventNetworkList()
+{
+ return m_eventNetworkList;
+}
+
+EventWifiNetworkList Systeminfo::EventMgr::getEventWifiNetworkList()
+{
+ return m_eventWifiNetworkList;
+}
+
+EventCellularNetworkList Systeminfo::EventMgr::getEventCellularNetworkList()
+{
+ return m_eventCelluarNetworkList;
+}
+
+EventStorageList Systeminfo::EventMgr::getEventStorageList()
+{
+ return m_eventStorageList;
+}
+
+EventCpuList Systeminfo::EventMgr::getEventCpuList()
+{
+ return m_eventCpuList;
+}
+
+EventDeviceOrientationList Systeminfo::EventMgr::getEventDeviceOrientationList()
+{
+ return m_eventDeviceOrientationList;
+}
+
+EventSimList Systeminfo::EventMgr::getEventSimList()
+{
+ return m_eventSimList;
+}
+
+EventLocaleList Systeminfo::EventMgr::getEventLocaleList()
+{
+ return m_eventLocaleList;
+}
+
+EventPeripheralList Systeminfo::EventMgr::getEventPeripheralList()
+{
+ return m_eventPeripheralList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Battery) {
+ BatteryPropertiesPtr BatteryPtr(new BatteryProperties());
+ int value=0;
+ int value2=0;
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &value) != 0) {
+ return JSValueMakeNull(context);
+ } else {
+ BatteryPtr->level = (double)(value)/CPU_POWER_DEVICE_VALUE;
+ }
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &value2) != 0) {
+ return JSValueMakeNull(context);
+ } else {
+ BatteryPtr->isCharging = (value2 == 0) ? false : true;
+ }
+
+ return JSBatteryInfo::createJSObject(context, BatteryPtr);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Cpu) {
+ Converter converter(context);
+
+ CpuPropertiesPtr cpuPtr(new CpuProperties());
+ FILE *fp = NULL;
+ long long usr = 0, nice = 0, system = 0, idle = 0, total = 0, cpuUsage = 0;
+
+ fp = fopen("/proc/stat", "r");
+ if(fp == NULL) {
+ return JSValueMakeNull(context);
+ }
+
+ if (fscanf(fp, "%*s %lld %lld %lld %lld", &usr, &system, &nice, &idle) > 0) {
+ total = usr + nice + system + idle;
+ if ((total > 0LL) && (idle > 0LL)) {
+ cpuUsage = idle * 100LL / total;
+ cpuPtr->load = (double)cpuUsage / 100.0;
+ LoggerD("cpu load : " << cpuPtr->load);
+ }
+ }
+
+ fclose(fp);
+ return JSCpuInfo::createJSObject(context, cpuPtr);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Storage) {
+ Converter converter(context);
+ int sdcardState=0;
+ struct statfs fs;
+
+ if (statfs(STORAGE_INTERNAL_PATH, &fs) < 0) {
+ return JSValueMakeNull(context);
+ }
+ StoragePropertiesPtr storagePtr(new StorageProperties());
+ storagePtr->units[0].type = "INTERNAL";
+ storagePtr->units[0].capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
+ storagePtr->units[0].availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
+ storagePtr->units[0].isRemoveable = false;
+ storagePtr->units[0].isRemovable = false;
+ storagePtr->cnt = 1;
+ LoggerD("type : " << storagePtr->units[0].type);
+ if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
+ if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED){
+ if (statfs(STORAGE_SDCARD_PATH, &fs) < 0) {
+ return JSValueMakeNull(context);
+ }
+ storagePtr->units[1].type = "MMC";
+ storagePtr->units[1].capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
+ storagePtr->units[1].availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
+ storagePtr->units[1].isRemoveable = true;
+ storagePtr->units[1].isRemovable = true;
+ storagePtr->cnt = 2;
+ LoggerD("type : " << storagePtr->units[1].type);
+ }
+ }
+ return JSStorageInfo::createJSObject(context, storagePtr);
+
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
+ Converter converter(context);
+
+ DisplayPropertiesPtr display(new DisplayProperties());
+ int brightness=0, dotsPerInch=0, physicalW=0, physicalH=0;
+ bool screenSizeSmall = false, screenSizeBig = false;
+
+ if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness) == 0) {
+ display->brightness = (double)(brightness)/DISPLAY_BRIGHTNESS_DIVIDE_VALUE;
+ }
+
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.480.800", &screenSizeSmall) == SYSTEM_INFO_ERROR_NONE) {
+ if (screenSizeSmall) {
+ display->resolutionWidth = 480;
+ display->resolutionHeight = 800;
+ } else {
+ if (system_info_get_platform_bool("tizen.org/feature/screen.size.normal.720.1280", &screenSizeBig) == SYSTEM_INFO_ERROR_NONE) {
+ if (screenSizeBig) {
+ display->resolutionWidth = 720;
+ display->resolutionHeight = 1280;
+ }
+ }
+ }
+ }
+
+ if(system_info_get_platform_int("tizen.org/feature/screen.dpi", &dotsPerInch) == SYSTEM_INFO_ERROR_NONE) {
+ display->dotsPerInchWidth = dotsPerInch;
+ display->dotsPerInchHeight = dotsPerInch;
+ }
+
+ if(system_info_get_value_int(SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, &physicalW) == SYSTEM_INFO_ERROR_NONE) {
+ display->physicalWidth = physicalW;
+ }
+
+ if(system_info_get_value_int(SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, &physicalH) == SYSTEM_INFO_ERROR_NONE) {
+ display->physicalHeight = physicalH;
+ }
+
+ return JSDisplayInfo::createJSObject(context, display);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Network) {
+ LoggerD("enter");
+ Converter converter(context);
+ NetworkPropertiesPtr Network(new NetworkProperties());
+ connection_h connectionHandle = (connection_h)handle;
+ connection_type_e connectionType;
+ int networkType = 0;
+
+ if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
+ LoggerD("get connection type is failed");
+ return JSNetworkInfo::createJSObject(context, Network);
+ }
+
+ if (connectionType == CONNECTION_TYPE_WIFI) {
+ LoggerD("wifi network");
+ Network->networkType= "WIFI";
+ } else if (connectionType == CONNECTION_TYPE_CELLULAR) {
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &networkType) == 0) {
+ if (networkType < VCONFKEY_TELEPHONY_SVCTYPE_2G) {
+ Network->networkType= "NONE";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_2G) {
+ Network->networkType= "2G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_2G || networkType == VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE) {
+ Network->networkType= "2.5G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_3G || networkType == VCONFKEY_TELEPHONY_SVCTYPE_HSDPA) {
+ Network->networkType= "3G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_LTE) {
+ Network->networkType= "4G";
+ } else {
+ Network->networkType= "NONE";
+ }
+ }
+ } else if (connectionType == CONNECTION_TYPE_ETHERNET) {
+ LoggerD("ethernet network");
+ Network->networkType= "ETHERNET";
+ } else {
+ Network->networkType= "NONE";
+ }
+
+ return JSNetworkInfo::createJSObject(context, Network);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(WifiNetwork) {
+ Converter converter(context);
+ WifiNetworkPropertiesPtr wifiNetwork(new WifiNetworkProperties());
+ connection_h connectionHandle = (connection_h)handle;
+ connection_type_e connectionType;
+ connection_profile_h profileHandle = NULL;
+ connection_address_family_e addressFamily = CONNECTION_ADDRESS_FAMILY_IPV4;
+ char* ipAddr = NULL;
+ char* essid = NULL;
+ int rssi = 0;
+
+ if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+ }
+
+ if (connectionType == CONNECTION_TYPE_WIFI) {
+ wifiNetwork->status = "ON";
+ } else {
+ wifiNetwork->status = "OFF";
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+ }
+
+ if (connection_get_current_profile(connectionHandle, &profileHandle) != CONNECTION_ERROR_NONE) {
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+ }
+
+ if (connection_profile_get_wifi_essid(profileHandle, &essid) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->ssid = essid;
+ free(essid);
+ }
+
+ if (connection_profile_get_ip_address(profileHandle, addressFamily, &ipAddr) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->ipAddress = ipAddr;
+ free(ipAddr);
+ }
+
+ if (connection_profile_get_wifi_rssi(profileHandle, &rssi) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->signalStrength = (double) rssi/WIFI_SIGNAL_STRENGTH_DIVIDE_VALUE;
+ }
+
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(CellularNetwork) {
+ Converter converter(context);
+ CellularNetworkPropertiesPtr cellularNetwork(new CellularNetworkProperties());
+ connection_h connectionHandle = (connection_h)handle;
+ connection_type_e connectionType;
+ connection_profile_h profileHandle = NULL;
+ connection_address_family_e addressFamily = CONNECTION_ADDRESS_FAMILY_IPV4;
+ char* ipAddr = NULL;
+ char* apn = NULL;
+ char* imei = NULL;
+ int plmn = 0, cellId = 0, lac = 0, isRoaming = 0, isFlightMode = 0;
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)mcc", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn) == 0) {
+ cellularNetwork->mcc = plmn / 100;
+ cellularNetwork->mnc = plmn % 100;
+ }
+ TIME_TRACER_ITEM_END("(cellular)mcc", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)cellId", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_CELLID, &cellId) == 0) {
+ cellularNetwork->cellId = cellId;
+ }
+ TIME_TRACER_ITEM_END("(cellular)cellId", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)lac", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_LAC, &lac) == 0) {
+ cellularNetwork->lac = lac;
+ }
+ TIME_TRACER_ITEM_END("(cellular)lac", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)isRoaming", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &isRoaming) == 0) {
+ if (isRoaming) {
+ cellularNetwork->isRoaming = true;
+ } else {
+ cellularNetwork->isRoaming = false;
+ }
+ }
+ TIME_TRACER_ITEM_END("(cellular)isRoaming", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)isFlightMode", 0);
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &isFlightMode) == 0) {
+ if (isFlightMode) {
+ cellularNetwork->isFlightMode = true;
+ } else {
+ cellularNetwork->isFlightMode = false;
+ }
+ }
+ TIME_TRACER_ITEM_END("(cellular)isFlightMode", 0);
+
+ if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
+ return JSCellularNetworkInfo::createJSObject(context, cellularNetwork);
+ }
+
+ if (connectionType == CONNECTION_TYPE_CELLULAR) {
+ cellularNetwork->status = "ON";
+ if (connection_get_current_profile(connectionHandle, &profileHandle) == CONNECTION_ERROR_NONE) {
+ TIME_TRACER_ITEM_BEGIN("(cellular)apn", 0);
+ if (connection_profile_get_cellular_apn(profileHandle, &apn) == CONNECTION_ERROR_NONE) {
+ cellularNetwork->apn = apn;
+ free(apn);
+ }
+ TIME_TRACER_ITEM_END("(cellular)apn", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)ipAddress", 0);
+ if (connection_profile_get_ip_address(profileHandle, addressFamily, &ipAddr) == CONNECTION_ERROR_NONE) {
+ cellularNetwork->ipAddress = ipAddr;
+ free(ipAddr);
+ }
+ TIME_TRACER_ITEM_END("(cellular)ipAddress", 0);
+ connection_profile_destroy(profileHandle);
+ }
+ } else {
+ cellularNetwork->status = "OFF";
+ if (connection_get_default_cellular_service_profile(connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, &profileHandle) == CONNECTION_ERROR_NONE) {
+ TIME_TRACER_ITEM_BEGIN("(cellular)apn", 0);
+ if (connection_profile_get_cellular_apn(profileHandle, &apn) == CONNECTION_ERROR_NONE) {
+ cellularNetwork->apn = apn;
+ free(apn);
+ }
+ TIME_TRACER_ITEM_END("(cellular)apn", 0);
+ connection_profile_destroy(profileHandle);
+ }
+ }
+
+ imei = tel_get_misc_me_imei_sync((TapiHandle*)tapiHandle);
+
+ if (imei != NULL) {
+ LoggerD("imei : " << imei);
+ cellularNetwork->imei = imei;
+ free(imei);
+ } else {
+ LoggerD("get fail imei");
+ }
+
+ return JSCellularNetworkInfo::createJSObject(context, cellularNetwork);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(SIM) {
+ Converter converter(context);
+ SIMPropertiesPtr SIM(new SIMProperties());
+
+ return JSSIMInfo::createJSObject(context, SIM);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(DeviceOrientation) {
+ LoggerD("enter");
+ Converter converter(context);
+ DeviceOrientationPropertiesPtr deviceOrientation(new DeviceOrientationProperties());
+
+ unsigned long rotation = 0;
+ int handleOrientaion = 0;
+ int isAutoRotation = 0;
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &isAutoRotation) == 0) {
+ if (isAutoRotation) {
+ deviceOrientation->isAutoRotation = true;
+ } else {
+ deviceOrientation->isAutoRotation = false;
+ }
+ }
+
+ handleOrientaion = sf_connect(ACCELEROMETER_SENSOR);
+ LoggerD("handleOrientaion : " << handleOrientaion);
+ if (handleOrientaion < 0) {
+ LoggerD ("sensor attach fail");
+ return JSDeviceOrientationInfo::createJSObject(context, deviceOrientation);
+ }
+ int state = sf_start(handleOrientaion, 0);
+ if(state < 0) {
+ LoggerD("start failed");
+ }
+
+ int ret_val = sf_check_rotation(&rotation);
+ if (ret_val < 0) {
+ LoggerD("sf_check_rotation fail to gather data\n");
+ }
+
+ LoggerD(" rotation value = " << rotation);
+
+ switch (rotation) {
+ case 0:
+ case ROTATION_EVENT_0:
+ LoggerD("my_callback_func received data (PORTRAIT_TOP|HEAD_CENTER)\n");
+ deviceOrientation->status = "PORTRAIT_PRIMARY";
+ break;
+ case ROTATION_EVENT_90:
+ LoggerD("my_callback_func received data (LANDSCAPE|HEAD_RIGHT)\n");
+ deviceOrientation->status = "LANDSCAPE_PRIMARY";
+ break;
+ case ROTATION_EVENT_180:
+ LoggerD("my_callback_func received data (PORTRAIT_BTM|HEAD_CENTER)\n");
+ deviceOrientation->status = "PORTRAIT_SECONDARY";
+ break;
+ case ROTATION_EVENT_270:
+ LoggerD("my_callback_func received data (LANDSCAPE|HEAD_LEFT)\n");
+ deviceOrientation->status = "LANDSCAPE_SECONDARY";
+ break;
+ default:
+ LoggerD(" received data unexpected\n");
+ break;
+ }
+
+ state = sf_stop(handleOrientaion);
+ LoggerD("handleOrientaion 1 state = " << state);
+
+ state = sf_disconnect(handleOrientaion);
+ LoggerD("handleOrientaion state =" << state);
+
+ return JSDeviceOrientationInfo::createJSObject(context, deviceOrientation);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Build) {
+ LoggerD("enter");
+ Converter converter(context);
+ BuildPropertiesPtr Build(new BuildProperties());
+
+ char* model = NULL;
+ char* manufacturer = NULL;
+ char* buildVersion = NULL;
+
+ if(system_info_get_platform_string("tizen.org/system/model_name", &model) == SYSTEM_INFO_ERROR_NONE) {
+ if (model != NULL) {
+ LoggerD("model : " << model);
+ Build->model = model;
+ free(model);
+ }
+ }
+
+ if (system_info_get_value_string(SYSTEM_INFO_KEY_MANUFACTURER, &manufacturer) == SYSTEM_INFO_ERROR_NONE) {
+ if (manufacturer != NULL) {
+ LoggerD("manufacturer : " << manufacturer);
+ Build->manufacturer = manufacturer;
+ free(manufacturer);
+ }
+ }
+
+ if (system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &buildVersion) == SYSTEM_INFO_ERROR_NONE) {
+ if (buildVersion != NULL) {
+ LoggerD("buildVersion : " << buildVersion);
+ Build->buildVersion = buildVersion;
+ free(buildVersion);
+ }
+ }
+
+ return JSBuildInfo::createJSObject(context, Build);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Locale) {
+ LoggerD("enter");
+ Converter converter(context);
+ LocalePropertiesPtr Locale(new LocaleProperties());
+
+ char* country = NULL;
+ char* language = NULL;
+
+ if (runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &language) == RUNTIME_INFO_ERROR_NONE) {
+ if (language != NULL) {
+ LoggerD("language : " << language);
+ Locale->language = language;
+ free(language);
+ }
+ }
+
+ if (runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &country) == RUNTIME_INFO_ERROR_NONE) {
+ if (country != NULL) {
+ LoggerD("country : " << country);
+ char* token = NULL;
+ char* countryTemp = NULL;
+ token = strtok(country, ".");
+ if (token != NULL) {
+ countryTemp = strdup(token);
+ if (countryTemp != NULL) {
+ Locale->country = countryTemp;
+ free(countryTemp);
+ }
+ }
+ free(country);
+ }
+ }
+
+ return JSLocaleInfo::createJSObject(context, Locale);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Peripheral) {
+ Converter converter(context);
+ PeripheralPropertiesPtr peripheral(new PeripheralProperties());
+ int hdmiStatus = 0, wirelessDisplayStatus = 0 ;
+
+ if (vconf_get_int(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &wirelessDisplayStatus) == 0) {
+ switch(wirelessDisplayStatus) {
+ case VCONFKEY_MIRACAST_WFD_SOURCE_ON:
+ peripheral->isVideoOutputOn = true;
+ break;
+ default:
+ LoggerD("VideOutput status is off");
+ break;
+ }
+ }
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_HDMI, &hdmiStatus) == 0) {
+ switch(hdmiStatus) {
+ case VCONFKEY_SYSMAN_HDMI_CONNECTED:
+ peripheral->isVideoOutputOn = true;
+ break;
+ default:
+ LoggerD("VideOutput status is off");
+ break;
+ }
+ }
+
+ return JSPeripheralInfo::createJSObject(context, peripheral);
+}
+
+}
+}