2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 //==========================================================================
12 * @file CicoSCPolicyManager.cpp
14 * @brief This file implementation of CicoSCPolicyManager class
16 //==========================================================================
21 #include "CicoSCPolicyManager.h"
22 #include "CicoStateMachine.h"
23 #include "CicoState.h"
24 #include "CicoHistoryState.h"
25 #include "CicoStateMachineCreator.h"
26 #include "CicoSCPolicyDef.h"
27 #include "CicoSCResourceManager.h"
29 #include "ico_syc_error.h"
30 #include "CicoSCServer.h"
31 #include "CicoSCMessage.h"
32 #include "ico_syc_msg_cmd_def.h"
33 #include "ico_syc_type.h"
35 //==========================================================================
37 //==========================================================================
39 // Defines of D-Bus target.
40 #define DBUS_SERVICE "org.automotive.message.broker"
41 #define DBUS_INTERFACE "org.freedesktop.DBus.Properties"
42 #define DBUS_METHOD "Get"
44 // Defines of maximum number.
45 #define AMB_MAX_VHCLINFO 10 /**< maximum number of vehicle info */
47 // Enumerations of Vehicle information key.
49 AMB_VHCL_SPEED = 1, /**< Vehicle speed */
50 AMB_SHIFT_POSITION, /**< Shift position */
51 AMB_LIGHT_LEFT, /**< Light left(Turn left) */
52 AMB_LIGHT_RIGHT, /**< Light right(Turn right) */
53 AMB_NIGHT_MODE, /**< Night mode */
54 AMB_MAX_INFO /**< Maximum number of type */
58 typedef struct _vehicle_info_property_t {
59 int key; /* Vehicle Information key */
60 const char *property; /* D-Bus property name */
61 const char *path; /* D-Bus path name */
62 const char *interface; /* D-Bus interface name */
65 // structure of Vehicle information data.
66 typedef struct _vehicle_info_data {
67 int key; /* Vehicle Information key */
68 DBusPendingCall *pending;
73 _vhcldata_t vhcl_data[AMB_MAX_INFO];
75 //*========================================================================
77 //========================================================================
79 static const vhcl_info_prop_t apf_vhcl_info[] = {
83 "/org/automotive/runningstatus/VehicleSpeed",
84 "org.automotive.VehicleSpeed"
89 "/org/automotive/runningstatus/Transmission",
90 "org.automotive.Transmission"
92 #if 0 // use LightStatus
93 /* use LightStatus, because AMB not support access of TurnSignal by D-Bus */
95 ICO_SYC_VEHICLEINFO_TURN_SIGNAL,
97 "/org/automotive/runningstatus/TurnSignal",
98 "org.automotive.TurnSignal"
100 #else // use LightStatus
104 "/org/automotive/runningstatus/LightStatus",
105 "org.automotive.LightStatus"
110 "/org/automotive/runningstatus/LightStatus",
111 "org.automotive.LightStatus"
113 #endif // use LightStatus
117 "/org/automotive/custom/NightMode",
118 "org.automotive.NightMode"
120 { 0, "\0", "\0", "\0" }
123 //--------------------------------------------------------------------------
125 * @brief default constructor
127 //--------------------------------------------------------------------------
128 CicoSCPolicyManager::CicoSCPolicyManager(CicoSCResourceManager* resourceMgr)
129 : m_initialized(false),
130 m_dbusConnection(NULL),
132 m_stateMachine(NULL),
133 m_resourceMgr(resourceMgr)
137 //--------------------------------------------------------------------------
141 //--------------------------------------------------------------------------
142 CicoSCPolicyManager::~CicoSCPolicyManager()
146 //--------------------------------------------------------------------------
148 * @brief initialize policy manager
150 //--------------------------------------------------------------------------
152 CicoSCPolicyManager::initialize(void)
154 ICO_DBG("CicoSCPolicyManager::initialize Enter");
156 int ret = ICO_SYC_EOK;
158 if (ICO_SYC_EOK != ret) {
162 ret = initStateMachine();
163 if (ICO_SYC_EOK != ret) {
167 ICO_DBG("CicoSCPolicyManager::initialize Leave");
171 //--------------------------------------------------------------------------
173 * @brief terminate policy manager
175 //--------------------------------------------------------------------------
177 CicoSCPolicyManager::terminate(void)
179 ICO_DBG("CicoSCPolicyManager::terminate Enter");
180 ICO_DBG("CicoSCPolicyManager::terminate Leave");
183 //--------------------------------------------------------------------------
185 * @brief initialize amb connection
187 //--------------------------------------------------------------------------
189 CicoSCPolicyManager::initAMB(void)
191 ICO_DBG("CicoSCPolicyManager::initAMB Enter");
194 DBusError dbus_error;
196 if (true == m_initialized) {
197 ICO_DBG("CicoSCPolicyManager::initAMB Leave(EOK)");
201 /* Zero clear vhcl_data */
202 memset(vhcl_data, 0, sizeof(vhcl_data));
204 /* Reset D-Bus error */
205 dbus_error_init(&dbus_error);
207 /* Get D-Bus connection */
208 m_dbusConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
209 if (! m_dbusConnection) {
210 ICO_ERR("dbus_bus_get failed.");
211 ICO_ERR("CicoSCPolicyManager::initAMB Leave(EIO)");
215 /* send request to AMB */
218 /* recv response from AMB timer start */
221 ICO_ERR("ecore_init");
222 ICO_ERR("CicoSCPolicyManager::initAMB Leave(ENOSYS)");
223 return ICO_SYC_ENOSYS;
226 m_ecoreTimer = ecore_timer_add(0.2, //TODO
227 CicoSCPolicyManager::ecoreTimerCB, this);
228 if (! m_ecoreTimer) {
229 ICO_ERR("ecore_timer_add failed.");
230 ICO_ERR("CicoSCPolicyManager::initAMB Leave(ENOSYS)");
231 return ICO_SYC_ENOSYS;
234 m_initialized = true;
236 ICO_DBG("CicoSCPolicyManager::initAMB Leave(EOK)");
240 //--------------------------------------------------------------------------
242 * @brief send AMB request
244 //--------------------------------------------------------------------------
246 CicoSCPolicyManager::sendAMBRequest(void)
248 // ICO_DBG("CicoSCPolicyManager::sendAMBRequest Enter");
250 DBusMessage *dbus_message = NULL;
252 int ret = ICO_SYC_EOK;
254 for (idx = 0; apf_vhcl_info[idx].key; idx++) {
255 /* set vehicle info key */
256 vhcl_data[idx].key = apf_vhcl_info[idx].key;
258 /* status is pending ? */
259 if (vhcl_data[idx].pending) {
260 ICO_WRN("(%s) not complete", apf_vhcl_info[idx].property);
264 if (apf_vhcl_info[idx].path[0] == 0) {
265 /* currently not support this vehicle information */
269 /* Create send message */
270 dbus_message = dbus_message_new_method_call(DBUS_SERVICE,
271 apf_vhcl_info[idx].path,
274 if (! dbus_message) {
275 ICO_ERR("dbus_message_new_method_call");
278 /* Set parameters into message */
279 else if (! dbus_message_append_args(dbus_message,
281 &apf_vhcl_info[idx].interface,
283 &apf_vhcl_info[idx].property,
284 DBUS_TYPE_INVALID)) {
285 ICO_ERR("dbus_message_append_args");
288 /* Set destination */
289 else if (! dbus_message_set_destination(dbus_message,
291 ICO_ERR("dbus_message_set_destination");
295 else if (! dbus_connection_send_with_reply(m_dbusConnection,
297 &vhcl_data[idx].pending,
299 ICO_ERR("dbus_connection_send");
300 vhcl_data[idx].pending = NULL;
304 //ICO_DBG("REQUEST req (%s)", apf_vhcl_info[idx].property);
308 /* Release message */
309 dbus_message_unref(dbus_message);
313 /* dispatch if data queue exist */
315 dbus_connection_read_write_dispatch(m_dbusConnection, 0);
316 } while (dbus_connection_get_dispatch_status(m_dbusConnection)
317 == DBUS_DISPATCH_DATA_REMAINS);
319 //ICO_DBG("CicoSCPolicyManager::sendAMBRequest Leave");
323 //--------------------------------------------------------------------------
325 * @brief get vehicle information
327 //--------------------------------------------------------------------------
329 CicoSCPolicyManager::getVehicleInfo(void)
331 DBusMessage *dbus_message = NULL;
332 DBusMessageIter iter_head;
333 DBusMessageIter iter;
344 /* dispatch if data queue exist */
346 dbus_connection_read_write_dispatch(m_dbusConnection, 0);
347 } while (dbus_connection_get_dispatch_status(m_dbusConnection)
348 == DBUS_DISPATCH_DATA_REMAINS);
350 /* analyze reply data */
351 for (idx = 0; apf_vhcl_info[idx].key; idx++) {
352 if (! vhcl_data[idx].pending) {
355 if (! dbus_pending_call_get_completed(vhcl_data[idx].pending)) {
356 //ICO_WRN("(%s) NOT complete", apf_vhcl_info[idx].property);
360 dbus_message = dbus_pending_call_steal_reply(vhcl_data[idx].pending);
361 if (! dbus_message) {
362 //ICO_WRN("(%s) NO reply", apf_vhcl_info[idx].property);
366 if (dbus_message_get_type(dbus_message) == DBUS_MESSAGE_TYPE_ERROR) {
367 dbus_message_unref(dbus_message);
368 dbus_pending_call_cancel(vhcl_data[idx].pending);
369 vhcl_data[idx].pending = NULL;
370 //ICO_ERR("(%s) reply error", apf_vhcl_info[idx].property);
374 dbus_message_iter_init(dbus_message, &iter_head);
375 dbus_message_iter_recurse(&iter_head, &iter);
377 type = dbus_message_iter_get_arg_type(&iter);
379 case DBUS_TYPE_INT32:
380 dbus_message_iter_get_basic(&iter, &i32);
381 vhcl_data[idx].val = (double)i32;
383 case DBUS_TYPE_INT16:
384 dbus_message_iter_get_basic(&iter, &i16);
385 vhcl_data[idx].val = (double)i16;
387 case DBUS_TYPE_UINT32:
388 dbus_message_iter_get_basic(&iter, &u32);
390 case DBUS_TYPE_UINT16:
391 dbus_message_iter_get_basic(&iter, &u16);
392 vhcl_data[idx].val = (double)u16;
394 case DBUS_TYPE_BOOLEAN:
395 dbus_message_iter_get_basic(&iter, &b);
396 if (b) vhcl_data[idx].val = (double)1.0;
397 else vhcl_data[idx].val = (double)0.0;
400 dbus_message_iter_get_basic(&iter, &u8);
401 vhcl_data[idx].val = (double)u8;
403 case DBUS_TYPE_DOUBLE:
404 dbus_message_iter_get_basic(&iter, &d64);
405 vhcl_data[idx].val = (double)d64;
408 ICO_ERR("(%s) illegal data type(0x%02x)",
409 apf_vhcl_info[idx].property, ((int)type) & 0x0ff);
412 //ICO_DBG("REQUEST ans (%s) = %.2f",
413 // apf_vhcl_info[idx].property, vhcl_data[idx].val);
415 /* free message and pending */
416 dbus_message_unref(dbus_message);
417 dbus_pending_call_cancel(vhcl_data[idx].pending);
418 vhcl_data[idx].pending = NULL;
424 //--------------------------------------------------------------------------
426 * @brief ecore timer callback
428 //--------------------------------------------------------------------------
430 CicoSCPolicyManager::ecoreTimerCB(void *user_data)
432 CicoSCPolicyManager *policyMgr =
433 static_cast<CicoSCPolicyManager*>(user_data);
434 policyMgr->recvAMBVehicleInfo();
436 return ECORE_CALLBACK_RENEW;
439 //--------------------------------------------------------------------------
441 * @brief receive AMB vehicle information
443 //--------------------------------------------------------------------------
445 CicoSCPolicyManager::recvAMBVehicleInfo(void)
447 // ICO_DBG("CicoSCPolicyManager::recvAMBVehicleInfo Enter");
451 bool chgCamera = false;
452 bool chgRegulation = false;
453 bool chgNightMode = false;
457 /* get vehicle info values */
458 for (idx = 0; idx < AMB_MAX_VHCLINFO; idx++) {
459 if (vhcl_data[idx].key == 0) break;
460 key = vhcl_data[idx].key;
463 (void)sendSMEvent(EVID_VELOCTY, (int)vhcl_data[idx].val);
464 if (true == sendSMEvent(EVID_DRVREGULATION)) {
465 chgRegulation = true;
468 case AMB_SHIFT_POSITION:
469 (void)sendSMEvent(EVID_SHIFTPOS, (int)vhcl_data[idx].val);
470 if (true == sendSMEvent(EVID_CAMERA)) {
475 if (0.0 == vhcl_data[idx].val) {
476 (void)sendSMEvent(EVID_TURN_OFF);
479 (void)sendSMEvent(EVID_TURN_LEFT);
481 if (true == sendSMEvent(EVID_CAMERA)) {
485 case AMB_LIGHT_RIGHT:
486 if (0.0 == vhcl_data[idx].val) {
487 (void)sendSMEvent(EVID_TURN_OFF);
490 (void)sendSMEvent(EVID_TURN_LEFT);
492 if (true == sendSMEvent(EVID_CAMERA)) {
497 chgNightMode = sendSMEvent(EVID_NIGHTMODE, (int)vhcl_data[idx].val);
500 ICO_WRN("not such key (%d)", key);
505 if (true == chgRegulation) {
506 ICO_DBG("true == chgRegulation");
507 // notify changed state to resource manager
509 (CicoState*)m_stateMachine->getState(STID_DRVREGULATION);
511 vector<const CicoState*> currents;
512 state->getCurrentState(currents, CicoStateCore::ELvlTop);
513 if (0 != currents.size()) {
514 ICO_DBG("current=%s", currents[0]->getName().c_str());
515 notifyChangedState(currents[0]->getValue());
519 // Notify regulation changed state
520 CicoSCMessage *message = new CicoSCMessage();
521 message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
522 message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_REGULATION);
523 if (true == m_policyStates[STID_DRVREGULATION_ON]->isActive()) {
524 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
527 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
529 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
532 if (true == chgCamera) {
533 ICO_DBG("true == chgCamera");
534 // notify changed state to resource manager
535 CicoState* state = (CicoState*)m_stateMachine->getState(STID_CAMERA);
537 vector<const CicoState*> currents;
538 state->getCurrentState(currents, CicoStateCore::ELvlTop);
539 if (0 != currents.size()) {
540 ICO_DBG("current=%s", currents[0]->getName().c_str());
541 notifyChangedState(currents[0]->getValue());
546 if (true == chgNightMode) {
547 ICO_DBG("true == chgNightMode");
548 // Notify NightMode changed state
549 CicoSCMessage *message = new CicoSCMessage();
550 message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
551 message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_NIGHTMODE);
552 if (true == m_policyStates[STID_NIGHTMODE_ON]->isActive()) {
553 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
556 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
558 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
561 /* send request to AMB */
564 // ICO_DBG("CicoSCPolicyManager::recvAMBVehicleInfo Leave");
567 //--------------------------------------------------------------------------
569 * @brief get policy states
571 //--------------------------------------------------------------------------
572 const std::map<int, const CicoState*>&
573 CicoSCPolicyManager::getPolicyStates(void)
575 return m_policyStates;
578 //--------------------------------------------------------------------------
580 * @brief initialize state machine
582 //--------------------------------------------------------------------------
584 CicoSCPolicyManager::initStateMachine(void)
586 ICO_DBG("CicoSCPolicyManager::initStateMachine Enter");
588 CicoStateMachineCreator creator;
591 m_stateMachine = creator.createFile("/usr/apps/org.tizen.ico.system-controller/res/config/policy.json");
592 if (NULL == m_stateMachine) {
593 ICO_ERR("CicoStateMachineCreator::createFile failed.(reason:%s)",
594 creator.getError().c_str());
595 return ICO_SYC_ENOSYS;
598 int ret = m_stateMachine->start();
600 ICO_ERR("CicoStateMachine::start failed.");
601 return ICO_SYC_ENOSYS;
604 vector<CicoStateCore*> objects;
605 m_stateMachine->getObjects(objects);
606 vector<CicoStateCore*>::iterator itr;
607 itr = objects.begin();
608 for (; itr != objects.end(); ++itr) {
609 const CicoState* state = static_cast<const CicoState*>(*itr);
610 m_policyStates[state->getValue()] = state;
611 #if 1 //-- { debug dump
612 ICO_DBG("State=[%-45s] Active=%s",
613 state->getName().c_str(),
614 state->isActive() ? "true" : "false");
615 #endif //-- } debug dump
618 m_dispZoneStates.push_back(NULL);
619 m_dispZoneStates.push_back(m_policyStates[STID_DISPLAY0_ZONE1]);
620 m_dispZoneStates.push_back(m_policyStates[STID_DISPLAY0_ZONE2]);
621 m_dispZoneStates.push_back(m_policyStates[STID_DISPLAY0_ZONE3]);
623 m_soundZoneStates.push_back(NULL);
624 m_soundZoneStates.push_back(m_policyStates[STID_SOUND_ZONE1]);
625 m_soundZoneStates.push_back(m_policyStates[STID_SOUND_ZONE2]);
626 m_soundZoneStates.push_back(m_policyStates[STID_SOUND_ZONE3]);
628 m_inputStates.push_back(NULL);
629 m_inputStates.push_back(m_policyStates[STID_INPUT1_USING]);
630 m_inputStates.push_back(m_policyStates[STID_INPUT2_USING]);
632 ICO_DBG("CicoSCPolicyManager::initStateMachine Leave");
636 //--------------------------------------------------------------------------
638 * @brief query whether a state transition
640 * @param [in] event_id trigger event id
642 * @return true on test success, false on test failed
644 //--------------------------------------------------------------------------
646 CicoSCPolicyManager::testSMEvent(unsigned short event_id)
648 CicoEvent event(event_id);
649 return m_stateMachine->eventTest(event);
652 //--------------------------------------------------------------------------
654 * @brief query whether a state transition
656 * @param [in] event_id trigger event id
657 * @param [in] value trigger optional integer value
659 * @return true on test success, false on test failed
661 //--------------------------------------------------------------------------
663 CicoSCPolicyManager::testSMEvent(unsigned short event_id, int value)
665 CicoEvent event(event_id, value);
666 return m_stateMachine->eventTest(event);
669 //--------------------------------------------------------------------------
671 * @brief send tigger event
673 * @param [in] event_id trigger event id
675 * @return true on state transition, false on not state transition
677 //--------------------------------------------------------------------------
679 CicoSCPolicyManager::sendSMEvent(unsigned short event_id)
681 CicoEvent event(event_id);
682 return m_stateMachine->eventEntry(event);
685 //--------------------------------------------------------------------------
687 * @brief send tigger event
689 * @param [in] event_id trigger event id
690 * @param [in] value trigger optional integer value
692 * @return true on state transition, false on not state transition
694 //--------------------------------------------------------------------------
696 CicoSCPolicyManager::sendSMEvent(unsigned short event_id, int value)
698 CicoEvent event(event_id, value);
699 return m_stateMachine->eventEntry(event);
703 CicoSCPolicyManager::acquireDisplayResource(int type, int zoneid, int priority)
705 ICO_DBG("CicoSCPolicyManager::acquireDisplayResource Enter"
706 "(type=0x%08X zoneid=%d priority=%d)", type, zoneid, priority);
710 if (RESID_TYPE_BASIC == type) {
711 bool zoneChg = testSMEvent(EVID_DISPLAY0_ZONE, zoneid);
712 bool cateChg = testSMEvent(EVID_DISPLAY0_CATEGORY, priority);
713 ICO_DBG("zoneChg=%d cateChg=%d", zoneChg, cateChg);
714 if ((true == zoneChg) && (true == cateChg)) {
715 sendSMEvent(EVID_DISPLAY0_ZONE, zoneid);
716 sendSMEvent(EVID_DISPLAY0_CATEGORY, priority);
720 else if (RESID_TYPE_INTERRUPT == type) {
722 chg = sendSMEvent(EVID_INTTERPUT_D0_Z1, priority);
724 else if (2 == zoneid) {
725 chg = sendSMEvent(EVID_INTTERPUT_D0_Z2, priority);
727 else if (3 == zoneid) {
728 chg = sendSMEvent(EVID_INTTERPUT_D0_Z3, priority);
731 else if (RESID_TYPE_ONSCREEN == type) {
732 chg = sendSMEvent(EVID_ONSCREEN, priority);
734 ICO_DBG("CicoSCPolicyManager::acquireDisplayResource Leave(%s)",
735 chg ? "true" : "false");
740 CicoSCPolicyManager::releaseDisplayResource(int zoneid, int priority)
746 CicoSCPolicyManager::acquireSoundResource(int type, int zoneid, int priority)
748 ICO_DBG("CicoSCPolicyManager::acquireSoundResource Enter"
749 "(type=0x%08X zoneid=%d priority=%d)", type, zoneid, priority);
753 if (RESID_TYPE_BASIC == type) {
754 bool zoneChg = testSMEvent(EVID_SOUND_ZONE, zoneid);
755 bool cateChg = testSMEvent(EVID_SOUND_CATEGORY, priority);
756 ICO_DBG("zoneChg=%d cateChg=%d", zoneChg, cateChg);
757 if ((true == zoneChg) && (true == cateChg)) {
758 sendSMEvent(EVID_SOUND_ZONE, zoneid);
759 sendSMEvent(EVID_SOUND_CATEGORY, priority);
763 else if (RESID_TYPE_INTERRUPT == type) {
765 chg = sendSMEvent(EVID_INTTERPUT_S_Z1, priority);
767 else if (2 == zoneid) {
768 chg = sendSMEvent(EVID_INTTERPUT_S_Z2, priority);
770 else if (3 == zoneid) {
771 chg = sendSMEvent(EVID_INTTERPUT_S_Z3, priority);
775 ICO_DBG("CicoSCPolicyManager::acquireSoundResource Leave(%s)",
776 chg ? "true" : "false");
781 CicoSCPolicyManager::releaseSoundResource(int type, int zoneid)
783 ICO_DBG("CicoSCPolicyManager::acquireSoundResource Enter"
784 "(type=%d zoneid=%d)", type, zoneid);
787 if (RESID_TYPE_BASIC == type) {
788 chg = sendSMEvent(EVID_SOUND_ZONE_NOUSE);
789 chg = sendSMEvent(EVID_SOUND_CATEGORY_UNKNOWN);
791 else if (RESID_TYPE_INTERRUPT == type) {
793 chg = sendSMEvent(EVID_INTTERPUT_S_Z1_NOOUTPUT);
795 else if (2 == zoneid) {
796 chg = sendSMEvent(EVID_INTTERPUT_S_Z2_NOOUTPUT);
798 else if (3 == zoneid) {
799 chg = sendSMEvent(EVID_INTTERPUT_S_Z3_NOOUTPUT);
803 ICO_DBG("CicoSCPolicyManager::acquireSoundResource Leave(%s)",
804 chg ? "true" : "false");
810 CicoSCPolicyManager::acquireInputResource(int input, int priority)
812 ICO_DBG("CicoSCPolicyManager::acquireInputResource Enter"
813 "input=%d priority=%d", input, priority);
818 chg = sendSMEvent(EVID_INPUT1_ACQUIRE, input);
820 else if (2 == input) {
821 chg = sendSMEvent(EVID_INPUT2_ACQUIRE, input);
824 ICO_DBG("CicoSCPolicyManager::acquireInputResource Leave(%s)",
825 chg ? "true" : "false");
830 CicoSCPolicyManager::releaseInputResource(int input)
833 (void)sendSMEvent(EVID_INPUT1_RELEASE, input);
835 else if (2 == input) {
836 (void)sendSMEvent(EVID_INPUT2_RELEASE, input);
842 CicoSCPolicyManager::notifyChangedState(int state)
844 m_resourceMgr->receiveChangedState(state);
848 CicoSCPolicyManager::getDispZoneState(int zoneid) const
850 if ((0 < zoneid) && ((int)m_dispZoneStates.size()-1 > zoneid)) {
851 return m_dispZoneStates[zoneid]->isActive();
857 CicoSCPolicyManager::getSoundZoneState(int zoneid) const
859 if ((0 < zoneid) && ((int)m_soundZoneStates.size()-1 > zoneid)) {
860 return m_soundZoneStates[zoneid]->isActive();
866 CicoSCPolicyManager::getInputState(int input) const
868 if ((0 < input) && ((int)m_inputStates.size()-1 > input)) {
869 return m_inputStates[input]->isActive();
874 //--------------------------------------------------------------------------
876 * @brief notify connected
878 //--------------------------------------------------------------------------
880 CicoSCPolicyManager::notifyConnected(const string & appid)
882 // Notify regulation changed state
883 CicoSCMessage *message = new CicoSCMessage();
884 message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
885 message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_REGULATION);
886 if (true == m_policyStates[STID_DRVREGULATION_ON]->isActive()) {
887 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
890 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
892 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
894 // Notify NightMode changed state
895 message = new CicoSCMessage();
896 message->addRootObject("command", MSG_CMD_NOTIFY_CHANGED_STATE);
897 message->addArgObject(MSG_PRMKEY_STATEID, ICO_SYC_STATE_NIGHTMODE);
898 if (true == m_policyStates[STID_NIGHTMODE_ON]->isActive()) {
899 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_ON);
902 message->addArgObject(MSG_PRMKEY_STATE, ICO_SYC_STATE_OFF);
904 CicoSCServer::getInstance()->sendMessageToHomeScreen(message);
906 // vim:set expandtab ts=4 sw=4: