IssueNo:#I5H65Q

Description:add getStringById getIocnById
Sig:SIG_ApplicaitonFramework
Feature or Bugfix:Feature
Binary Source:No

Signed-off-by: wanghang <wanghang26@huawei.com>
Change-Id: Ie7432c5fad0804b95f9b1bf50050befc42def989
This commit is contained in:
wanghang 2022-07-14 19:23:43 +08:00
parent bb4a5d7ef1
commit 0e7393a538
35 changed files with 1135 additions and 13 deletions

View File

@ -34,6 +34,7 @@ declare_args() {
configpolicy_enable = true
device_manager_enable = true
global_resmgr_enable = true
global_i18n_enable = true
hicollie_enable = true
hisysevent_enable = true
bms_rdb_enable = false
@ -66,6 +67,10 @@ declare_args() {
global_resmgr_enable = false
}
if (defined(global_parts_info) && !defined(global_parts_info.global_i18n)) {
global_i18n_enable = false
}
if (defined(global_parts_info) &&
!defined(global_parts_info.hiviewdfx_hicollie_native)) {
hicollie_enable = false

View File

@ -50,6 +50,7 @@
"hisysevent_native",
"hitrace_native",
"hiviewdfx_hilog_native",
"i18n",
"init",
"ipc",
"jsoncpp",

View File

@ -539,6 +539,10 @@ private:
ErrCode HandleGetMediaFileDescriptor(MessageParcel &data, MessageParcel &reply);
ErrCode HandleGetStringById(MessageParcel &data, MessageParcel &reply);
ErrCode HandleGetIconById(MessageParcel &data, MessageParcel &reply);
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
ErrCode HandleGetDefaultAppProxy(MessageParcel &data, MessageParcel &reply);
#endif

View File

@ -950,6 +950,18 @@ public:
return nullptr;
}
virtual std::string GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId)
{
return Constants::EMPTY_STRING;
}
virtual std::string GetIconById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId)
{
return Constants::EMPTY_STRING;
}
enum Message : uint32_t {
GET_APPLICATION_INFO = 0,
GET_APPLICATION_INFOS,
@ -1040,6 +1052,8 @@ public:
GET_SANDBOX_MODULE_INFO,
GET_MEDIA_FILE_DESCRIPTOR,
GET_QUICK_FIX_MANAGER_PROXY,
GET_STRING_BY_ID,
GET_ICON_BY_ID,
};
};
} // namespace AppExecFwk

View File

@ -647,6 +647,12 @@ public:
virtual int32_t GetMediaFileDescriptor(const std::string &bundleName, const std::string &moduleName,
const std::string &abilityName) override;
virtual std::string GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId) override;
virtual std::string GetIconById(const std::string &bundleName, const std::string &moduleName,
uint32_t resId, uint32_t density, int32_t userId) override;
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
virtual sptr<IDefaultApp> GetDefaultAppProxy() override;
#endif

View File

@ -172,6 +172,8 @@ void BundleMgrHost::init()
funcMap_.emplace(IBundleMgr::Message::GET_BUNDLE_STATS, &BundleMgrHost::HandleGetBundleStats);
funcMap_.emplace(IBundleMgr::Message::CHECK_ABILITY_ENABLE_INSTALL,
&BundleMgrHost::HandleCheckAbilityEnableInstall);
funcMap_.emplace(IBundleMgr::Message::GET_STRING_BY_ID, &BundleMgrHost::HandleGetStringById);
funcMap_.emplace(IBundleMgr::Message::GET_ICON_BY_ID, &BundleMgrHost::HandleGetIconById);
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
funcMap_.emplace(IBundleMgr::Message::GET_DEFAULT_APP_PROXY, &BundleMgrHost::HandleGetDefaultAppProxy);
#endif
@ -1728,6 +1730,51 @@ ErrCode BundleMgrHost::HandleCheckAbilityEnableInstall(MessageParcel &data, Mess
return ERR_OK;
}
ErrCode BundleMgrHost::HandleGetStringById(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::string bundleName = data.ReadString();
std::string moduleName = data.ReadString();
uint32_t resId = data.ReadUint32();
int32_t userId = data.ReadInt32();
APP_LOGD("GetStringById bundleName: %{public}s, moduleName: %{public}s, resId:%{public}d",
bundleName.c_str(), moduleName.c_str(), resId);
std::string label = Constants::EMPTY_STRING;
if (bundleName.empty() || moduleName.empty()) {
APP_LOGW("fail to GetStringById due to params empty");
} else {
label = GetStringById(bundleName, moduleName, resId, userId);
}
if (!reply.WriteString(label)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
}
ErrCode BundleMgrHost::HandleGetIconById(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
std::string bundleName = data.ReadString();
std::string moduleName = data.ReadString();
uint32_t resId = data.ReadUint32();
uint32_t density = data.ReadUint32();
int32_t userId = data.ReadInt32();
APP_LOGD("GetStringById bundleName: %{public}s, moduleName: %{public}s, resId:%{public}d, density:%{public}d",
bundleName.c_str(), moduleName.c_str(), resId, density);
std::string label = Constants::EMPTY_STRING;
if (bundleName.empty() || moduleName.empty()) {
APP_LOGW("fail to GetStringById due to params empty");
} else {
label = GetIconById(bundleName, moduleName, resId, density, userId);
}
if (!reply.WriteString(label)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
}
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
ErrCode BundleMgrHost::HandleGetDefaultAppProxy(MessageParcel &data, MessageParcel &reply)
{

View File

@ -2530,6 +2530,92 @@ bool BundleMgrProxy::CheckAbilityEnableInstall(
return reply.ReadBool();
}
std::string BundleMgrProxy::GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId)
{
APP_LOGI("begin to GetStringById.");
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
if (bundleName.empty() || moduleName.empty()) {
APP_LOGE("fail to GetStringById due to params empty");
return Constants::EMPTY_STRING;
}
APP_LOGD("GetStringById bundleName: %{public}s, moduleName: %{public}s, resId:%{public}d",
bundleName.c_str(), moduleName.c_str(), resId);
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
APP_LOGE("fail to GetStringById due to write InterfaceToken fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteString(bundleName)) {
APP_LOGE("fail to GetStringById due to write bundleName fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteString(moduleName)) {
APP_LOGE("fail to GetStringById due to write moduleName fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteUint32(resId)) {
APP_LOGE("fail to GetStringById due to write resId fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteInt32(userId)) {
APP_LOGE("fail to GetStringById due to write userId fail");
return Constants::EMPTY_STRING;
}
MessageParcel reply;
if (!SendTransactCmd(IBundleMgr::Message::GET_STRING_BY_ID, data, reply)) {
APP_LOGE("fail to GetStringById from server");
return Constants::EMPTY_STRING;
}
return reply.ReadString();
}
std::string BundleMgrProxy::GetIconById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId)
{
APP_LOGI("begin to GetIconById.");
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
if (bundleName.empty() || moduleName.empty()) {
APP_LOGE("fail to GetIconById due to params empty");
return Constants::EMPTY_STRING;
}
APP_LOGD("GetIconById bundleName: %{public}s, moduleName: %{public}s, resId:%{public}d",
bundleName.c_str(), moduleName.c_str(), resId);
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
APP_LOGE("fail to GetIconById due to write InterfaceToken fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteString(bundleName)) {
APP_LOGE("fail to GetIconById due to write bundleName fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteString(moduleName)) {
APP_LOGE("fail to GetIconById due to write moduleName fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteUint32(resId)) {
APP_LOGE("fail to GetIconById due to write resId fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteUint32(density)) {
APP_LOGE("fail to GetIconById due to write density fail");
return Constants::EMPTY_STRING;
}
if (!data.WriteInt32(userId)) {
APP_LOGE("fail to GetIconById due to write userId fail");
return Constants::EMPTY_STRING;
}
MessageParcel reply;
if (!SendTransactCmd(IBundleMgr::Message::GET_ICON_BY_ID, data, reply)) {
APP_LOGE("fail to GetIconById from server");
return Constants::EMPTY_STRING;
}
return reply.ReadString();
}
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
sptr<IDefaultApp> BundleMgrProxy::GetDefaultAppProxy()
{

View File

@ -268,6 +268,11 @@ ohos_shared_library("libbms") {
external_deps += [ "resource_management:global_resmgr" ]
}
if (global_i18n_enable) {
defines += [ "GLOBAL_I18_ENABLE" ]
external_deps += [ "i18n:intl_util" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie_native:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]

View File

@ -703,6 +703,12 @@ public:
std::vector<sptr<IBundleStatusCallback>> GetCallBackList() const;
std::string GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId);
std::string GetIconById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId);
private:
/**
* @brief Init transferStates.
@ -762,7 +768,7 @@ private:
std::vector<ExtensionAbilityInfo> &einfos) const;
#ifdef GLOBAL_RESMGR_ENABLE
std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager(
const AppExecFwk::BundleInfo &bundleInfo) const;
const std::string &bundleName, const std::string &moduleName, int32_t userId) const;
#endif
void FilterAbilityInfosByModuleName(const std::string &moduleName, std::vector<AbilityInfo> &abilityInfos) const;

View File

@ -651,10 +651,15 @@ public:
std::vector<ExtensionAbilityInfo> &infos) override;
virtual ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId,
HapModuleInfo &info) override;
virtual int32_t GetMediaFileDescriptor(const std::string &bundleName, const std::string &moduleName,
const std::string &abilityName) override;
virtual sptr<IQuickFixManager> GetQuickFixManagerProxy() override;
virtual std::string GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId) override;
virtual std::string GetIconById(const std::string &bundleName, const std::string &moduleName,
uint32_t resId, uint32_t density, int32_t userId) override;
private:
const std::shared_ptr<BundleDataMgr> GetDataMgrFromService();

View File

@ -40,6 +40,9 @@
#endif
#include "ipc_skeleton.h"
#include "json_serializer.h"
#ifdef GLOBAL_I18_ENABLE
#include "locale_config.h"
#endif
#include "nlohmann/json.hpp"
#include "free_install_params.h"
#include "singleton.h"
@ -1303,14 +1306,13 @@ std::string BundleDataMgr::GetAbilityLabel(const std::string &bundleName, const
if ((*ability).labelId == 0) {
return (*ability).label;
}
std::string abilityLabel;
BundleInfo bundleInfo;
innerBundleInfo.GetBundleInfo(0, bundleInfo, GetUserIdByCallingUid());
std::shared_ptr<OHOS::Global::Resource::ResourceManager> resourceManager = GetResourceManager(bundleInfo);
std::shared_ptr<OHOS::Global::Resource::ResourceManager> resourceManager =
GetResourceManager(bundleName, moduleName, GetUserId());
if (resourceManager == nullptr) {
APP_LOGE("InitResourceManager failed");
return Constants::EMPTY_STRING;
}
std::string abilityLabel;
OHOS::Global::Resource::RState errval =
resourceManager->GetStringById(static_cast<uint32_t>((*ability).labelId), abilityLabel);
if (errval != OHOS::Global::Resource::RState::SUCCESS) {
@ -2768,22 +2770,88 @@ void BundleDataMgr::GetAllUriPrefix(std::vector<std::string> &uriPrefixList, int
}
}
std::string BundleDataMgr::GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId)
{
APP_LOGD("GetStringById:%{public}s , %{public}s, %{public}d", bundleName.c_str(), moduleName.c_str(), resId);
#ifdef GLOBAL_RESMGR_ENABLE
std::shared_ptr<OHOS::Global::Resource::ResourceManager> resourceManager =
GetResourceManager(bundleName, moduleName, userId);
if (resourceManager == nullptr) {
APP_LOGE("InitResourceManager failed");
return Constants::EMPTY_STRING;
}
std::string label;
OHOS::Global::Resource::RState errValue = resourceManager->GetStringById(resId, label);
if (errValue != OHOS::Global::Resource::RState::SUCCESS) {
APP_LOGE("GetStringById failed");
return Constants::EMPTY_STRING;
}
return label;
#else
APP_LOGW("GLOBAL_RESMGR_ENABLE is false");
return Constants::EMPTY_STRING;
#endif
}
std::string BundleDataMgr::GetIconById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId)
{
APP_LOGI("GetIconById bundleName:%{public}s, moduleName:%{public}s, resId:%{public}d, density:%{public}d",
bundleName.c_str(), moduleName.c_str(), resId, density);
#ifdef GLOBAL_RESMGR_ENABLE
std::shared_ptr<OHOS::Global::Resource::ResourceManager> resourceManager =
GetResourceManager(bundleName, moduleName, userId);
if (resourceManager == nullptr) {
APP_LOGE("InitResourceManager failed");
return Constants::EMPTY_STRING;
}
std::string base64;
OHOS::Global::Resource::RState errValue = resourceManager->GetMediaBase64ByIdData(resId, density, base64);
if (errValue != OHOS::Global::Resource::RState::SUCCESS) {
APP_LOGE("GetIconById failed");
return Constants::EMPTY_STRING;
}
return base64;
#else
APP_LOGW("GLOBAL_RESMGR_ENABLE is false");
return Constants::EMPTY_STRING;
#endif
}
#ifdef GLOBAL_RESMGR_ENABLE
std::shared_ptr<Global::Resource::ResourceManager> BundleDataMgr::GetResourceManager(
const AppExecFwk::BundleInfo &bundleInfo) const
const std::string &bundleName, const std::string &moduleName, int32_t userId) const
{
std::lock_guard<std::mutex> lock(bundleInfoMutex_);
InnerBundleInfo innerBundleInfo;
if (!GetInnerBundleInfoWithFlags(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, innerBundleInfo, userId)) {
APP_LOGE("can not find bundle %{public}s", bundleName.c_str());
return nullptr;
}
BundleInfo bundleInfo;
innerBundleInfo.GetBundleInfo(BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId);
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager());
for (auto moduleResPath : bundleInfo.moduleResPaths) {
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
std::string moduleResPath;
if (moduleName.empty() || moduleName == hapModuleInfo.moduleName) {
moduleResPath = hapModuleInfo.resourcePath;
}
if (!moduleResPath.empty()) {
APP_LOGD("DistributedBms::InitResourceManager, moduleResPath: %{private}s", moduleResPath.c_str());
if (!resourceManager->AddResource(moduleResPath.c_str())) {
APP_LOGE("DistributedBms::InitResourceManager AddResource failed");
APP_LOGW("DistributedBms::InitResourceManager AddResource failed");
}
}
}
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
resConfig->SetLocaleInfo("zh", "Hans", "CN");
#ifdef GLOBAL_I18_ENABLE
std::string language = Global::I18n::LocaleConfig::GetSystemLanguage();
std::string locale = Global::I18n::LocaleConfig::GetSystemLocale();
std::string region = Global::I18n::LocaleConfig::GetSystemRegion();
resConfig->SetLocaleInfo(language.c_str(), locale.c_str(), region.c_str());
#endif
resourceManager->UpdateResConfig(*resConfig);
return resourceManager;
}
@ -3072,10 +3140,8 @@ int32_t BundleDataMgr::GetMediaFileDescriptor(const std::string &bundleName, con
APP_LOGE("abilityName:%{public}s not find", abilityName.c_str());
return fd;
}
BundleInfo bundleInfo;
int32_t flags = fd;
infoItem->second.GetBundleInfo(flags, bundleInfo, GetUserId());
std::shared_ptr<Global::Resource::ResourceManager> resourceManager = GetResourceManager(bundleInfo);
std::shared_ptr<Global::Resource::ResourceManager> resourceManager =
GetResourceManager(bundleName, moduleName, GetUserId());
if (resourceManager == nullptr) {
APP_LOGE("InitResourceManager failed");
return fd;

View File

@ -1587,6 +1587,28 @@ bool BundleMgrHostImpl::GetBundleStats(const std::string &bundleName, int32_t us
return true;
}
std::string BundleMgrHostImpl::GetStringById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, int32_t userId)
{
auto dataMgr = GetDataMgrFromService();
if (dataMgr == nullptr) {
APP_LOGE("DataMgr is nullptr");
return Constants::EMPTY_STRING;
}
return dataMgr->GetStringById(bundleName, moduleName, resId, userId);
}
std::string BundleMgrHostImpl::GetIconById(
const std::string &bundleName, const std::string &moduleName, uint32_t resId, uint32_t density, int32_t userId)
{
auto dataMgr = GetDataMgrFromService();
if (dataMgr == nullptr) {
APP_LOGE("DataMgr is nullptr");
return Constants::EMPTY_STRING;
}
return dataMgr->GetIconById(bundleName, moduleName, resId, density, userId);
}
#ifdef BUNDLE_FRAMEWORK_DEFAULT_APP
sptr<IDefaultApp> BundleMgrHostImpl::GetDefaultAppProxy()
{

View File

@ -53,6 +53,7 @@ group("unittest") {
"unittest/bms_bundle_kit_service_test:unittest",
"unittest/bms_bundle_parser_test:unittest",
"unittest/bms_bundle_permission_grant_test:unittest",
"unittest/bms_bundle_resource_manager_test:unittest",
"unittest/bms_bundle_sandbox_app_test:unittest",
"unittest/bms_bundle_uninstaller_test:unittest",
"unittest/bms_bundle_updater_test:unittest",

View File

@ -0,0 +1,150 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("../../../../../appexecfwk.gni")
import("../../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = "bundle_framework/bundlemgrservice"
ohos_unittest("BmsBundleResourceManagerTest") {
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
]
sources = [
"${services_path}/bundlemgr/src/account_helper.cpp",
"${services_path}/bundlemgr/src/bundle_common_event_mgr.cpp",
"${services_path}/bundlemgr/src/bundle_data_mgr.cpp",
"${services_path}/bundlemgr/src/bundle_data_storage_database.cpp",
"${services_path}/bundlemgr/src/bundle_mgr_host_impl.cpp",
"${services_path}/bundlemgr/src/bundle_mgr_service.cpp",
"${services_path}/bundlemgr/src/bundle_mgr_service_event_handler.cpp",
"${services_path}/bundlemgr/src/bundle_scanner.cpp",
"${services_path}/bundlemgr/src/bundle_state_storage.cpp",
"${services_path}/bundlemgr/src/bundle_status_callback_death_recipient.cpp",
"${services_path}/bundlemgr/src/bundle_user_mgr_host_impl.cpp",
"${services_path}/bundlemgr/src/distributed_data_storage.cpp",
"${services_path}/bundlemgr/src/hidump_helper.cpp",
"${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/src/installd/installd_service.cpp",
"${services_path}/bundlemgr/src/kvstore_death_recipient_callback.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage.cpp",
]
sources += [
"${services_path}/bundlemgr/test/mock/src/mock_bundle_status.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += bundle_install_sources
sources += [ "bms_bundle_resource_manager_test.cpp" ]
configs = [
"${services_path}/bundlemgr/test:bundlemgr_test_config",
"//base/notification/eventhandler/frameworks/eventhandler:libeventhandler_config",
]
cflags = []
if (target_cpu == "arm") {
cflags += [ "-DBINDER_IPC_32BIT" ]
}
deps = [
"${appexecfwk_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
"${appexecfwk_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest",
]
if (bundle_framework_graphics) {
include_dirs += [
"//foundation/multimedia/image_standard/interfaces/innerkits/include",
]
deps += [ "//foundation/multimedia/image_standard/interfaces/innerkits:image_native" ]
}
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"appverify:libhapverify",
"bundle_framework:appexecfwk_core",
"common_event_service:cesfwk_innerkits",
"distributeddatamgr:distributeddata_inner",
"eventhandler:libeventhandler",
"hitrace_native:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
defines = []
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux:libhap_restorecon" ]
cflags += [ "-DWITH_SELINUX" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_info_manager:distributed_device_profile_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (device_manager_enable) {
sources += [ "${services_path}/bundlemgr/src/bms_device_manager.cpp" ]
external_deps += [ "device_manager:devicemanagersdk" ]
defines += [ "DEVICE_MANAGER_ENABLE" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie_native:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent_native:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (bundle_framework_default_app) {
sources += default_app
defines += [ "BUNDLE_FRAMEWORK_DEFAULT_APP" ]
}
}
group("unittest") {
testonly = true
if (ability_runtime_enable) {
deps = [ ":BmsBundleResourceManagerTest" ]
}
}

View File

@ -0,0 +1,459 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <fstream>
#include <gtest/gtest.h>
#include <set>
#include <sstream>
#include <string>
#include "bundle_installer_host.h"
#include "bundle_mgr_service.h"
#include "installd/installd_service.h"
#include "installd_client.h"
#include "mock_status_receiver.h"
using namespace testing::ext;
using namespace OHOS;
using namespace OHOS::AppExecFwk;
namespace OHOS {
namespace {
const std::string BUNDLE_PATH = "/data/test/resource/bms/resource_manager/resourceManagerTest.hap";
const std::string BUNDLE_NAME = "com.ohos.resourcedemo";
const std::string MODULE_NAME = "entry";
const std::string APP_LABEL = "ResourceDemo";
const std::string DESCRIPTION = "description";
const std::string ABILITY_LABEL = "label";
const int32_t APP_LABEL_ID = 16777216;
const int32_t DESCRIPTION_ID = 16777218;
const int32_t ABILITY_LABEL_ID = 16777219;
const int32_t APP_ICON_ID = 16777217;
const int32_t ABILITY_ICON_ID = 16777222;
const int32_t USER_ID = 100;
const int32_t WAIT_TIME = 5; // init mocked bms
const uint32_t DENSITY_120_STR = 120; // sdpi
const uint32_t DENSITY_160_STR = 160; // mdpi
const uint32_t DENSITY_240_STR = 240; // ldpi
const uint32_t DENSITY_320_STR = 320; // xldpi
const uint32_t DENSITY_480_STR = 480; // xxldpi
const uint32_t DENSITY_640_STR = 640; // xxxldpi
class BmsBundleResourceManagerTest : public testing::Test {
public:
BmsBundleResourceManagerTest();
~BmsBundleResourceManagerTest();
static void SetUpTestCase();
static void TearDownTestCase();
void SetUp();
void TearDown();
ErrCode InstallBundle(const std::string &bundlePath) const;
ErrCode UnInstallBundle(const std::string &bundleName) const;
void StartInstalldService() const;
void StartBundleService();
const std::shared_ptr<BundleDataMgr> GetBundleDataMgr() const;
private:
std::shared_ptr<InstalldService> installdService_ = std::make_shared<InstalldService>();
std::shared_ptr<BundleMgrService> bundleMgrService_ = DelayedSingleton<BundleMgrService>::GetInstance();
};
BmsBundleResourceManagerTest::BmsBundleResourceManagerTest()
{}
BmsBundleResourceManagerTest::~BmsBundleResourceManagerTest()
{}
void BmsBundleResourceManagerTest::SetUpTestCase()
{}
void BmsBundleResourceManagerTest::TearDownTestCase()
{}
void BmsBundleResourceManagerTest::SetUp()
{
StartBundleService();
StartInstalldService();
InstallBundle(BUNDLE_PATH);
}
void BmsBundleResourceManagerTest::TearDown()
{
UnInstallBundle(BUNDLE_NAME);
}
ErrCode BmsBundleResourceManagerTest::InstallBundle(const std::string &bundlePath) const
{
if (!bundleMgrService_) {
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
auto installer = bundleMgrService_->GetBundleInstaller();
if (!installer) {
EXPECT_FALSE(true) << "the installer is nullptr";
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
sptr<MockStatusReceiver> receiver = new (std::nothrow) MockStatusReceiver();
if (!receiver) {
EXPECT_FALSE(true) << "the receiver is nullptr";
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
InstallParam installParam;
installParam.installFlag = InstallFlag::REPLACE_EXISTING;
installParam.userId = USER_ID;
bool result = installer->Install(bundlePath, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
}
ErrCode BmsBundleResourceManagerTest::UnInstallBundle(const std::string &bundleName) const
{
if (!bundleMgrService_) {
return ERR_APPEXECFWK_UNINSTALL_BUNDLE_MGR_SERVICE_ERROR;
}
auto installer = bundleMgrService_->GetBundleInstaller();
if (!installer) {
EXPECT_FALSE(true) << "the installer is nullptr";
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
sptr<MockStatusReceiver> receiver = new (std::nothrow) MockStatusReceiver();
if (!receiver) {
EXPECT_FALSE(true) << "the receiver is nullptr";
return ERR_APPEXECFWK_INSTALL_INTERNAL_ERROR;
}
InstallParam installParam;
installParam.installFlag = InstallFlag::NORMAL;
installParam.userId = USER_ID;
bool result = installer->Uninstall(bundleName, installParam, receiver);
EXPECT_TRUE(result);
return receiver->GetResultCode();
}
const std::shared_ptr<BundleDataMgr> BmsBundleResourceManagerTest::GetBundleDataMgr() const
{
return bundleMgrService_->GetDataMgr();
}
void BmsBundleResourceManagerTest::StartInstalldService() const
{
if (!installdService_->IsServiceReady()) {
installdService_->Start();
}
}
void BmsBundleResourceManagerTest::StartBundleService()
{
if (!bundleMgrService_->IsServiceReady()) {
bundleMgrService_->OnStart();
std::this_thread::sleep_for(std::chrono::seconds(WAIT_TIME));
}
}
/**
* @tc.number: GetStringById_001
* @tc.name: test the getStringById
* @tc.desc: 1.install the hap
* 2.getStringById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetStringById_001, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string label = dataMgr->GetStringById(BUNDLE_NAME, MODULE_NAME, APP_LABEL_ID, USER_ID);
EXPECT_EQ(label, APP_LABEL);
}
/**
* @tc.number: GetStringById_002
* @tc.name: test the getStringById
* @tc.desc: 1.install the hap
* 2.getStringById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetStringById_002, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string label = dataMgr->GetStringById(BUNDLE_NAME, MODULE_NAME, ABILITY_LABEL_ID, USER_ID);
EXPECT_EQ(label, ABILITY_LABEL);
std::string description = dataMgr->GetStringById(BUNDLE_NAME, MODULE_NAME, DESCRIPTION_ID, USER_ID);
EXPECT_EQ(description, DESCRIPTION);
}
/**
* @tc.number: GetStringById_003
* @tc.name: test the getStringById
* @tc.desc: 1.install the hap
* 2.getStringById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetStringById_003, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string description = dataMgr->GetStringById("", MODULE_NAME, ABILITY_LABEL_ID, USER_ID);
EXPECT_EQ(description, "");
}
/**
* @tc.number: GetStringById_004
* @tc.name: test the getStringById
* @tc.desc: 1.install the hap
* 2.getStringById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetStringById_004, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string abilityLabel = dataMgr->GetStringById(BUNDLE_NAME, "", ABILITY_LABEL_ID, USER_ID);
EXPECT_EQ(abilityLabel, ABILITY_LABEL);
}
/**
* @tc.number: GetStringById_005
* @tc.name: test the getStringById
* @tc.desc: 1.install the hap
* 2.getStringById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetStringById_005, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string description = dataMgr->GetStringById(BUNDLE_NAME, MODULE_NAME, 0, USER_ID);
EXPECT_EQ(description, "");
}
/**
* @tc.number: GetStringById_006
* @tc.name: test the getStringById
* @tc.desc: 1.install the hap
* 2.getStringById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetStringById_006, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string description = dataMgr->GetStringById(BUNDLE_NAME, MODULE_NAME, ABILITY_LABEL_ID, 0);
EXPECT_EQ(description, "");
}
/**
* @tc.number: GetIconById_001
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_001, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 = dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, APP_ICON_ID, 0, USER_ID);
EXPECT_NE(iconBase64, "");
}
/**
* @tc.number: GetIconById_002
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_002, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string icon120Base64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, DENSITY_120_STR, USER_ID);
EXPECT_NE(icon120Base64, "");
}
/**
* @tc.number: GetIconById_003
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_003, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string icon160Base64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, DENSITY_160_STR, USER_ID);
EXPECT_NE(icon160Base64, "");
}
/**
* @tc.number: GetIconById_004
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_004, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string icon240Base64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, DENSITY_240_STR, USER_ID);
EXPECT_NE(icon240Base64, "");
}
/**
* @tc.number: GetIconById_005
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_005, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string icon320Base64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, DENSITY_320_STR, USER_ID);
EXPECT_NE(icon320Base64, "");
}
/**
* @tc.number: GetIconById_007
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_006, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string icon480Base64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, DENSITY_480_STR, USER_ID);
EXPECT_NE(icon480Base64, "");
}
/**
* @tc.number: GetIconById_008
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_007, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string icon640Base64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, DENSITY_640_STR, USER_ID);
EXPECT_NE(icon640Base64, "");
}
/**
* @tc.number: GetIconById_009
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_008, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconDefaultBase64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, 0, USER_ID);
EXPECT_NE(iconDefaultBase64, "");
}
/**
* @tc.number: GetIconById_009
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_009, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, 0, -1);
EXPECT_EQ(iconBase64, "");
}
/**
* @tc.number: GetIconById_0010
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_0010, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 =
dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, 0, USER_ID);
EXPECT_NE(iconBase64, "");
}
/**
* @tc.number: GetIconById_0011
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_0011, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 = dataMgr->GetIconById("", MODULE_NAME, ABILITY_ICON_ID, 0, USER_ID);
EXPECT_EQ(iconBase64, "");
}
/**
* @tc.number: GetIconById_0012
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_0012, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 = dataMgr->GetIconById(BUNDLE_NAME, "", ABILITY_ICON_ID, 0, USER_ID);
EXPECT_NE(iconBase64, "");
}
/**
* @tc.number: GetIconById_0013
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_0013, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 = dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, 0, 0, USER_ID);
EXPECT_EQ(iconBase64, "");
}
/**
* @tc.number: GetIconById_0014
* @tc.name: test the GetIconById
* @tc.desc: 1.install the hap
* 2.GetIconById
*/
HWTEST_F(BmsBundleResourceManagerTest, GetIconById_0014, Function | SmallTest | Level0)
{
auto dataMgr = GetBundleDataMgr();
EXPECT_NE(dataMgr, nullptr);
std::string iconBase64 = dataMgr->GetIconById(BUNDLE_NAME, MODULE_NAME, ABILITY_ICON_ID, 0, 0);
EXPECT_EQ(iconBase64, "");
}
}
} // OHOS

View File

@ -14,6 +14,12 @@
* limitations under the License.
-->
<configuration ver="2.0">
<target name="BmsBundleResourceManagerTest">
<preparer>
<option name="push" value="test_bundle/resourceManagerTest.hap -> /data/test/resource/bms/resource_manager/"
src="res" />
</preparer>
</target>
<target name="BmsBundleDefaultAppTest">
<preparer>
<option name="push" value="test_bundle/defaultAppTest.hap -> /data/test/resource/bms/default_app_bundle/"

View File

@ -19,6 +19,7 @@ group("test_bundle") {
# deps file
"defaultAppTest:defaultAppTest",
"first_right:first_right",
"resourceManagerTest:resourceManagerTest",
"sandboxTest:sandboxTest",
]
}

View File

@ -0,0 +1,15 @@
{
"app": {
"bundleName": "com.ohos.resourcedemo",
"distributedNotificationEnabled": true,
"icon": "$media:app_icon",
"iconId": 16777217,
"label": "$string:app_name",
"labelId": 16777216,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0"
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "ResourceDemo"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,44 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos.gni")
import("../../../../../appexecfwk.gni")
ohos_hap("resourceManagerTest") {
hap_profile = "entry/src/main/module.json"
hap_name = "resourceManagerTest"
subsystem_name = "bundlemanager"
final_hap_path = "$root_out_dir/tests/unittest/bundle_framework/bundlemgrservice/resource/test_bundle/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile =
"${appexecfwk_path}/test/sceneProject/openharmony_sx.p7b"
}
ohos_app_scope("bmsstagedemoone_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("hjs_demo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":bmsstagedemoone_app_profile" ]
hap_profile = "entry/src/main/module.json"
}

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}

View File

@ -0,0 +1,39 @@
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}

View File

@ -0,0 +1,16 @@
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB