diff --git a/frameworks/src/core/modules/app_module.cpp b/frameworks/src/core/modules/app_module.cpp index 410632e6b548a3f94943dd28389497ec69243a68..2fe46cde9e3a0e7b91fedee53cba961757e1bda3 100644 --- a/frameworks/src/core/modules/app_module.cpp +++ b/frameworks/src/core/modules/app_module.cpp @@ -16,6 +16,9 @@ #include "app_module.h" #include "ace_log.h" #include "js_app_context.h" +#if (TARGET_SIMULATOR != 1) +#include "bundle_manager.h" +#endif #if (FEATURE_SCREEN_ON_VISIBLE == 1) #include "js_async_work.h" #include "product_adapter.h" @@ -27,6 +30,9 @@ const char * const AppModule::FILE_MANIFEST = "manifest.json"; const char * const AppModule::KEY_APP_NAME = "appName"; const char * const AppModule::KEY_VERSION_NAME = "versionName"; const char * const AppModule::KEY_VERSION_CODE = "versionCode"; +#if (TARGET_SIMULATOR != 1) +const char * const AppModule::KEY_APP_ID = "appID"; +#endif #if (FEATURE_SCREEN_ON_VISIBLE == 1) const char * const AppModule::SCREEN_ON_VISIBLE_KEY = "visible"; @@ -55,14 +61,25 @@ JSIValue AppModule::GetInfo(const JSIValue thisVal, const JSIValue *args, uint8_ return result; } - cJSON *appName = cJSON_GetObjectItem(manifest, KEY_APP_NAME); cJSON *versionName = cJSON_GetObjectItem(manifest, KEY_VERSION_NAME); cJSON *versionCode = cJSON_GetObjectItem(manifest, KEY_VERSION_CODE); - result = JSI::CreateObject(); + +#if (TARGET_SIMULATOR != 1) + cJSON *appID = cJSON_GetObjectItem(manifest, KEY_APP_ID); + if (appID != nullptr && appID->type == cJSON_String) { + BundleInfo bundleInfo; + uint8_t ret = GetBundleInfo(appID->valuestring, true, &bundleInfo); + if (ret == 0) { + JSI::SetStringProperty(result, KEY_APP_NAME, bundleInfo.label); + } + } +#else + cJSON *appName = cJSON_GetObjectItem(manifest, KEY_APP_NAME); if (appName != nullptr && appName->type == cJSON_String) { JSI::SetStringProperty(result, KEY_APP_NAME, appName->valuestring); } +#endif if (versionName != nullptr && versionName->type == cJSON_String) { JSI::SetStringProperty(result, KEY_VERSION_NAME, versionName->valuestring); } diff --git a/frameworks/src/core/modules/app_module.h b/frameworks/src/core/modules/app_module.h index 8eef43e42a9d82415903fbb679d26205820eef37..be3696132fbf0d92b1a1978c65a7d610fb6966ae 100644 --- a/frameworks/src/core/modules/app_module.h +++ b/frameworks/src/core/modules/app_module.h @@ -39,7 +39,9 @@ private: static const char * const KEY_APP_NAME; static const char * const KEY_VERSION_NAME; static const char * const KEY_VERSION_CODE; - +#if (TARGET_SIMULATOR != 1) + static const char * const KEY_APP_ID; +#endif static cJSON* ReadManifest(); #if (FEATURE_SCREEN_ON_VISIBLE == 1)