2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FSysRuntimeInfo.cpp
20 * @brief This is the implementation file for _RuntimeInfoImpl class.
23 * This file contains the implementation of _RuntimeInfoImpl class.
26 #include <unique_ptr.h>
33 #include <app_storage.h>
35 #include <runtime_info.h>
39 #include <FBaseRtEvent.h>
40 #include <FBaseRtIEventArg.h>
41 #include <FBaseRtIEventListener.h>
42 #include <FBaseRtThread.h>
43 #include <FBaseSysLog.h>
44 #include <FApp_AppInfo.h>
45 #include <FBase_StringConverter.h>
46 #include <FSys_EnvironmentImpl.h>
47 #include <FSys_RuntimeInfoImpl.h>
49 using namespace Tizen::App;
50 using namespace Tizen::Base;
51 using namespace Tizen::Base::Runtime;
55 namespace Tizen { namespace System
58 static const wchar_t* _ALLOCATED_MEMORY = L"AllocatedMemory";
59 static const wchar_t* _MEMORY_ALLOCATED = L"http://tizen.org/runtime/memory.allocated";
60 static const wchar_t* _MEMORY_ALLOCATED_SELF = L"http://tizen.org/runtime/memory.allocated.self";
62 static const wchar_t* _AVAILABLE_EXTERNAL_STORAGE = L"AvailableExternalStorage";
63 static const wchar_t* _STORAGE_AVAILABLE_EXTERNAL = L"http://tizen.org/runtime/storage.available.external";
65 static const wchar_t* _AVAILABLE_INTERNAL_STORAGE = L"AvailableInternalStorage";
66 static const wchar_t* _STORAGE_AVAILABLE_INTERNAL = L"http://tizen.org/runtime/storage.available.internal";
68 static const wchar_t* _AVAILABLE_MEDIA_STORAGE = L"AvailableMediaStorage";
69 static const wchar_t* _STORAGE_AVAILABLE_INTERNAL_MEDIA = L"http://tizen.org/runtime/storage.available.internal.media";
71 static const wchar_t* _BATTERY_LEVEL = L"BatteryLevel";
72 static const wchar_t* _CHARGING = L"IsCharging";
74 static const wchar_t* _CPU_CORE_ALL_USAGE = L"http://tizen.org/runtime/cpu.core.all.usage";
76 static const wchar_t* _MAX_ALLOCATABLE_MEMORY = L"MaxAllocatableMemory";
77 static const wchar_t* _AVAILABLE_VIDEO_MEMORY = L"AvailableVideoMemory";
78 static const wchar_t* _ALLOCATED_VIDEO_MEMORY = L"AllocatedVideoMemory";
79 static const wchar_t* _AVAILABLE_MEMORY = L"AvailableMemory";
80 static const wchar_t* _MEMORY_AVAILABLE = L"http://tizen.org/runtime/memory.available";
81 static const wchar_t* _MEMORY_AVAILABLE_VIDEO = L"http://tizen.org/runtime/memory.available.video";
82 static const wchar_t* _MEMORY_ALLOCATED_VIDEO = L"http://tizen.org/runtime/memory.allocated.video";
84 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_APPLICATION = L"http://tizen.org/runtime/storage.allocated.internal.application";
85 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_AUDIO = L"http://tizen.org/runtime/storage.allocated.internal.audio";
86 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_VIDEO = L"http://tizen.org/runtime/storage.allocated.internal.video";
87 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_IMAGE = L"http://tizen.org/runtime/storage.allocated.internal.image";
88 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_DOWNLOAD = L"http://tizen.org/runtime/storage.allocated.internal.download";
89 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_APPLICATION = L"http://tizen.org/runtime/storage.allocated.external.application";
90 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_AUDIO = L"http://tizen.org/runtime/storage.allocated.external.audio";
91 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_VIDEO = L"http://tizen.org/runtime/storage.allocated.external.video";
92 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_IMAGE = L"http://tizen.org/runtime/storage.allocated.external.image";
93 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_DOWNLOAD = L"http://tizen.org/runtime/storage.allocated.external.download";
95 static const int _RUNTIME_INFO_EVENT_TYPE_INT = 101;
96 static const int _RUNTIME_INFO_EVENT_TYPE_LONGLONG = 102;
99 static const char* const _PROC_SYSTEM_MEMORY_INFO = "/proc/meminfo";
100 static const char* const _PROC_PROCESS_MEMORY_INFO = "/proc/self/status";
101 static const char* const _PROC_STAT = "/proc/stat";
103 static const char* const _PROC_KEY_SYSTEM_MEMORY_TOTAL = "MemTotal";
104 static const char* const _PROC_KEY_SYSTEM_MEMORY_FREE = "MemFree";
105 static const char* const _PROC_KEY_PROCESS_MEMORY = "VmSize";
107 static const char* const _ROOT_PATH = "/";
109 static const int _MAX_BUFFER_LENGTH = 1024;
111 static const int _CPU_USAGE_EVALUATION_INTERVAL = 1000000; //1 sec
115 unsigned long long user;
116 unsigned long long system;
117 unsigned long long nice;
118 unsigned long long idle;
119 unsigned long long wait;
120 unsigned long long hi;
121 unsigned long long si;
122 unsigned long long zero;
125 bool read_proc_stat(procstat_t *p)
130 fp = fopen(_PROC_STAT, "r");
136 ret = fscanf(fp, "%s %llu %llu %llu %llu %llu %llu %llu %llu",
164 void diff_proc_stat(procstat_t *a, procstat_t *b, procstat_t *d)
166 d->user = a->user - b->user;
167 d->system = a->system - b->system;
168 d->nice = a->nice - b->nice;
169 d->idle = a->idle - b->idle;
170 d->wait = a->wait - b->wait;
171 d->hi = a->hi - b->hi;
172 d->si = a->si - b->si;
173 d->zero = a->zero - b->zero;
176 class _RuntimeInfoEventArg : public IEventArg
179 _RuntimeInfoEventArg()
183 , errorCode(E_SUCCESS)
184 , DirectoryPath(null)
189 ~_RuntimeInfoEventArg()
191 if(DirectoryPath != null)
193 delete [] DirectoryPath;
199 long long longLongValue;
202 IEventListener* pListener;
205 class _RuntimeInfoEvent : public Event
208 void FireImpl(IEventListener& listener, const IEventArg& arg)
210 const _RuntimeInfoEventArg* runtimeArg = dynamic_cast<const _RuntimeInfoEventArg*> (&arg);
212 if(runtimeArg == null)
214 SysLogException(NID_SYS, E_SYSTEM, "Argument is null.");
218 switch(runtimeArg->Type)
220 case _RUNTIME_INFO_EVENT_TYPE_INT:
222 IRuntimeInfoGetIntAsyncResultListener* pIntListener = dynamic_cast<IRuntimeInfoGetIntAsyncResultListener*>(&listener);
224 if(pIntListener == runtimeArg->pListener)
226 pIntListener->OnResultReceivedForGetValueAsync(runtimeArg->intValue, runtimeArg->errorCode);
227 RemoveListener(listener);
231 case _RUNTIME_INFO_EVENT_TYPE_LONGLONG:
233 IRuntimeInfoGetLonglongAsyncResultListener* pLonglongListener = dynamic_cast<IRuntimeInfoGetLonglongAsyncResultListener*>(&listener);
234 if(pLonglongListener == runtimeArg->pListener)
236 pLonglongListener->OnResultReceivedForGetValueAsync(runtimeArg->longLongValue, runtimeArg->errorCode);
237 RemoveListener(listener);
245 _RuntimeInfoEvent runtimeInfoEvent;
247 _RuntimeInfoImpl::_RuntimeInfoImpl(void)
251 _RuntimeInfoImpl::~_RuntimeInfoImpl(void)
256 _RuntimeInfoImpl::GetValue(const String& key, String& value)
258 return E_OBJ_NOT_FOUND;
262 _RuntimeInfoImpl::GetValue(const String& key, int& value)
266 result r = E_OBJ_NOT_FOUND;
268 if (key == _BATTERY_LEVEL)
270 return GetBatteryLevel(value);
272 else if (key == _ALLOCATED_MEMORY || key == _ALLOCATED_VIDEO_MEMORY)
274 r = GetFromProc(_PROC_PROCESS_MEMORY_INFO, _PROC_KEY_PROCESS_MEMORY, free_size);
275 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
276 value = free_size * 1024;
278 else if (key == _AVAILABLE_MEMORY || key == _AVAILABLE_VIDEO_MEMORY || key == _MAX_ALLOCATABLE_MEMORY)
280 r = GetFromProc(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
281 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
282 value = free_size * 1024;
288 _RuntimeInfoImpl::GetValue(const String& key, long long& value)
291 long long total_size = 0;
292 long long free_size =0;
293 result r = E_OBJ_NOT_FOUND;
295 if (key == _MEMORY_AVAILABLE || key == _MEMORY_AVAILABLE_VIDEO)
297 r = GetFromProcLonglong(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
298 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
299 value = free_size * 1024;
301 else if (key == _MEMORY_ALLOCATED || key == _MEMORY_ALLOCATED_VIDEO)
303 r = GetFromProcLonglong(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_TOTAL, total_size);
304 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
305 r = GetFromProcLonglong(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
306 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
307 value = (total_size - free_size) * 1024;
309 else if (key == _MEMORY_ALLOCATED_SELF)
311 r = GetFromProcLonglong(_PROC_PROCESS_MEMORY_INFO, _PROC_KEY_PROCESS_MEMORY, free_size);
312 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
313 value = free_size * 1024;
315 else if (key == _AVAILABLE_INTERNAL_STORAGE)
317 return GetAvailableInternalStorage(value);
319 else if (key == _AVAILABLE_EXTERNAL_STORAGE)
321 return GetAvailableExternalStorage(value);
323 else if (key == _AVAILABLE_MEDIA_STORAGE)
325 return GetAvailableMediaStorage(value);
327 else if(key == _STORAGE_AVAILABLE_INTERNAL)
329 return GetAvailableInternalStorage(value);
331 else if(key == _STORAGE_AVAILABLE_EXTERNAL)
333 return GetAvailableExternalStorage(value);
335 else if(key == _STORAGE_AVAILABLE_INTERNAL_MEDIA)
337 return GetAvailableMediaStorage(value);
341 SysLogException(NID_SYS, r, "Key[%ls] is not valid.", key.GetPointer());
347 _RuntimeInfoImpl::GetDirectorySize(const char* path)
354 char command[512] = {0,};
355 char fileName[512] = {0,};
359 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
365 String appId(pApp->GetAppId());
366 unique_ptr <char> appIdPath(_StringConverter::CopyToCharArrayN(appId));
368 ret = sprintf(fileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
371 SysLogException(NID_SYS, E_SYSTEM, "It is failed to write file path.");
375 ret = sprintf(command, "rm -rf %s", fileName);
378 SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
382 ret = system(command);
386 SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
389 ret = sprintf(command, "du -skb -P %s >> %s", path, fileName);
392 SysLogException(NID_SYS, E_SYSTEM, "It is failed to write du command.");
396 ret = system(command);
399 SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
404 pFile = fopen(fileName, "r");
410 ret = fscanf(pFile, "%lld", &size);
426 ret = sprintf(command, "rm -rf %s", fileName);
429 SysLogException(NID_SYS, E_SYSTEM, "It is failed to write remove command.");
433 ret = system(command);
436 SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute command[%s].", command);
444 _RuntimeInfoImpl::GetValue(const String& key, double& value)
446 return E_OBJ_NOT_FOUND;
450 _RuntimeInfoImpl::GetValue(const String& key, bool& value)
452 if (key == _CHARGING)
454 return IsChargingMode(value);
458 return E_OBJ_NOT_FOUND;
463 _RuntimeInfoImpl::GetValue(const String& key, UuId& value)
465 return E_OBJ_NOT_FOUND;
469 _RuntimeInfoImpl::GetBatteryLevel(int& value)
471 int batteryValue = -1;
472 batteryValue = device_get_battery_pct();
473 SysTryReturnResult(NID_SYS, !(batteryValue < 0 || value > 100), E_SYSTEM, "[E_SYSTEM] device_get_battery_pct return %d", batteryValue);
474 value = batteryValue;
480 _RuntimeInfoImpl::IsChargingMode(bool& value)
482 bool chargeState = false;
484 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, &chargeState);
485 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_bool returns %d.", ret);
492 _RuntimeInfoImpl::GetAvailableInternalStorage(long long& value)
495 result r = E_SUCCESS;
497 r = GetCapacity(_ROOT_PATH, total, value);
498 SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[E_SYSTEM] system error has occurred. ");
503 _RuntimeInfoImpl::GetAvailableExternalStorage(long long& value)
505 int sdCardStatus = 0;
509 ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdCardStatus);
510 SysTryReturn(NID_SYS, !(ret < 0), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] vconf_get_int VCONFKEY_SYSMAN_MMC_STATUS failed");
512 if(sdCardStatus == 0)
517 char* directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetExternalStoragePath());
518 SysTryReturnResult(NID_SYS, directoryPath != null, E_SYSTEM, "It is failed to get external directory path.");
519 result r = GetCapacity(directoryPath, total, value);
520 delete [] directoryPath;
525 _RuntimeInfoImpl::GetAvailableMediaStorage(long long& value)
529 char* directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetMediaPath());
530 SysTryReturnResult(NID_SYS, directoryPath != null, E_SYSTEM, "It is failed to get media directory path.");
531 result r = GetCapacity(directoryPath, total, value);
532 delete [] directoryPath;
537 _RuntimeInfoImpl::GetCapacity(const char* path, long long& totalSize, long long& availableSize)
540 if (statfs(path, &fs) < 0)
542 SysLogException(NID_SYS, E_SYSTEM, "[E_SYSTEM] statfs() failed");
546 totalSize = static_cast< long long >(fs.f_bsize) * static_cast< long long >(fs.f_blocks);
547 availableSize = static_cast< long long >(fs.f_bsize) * static_cast< long long >(fs.f_bavail);
553 _RuntimeInfoImpl::GetFromProcLonglong(const char* path, const char* key, long long& value)
555 FILE* pStream = null;
556 char line[_MAX_BUFFER_LENGTH] = {0, };
557 char fieldName[_MAX_BUFFER_LENGTH] = {0, };
558 long long keyValue = 0;
559 pStream = fopen(path, "r");
560 SysTryReturnResult(NID_SYS, pStream != null, E_SYSTEM, "%s open is failed.", path);
562 while (fgets(line, sizeof(line), pStream))
564 if (sscanf(line, "%s %lld %*s", fieldName, &keyValue) == 2)
566 if (strncmp(fieldName, key, static_cast< int >(strlen(key))) == 0)
576 SysLogException(NID_SYS, E_OBJ_NOT_FOUND, "it can't find %s field", key);
577 return E_OBJ_NOT_FOUND;
581 _RuntimeInfoImpl::GetFromProc(const char* path, const char* key, int& value)
583 FILE* pStream = null;
584 char line[_MAX_BUFFER_LENGTH] = {0, };
585 char fieldName[_MAX_BUFFER_LENGTH] = {0, };
587 pStream = fopen(path, "r");
588 SysTryReturnResult(NID_SYS, pStream != null, E_SYSTEM, "%s open is failed.", path);
590 while (fgets(line, sizeof(line), pStream))
592 if (sscanf(line, "%s %d %*s", fieldName, &keyValue) == 2)
594 if (strncmp(fieldName, key, static_cast< int >(strlen(key))) == 0)
604 SysLogException(NID_SYS, E_OBJ_NOT_FOUND, "it can't find %s field", key);
605 return E_OBJ_NOT_FOUND;
609 _RuntimeInfoImpl::GetDirectorySizeAsync(void* data)
615 _RuntimeInfoEventArg* pEventArg = (_RuntimeInfoEventArg*)data;
616 long long size = _RuntimeInfoImpl::GetDirectorySize(pEventArg->DirectoryPath);
618 if(pEventArg == null)
620 SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of _RuntimeInfoEventArg");
623 pEventArg->Type = _RUNTIME_INFO_EVENT_TYPE_LONGLONG;
624 pEventArg->longLongValue = size;
625 SysLog(NID_SYS, "Fire event %x %s %lld", pEventArg, pEventArg->DirectoryPath, size);
626 runtimeInfoEvent.Fire(*pEventArg);
632 _RuntimeInfoImpl::GetCpuUsageAsync(void* data)
634 result r = E_SUCCESS;
637 procstat_t first, second, diffrence;
638 unsigned long long total, usage;
640 if(read_proc_stat(&first) != false)
642 usleep(_CPU_USAGE_EVALUATION_INTERVAL);
643 if(read_proc_stat(&second) != false)
645 diff_proc_stat(&second, &first, &diffrence);
646 total = diffrence.user + diffrence.system
647 + diffrence.nice + diffrence.idle
648 + diffrence.wait + diffrence.hi
650 usage = 10000 - (diffrence.idle * 10000 / total);
664 _RuntimeInfoEventArg* pEventArg = (_RuntimeInfoEventArg*) data;
665 if(pEventArg == null)
667 SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of _RuntimeInfoEventArg");
670 pEventArg->errorCode = r;
671 pEventArg->Type = _RUNTIME_INFO_EVENT_TYPE_INT;
672 pEventArg->intValue = value;
674 runtimeInfoEvent.Fire(*pEventArg);
680 _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetIntAsyncResultListener* listener)
682 result r = E_SUCCESS;
684 SysTryReturnResult(NID_SYS, listener != null, E_INVALID_ARG, "listener is null");
686 if (key == _CPU_CORE_ALL_USAGE)
690 runtimeInfoEvent.AddListener(*listener);
695 _RuntimeInfoEventArg* pEventArg = new (std::nothrow) _RuntimeInfoEventArg();
696 pEventArg->pListener = listener;
697 thr_id = pthread_create(&p_thread, null, GetCpuUsageAsync, pEventArg);
698 pthread_detach(p_thread);
702 SysLogException(NID_SYS, E_INVALID_ARG, "Required key[%ls] is not valid", key.GetPointer());
709 _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetLonglongAsyncResultListener* listener)
713 result r = E_SUCCESS;
714 char* directoryPath = null;
716 SysTryReturnResult(NID_SYS, listener != null, E_INVALID_ARG, "listener is null");
718 if(key == _STORAGE_ALLOCATED_INTERNAL_APPLICATION)
720 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_APPLICATIONS));
722 else if (key == _STORAGE_ALLOCATED_INTERNAL_AUDIO)
724 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_SOUNDS));
726 else if (key == _STORAGE_ALLOCATED_INTERNAL_VIDEO)
728 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_VIDEOS));
730 else if (key == _STORAGE_ALLOCATED_INTERNAL_IMAGE)
732 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_IMAGES));
734 else if (key == _STORAGE_ALLOCATED_INTERNAL_DOWNLOAD)
736 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_DOWNLOADS));
738 else if (key == _STORAGE_ALLOCATED_EXTERNAL_APPLICATION)
740 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_APPLICATIONS));
742 else if (key == _STORAGE_ALLOCATED_EXTERNAL_AUDIO)
744 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_SOUNDS));
746 else if (key == _STORAGE_ALLOCATED_EXTERNAL_VIDEO)
748 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_VIDEOS));
750 else if (key == _STORAGE_ALLOCATED_EXTERNAL_IMAGE)
752 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_IMAGES));
755 else if (key == _STORAGE_ALLOCATED_EXTERNAL_DOWNLOAD)
757 directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_DOWNLOADS));
761 SysLogException(NID_SYS, E_INVALID_ARG, "Required key[%ls] is not valid", key.GetPointer());
765 SysLog(NID_SYS, "%s", GetErrorMessage(r));
766 SysLog(NID_SYS, "%s", directoryPath);
771 SysLog(NID_SYS, "listener instance is %x.", listener);
772 runtimeInfoEvent.AddListener(*listener);
775 _RuntimeInfoEventArg* pEventArg = new (std::nothrow) _RuntimeInfoEventArg();
776 pEventArg->pListener = listener;
777 pEventArg->DirectoryPath = directoryPath;
779 thr_id = pthread_create(&p_thread, null, GetDirectorySizeAsync, pEventArg);
780 SysLog(NID_SYS, "Thread id is %d.", thr_id);
781 pthread_detach(p_thread);
788 _RuntimeInfoImpl::GetInstance(RuntimeInfo& runtimeinfo)
790 return runtimeinfo.__pRuntimeInfoImpl;
793 const _RuntimeInfoImpl*
794 _RuntimeInfoImpl::GetInstance(const RuntimeInfo& runtimeinfo)
796 return runtimeinfo.__pRuntimeInfoImpl;