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
20 #include "ico_syc_error.h"
22 #include "CicoAulItems.h"
23 #include "CicoAilItems.h"
24 #include "CicoSCLifeCycleController.h"
26 #include "CicoSystemConfig.h"
27 #include "CicoSCSysResourceController.h"
28 #include "CicoSCAppResourceController.h"
29 #include "Cico_aul_listen_app.h"
34 CicoSCLifeCycleController* CicoSCLifeCycleController::ms_myInstance = NULL;
36 const char* DAilTypeFilPrm_Menu="menu";
37 const char* DAilTypeFilPrm_App="Application";
38 const char* DNil = "(nil)";
39 const char* sectAppAttr = "app-attributes";
40 const char* DNull = "(null)";
42 #define APP_CONF_AIL_NULL_STR DNull
48 * @param pkg_name package name
49 * @param key "start"/"end"/"install_percent"/"command" strings
50 * @param val "ok"/"error"/"0.000000"-"100.000000" strings
51 * @param pmsg pkgmgr message
52 * @param data user data
54 static int CSCLCCpkgmgr_handler(int req_id, const char *pkg_type,
55 const char *pkg_name, const char *key,
56 const char *val, const void *pmsg, void *data)
58 CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
60 CSCLCCpkgmgr_handlerX(req_id, pkg_type, pkg_name, key, val, pmsg, x);
64 * @brief ail_filter_list_appinfo_foreach callback function
65 * @param appinfo appinfo_h the appinfo's handle
66 * @param data user data
67 * @retval AIL_CB_RET_CONTINUE return if you continue iteration
68 * @retval AIL_CB_RET_CANCEL return if you cancel iteration
70 static ail_cb_ret_e CSCLCCail_list_appinfo_cb(const ail_appinfo_h appinfo,
71 void *data, uid_t uid)
73 CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
74 return CSCLCCail_list_appinfo_cbX(appinfo, x, uid);
78 * @brief applications are launched. callback function
80 * @param data user data
82 static int CSCLCCapp_launch_handler(int pid, void *data)
84 CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
85 return CSCLCCapp_launch_handlerX(pid, x);
89 * @brief applications die. callback function
91 * @param data user data
93 static int CSCLCCapp_dead_handler(int pid, void *data)
95 CicoSCLifeCycleController* x = (CicoSCLifeCycleController*)data;
96 return CSCLCCapp_dead_handlerX(pid, x);
100 * @brief This API get application appid by pid
102 * @param appid store appid string
103 * @param len appid buffer size
104 * @ret aul_app_get_appid_bypid return value
105 * @retval AUL_R_OK - success
106 * @retval AUL_R_ERROR - no such a appid
108 int Xaul_app_get_appid_bypid(int pid, char *appid, int len)
110 int r = aul_app_get_appid_bypid(pid, appid, len);
115 sprintf(fn, "/proc/%d/cmdline", pid);
120 const char* p = tmp.c_str();
125 strncpy(appid, &p[i+1], len);
126 break; // break of while i
136 CicoSCLifeCycleController::CicoSCLifeCycleController()
138 m_gconf = (GKeyFile*)NULL;
139 m_pc = (pkgmgr_client*)NULL;
141 m_RC = new CicoSCSysResourceController;
142 m_RC->startSysResource();
144 m_RC = new CicoSCAppResourceController;
145 if (false == m_RC->startSysResource()) {
146 m_RC->initAppResource();
153 CicoSCLifeCycleController::ms_myInstance = this;
159 CicoSCLifeCycleController::~CicoSCLifeCycleController()
162 CicoSCLifeCycleController::ms_myInstance = NULL;
165 CicoSCLifeCycleController*
166 CicoSCLifeCycleController::getInstance(void)
168 if (NULL == ms_myInstance) {
169 ms_myInstance = new CicoSCLifeCycleController();
171 return ms_myInstance;
175 * @brief application launch
176 * @param appid application id
177 * @retval ICO_SYC_EOK success
178 * @retval ICO_SYC_ESRCH error(not initialized)
179 * @retval ICO_SYC_ENOENT error(does not exist)
180 * @retval ICO_SYC_EBUSY error(already launch)
181 * @retval ICO_SYC_EPERM error(no authority)
183 int CicoSCLifeCycleController::launch(const char* appid, bundle* b)
185 ICO_TRA("start %s", appid);
186 // appid check AIL table exist
187 if (NULL == findAIL(appid)) {
188 ICO_TRA("end fail(not find)");
189 return ICO_SYC_ENOSYS;
191 ICO_PRF("CHG_APP_STA request app=%s", appid);
192 int r = aul_launch_app(appid, b);
194 ICO_TRA("end fail(%d)", r);
195 return ICO_SYC_ENOSYS;
197 ICO_TRA("end success(%d)", r);
202 * @brief application launch
203 * @param appid application id
204 * @retval ICO_SYC_EOK success
205 * @retval ICO_SYC_ESRCH error(not initialized)
206 * @retval ICO_SYC_ENOENT error(does not exist)
207 * @retval ICO_SYC_EBUSY error(already launch)
208 * @retval ICO_SYC_EPERM error(no authority)
210 int CicoSCLifeCycleController::launch(const std::string& appid, bundle* b)
212 return launch((const char*)appid.c_str(), b);
216 * @brief application terminate
217 * @param appid application id
218 * @retval ICO_SYC_EOK success
219 * @retval ICO_SYC_ESRCH error(not initialized)
220 * @retval ICO_SYC_ENOENT error(does not exist)
221 * @retval ICO_SYC_EBUSY error(already launch)
222 * @retval ICO_SYC_EPERM error(no authority)
224 int CicoSCLifeCycleController::terminate(const char* appid)
226 ICO_TRA("CicoSCLifeCycleController::terminate %s", appid);
229 if (true == getPIDs(appid, pids)) {
230 vector<int>::iterator it;
231 for(it = pids.begin(); it != pids.end(); ++it) {
232 int tr = terminateR(*it);
233 if (ICO_SYC_EOK != tr) {
239 ICO_TRA("end ICO_SYC_EPERM");
240 return ICO_SYC_EPERM;
242 ICO_TRA("end %d", r);
247 * @brief application terminate
248 * @param appid application id
249 * @retval ICO_SYC_EOK success
250 * @retval ICO_SYC_ESRCH error(not initialized)
251 * @retval ICO_SYC_ENOENT error(does not exist)
252 * @retval ICO_SYC_EBUSY error(already launch)
253 * @retval ICO_SYC_EPERM error(no authority)
255 int CicoSCLifeCycleController::terminate(const std::string& appid)
257 return terminate((const char*)appid.c_str());
261 * @brief application terminate
263 * @retval ICO_SYC_EOK success
264 * @retval ICO_SYC_ESRCH error(not initialized)
265 * @retval ICO_SYC_ENOENT error(does not exist)
266 * @retval ICO_SYC_EBUSY error(already launch)
267 * @retval ICO_SYC_EPERM error(no authority)
269 int CicoSCLifeCycleController::terminate(int pid)
271 ICO_TRA("CicoSCLifeCycleController::terminate %d", pid);
272 const CicoAulItems* t = findAUL(pid);
273 if ((NULL == t) || (0 == t)) {
275 return ICO_SYC_EPERM;
277 return terminateR(pid);
281 * @brief application terminate
283 * @retval ICO_SYC_EOK success
284 * @retval ICO_SYC_ENOSYS error
286 int CicoSCLifeCycleController::terminateR(int pid)
288 ICO_TRA("CicoSCLifeCycleController::terminateR %d", pid);
289 int r = aul_terminate_pid(pid);
291 ICO_DBG("terminate error pid:%d, r:%d", pid, r);
292 return ICO_SYC_ENOSYS;
298 * @brief application suspend
299 * @param appid application id
300 * @retval ICO_SYC_EOK success
301 * @retval ICO_SYC_ESRCH error(not initialized)
302 * @retval ICO_SYC_ENOENT error(does not exist)
303 * @retval ICO_SYC_EBUSY error(already launch)
304 * @retval ICO_SYC_EPERM error(no authority)
306 int CicoSCLifeCycleController::suspend(const char* appid)
310 if (true == getPIDs(appid, pids)) {
311 vector<int>::iterator it;
312 for(it = pids.begin(); it != pids.end(); ++it) {
313 int tr = suspend(*it);
314 if (ICO_SYC_EOK != tr) {
320 ICO_TRA("end ICO_SYC_EPERM");
321 return ICO_SYC_EPERM;
323 ICO_TRA("end %d", r);
328 * @brief application suspend
329 * @param appid application id
330 * @retval ICO_SYC_EOK success
331 * @retval ICO_SYC_ESRCH error(not initialized)
332 * @retval ICO_SYC_ENOENT error(does not exist)
333 * @retval ICO_SYC_EBUSY error(already launch)
334 * @retval ICO_SYC_EPERM error(no authority)
336 int CicoSCLifeCycleController::suspend(const std::string& appid)
338 return suspend((const char*)appid.c_str());
342 * @brief application suspend
344 * @retval ICO_SYC_EOK success
345 * @retval ICO_SYC_ESRCH error(not initialized)
346 * @retval ICO_SYC_ENOENT error(does not exist)
347 * @retval ICO_SYC_EBUSY error(already launch)
348 * @retval ICO_SYC_EPERM error(no authority)
350 int CicoSCLifeCycleController::suspend(int pid)
352 // TODO mk_k Not currently supported
353 // TODO mk_k What do I do now?
354 return ICO_SYC_EPERM;
358 * @brief appid is running check
359 * @param appid package
360 * @return running status
361 * @retval true is running
362 * @retval false not running
364 bool CicoSCLifeCycleController::isRunning(const char* appid)
366 ICO_TRA("start %s", appid);
369 vector<CicoAulItems>::iterator it;
370 for (it = m_aul.begin(); it != m_aul.end(); ++it) {
372 if (0 == strcasecmp(it->m_appid.c_str(), appid)) {
378 int sz = m_aul.size();
379 for (int i = 0; i < sz; i++) {
380 m_aul[i].update_appid();
381 if (0 == strcasecmp(m_aul[i].m_appid.c_str(), appid)) {
387 ICO_TRA("end %s", r? "true": "false");
392 * @brief appid is running check
393 * @param appid package
394 * @return running status
395 * @retval true is running
396 * @retval false not running
398 bool CicoSCLifeCycleController::isRunning(const std::string& appid)
400 return isRunning((const char*)appid.c_str());
404 * @brief find ail data
405 * @param appid find key
406 * @return CicoAilItems class pointer
407 * @retval NULL is not find
409 const CicoAilItems* CicoSCLifeCycleController::findAIL(const char* appid) const
412 const CicoAilItems* r = NULL;
413 int sz = m_ail.size();
414 for (int i = 0; i < sz; i++) {
415 if (0 == strcasecmp(m_ail[i].m_appid.c_str(), appid)) {
417 break; // break of for
420 ICO_TRA("end %x", r);
425 * @brief find ail data
426 * @param appid find key
427 * @return CicoAilItems class pointer
428 * @retval NULL is not find
430 const CicoAilItems* CicoSCLifeCycleController::findAIL(const std::string& appid) const
432 // ICO_TRA("call findAIL(const char*)");
433 return findAIL((const char*)appid.c_str());
437 * @brief get launched apprication pid
438 * @param appid target application appid
441 bool CicoSCLifeCycleController::getPIDs(const char* appid, std::vector<int>& pids) const
443 ICO_TRA("start %s", appid);
446 vector<CicoAulItems>::iterator it;
447 for (it = m_aul.begin(); it != m_aul.end(); ++it) {
449 if (0 == strcasecmp(it->m_appid.c_str(), appid)) {
450 pids.push_back(it->m_pid);
455 int sz = m_aul.size();
456 for (int i = 0; i < sz; i++) {
457 CicoAulItems* t = (CicoAulItems*)m_aul[i].p();
459 if (0 == strcasecmp(t->m_appid.c_str(), appid)) {
460 pids.push_back(t->m_pid);
465 ICO_TRA("end %d %s", pids.size(), r? "true": "false");
470 * @brief get launched apprication pid
471 * @param appid target application appid
474 bool CicoSCLifeCycleController::getPIDs(std::string& appid, std::vector<int>& pids) const
476 return getPIDs((const char*)appid.c_str(), pids);
480 * @brief get launched apprication pid
481 * @param appid target application appid
484 const CicoAulItems* CicoSCLifeCycleController::findAUL(int pid)
486 ICO_TRA("start %d", pid);
487 const CicoAulItems* r = NULL;
488 int sz = m_aul.size();
489 for (int i = 0; i < sz; i++) {
490 CicoAulItems* t = (CicoAulItems*)m_aul[i].p();
492 if (t->m_pid == pid) {
494 ICO_DBG("find %d -> %s", pid, t->m_appid.c_str());
495 break; // break of for
498 ICO_TRA("end %x", r);
504 * @brief ail information data initialization
506 void CicoSCLifeCycleController::initAIL()
508 ICO_TRA("start %x", m_pc);
510 if ((pkgmgr_client*)NULL == m_pc) {
511 m_pc = pkgmgr_client_new(PC_LISTENING);
512 ICO_TRA("pkgmgr client new %x", m_pc);
513 int r = pkgmgr_client_listen_status(m_pc, CSCLCCpkgmgr_handler,
515 ICO_TRA("pkgmgr_client_listen_status %d", r);
516 // if (PKGMGR_R_OK != r)
517 // pkgmgr_client_listen_status return is
518 // request_id (>0) if success, error code(<0) if fail
519 // PKGMGR_R_OK success (PKGMGR_R_OK is 0)
521 pkgmgr_client_free(m_pc);
525 ICO_TRA("end %x", m_pc);
531 int CSCLCCpkgmgr_handlerX(int req_id, const char *pkg_type, const char *pkg_name,
532 const char *key, const char *val, const void *pmsg,
533 CicoSCLifeCycleController* x)
535 // TODO mk_k packages install/uninstall handler Determination of the result undecided
536 ICO_TRA("pkgmgr t:%s, n:%s, k:%s, v:%s, m:%s",pkg_type, pkg_name, key,
538 if ((NULL == x) || (0 == x)) {
539 ICO_TRA("end user data none");
542 if (strcasecmp(key, "end") == 0) {
543 if (strcasecmp(val, "ok") == 0) {
544 ICO_DBG("receive end:ok");
550 // TODO mk_k packages install/uninstall handler Determination of the result undecided
554 * @brief AIL list renew
556 void CicoSCLifeCycleController::renewAIL()
559 vector<CicoAilItems> old = m_ail;
562 while (false == createAilItems()) {
572 ICO_TRA("end error AIL I/F");
575 #if 0 // TODO mk_k I do not know unnecessary
576 vector<string> add_appid;
577 vector<string> remove_appid;
579 vector<CicoAulItems>::iterator it_n;
580 vector<CicoAulItems>::iterator it_o;
581 for(it_n = m_aul.begin(); it_n != m_aul.end(); ++it_n) {
583 for(it_o = old.begin(); it_o != old.end(); ++it_o) {
584 if (it_n->m_appid.compaire(it_o->m_appid)) {
588 if (false == bingo) {
589 add_appid.push_back(it_n->m_appid);
592 for(it_o = old.begin(); it_o != old.end(); ++it_o) {
594 for(it_n = m_aul.begin(); it_n != m_aul.end(); ++it_n) {
595 if (it_o->m_appid.compaire(it_n->m_appid)) {
599 if (false == bingo) {
600 remove_appid.push_back(it_o->m_appid);
604 if (0 != add_appid.size()) {
607 if (0 != remove_appid.size()) {
608 // TODO mk_k uninstall
618 * @brief ail_filter_list_appinfo_foreach callback function
619 * @param appinfo appinfo_h the appinfo's handle
620 * @param x CicoSCLifeCycleController class pointer
621 * @retval AIL_CB_RET_CONTINUE return if you continue iteration
622 * @retval AIL_CB_RET_CANCEL return if you cancel iteration
625 ail_cb_ret_e CSCLCCail_list_appinfo_cbX(const ail_appinfo_h appinfo,
626 CicoSCLifeCycleController* x, uid_t uid)
629 if ((NULL == x) || (0 == x)) {
630 ICO_TRA("end bad end")
631 return AIL_CB_RET_CANCEL;
640 /* get package name for appid */
641 ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, uid, &pkg);
642 if (strcmp(pkg, APP_CONF_AIL_NULL_STR) == 0) {
646 ail_appinfo_get_usr_str(appinfo, AIL_PROP_ICON_STR, uid, &icn);
647 if (strcmp(icn, APP_CONF_AIL_NULL_STR) == 0) {
650 else if (icn != NULL) {
653 memset(&buff, 0, sizeof(buff));
654 if (stat(icn, &buff) == 0) {
655 if (S_ISDIR(buff.st_mode)) {
657 ICO_DBG("%s is directory", icn);
667 ail_appinfo_get_usr_str(appinfo, AIL_PROP_NAME_STR, uid, &nm);
668 if (strcmp(nm, APP_CONF_AIL_NULL_STR) == 0) {
672 ail_appinfo_get_usr_str(appinfo, AIL_PROP_CATEGORIES_STR, uid, &ctgry);
673 if (strcmp(ctgry, APP_CONF_AIL_NULL_STR) == 0) {
677 ail_appinfo_get_usr_str(appinfo, AIL_PROP_TYPE_STR, uid, &typ);
678 if (strcmp(typ, APP_CONF_AIL_NULL_STR) == 0) {
682 ail_appinfo_get_usr_str(appinfo, AIL_PROP_EXEC_STR, uid, &exe);
683 if (strcmp(exe, APP_CONF_AIL_NULL_STR) == 0) {
686 ail_appinfo_get_bool(appinfo, AIL_PROP_NODISPLAY_BOOL, &bndsp);
687 ICO_DBG("pkg:%s icn:%s nm:%s ctg:%s ty:%s exe:%s ds:%s", pkg? pkg:DNil,
688 icn? icn:DNil, nm? nm:DNil, ctgry? ctgry:DNil, typ? typ:DNil,
689 exe? exe:DNil, bndsp? "true":"false");
690 if (false == x->addAIL(pkg, icn, nm, ctgry, typ, exe, bndsp)) {
691 ICO_TRA("end bad end")
692 return AIL_CB_RET_CANCEL;
695 return AIL_CB_RET_CONTINUE;
699 * @brief create information ail data
700 * @retval true success
701 * @retval false fail create
703 bool CicoSCLifeCycleController::createAilItems()
706 m_ail.clear(); // clear items
707 if (NULL == m_gconf) {
708 m_gconf = g_key_file_new();
709 GString* gsfp = g_string_new("xx");
710 CicoSystemConfig* CSCSC = CicoSystemConfig::getInstance();
711 g_string_printf(gsfp, "%s/%s", CSCSC->getDefaultConf()->confdir.c_str(),
712 ICO_SYC_CONFIG_APPATTR);
715 flg = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS;
716 if (!g_key_file_load_from_file(m_gconf, gsfp->str, (GKeyFileFlags)flg, &gerr)) {
717 ICO_ERR("load error conf:%s %s", (char*)gsfp->str, gerr->message);
718 g_key_file_free(m_gconf);
720 g_string_free(gsfp, TRUE);
723 g_string_free(gsfp, TRUE);
726 uid_t uid = getuid();
728 ail_filter_new(&fil);
729 r = ail_filter_add_str(fil, AIL_PROP_TYPE_STR, DAilTypeFilPrm_Menu);
730 r = ail_filter_list_usr_appinfo_foreach(fil, CSCLCCail_list_appinfo_cb,
732 ail_filter_destroy(fil);
733 if (r != AIL_ERROR_OK) {
735 g_key_file_free(m_gconf);
738 ICO_TRA("end menu read NG(AIL)=%d", r);
742 ail_filter_new(&fil);
743 r = ail_filter_add_str(fil, AIL_PROP_TYPE_STR, DAilTypeFilPrm_App);
744 r = ail_filter_list_usr_appinfo_foreach(fil, CSCLCCail_list_appinfo_cb,
746 ail_filter_destroy(fil);
747 if (r != AIL_ERROR_OK) {
749 g_key_file_free(m_gconf);
752 ICO_TRA("end Application read NG(AIL)=%d", r);
756 g_key_file_free(m_gconf);
764 * @brief ail information data add one item
765 * @param sPkg string package (appid)
766 * @param sIco string icon full path
767 * @param sNm string name
768 * @param sCtg string categoies
769 * @param sTyp string type
770 * @param sExe string exec name
771 * @param bndsp bool nodisplay value
772 * @return method status
773 * @retval true success added item
774 * @retval false fail added item
776 bool CicoSCLifeCycleController::addAIL(const char* sPkg, const char* sIco,
777 const char* sNm, const char* sCtg,
778 const char* sTyp, const char* sExe,
781 ICO_TRA("start pkg(%s)", sPkg? sPkg: "(NULL)");
783 getCategory(sPkg, sNm, sCtg, category);
784 CicoAilItems CSCAI(sPkg, sIco, sNm, sCtg, sTyp, sExe, category, bndsp);
785 m_ail.push_back(CSCAI);
791 * @brief get category data
792 * @param sPkg ail package(appid) (get key)
793 * @param sNm ail name (get key)
794 * @param sCtg ail categories (get key)
795 * @param category read config file category string define
797 void CicoSCLifeCycleController::getCategory(const char* sPkg, const char* sNm,
799 std::string& category)
801 ICO_TRA("start pkg(%s)", sPkg? sPkg: "(NULL)");
810 /* get default category of this application */
813 appCtgry = g_key_file_get_string(m_gconf, sectAppAttr, sPkg, &gerr);
818 g_clear_error(&gerr);
820 appCtgry = g_key_file_get_string(m_gconf, sectAppAttr, sNm, &gerr);
827 g_clear_error(&gerr);
830 for (int i = 1;; i++) {
831 strncpy(&addCtgry[addCtgryLen], appCtgry,
832 sizeof(addCtgry)-addCtgryLen-2);
833 addCtgry[sizeof(addCtgry)-2] = 0;
834 addCtgryLen = strlen(addCtgry);
835 if (addCtgryLen > 0) {
836 if (addCtgry[addCtgryLen-1] != ';') {
837 strcpy(&addCtgry[addCtgryLen++], ";");
840 snprintf(work, sizeof(work)-1, "%s.%d",
841 appCtgryType == 0 ? sPkg : sNm, i);
844 if (NULL != appCtgry) {
849 appCtgry = g_key_file_get_string(m_gconf, sectAppAttr, work, &gerr);
851 g_clear_error(&gerr);
856 if (NULL != appCtgry) {
860 g_clear_error(&gerr);
864 strncpy(&addCtgry[addCtgryLen], sCtg, sizeof(addCtgry)-addCtgryLen-1);
865 addCtgry[sizeof(addCtgry)-1] = 0;
868 category.assign(addCtgry);
869 ICO_DBG("category=%s", category.c_str());
875 * @brief aul information data initialization
877 void CicoSCLifeCycleController::initAUL()
880 aul_listen_app_launch_signal_add(CSCLCCapp_launch_handler, (void*)this);
881 aul_listen_app_dead_signal_add(CSCLCCapp_dead_handler, (void*)this);
888 void CicoSCLifeCycleController::enterAUL(const char* appid, int pid,
889 const CicoSCWindow* obj, int aulstt)
892 bool bPushBack = true;
893 int sz = m_aul.size();
894 for (int i = 0; i < sz; i++) {
895 CicoAulItems* t = (CicoAulItems*) m_aul[i].p();
897 if (t->m_pid == pid) {
898 bPushBack = false; // push_back flag off
900 // Do not replace to NULL
901 ICO_DBG("Do not replace to NULL %d", t->m_CSCWptrs.size());
902 break; // break of for
905 ICO_DBG("add window info. %d, %x", t->m_CSCWptrs.size(), obj);
907 break; // break of for
911 if (true == bPushBack) { // push back flag on?
912 // AUL list Unregistered
913 ICO_DBG("push_back(AUL(%s, %d, %x))", appid, pid, obj);
914 int ctgry = DINITm_categoryID;
915 const CicoAilItems* ailObj = findAIL(appid);
916 if ((NULL != ailObj) && (0 != ailObj)) {
917 ctgry = ailObj->m_categoryID;
919 CicoAulItems entryAUL(appid, pid, ctgry, aulstt, obj);
920 m_aul.push_back(entryAUL);
921 if (-1 != entryAUL.m_cpucgroup) {
922 m_RC->entryCgroupCPU(pid, entryAUL.m_cpucgroup);
924 m_RC->entryApp(appid, pid);
930 * @brief application resource function is runnning
931 * @ret bool runnning state
932 * @retval true application resource runnning
933 * @retval true application resource stopping
935 bool CicoSCLifeCycleController::isAppResource() const
940 return m_RC->isAppResource();
945 * @param anem user login name
947 bool CicoSCLifeCycleController::startAppResource(const string& name)
954 bool bR = m_RC->startAppResource(name);
955 ICO_TRA("end %s", bR? "true": "false");
961 * @param anem user login name
963 void CicoSCLifeCycleController::createAppResourceFile(const string& user)
970 if (false == m_RC->isAppResource()) {
975 m_RC->getAppResourceFilePath(user, file);
978 memset(&buff, 0, sizeof(buff));
979 if (0 != stat(file.c_str(), &buff)) {
980 m_RC->createAppResourceFile(file);
988 bool CicoSCLifeCycleController::removeAUL(int pid)
990 ICO_TRA("start %d", pid);
992 vector<CicoAulItems>::iterator it;
993 for(it = m_aul.begin(); it != m_aul.end(); ++it) {
994 if (pid == it->m_pid) {
995 ICO_DBG("erase appid=%s", it->m_appid.c_str());
1001 ICO_TRA("end %s", r? "true":"false");
1007 * @param x CicoSCLifeCycleController class pointer
1009 int CSCLCCapp_launch_handlerX(int pid, CicoSCLifeCycleController* x)
1011 ICO_TRA("start %d, %x", pid, x);
1012 if ((NULL == x) || (0 == x)) {
1013 ICO_TRA("end user data is NULL");
1017 memset(appid, 0, sizeof(appid));
1018 int iR = Xaul_app_get_appid_bypid(pid, appid, sizeof(appid)); // pid to appid
1019 ICO_PRF("CHG_APP_STA notice app=%s, pid=%d, rval=%d", appid, pid, iR);
1020 x->enterAUL(appid, pid, NULL, iR);
1021 ICO_TRA("end %s %d", appid, pid);
1027 * @brief applications die. callback function
1029 * @param data user data
1030 * @param x CicoSCLifeCycleController class pointer
1032 int CSCLCCapp_dead_handlerX(int pid, CicoSCLifeCycleController* x)
1034 ICO_TRA("start %d, %x", pid, x);
1035 if ((NULL == x) || (0 == x)) {
1036 ICO_TRA("end user data is NULL");
1039 if (false == x->removeAUL(pid)) {
1040 ICO_TRA("end dead %d fail", pid);
1043 ICO_TRA("end dead %d success", pid);
1048 * @brief AUL infomaton list
1049 * @return AUL information item list Container
1051 const std::vector<CicoAulItems>& CicoSCLifeCycleController::getAulList()
1053 int sz = m_aul.size();
1054 for (int i = 0; i < sz; i++) {
1055 CicoAulItems* t = (CicoAulItems*)m_aul[i].p();