refined boot logic
authorYoung Ik Cho <youngik.cho@samsung.com>
Mon, 12 Aug 2013 06:26:33 +0000 (15:26 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Mon, 12 Aug 2013 06:26:33 +0000 (15:26 +0900)
Change-Id: I27a004929890708d8ed48c5d5188fe5799c1cd64
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
packaging/osp-appfw.spec
src/CMakeLists.txt
src/app/FApp_AppEntry.cpp
src/app/FApp_AppImpl.cpp
src/app/FApp_AppInfo.cpp
src/app/inc/FApp_AppInfo.h
src/base/FBaseCharacter.cpp
src/base/FBaseSys.cpp [changed mode: 0755->0644]

index 606053f..1fb068d 100644 (file)
@@ -74,6 +74,7 @@ BuildRequires:  boost-devel
 BuildRequires:  gettext-tools
 BuildRequires:  pkgconfig(security-server)
 BuildRequires:  pkgconfig(badge)
+BuildRequires:  pkgconfig(appinfo) >= 0.1.0
 
 # runtime requires
 Requires: capi-appfw-application
@@ -84,7 +85,7 @@ Requires: capi-system-runtime-info
 Requires: capi-security-privilege-manager
 Requires: chromium
 Requires: message-port
-Requires: osp-env-config
+Requires: osp-env-config >= 1.2.2.1
 Requires: sqlite
 Requires: iniparser
 
index 17ed1ca..de9d75c 100644 (file)
@@ -2,6 +2,7 @@
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
        alarm-service
+       appinfo
        aul
        appsvc
        bundle
index e81f4c2..e832374 100644 (file)
 #include <dlog.h>
 #include <privilege-control.h>
 #include <pkgmgr-info.h>
+#include <appinfo.h>
 
 #include <FOspConfig.h>
 
 
 #define LOG_IO_TAG  "LOADER"
-#define MAX_PACKAGE_ID   20
+#define MAX_PACKAGE_ID   10
 #define MAX_APP_EXECUTABLE_NAME        230
 #define MAX_PACKAGE_NAME       100
 #define        MAX_PR_NAME     16
@@ -141,7 +142,7 @@ AdjustCapability(void)
 
 
 static int
-GetAppIdAppExecutableNameFromPathNew(const char appName[], char* appId, char* exeName)
+GetPackageIdAppExecutableNameFromPath(const char appName[], char* appId, char* exeName)
 {
        char buffer[PATH_MAX];
 
@@ -185,54 +186,6 @@ GetAppIdAppExecutableNameFromPathNew(const char appName[], char* appId, char* ex
        return 0;
 }
 
-static int
-GetAppIdAppExecutableNameFromPath(const char appName[], char* appId, char* exeName)
-{
-       const char* begin = NULL;
-       const char* end = NULL;
-       const int path_len = strlen(appName);
-
-       // Calculate the header
-       const char* p = strstr(appName, "/apps/org.tizen.");
-       if (p == NULL)
-       {
-               return GetAppIdAppExecutableNameFromPathNew(appName, appId, exeName);
-       }
-
-       begin = p + 15;
-
-       end = strchr(begin + 1, '/');
-       if (end == NULL)
-       {
-               LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, Improper appname %s", appName);
-               return -1;
-       }
-
-       int len = end - begin - 1;
-
-       if (len > MAX_PACKAGE_ID)
-       {
-               LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, Improper appname %s with length %d", appName, len);
-               len = MAX_PACKAGE_ID;
-               //return -1;
-       }
-
-       strncpy(appId, begin + 1, len);
-       LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, app is %s", appId);
-
-       int exe_len = 0;
-
-       if (path_len > len + 21)
-       {
-               exe_len = std::min(MAX_APP_EXECUTABLE_NAME - 1, path_len - len - 21);
-               strncpy(exeName, end + 5, exe_len);
-       }
-
-       LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, exeName is %s", exeName);
-
-       return 0;
-}
-
 
 static void
 PrintArgs(int argc, char* argv[])
@@ -361,12 +314,12 @@ main(int argc, char* pArgv[])
 {
        bool bCommand = false;
 
-       char packageId[MAX_PACKAGE_ID];
+       char packageId[MAX_PACKAGE_ID + 1];
        char exeName[MAX_APP_EXECUTABLE_NAME];
        char fullPath[PATH_MAX];
 
-       memset(packageId, 0, MAX_PACKAGE_ID);
-       memset(exeName, 0, MAX_APP_EXECUTABLE_NAME);
+       memset(packageId, 0, sizeof(packageId));
+       memset(exeName, 0, sizeof(exeName));
        memset(fullPath, 0, PATH_MAX);
 
        LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, %s, %d > executable binary path: %s", __func__, __LINE__, pArgv[0]);
@@ -386,7 +339,7 @@ main(int argc, char* pArgv[])
        LOG(LOG_DEBUG, LOG_IO_TAG, "Tizen::Io, %s, %d > processed binary path: %s", __func__, __LINE__, fullPath);
 
        // convert package path to packageId
-       GetAppIdAppExecutableNameFromPath(fullPath, packageId, exeName);
+       GetPackageIdAppExecutableNameFromPath(fullPath, packageId, exeName);
 
        // acquire appId from packageId and exec
        char appId[MAX_PACKAGE_ID + MAX_APP_EXECUTABLE_NAME + 2] = {0, };
@@ -401,7 +354,7 @@ main(int argc, char* pArgv[])
                DoPreExec(packageId, fullPath);
 
                // adjust privilege
-               AdjustPrivilege(packageId);
+               AdjustPrivilege(appId);
        }
 
        AdjustCapability();
@@ -415,8 +368,9 @@ main(int argc, char* pArgv[])
 
        }
 
-       // dlopen will load Osp_Initialize() internally as __attribute__((constructor))
-       //Osp_Initialize();
+       appinfo_init(appId, 0);
+       appinfo_set_argv(argc, pArgv);
+
        InitAppInfo(packageId, exeName, argc, pArgv, -1);
 
        AdjustHwAccInfo(appId);
index 28d640d..5813241 100644 (file)
@@ -24,6 +24,7 @@
 #include <notification/notification.h>
 #include <appsvc/appsvc.h>
 #include <vconf.h>
+#include <appinfo.h>
 
 #include <FBaseInteger.h>
 #include <FBaseColArrayList.h>
@@ -146,8 +147,8 @@ _AppImpl::Execute(_IAppImpl* pIAppImpl)
        SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
        result r = E_SUCCESS;
        int eflResult = APP_ERROR_NONE;
-       int argc = _AppInfo::GetArgc();
-       char** pArgv = _AppInfo::GetArgv();
+       int argc = 0;
+       char** pArgv = NULL;
        _IAppManager* pAppManager = null;
 
        _AppImpl* pAppImpl = _AppImpl::GetInstance();
@@ -182,6 +183,7 @@ _AppImpl::Execute(_IAppImpl* pIAppImpl)
 //             SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
 //     }
 
+       appinfo_get_argv(&argc, &pArgv);
        eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
        SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
 
index 0268d65..53a6dc5 100644 (file)
 #include <new>
 #include <fcntl.h>
 
+#include <appinfo.h>
+
 #include <FBaseErrors.h>
 #include <FAppPkgPackageInfo.h>
-
 #include <FBaseSysLog.h>
+
 #include <FBaseRt_Process.h>
+#include <FBase_StringConverter.h>
 
 #include "FAppPkg_PackageInfoImpl.h"
 #include "FApp_AppInfo.h"
-#include "FApp_Aul.h"
-#include "FApp_AppArg.h"
 
 using namespace Tizen::App::Package;
 using namespace Tizen::Base;
@@ -79,9 +80,7 @@ namespace Tizen { namespace App
 const int MAX_APIVERSION = 8;
 const int MAX_APPID = 10;
 const char PACKAGE_PATH_FORMAT[] = "/opt/usr/apps/0000000000/";
-const char PACKAGE_PATH_FORMAT2[] = "/opt/apps/0000000000/";
 const char PATH_ROOT[] = "/opt/usr/apps/";
-const char PATH_ROOT2[] = "/opt/apps/";
 const char APPINFO_FILE_PATH[] = "info/version.info";
 const char COMPAT_FILE_PATH[] = "info/compat.info";
 const char VIRTUAL_ROOT_FILE_PATH[] = "info/virtual.info";
@@ -94,13 +93,9 @@ _AppInfo::_AppInfo(void)
        , __appRootDirFd(-1)
        , __appHandlerType(_APP_HANDLER_NONE)
        , __parentWindowHandle(-1)
-       , __apiVersion(_API_VERSION_2_2)
        , __pAppName(null)
        , __pAppVersion(null)
-       , __argc(0)
-       , __pArgv(null)
        , __isPackageInfoInitialized(false)
-       , __isOspCompat(false)
        , __isSubMode(false)
        , __isVirtualRoot(false)
 {
@@ -128,11 +123,23 @@ _AppInfo::GetAppInfo(void)
 
 
 result
+_AppInfo::Construct(void)
+{
+       SysAssertf(appinfo_is_initialized() == 1, "appinfo is not initialized.");
+
+       FBase_Initialize();
+
+       return E_SUCCESS;
+}
+
+
+result
 _AppInfo::Construct(const char* packageId, const char* exeName, int argc, char* argv[])
 {
        SysAssertf(packageId != null, "Valid appId required to launch application.");
+       SysAssertf(appinfo_is_initialized() == 1, "appinfo is not initialized.");
 
-     FBase_Initialize();
+       FBase_Initialize();
 
        __appExecutableName = exeName;
        __packageId = packageId;
@@ -144,7 +151,10 @@ _AppInfo::Construct(const char* packageId, const char* exeName, int argc, char*
 
                __isSubMode = true;
                __appExecutableName = name;
-               SysLog(NID_APP, "Executable name is changed to %ls.", __appExecutableName.GetPointer());
+
+               std::unique_ptr<char[]> pActualExec(_StringConverter::CopyToCharArrayN(name));
+               appinfo_update_submode_execname_and_appid(pActualExec.get());
+               SysLog(NID_APP, "Executable name is changed to %s.", pActualExec.get());
        }
 
        __appId = __packageId + L'.' + __appExecutableName;
@@ -154,34 +164,14 @@ _AppInfo::Construct(const char* packageId, const char* exeName, int argc, char*
 
        {
                char appInfoPath[PATH_MAX] = {0, };
-#if 0
-               const int len = strlen(PACKAGE_PATH_FORMAT2);
-               strncpy(appInfoPath, PACKAGE_PATH_FORMAT2, len);
-               appInfoPath[len] = '\0';
 
-               // due to possible dependency problem, FIoFile is not used
-               // app root path first
-
-               strncpy(appInfoPath + strlen(PATH_ROOT2), packageId, MAX_APPID);
-#else
-               // [FIXME] temporary code for directory location migration
-               int len = strlen(PACKAGE_PATH_FORMAT2);
-               strncpy(appInfoPath, PACKAGE_PATH_FORMAT2, len);
+               int len = strlen(PACKAGE_PATH_FORMAT);
+               strncpy(appInfoPath, PACKAGE_PATH_FORMAT, len);
                appInfoPath[len] = '\0';
-               strncpy(appInfoPath + strlen(PATH_ROOT2), packageId, MAX_APPID);
+               strncpy(appInfoPath + strlen(PATH_ROOT), packageId, MAX_APPID);
 
-               if (euidaccess(appInfoPath, R_OK) != 0)
-               {
-                       len = strlen(PACKAGE_PATH_FORMAT);
-                       strncpy(appInfoPath, PACKAGE_PATH_FORMAT, len);
-                       appInfoPath[len] = '\0';
-                       
-                       strncpy(appInfoPath + strlen(PATH_ROOT), packageId, MAX_APPID);
-               }
-#endif
                // app root directory file descriptor
                __appRootDirFd = open(appInfoPath, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
-
                __appRootPath = appInfoPath;
                
                SysLog(NID_APP, "App root directory (%s:%d) open.", appInfoPath, __appRootDirFd);
@@ -199,16 +189,13 @@ _AppInfo::Construct(const char* packageId, const char* exeName, int argc, char*
                fclose(pFile);
                // fd is closed when the stream is closed by fclose();
 
-               __apiVersion = GetApiVersionFromStr(apiVersion);
-
-               __argc = argc;
-               __pArgv = argv;
+               appinfo_set_api_version(appinfo_get_api_version_from_str(apiVersion));
 
                // to reduce package manager overhead, libc API is used
                if (faccessat(__appRootDirFd, COMPAT_FILE_PATH, F_OK, 0) == 0)
                {
                        SysLog(NID_APP, "OSP compatibility mode on.");
-                       __isOspCompat = true;
+                       appinfo_set_compat(1);
                }
 
                if (faccessat(__appRootDirFd, VIRTUAL_ROOT_FILE_PATH, F_OK, 0) == 0)
@@ -235,8 +222,9 @@ _AppInfo::Construct(const char* packageId, const char* exeName, int argc, char*
                        }
                }
 
+               SysLog(NID_APP, "New appinfo [%s][%s.%s].", appinfo_get_appid(), appinfo_get_packageid(), appinfo_get_execname());
                SysLog(NID_APP, "AppInfo initialization finished [%ls][%ls.%ls][%d].",
-                               __appId.GetPointer(), __packageId.GetPointer(), __appExecutableName.GetPointer(), __apiVersion);
+                               __appId.GetPointer(), __packageId.GetPointer(), __appExecutableName.GetPointer(), appinfo_get_api_version());
        }
 
        return E_SUCCESS;
@@ -266,7 +254,7 @@ _AppInfo::Construct(const char* appId, const char* appRoot, _AppType type)
 {
        SysAssertf(appId != null, "Valid appId required to launch application.");
 
-     FBase_Initialize();
+       FBase_Initialize();
 
        __appId = appId;
 
@@ -283,7 +271,7 @@ _AppInfo::Construct(const char* appId, const char* appRoot, _AppType type)
        }
 
        __appRootDirFd = open(appRoot, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
-       __apiVersion = _API_VERSION_2_1;
+       appinfo_set_api_version(APP_INFO_VERSION_2_2);
        __appType = type;
 
        __appRootPath = appRoot;
@@ -292,7 +280,7 @@ _AppInfo::Construct(const char* appId, const char* appRoot, _AppType type)
                __appRootPath.Append(L'/');
        }
 
-       SysLog(NID_APP, "AppInfo initialization finished [%ls][%ls.%ls][%ls][%d].", __appId.GetPointer(), __packageId.GetPointer(), __appExecutableName.GetPointer(), __appRootPath.GetPointer(),  __apiVersion);
+       SysLog(NID_APP, "AppInfo initialization finished [%ls][%ls.%ls][%ls][%d].", __appId.GetPointer(), __packageId.GetPointer(), __appExecutableName.GetPointer(), __appRootPath.GetPointer(),  appinfo_get_api_version());
 
        return E_SUCCESS;
 }
@@ -342,59 +330,17 @@ CATCH:
 }
 
 
-// [FIXME] refactoring to use hash
-_ApiVersion
-_AppInfo::GetApiVersionFromStr(const char* pVer)
-{
-       String ver(pVer);
-       ver.Trim();
-
-       if (ver == L"2.2")
-       {
-               return _API_VERSION_2_2;
-       }
-       else if (ver == L"2.1")
-       {
-               return _API_VERSION_2_1;
-       }
-       else if (ver == L"2.0")
-       {
-               return _API_VERSION_2_0;
-       }
-       else if (ver == L"1.2")
-       {
-               return _API_VERSION_1_2;
-       }
-       else if (ver == L"1.1")
-       {
-               return _API_VERSION_1_1;
-       }
-       else if (ver == L"1.0.2")
-       {
-               return _API_VERSION_1_0_2;
-       }
-       else if (ver == L"1.0")
-       {
-               return _API_VERSION_1_0;
-       }
-       else
-       {
-               return _API_VERSION_2_2;
-       }
-}
-
-
 _ApiVersion
 _AppInfo::GetApiVersion(void)
 {
-       return GetAppInfo()->__apiVersion;
+       return static_cast<_ApiVersion>(appinfo_get_api_version());
 }
 
 
 bool
 _AppInfo::IsOspCompat(void)
 {
-       return GetAppInfo()->__isOspCompat;
+       return (appinfo_is_compat() == 1);
 }
 
 bool
@@ -406,7 +352,7 @@ _AppInfo::IsVirtualRoot(void)
 result
 _AppInfo::SetApiVersion(_ApiVersion v)
 {
-       GetAppInfo()->__apiVersion = v;
+       appinfo_set_api_version(static_cast<app_info_version_e>(v));
        return E_SUCCESS;
 }
 
@@ -531,20 +477,6 @@ _AppInfo::SetAppType(_AppType appType)
 
 
 int
-_AppInfo::GetArgc(void)
-{
-       return GetAppInfo()->__argc;
-}
-
-
-char**
-_AppInfo::GetArgv(void)
-{
-       return GetAppInfo()->__pArgv;
-}
-
-
-int
 _AppInfo::GetAppHandlerType(void)
 {
        return GetAppInfo()->__appHandlerType;
index f910493..fb02954 100644 (file)
@@ -170,20 +170,6 @@ public:
        static void SetAppType(_AppType appType);
 
        /**
-        * Gets the argument count.
-        *
-        * @return      argc
-        */
-       _OSP_LOCAL_ static int GetArgc(void);
-
-       /**
-        * Gets the argument.
-        *
-        * @return      argv
-        */
-       _OSP_LOCAL_ static char** GetArgv(void);
-
-       /**
         * Gets the application handler type.
         *
         * @return      appHandlerType
@@ -214,6 +200,8 @@ public:
         */
        static void UpdatePackageInfo(bool update);
 
+       _OSP_LOCAL_ result Construct(void);
+
        _OSP_LOCAL_ result Construct(const char* appId, const char* exeName, int argc, char* pArgv[]);
 
        _OSP_LOCAL_ result Construct(const char* appId, const char* appRoot, _AppType type = _APP_TYPE_UI_APP);
@@ -227,8 +215,6 @@ private:
 
        _AppInfo& operator =(const _AppInfo& source);
 
-       _OSP_LOCAL_ static Tizen::Base::_ApiVersion GetApiVersionFromStr(const char* pVer);
-
        _OSP_LOCAL_ result UpdateAppInfoFromPackageInfo(const PackageId& packageId);
 
 private:
@@ -237,17 +223,13 @@ private:
        int __appRootDirFd;
        int __appHandlerType;
        int __parentWindowHandle;
-       Tizen::Base::_ApiVersion __apiVersion;
        AppId   __appId;
        PackageId       __packageId;
        Tizen::Base::String __appExecutableName;
        Tizen::Base::String __appRootPath;
        Tizen::Base::String* __pAppName;
        Tizen::Base::String* __pAppVersion;
-       int __argc;
-       char** __pArgv;
        bool    __isPackageInfoInitialized;
-       bool    __isOspCompat;
        bool    __isSubMode;
        bool    __isVirtualRoot;
 }; // _AppInfo
index a72e896..4429be9 100644 (file)
  * @file               FBaseCharacter.cpp
  * @brief              This is the implementation file for Char class.
  */
-#include <wctype.h>
+#include <cwctype>
+
+#include <appinfo.h>
+
 #include <FBaseCharacter.h>
-#include <FApp_AppInfo.h>
 #include <FBaseSysLog.h>
+
 #include "FBase_CharacterImpl.h"
 
 namespace Tizen { namespace Base
@@ -199,8 +202,7 @@ Character::IsDigit(wchar_t ch)
 bool
 Character::IsLetter(wchar_t ch)
 {
-
-       if (Tizen::App::_AppInfo::GetApiVersion() == _API_VERSION_2_0 && Tizen::App::_AppInfo::IsOspCompat())
+       if ((appinfo_get_api_version() == APP_INFO_VERSION_2_0) && (appinfo_is_compat() == 1))
        {
                return(iswalpha(ch) != 0);
        }
old mode 100755 (executable)
new mode 100644 (file)
index cb72ea2..36fd938
  * @brief              This file defines the diagnostics types.
  */
 
-#include <vconf.h>
-#include <dlog.h>
-#include <assert.h>
-#include <stdio.h>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
 #include <unistd.h>
-#include <string.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
+
+#include <vconf.h>
+#include <dlog.h>
+#include <appinfo.h>
+
 #include <FAppTypes.h>
 #include <FBaseLog.h>
 #include <FBaseSysLog.h>
+
 #include "FBase_Log.h"
 #include "FBase_StringConverter.h"
-#include "FApp_AppInfo.h"
 
 extern "C" {
 #include <iniparser.h>
 }
 
 using namespace Tizen::Base;
-using namespace Tizen::Io;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::App;
 
 #ifdef LOG_TAG
 #undef LOG_TAG
@@ -715,9 +715,7 @@ __PrintLog(_LogType type, const char* pFunction, int lineNumber, const char* pFo
        if (unlikely(!appNameLoaded))
        {
                appNameLoaded = true;
-               char* pAppName = _StringConverter::CopyToCharArrayN(_AppInfo::GetAppExecutableName());
-               strncpy(appName, pAppName, LOG_MODULE_NAME_LEN_MAX);
-               delete [] pAppName;
+               strncpy(appName, appinfo_get_execname(), LOG_MODULE_NAME_LEN_MAX);
        }
        snprintf(logTag, LOG_MODULE_NAME_LEN_MAX, "%s", appName);