Merge "Revert "add workaround code for LifeDuration"" into tizen_2.1
authorSeungWon Lee <lsw2000.lee@samsung.com>
Fri, 26 Apr 2013 05:54:49 +0000 (14:54 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 26 Apr 2013 05:54:49 +0000 (14:54 +0900)
12 files changed:
src/app/FApp_AppArg.cpp [changed mode: 0644->0755]
src/app/inc/FAppPkg_PackageManagerImpl.h
src/app/package/FAppPkg_PackageAppInfoImpl.cpp
src/app/package/FAppPkg_PackageInfoImpl.cpp
src/app/package/FAppPkg_PackageManagerImpl.cpp
src/base/FBaseString.cpp
src/io/FIo_IpcClient.cpp
src/io/inc/FIo_IpcClient.h
src/security/cert/FSecCert_Certificate.cpp
src/server/inc/FIo_IpcServer.h
src/server/io/FIo_IpcServer.cpp
src/system/FSys_PowerManagerImpl.cpp

old mode 100644 (file)
new mode 100755 (executable)
index e8ba5b7..f1796ba
@@ -431,6 +431,24 @@ BundleIterFnCb(const char* pKey, const int type, const bundle_keyval_t* pVal, vo
                                }
                        }
                        break;
+               case BUNDLE_TYPE_BYTE:
+                       bundle_keyval_get_basic_val(const_cast<bundle_keyval_t*>(pVal), reinterpret_cast<void**>(&pStr), &size);
+
+                       SysLog(NID_IO, "Bundle byte value = %s, size = %d", pStr, size);
+
+                       if (pStr)
+                       {
+                               ByteBuffer* pBuffer = new (std::nothrow) ByteBuffer();
+                               SysTryLog(NID_IO, pBuffer != null, "The memory is insufficient.");
+                               result r = pBuffer->Construct(size);
+                               SysTryLog(NID_IO, r == E_SUCCESS, "Constructing pBuffer is failed.");
+
+                               pBuffer->SetArray((const byte*)pStr, 0, size);
+                               pBuffer->Flip();
+
+                               pMap->Add(new (std::nothrow) String(pKey), pBuffer);
+                       }
+                       break;
                default:
                        SysLog(NID_APP, "Invalid type for %s : %d", pKey, type);
                        break;
@@ -702,6 +720,10 @@ _AppArg::AddStrMap(bundle* b, const IMap* pMap)
                        else if (typeid(*pObj) == typeid(const ByteBuffer))
                        {
                                SysLog(NID_APP, "ByteBuffer type");
+                               const ByteBuffer* pBuffer = static_cast<const ByteBuffer*>(pObj);
+
+                               std::unique_ptr<char[]> pBundleKey(_StringConverter::CopyToCharArrayN(*pKey));
+                               bundle_add_byte(b, pBundleKey.get(), pBuffer->GetPointer(), pBuffer->GetLimit());
                        }
                }
        }
index 8764e03..4fe5ee0 100644 (file)
@@ -65,6 +65,9 @@ static const wchar_t PACKAGE_FILTER_DOWNLOADED[] = L"http://tizen.org/package/do
 static const wchar_t PACKAGE_FILTER_EXTERNAL_STORAGE[] = L"http://tizen.org/package/externalstorage";
 static const wchar_t PACKAGE_FILTER_APP_SETTING[] = L"http://tizen.org/package/appsetting";
 
+// PackageFilter(internal)
+static const wchar_t PACKAGE_FILTER_TPK[] = L"http://tizen.org/package/tpk";
+
 // PackageAppFilter
 static const wchar_t PACKAGE_APP_FILTER_MENUICON_VISIBLE[] = L"http://tizen.org/package/app/menuiconvisible";
 static const wchar_t PACKAGE_APP_FILTER_CATEGORY_HOMEAPP[] = L"http://tizen.org/category/homeapp";
index 1081299..47799d1 100755 (executable)
@@ -33,6 +33,7 @@
 #include <FIoDbEnumerator.h>
 #include <FIoDbStatement.h>
 #include <FIoFile.h>
+#include <FIoDirectory.h>
 #include <FBase_StringConverter.h>
 
 #include "FAppPkg_PackageManagerImpl.h"
@@ -369,7 +370,6 @@ _PackageAppInfoImpl::Construct(const AppId& appId)
        res = pkgmgrinfo_appinfo_get_icon(__pAppInfoHandle, &pMenuIcon);
        if (res == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_get_icon(): MenuIcon = [%s]", pMenuIcon);
                String menuIcon(pMenuIcon);
                SetAppMenuIconPath(menuIcon);
        }
@@ -381,7 +381,6 @@ _PackageAppInfoImpl::Construct(const AppId& appId)
        res = pkgmgrinfo_appinfo_get_setting_icon(__pAppInfoHandle, &pSettingIcon);
        if (res == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_get_setting_icon(): SettingIcon = [%s]", pSettingIcon);
                String settingIcon(pSettingIcon);
                SetAppSettingIconPath(settingIcon);
        }
@@ -393,7 +392,6 @@ _PackageAppInfoImpl::Construct(const AppId& appId)
        res = pkgmgrinfo_appinfo_get_notification_icon(__pAppInfoHandle, &pNotificationIcon);
        if (res == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_appinfo_get_notification_icon(): NotificationIcon = [%s]", pNotificationIcon);
                String notificationIcon(pNotificationIcon);
                SetAppNotificationIconPath(notificationIcon);
        }
@@ -536,6 +534,9 @@ _PackageAppInfoImpl::~_PackageAppInfoImpl(void)
        if (File::IsFileExist(__appTempIconPath) == true)
        {
                File::Remove(__appTempIconPath);
+
+               String tmp(L"/tmp/__icon/");
+               Directory::Remove(tmp, true);
        }
 }
 
index 34dd145..3cafda7 100755 (executable)
@@ -1007,7 +1007,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_pkgname(__packageInfoHandle, &pPackage);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_pkgname(): package = [%s]", pPackage);
                String package(pPackage);
                __id = package;
        }
@@ -1019,7 +1018,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_version(__packageInfoHandle, &pVersion);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_version(): version = [%s]", pVersion);
                String version(pVersion);
                __version = version;
        }
@@ -1031,7 +1029,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_type(__packageInfoHandle, &pType);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_type(): type = [%s]", pType);
                String type(pType);
                __type = type;
        }
@@ -1043,7 +1040,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_label(__packageInfoHandle, &pName);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_label(): name = [%s]", pName);
                String Name(pName);
                __displayName = Name;
        }
@@ -1055,7 +1051,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_icon(__packageInfoHandle, &pIconPath);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_icon(): iconpath = [%s]", pIconPath);
                String path(pIconPath);
                __appIconPath = path;
        }
@@ -1067,8 +1062,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_is_removable(__packageInfoHandle, &removable);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_is_removable(): removable = [%d]", removable);
-
                if (removable == false)
                {
                        __uninstallable = false;
@@ -1082,8 +1075,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_is_preload(__packageInfoHandle, &preloaded);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_is_preload(): preloaded = [%d]", preloaded);
-
                if (preloaded == false)
                {
                        __downloaded = true;
@@ -1097,7 +1088,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_description(__packageInfoHandle, &pDescription);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_description(): description = [%s]", pDescription);
                String description(pDescription);
                __description = description;
        }
@@ -1109,7 +1099,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_author_name(__packageInfoHandle, &pAuthor);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_author_name(): author = [%s]", pAuthor);
                String author(pAuthor);
                __author = author;
        }
@@ -1143,7 +1132,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_installed_storage(__packageInfoHandle, &storage);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_installed_storage(): storage = [%d]", storage);
                if (storage == PMINFO_EXTERNAL_STORAGE)
                {
                        __externalStorage = true;
@@ -1157,7 +1145,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_url(__packageInfoHandle, &pUrl);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_url(): url = [%s]", pUrl);
                String url(pUrl);
                __url = url;
        }
@@ -1169,7 +1156,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_mainappid(__packageInfoHandle, &pMainAppId);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_mainappid(): mainApp = [%s]", pMainAppId);
                AppId mainAppId(pMainAppId);
                __mainAppId = mainAppId;
        }
@@ -1181,7 +1167,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_storeclientid(__packageInfoHandle, &pStoreClientId);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_storeclientid(): storeClientId = [%s]", pStoreClientId);
                String storeClientId(pStoreClientId);
                __storeClientId = storeClientId;
        }
@@ -1193,7 +1178,6 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
        result = pkgmgrinfo_pkginfo_get_root_path(__packageInfoHandle, &pRootPath);
        if (result == PMINFO_R_OK)
        {
-               SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_root_path(): rootPath = [%s]", pRootPath);
                String rootPath(pRootPath);
                __appRootPath = rootPath;
        }
@@ -1202,6 +1186,11 @@ _PackageInfoImpl::Construct(const PackageId& packageId)
                SysLog(NID_APP, "pkgmgrinfo_pkginfo_get_root_path() is failed. result = [%d]", result);
        }
 
+       SysLog(NID_APP, "package(%ls), version(%ls), type(%ls), displayName(%ls), uninstallable(%d), downloaded(%d), "
+                                                                       "externalStorage(%d), mainApp(%ls), storeClient(%ls), appRootPath(%ls)",
+                       __id.GetPointer(), __version.GetPointer(), __type.GetPointer(), __displayName.GetPointer(), __uninstallable, __downloaded,
+                       __externalStorage, __mainAppId.GetPointer(), __storeClientId.GetPointer(), __appRootPath.GetPointer());
+
        return r;
 }
 
index 98f8be5..35efd1d 100755 (executable)
@@ -381,8 +381,8 @@ _PackageManagerImpl::InstallPackage(const PackageId& packageId, const String& pa
                return E_SYSTEM;
        }
 
-       // optionalData = 12345abcde:StoreClientId=XXXXX12345.TizenStore
-       AppId StoreClientId = _AppInfo::GetApplicationId();
+       // optionalData = 12345abcde:StoreClientId=XXXXX12345
+       PackageId StoreClientId = _AppInfo::GetPackageId();
        String optionalData;
        optionalData.Append(packageId);
        optionalData.Append(":StoreClientId=");
@@ -872,6 +872,13 @@ _PackageManagerImpl::GetPackageInfoListN(const IMap& packageFilterMap) const
                        res = pkgmgrinfo_pkginfo_filter_add_bool(handle, PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING, value);
                        SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_bool(APPSETTING, %d) is failed. [%d]", value, res);
                }
+               else if ((*pKey) == PACKAGE_FILTER_TPK)
+               {
+                       SysTryCatch(NID_APP, value == true, , E_SYSTEM, "Value(false) is invalid for PACKAGE_FILTER_TPK.");
+
+                       res = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, "tpk");
+                       SysTryCatch(NID_APP, res == PMINFO_R_OK, , E_SYSTEM, "pkgmgrinfo_pkginfo_filter_add_string(TYPE, tpk) is failed. [%d]", res);
+               }
                else if ((*pKey) == PACKAGE_FILTER_EXTERNAL_STORAGE)
                {
                        String installedStorage;
index 24dda81..ec9aae1 100644 (file)
@@ -995,7 +995,7 @@ String::Replace(const String& org, const String& rep, int startIndex)
 void
 String::Reverse(void)
 {
-       if (*__pRefCount > 0)
+       if (*__pRefCount > 1)
        {
                result r = CopyOnWrite(__capacity);
                SysTryReturnVoidResult(NID_BASE, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed.");
@@ -1304,7 +1304,7 @@ String::ToLower(void)
 void
 String::ToLowerCase(void)
 {
-       if (*__pRefCount > 0)
+       if (*__pRefCount > 1)
        {
                result r = CopyOnWrite(__capacity);
                SysTryReturnVoidResult(NID_BASE, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed.");
@@ -1396,14 +1396,26 @@ String::Trim(void)
                --lastIndex;
        }
 
-       // trim right
-       if (lastIndex < __length)
+       bool trimRight = lastIndex < __length;
+       bool trimLeft = startIndex > 0;
+
+       if (!trimRight && !trimLeft)    // nothing to trim
+       {
+               return;
+       }
+
+       if (*__pRefCount > 1)
+       {
+               result r = CopyOnWrite(__capacity);
+               SysTryReturnVoidResult(NID_BASE, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed");
+       }
+
+       if (trimRight)
        {
                Remove(lastIndex, __length - lastIndex);
        }
 
-       // trim left
-       if (startIndex > 0)
+       if (trimLeft)
        {
                Remove(0, startIndex);
        }
index 32843d0..9e98c93 100644 (file)
@@ -57,6 +57,7 @@ namespace Tizen { namespace Io
 
 _IpcClient::_IpcClient(void)
        : __pReverseSource(null)
+       , __fdCount(0)
        , __pFdLock(null)
        , __pListener(null)
 {
@@ -133,7 +134,9 @@ _IpcClient::GetName(void) const
 struct HelloMessage
 {
        int pid;
-       int reverse;
+       bool reverse;
+       char pkgId[256];
+       char appExecutableName[256];
 };
 
 result
@@ -172,6 +175,34 @@ _IpcClient::MakeConnection(bool forReverse)
        socketNameLength = socketName.size() + 1;
        SysTryReturnResult(NID_IO, socketNameLength < 108, E_INVALID_ARG, "Server name is too long.");
 
+       if (__fdCount == 0)
+       {
+               // Set an pkgId
+               String pkgId = _AppInfo::GetPackageId();
+               int length = (pkgId.GetLength() + 1) * sizeof(wchar_t);
+               if (length > 255)
+               {
+                       length = 255;
+               }
+
+               SysTryReturnResult(NID_IO, pkgId.GetLength() > 0, E_SYSTEM, "AppId dose not exist.");
+
+               memcpy(helloMessage.pkgId, pkgId.GetPointer(), length);
+
+               // Set an executableName
+               String appExecutableName = _AppInfo::GetAppExecutableName();
+               length = (appExecutableName.GetLength() + 1) * sizeof(wchar_t);
+               if (length > 255)
+               {
+                       length = 255;
+               }
+
+               if (appExecutableName.GetLength() != 0)
+               {
+                       memcpy(helloMessage.appExecutableName, appExecutableName.GetPointer(), length);
+               }
+       }
+
        client = socket(AF_UNIX, SOCK_STREAM, 0);
        SysTryCatch(NID_IO, client != -1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to create a socket : %s.", strerror(errno));
 
@@ -267,6 +298,8 @@ _IpcClient::MakeConnection(bool forReverse)
        }
        else
        {
+               ++__fdCount;
+
                ReleaseFd(client);
        }
 
index 60c2c85..ef48ac5 100644 (file)
@@ -137,6 +137,7 @@ private:
        GSource* __pReverseSource;
 
        std::vector <int> __fds;
+       int __fdCount;
        Tizen::Base::Runtime::Mutex* __pFdLock;
        Tizen::Base::String __name;
        _IIpcClientEventListener* __pListener;
index a541746..2c86cc0 100644 (file)
@@ -747,7 +747,7 @@ _X509Certificate::ParseIssuerName(void)
        SysTryReturnResult(NID_SEC_CERT, pName != null, E_PARSING_FAILED, "Failed to get certificate issuer name.");
 
        __tbsCert.SetIssuerName(pName);
-
+       free(pName);
        return E_SUCCESS;
 }
 
@@ -813,6 +813,7 @@ _X509Certificate::ParseSubjectName(void)
                __x509IsSelfSign = false;
        }
 
+       free(pSubject);
        return r;
 }
 
@@ -848,6 +849,7 @@ _X509Certificate::ParseSubjectPublicKeyInfo(void)
        __tbsCert.SetPublicKeyInfo(pubKeyLen, pPubKey);
 
        OPENSSL_free(pPubKey);
+       EVP_PKEY_free(pKey);
        return r;
 }
 
index 758237d..df1530c 100644 (file)
@@ -190,7 +190,8 @@ private:
                _IpcServer* pIpcServer;                    /**< the pointer to an _ IpcServer */
                GIOChannel* pReverseChannel;               /**< the channel for sending reverse message */
                std::vector <struct _ChannelInfo*> channels;   /**< the set of channels associated with a client */
-               Tizen::Base::String appId;
+               Tizen::Base::String pkgId;
+               Tizen::Base::String appExecutableName;
        };
 
        Tizen::Base::String __name;
index 91f9808..43dfffe 100644 (file)
@@ -36,8 +36,6 @@
 
 #include <ipc/ipc_message.h>
 
-#include <app_manager.h>
-
 #include <FBaseRtMutex.h>
 #include <FBaseSysLog.h>
 #include <FBase_StringConverter.h>
@@ -279,7 +277,9 @@ CATCH:
 struct HelloMessage
 {
        int pid;
-       int reverse;  // if the connection is for reverse message
+       bool reverse;  // true if the connection is for reverse message
+       char pkgId[256];
+       char appExecutableName[256];
 };
 
 gboolean
@@ -304,9 +304,11 @@ _IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoi
        server = g_io_channel_unix_get_fd(source);
 
        client = accept(server, (struct sockaddr*) &clientAddress, &clientLen);
-       SysTryCatch(NID_IO, client != -1, ,E_SYSTEM, "[E_SYSTEM] Accept failed.");
+       SysTryCatch(NID_IO, client != -1, , E_SYSTEM, "[E_SYSTEM] Accept failed.");
 
        read(client, &helloMessage, sizeof(helloMessage));
+       helloMessage.pkgId[255] = '\0';
+       helloMessage.appExecutableName[255] = '\0';
 
        pChannel = g_io_channel_unix_new(client);
        SysTryCatch(NID_IO, pChannel != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Not enough memory.");
@@ -325,17 +327,12 @@ _IpcServer::OnConnectionRequest(GIOChannel* source, GIOCondition condition, gpoi
 
                pClientInfo->pIpcServer = pIpcServer;
                pClientInfo->clientId = helloMessage.pid;
-
-               char* pAppId = NULL;
-               int ret = app_manager_get_app_id(helloMessage.pid, &pAppId);
-               SysTryCatch(NID_IO, ret >= 0, delete pClientInfo, E_SYSTEM, "[E_SYSTEM] Failed to get_app_id: %d", ret);
-
-               pClientInfo->appId = pAppId;
-               free(pAppId);
-
+               pClientInfo->pkgId.Append((wchar_t*) helloMessage.pkgId);
+               pClientInfo->appExecutableName.Append((wchar_t*) helloMessage.appExecutableName);
                pClientInfo->pReverseChannel = null;
 
                pIpcServer->__clients[helloMessage.pid] = pClientInfo;
+
                pIpcServer->__pCurrentClientInfo = pClientInfo;
                pIpcServer->__pListener->OnIpcClientConnected(*pIpcServer, helloMessage.pid);
                pIpcServer->__pCurrentClientInfo = null;
@@ -406,10 +403,7 @@ _IpcServer::GetClientAppId(void) const
 
        if (__pCurrentClientInfo)
        {
-               String pkgId;
-               __pCurrentClientInfo->appId.SubString(0, 10, pkgId);
-
-               return pkgId;
+               return __pCurrentClientInfo->pkgId;
        }
 
        return nullString;
@@ -422,10 +416,7 @@ _IpcServer::GetClientAppExecutableName(void) const
 
        if (__pCurrentClientInfo)
        {
-               String appName;
-               __pCurrentClientInfo->appId.SubString(11, appName);
-
-               return appName;
+               return __pCurrentClientInfo->appExecutableName;
        }
 
        return nullString;
@@ -438,10 +429,7 @@ _IpcServer::GetClientPackageId(void) const
 
        if (__pCurrentClientInfo)
        {
-               String pkgId;
-               __pCurrentClientInfo->appId.SubString(0, 10, pkgId);
-
-               return pkgId;
+               return __pCurrentClientInfo->pkgId;
        }
 
        return nullString;
@@ -454,7 +442,11 @@ _IpcServer::GetClientApplicationId(void) const
 
        if (__pCurrentClientInfo)
        {
-               return __pCurrentClientInfo->appId;
+               String appId(__pCurrentClientInfo->pkgId);
+               appId.Append(L'.');
+               appId.Append(__pCurrentClientInfo->appExecutableName);
+
+               return appId;
        }
 
        return nullString;
index 76c5610..c155c71 100644 (file)
@@ -143,13 +143,13 @@ BatteryLevelVConfCallback(keynode_t* node, void* userData)
                                batteryLevel = BATTERY_CRITICAL;
                                break;
                        case VCONFKEY_SYSMAN_BAT_LEVEL_LOW:
-                               batteryLevel = BATTERY_EMPTY;
+                               batteryLevel = BATTERY_LOW;
                                break;
                        case VCONFKEY_SYSMAN_BAT_LEVEL_HIGH:
-                               batteryLevel = BATTERY_EMPTY;
+                               batteryLevel = BATTERY_HIGH;
                                break;
                        case VCONFKEY_SYSMAN_BAT_LEVEL_FULL:
-                               batteryLevel = BATTERY_EMPTY;
+                               batteryLevel = BATTERY_FULL;
                                break;
                        default:
                                SysLogException(NID_SYS, E_SYSTEM, "Unavailable battery level is required.");