2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FSysRuntimeInfo.cpp
19 * @brief This is the implementation file for _RuntimeInfoImpl class.
22 * This file contains the implementation of _RuntimeInfoImpl class.
25 #include <unique_ptr.h>
32 #include <app_storage.h>
34 #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>
47 #include "FSys_EnvironmentImpl.h"
48 #include "FSys_RuntimeInfoImpl.h"
49 #include "FSys_RuntimeClient.h"
51 using namespace Tizen::App;
52 using namespace Tizen::Base;
53 using namespace Tizen::Base::Runtime;
57 namespace Tizen { namespace System
60 #ifndef VCONFKEY_SERVICE_READY
61 #define VCONFKEY_SERVICE_READY "memory/deviced/boot_power_on"
64 static const wchar_t* _ALLOCATED_MEMORY = L"AllocatedMemory";
65 static const wchar_t* _MEMORY_ALLOCATED = L"http://tizen.org/runtime/memory.allocated";
66 static const wchar_t* _MEMORY_ALLOCATED_SELF = L"http://tizen.org/runtime/memory.allocated.self";
68 static const wchar_t* _AVAILABLE_EXTERNAL_STORAGE = L"AvailableExternalStorage";
69 static const wchar_t* _STORAGE_AVAILABLE_EXTERNAL = L"http://tizen.org/runtime/storage.available.external";
71 static const wchar_t* _AVAILABLE_INTERNAL_STORAGE = L"AvailableInternalStorage";
72 static const wchar_t* _STORAGE_AVAILABLE_INTERNAL = L"http://tizen.org/runtime/storage.available.internal";
74 static const wchar_t* _AVAILABLE_MEDIA_STORAGE = L"AvailableMediaStorage";
75 static const wchar_t* _STORAGE_AVAILABLE_INTERNAL_MEDIA = L"http://tizen.org/runtime/storage.available.internal.media";
77 static const wchar_t* _BATTERY_LEVEL = L"BatteryLevel";
78 static const wchar_t* _CHARGING = L"IsCharging";
80 static const wchar_t* _CPU_CORE_ALL_USAGE = L"http://tizen.org/runtime/cpu.core.all.usage";
82 static const wchar_t* _MAX_ALLOCATABLE_MEMORY = L"MaxAllocatableMemory";
83 static const wchar_t* _AVAILABLE_VIDEO_MEMORY = L"AvailableVideoMemory";
84 static const wchar_t* _ALLOCATED_VIDEO_MEMORY = L"AllocatedVideoMemory";
85 static const wchar_t* _AVAILABLE_MEMORY = L"AvailableMemory";
86 static const wchar_t* _MEMORY_AVAILABLE = L"http://tizen.org/runtime/memory.available";
87 static const wchar_t* _MEMORY_AVAILABLE_VIDEO = L"http://tizen.org/runtime/memory.available.video";
88 static const wchar_t* _MEMORY_ALLOCATED_VIDEO = L"http://tizen.org/runtime/memory.allocated.video";
90 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_APPLICATION = L"http://tizen.org/runtime/storage.allocated.internal.application";
91 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_AUDIO = L"http://tizen.org/runtime/storage.allocated.internal.audio";
92 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_VIDEO = L"http://tizen.org/runtime/storage.allocated.internal.video";
93 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_IMAGE = L"http://tizen.org/runtime/storage.allocated.internal.image";
94 static const wchar_t* _STORAGE_ALLOCATED_INTERNAL_DOWNLOAD = L"http://tizen.org/runtime/storage.allocated.internal.download";
95 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_APPLICATION = L"http://tizen.org/runtime/storage.allocated.external.application";
96 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_AUDIO = L"http://tizen.org/runtime/storage.allocated.external.audio";
97 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_VIDEO = L"http://tizen.org/runtime/storage.allocated.external.video";
98 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_IMAGE = L"http://tizen.org/runtime/storage.allocated.external.image";
99 static const wchar_t* _STORAGE_ALLOCATED_EXTERNAL_DOWNLOAD = L"http://tizen.org/runtime/storage.allocated.external.download";
101 static const wchar_t _BOOT_STATUS_KEY[] = L"http://tizen.org/runtime/system.status";
102 static const wchar_t _BOOT_STATUS_INITIALIZING[] = L"initializing";
103 static const wchar_t _BOOT_STATUS_READY[] = L"ready";
106 static const int _RUNTIME_INFO_EVENT_TYPE_INT = 101;
107 static const int _RUNTIME_INFO_EVENT_TYPE_LONGLONG = 102;
110 static const char* const _PROC_SYSTEM_MEMORY_INFO = "/proc/meminfo";
111 static const char* const _PROC_PROCESS_MEMORY_INFO = "/proc/self/status";
112 static const char* const _PROC_STAT = "/proc/stat";
114 static const char* const _PROC_KEY_SYSTEM_MEMORY_TOTAL = "MemTotal";
115 static const char* const _PROC_KEY_SYSTEM_MEMORY_FREE = "MemFree";
116 static const char* const _PROC_KEY_PROCESS_MEMORY = "VmSize";
118 static const char* const _ROOT_PATH = "/";
120 static const int _MAX_BUFFER_LENGTH = 1024;
122 static const int _CPU_USAGE_EVALUATION_INTERVAL = 1000000; //1 sec
126 unsigned long long user;
127 unsigned long long system;
128 unsigned long long nice;
129 unsigned long long idle;
130 unsigned long long wait;
131 unsigned long long hi;
132 unsigned long long si;
133 unsigned long long zero;
136 bool read_proc_stat(procstat_t *p)
141 fp = fopen(_PROC_STAT, "r");
147 ret = fscanf(fp, "%s %llu %llu %llu %llu %llu %llu %llu %llu",
175 void diff_proc_stat(procstat_t *a, procstat_t *b, procstat_t *d)
177 d->user = a->user - b->user;
178 d->system = a->system - b->system;
179 d->nice = a->nice - b->nice;
180 d->idle = a->idle - b->idle;
181 d->wait = a->wait - b->wait;
182 d->hi = a->hi - b->hi;
183 d->si = a->si - b->si;
184 d->zero = a->zero - b->zero;
187 class _RuntimeInfoEventArg : public IEventArg
190 _RuntimeInfoEventArg()
194 , errorCode(E_SUCCESS)
195 , DirectoryPath(null)
200 ~_RuntimeInfoEventArg()
202 if(DirectoryPath != null)
204 delete [] DirectoryPath;
210 long long longLongValue;
213 IEventListener* pListener;
216 class _RuntimeInfoEvent : public Event
219 void FireImpl(IEventListener& listener, const IEventArg& arg)
221 const _RuntimeInfoEventArg* runtimeArg = dynamic_cast<const _RuntimeInfoEventArg*> (&arg);
223 if(runtimeArg == null)
225 SysLogException(NID_SYS, E_SYSTEM, "Argument is null.");
229 switch(runtimeArg->Type)
231 case _RUNTIME_INFO_EVENT_TYPE_INT:
233 IRuntimeInfoGetIntAsyncResultListener* pIntListener = dynamic_cast<IRuntimeInfoGetIntAsyncResultListener*>(&listener);
235 if(pIntListener == runtimeArg->pListener)
237 pIntListener->OnResultReceivedForGetValueAsync(runtimeArg->intValue, runtimeArg->errorCode);
238 RemoveListener(listener);
242 case _RUNTIME_INFO_EVENT_TYPE_LONGLONG:
244 IRuntimeInfoGetLonglongAsyncResultListener* pLonglongListener = dynamic_cast<IRuntimeInfoGetLonglongAsyncResultListener*>(&listener);
245 if(pLonglongListener == runtimeArg->pListener)
247 pLonglongListener->OnResultReceivedForGetValueAsync(runtimeArg->longLongValue, runtimeArg->errorCode);
248 RemoveListener(listener);
256 _RuntimeInfoEvent runtimeInfoEvent;
258 _RuntimeInfoImpl::_RuntimeInfoImpl(void)
262 _RuntimeInfoImpl::~_RuntimeInfoImpl(void)
267 _RuntimeInfoImpl::GetValue(const String& key, String& value)
269 if (key == _BOOT_STATUS_KEY)
272 const int errorCode = vconf_get_int(VCONFKEY_SERVICE_READY, &bootReady);
275 value = (bootReady == 1 ) ? _BOOT_STATUS_READY : _BOOT_STATUS_INITIALIZING;
284 return E_OBJ_NOT_FOUND;
289 _RuntimeInfoImpl::GetValue(const String& key, int& value)
293 result r = E_OBJ_NOT_FOUND;
295 if (key == _BATTERY_LEVEL)
297 return GetBatteryLevel(value);
299 else if (key == _ALLOCATED_MEMORY || key == _ALLOCATED_VIDEO_MEMORY)
301 r = GetFromProc(_PROC_PROCESS_MEMORY_INFO, _PROC_KEY_PROCESS_MEMORY, free_size);
302 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
303 value = free_size * 1024;
305 else if (key == _AVAILABLE_MEMORY || key == _AVAILABLE_VIDEO_MEMORY || key == _MAX_ALLOCATABLE_MEMORY)
307 r = GetFromProc(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
308 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
309 value = free_size * 1024;
315 _RuntimeInfoImpl::GetValue(const String& key, long long& value)
318 long long total_size = 0;
319 long long free_size =0;
320 result r = E_OBJ_NOT_FOUND;
322 if (key == _MEMORY_AVAILABLE || key == _MEMORY_AVAILABLE_VIDEO)
324 r = GetFromProcLonglong(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
325 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
326 value = free_size * 1024;
328 else if (key == _MEMORY_ALLOCATED || key == _MEMORY_ALLOCATED_VIDEO)
330 r = GetFromProcLonglong(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_TOTAL, total_size);
331 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
332 r = GetFromProcLonglong(_PROC_SYSTEM_MEMORY_INFO, _PROC_KEY_SYSTEM_MEMORY_FREE, free_size);
333 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
334 value = (total_size - free_size) * 1024;
336 else if (key == _MEMORY_ALLOCATED_SELF)
338 r = GetFromProcLonglong(_PROC_PROCESS_MEMORY_INFO, _PROC_KEY_PROCESS_MEMORY, free_size);
339 SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get memory size.");
340 value = free_size * 1024;
342 else if (key == _AVAILABLE_INTERNAL_STORAGE)
344 return GetAvailableInternalStorage(value);
346 else if (key == _AVAILABLE_EXTERNAL_STORAGE)
348 return GetAvailableExternalStorage(value);
350 else if (key == _AVAILABLE_MEDIA_STORAGE)
352 return GetAvailableMediaStorage(value);
354 else if(key == _STORAGE_AVAILABLE_INTERNAL)
356 return GetAvailableInternalStorage(value);
358 else if(key == _STORAGE_AVAILABLE_EXTERNAL)
360 return GetAvailableExternalStorage(value);
362 else if(key == _STORAGE_AVAILABLE_INTERNAL_MEDIA)
364 return GetAvailableMediaStorage(value);
368 SysLogException(NID_SYS, r, "Key[%ls] is not valid.", key.GetPointer());
374 _RuntimeInfoImpl::GetDirectorySize(const char* path)
381 char* pCommand = null;
382 char* pFileName = null;
384 int commandLength = 0;
389 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
395 String appId(pApp->GetAppId());
396 unique_ptr <char[]> appIdPath(_StringConverter::CopyToCharArrayN(appId));
398 fileLength = strlen(appIdPath.get()) + 29;
399 pFileName = (char*)malloc(fileLength);
400 ret = sprintf(pFileName, "/tmp/size_of_directory_%s.tmp", appIdPath.get());
401 SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write file path.");
403 commandLength = strlen(pFileName) + 8;
404 pCommand = (char*) malloc(commandLength);
405 ret = sprintf(pCommand, "rm -rf %s", pFileName);
406 SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write remove pCommand.");
408 ret = system(pCommand);
411 SysLogException(NID_SYS, E_SYSTEM, "It is failed to execute pCommand[%s].", pCommand);
416 commandLength = strlen(pFileName) + strlen(path) + 16;
417 pCommand = (char*)malloc(commandLength);
418 ret = sprintf(pCommand, "du -skb -P %s >> %s", path, pFileName);
419 SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write du pCommand.");
421 ret = system(pCommand);
422 SysTryCatch(NID_SYS, ret != -1, E_SYSTEM, E_SYSTEM, "It is failed to execute pCommand[%s].", pCommand);
424 pFile = fopen(pFileName, "r");
425 SysTryCatch(NID_SYS, pFile != null, E_SYSTEM, E_SYSTEM, "It is failed to read file [%s].", pFileName);
427 ret = fscanf(pFile, "%lld", &size);
428 SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to read file [%s].", pFileName);
430 ret = sprintf(pCommand, "rm -rf %s", pFileName);
431 SysTryCatch(NID_SYS, ret > 0, E_SYSTEM, E_SYSTEM, "It is failed to write remove pCommand.");
433 ret = system(pCommand);
434 SysTryCatch(NID_SYS, ret != -1, E_SYSTEM, E_SYSTEM, "It is failed to execute pCommand[%s].", pCommand);
453 _RuntimeInfoImpl::GetValue(const String& key, double& value)
455 return E_OBJ_NOT_FOUND;
459 _RuntimeInfoImpl::GetValue(const String& key, bool& value)
461 if (key == _CHARGING)
463 return IsChargingMode(value);
467 return E_OBJ_NOT_FOUND;
472 _RuntimeInfoImpl::GetValue(const String& key, UuId& value)
474 return E_OBJ_NOT_FOUND;
478 _RuntimeInfoImpl::GetBatteryLevel(int& value)
480 int batteryValue = -1;
481 batteryValue = device_get_battery_pct();
482 SysTryReturnResult(NID_SYS, !(batteryValue < 0 || value > 100), E_SYSTEM, "[E_SYSTEM] device_get_battery_pct return %d", batteryValue);
483 value = batteryValue;
489 _RuntimeInfoImpl::IsChargingMode(bool& value)
491 bool chargeState = false;
493 ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, &chargeState);
494 SysTryReturnResult(NID_SYS, ret == 0, E_SYSTEM, "[E_SYSTEM] runtime_info_get_value_bool returns %d.", ret);
501 _RuntimeInfoImpl::GetAvailableInternalStorage(long long& value)
504 result r = E_SUCCESS;
506 r = GetCapacity(_ROOT_PATH, total, value);
507 SysTryReturn(NID_SYS, !IsFailed(r), E_SYSTEM, r, "[E_SYSTEM] system error has occurred. ");
512 _RuntimeInfoImpl::GetAvailableExternalStorage(long long& value)
514 int sdCardStatus = 0;
518 ret = vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdCardStatus);
519 SysTryReturn(NID_SYS, !(ret < 0), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] vconf_get_int VCONFKEY_SYSMAN_MMC_STATUS failed");
521 if(sdCardStatus == 0)
526 char* directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetExternalStoragePath());
527 SysTryReturnResult(NID_SYS, directoryPath != null, E_SYSTEM, "It is failed to get external directory path.");
528 result r = GetCapacity(directoryPath, total, value);
529 delete [] directoryPath;
534 _RuntimeInfoImpl::GetAvailableMediaStorage(long long& value)
538 char* directoryPath = _StringConverter::CopyToCharArrayN(_EnvironmentImpl::GetMediaPath());
539 SysTryReturnResult(NID_SYS, directoryPath != null, E_SYSTEM, "It is failed to get media directory path.");
540 result r = GetCapacity(directoryPath, total, value);
541 delete [] directoryPath;
546 _RuntimeInfoImpl::GetCapacity(const char* path, long long& totalSize, long long& availableSize)
549 if (statfs(path, &fs) < 0)
551 SysLogException(NID_SYS, E_SYSTEM, "[E_SYSTEM] statfs() failed");
555 totalSize = static_cast< long long >(fs.f_bsize) * static_cast< long long >(fs.f_blocks);
556 availableSize = static_cast< long long >(fs.f_bsize) * static_cast< long long >(fs.f_bavail);
562 _RuntimeInfoImpl::GetFromProcLonglong(const char* path, const char* key, long long& value)
564 FILE* pStream = null;
565 char line[_MAX_BUFFER_LENGTH] = {0, };
566 char fieldName[_MAX_BUFFER_LENGTH] = {0, };
567 long long keyValue = 0;
568 pStream = fopen(path, "r");
569 SysTryReturnResult(NID_SYS, pStream != null, E_SYSTEM, "%s open is failed.", path);
571 while (fgets(line, sizeof(line), pStream))
573 if (sscanf(line, "%s %lld %*s", fieldName, &keyValue) == 2)
575 if (strncmp(fieldName, key, static_cast< int >(strlen(key))) == 0)
585 SysLogException(NID_SYS, E_OBJ_NOT_FOUND, "it can't find %s field", key);
586 return E_OBJ_NOT_FOUND;
590 _RuntimeInfoImpl::GetFromProc(const char* path, const char* key, int& value)
592 FILE* pStream = null;
593 char line[_MAX_BUFFER_LENGTH] = {0, };
594 char fieldName[_MAX_BUFFER_LENGTH] = {0, };
596 pStream = fopen(path, "r");
597 SysTryReturnResult(NID_SYS, pStream != null, E_SYSTEM, "%s open is failed.", path);
599 while (fgets(line, sizeof(line), pStream))
601 if (sscanf(line, "%s %d %*s", fieldName, &keyValue) == 2)
603 if (strncmp(fieldName, key, static_cast< int >(strlen(key))) == 0)
613 SysLogException(NID_SYS, E_OBJ_NOT_FOUND, "it can't find %s field", key);
614 return E_OBJ_NOT_FOUND;
618 _RuntimeInfoImpl::GetDirectorySizeAsync(void* data)
624 _RuntimeInfoEventArg* pEventArg = (_RuntimeInfoEventArg*)data;
625 long long size = _RuntimeInfoImpl::GetDirectorySize(pEventArg->DirectoryPath);
627 if(pEventArg == null)
629 SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of _RuntimeInfoEventArg");
632 pEventArg->Type = _RUNTIME_INFO_EVENT_TYPE_LONGLONG;
633 pEventArg->longLongValue = size;
634 SysLog(NID_SYS, "Fire event %x %s %lld", pEventArg, pEventArg->DirectoryPath, size);
635 runtimeInfoEvent.Fire(*pEventArg);
641 _RuntimeInfoImpl::GetCpuUsageAsync(void* data)
643 result r = E_SUCCESS;
646 procstat_t first, second, diffrence;
647 unsigned long long total, usage;
649 if(read_proc_stat(&first) != false)
651 usleep(_CPU_USAGE_EVALUATION_INTERVAL);
652 if(read_proc_stat(&second) != false)
654 diff_proc_stat(&second, &first, &diffrence);
655 total = diffrence.user + diffrence.system
656 + diffrence.nice + diffrence.idle
657 + diffrence.wait + diffrence.hi
659 usage = 10000 - (diffrence.idle * 10000 / total);
673 _RuntimeInfoEventArg* pEventArg = (_RuntimeInfoEventArg*) data;
674 if(pEventArg == null)
676 SysLogException(NID_SYS, E_OUT_OF_MEMORY, "It is failed to create instance of _RuntimeInfoEventArg");
679 pEventArg->errorCode = r;
680 pEventArg->Type = _RUNTIME_INFO_EVENT_TYPE_INT;
681 pEventArg->intValue = value;
683 runtimeInfoEvent.Fire(*pEventArg);
689 _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetIntAsyncResultListener* listener)
691 result r = E_SUCCESS;
693 SysTryReturnResult(NID_SYS, listener != null, E_INVALID_ARG, "listener is null");
695 if (key == _CPU_CORE_ALL_USAGE)
699 runtimeInfoEvent.AddListener(*listener);
704 _RuntimeInfoEventArg* pEventArg = new (std::nothrow) _RuntimeInfoEventArg();
705 pEventArg->pListener = listener;
706 thr_id = pthread_create(&p_thread, null, GetCpuUsageAsync, pEventArg);
707 pthread_detach(p_thread);
711 SysLogException(NID_SYS, E_INVALID_ARG, "Required key[%ls] is not valid", key.GetPointer());
718 _RuntimeInfoImpl::GetValueAsync(const String& key, IRuntimeInfoGetLonglongAsyncResultListener* listener)
722 result r = E_SUCCESS;
723 String directoryPath;
725 SysTryReturnResult(NID_SYS, listener != null, E_INVALID_ARG, "listener is null");
727 if(key == _STORAGE_ALLOCATED_INTERNAL_APPLICATION)
729 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_APPLICATIONS));
731 else if (key == _STORAGE_ALLOCATED_INTERNAL_AUDIO)
733 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_SOUNDS));
735 else if (key == _STORAGE_ALLOCATED_INTERNAL_VIDEO)
737 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_VIDEOS));
739 else if (key == _STORAGE_ALLOCATED_INTERNAL_IMAGE)
741 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_IMAGES));
743 else if (key == _STORAGE_ALLOCATED_INTERNAL_DOWNLOAD)
745 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_DOWNLOADS));
747 else if (key == _STORAGE_ALLOCATED_EXTERNAL_APPLICATION)
749 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_APPLICATIONS));
751 else if (key == _STORAGE_ALLOCATED_EXTERNAL_AUDIO)
753 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_SOUNDS));
755 else if (key == _STORAGE_ALLOCATED_EXTERNAL_VIDEO)
757 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_VIDEOS));
759 else if (key == _STORAGE_ALLOCATED_EXTERNAL_IMAGE)
761 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_IMAGES));
763 else if (key == _STORAGE_ALLOCATED_EXTERNAL_DOWNLOAD)
765 directoryPath.Append(_EnvironmentImpl::GetPredefinedPath(PREDEFINED_DIRECTORY_EXTERNAL_DOWNLOADS));
769 SysLogException(NID_SYS, E_INVALID_ARG, "Required key[%ls] is not valid", key.GetPointer());
773 SysLog(NID_SYS, "%s", GetErrorMessage(r));
774 SysLog(NID_SYS, "%ls", directoryPath.GetPointer());
777 _RuntimeClient* pRuntimeClient = _RuntimeClient::GetInstance();
778 pRuntimeClient->GetDirectorySizeValueAsync(directoryPath, listener);
785 _RuntimeInfoImpl::GetInstance(RuntimeInfo& runtimeinfo)
787 return runtimeinfo.__pRuntimeInfoImpl;
790 const _RuntimeInfoImpl*
791 _RuntimeInfoImpl::GetInstance(const RuntimeInfo& runtimeinfo)
793 return runtimeinfo.__pRuntimeInfoImpl;