issueNo: I49MN4

Description:fix the baseline bug of text
Feature or Bugfix:Bugfix
Binary Source:No

Signed-off-by: youzhi92 <chenyouzhi@huawei.com>
Change-Id: I07e9c03d07d2c099a171edb32870985c96f49245
This commit is contained in:
youzhi92
2021-09-11 15:55:33 +08:00
parent c6d25d4a0e
commit ad84833d5d
10 changed files with 203 additions and 1 deletions
+1
View File
@@ -78,5 +78,6 @@ shared_library("ace_lite") {
if (enable_ohos_appexecfwk_feature_ability == true) {
defines += [ "ABILITY_WINDOW_SUPPORT" ]
defines += [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ]
}
}
@@ -18,6 +18,7 @@
#include <string.h>
#include "ace_log.h"
#include "font/ui_font_header.h"
#include "js_app_context.h"
#include "key_parser.h"
#include "keys.h"
#include "product_adapter.h"
@@ -42,6 +43,8 @@ bool TextComponent::CreateNativeViews()
/* set default text OverFlow clip */
uiLabel_.SetLineBreakMode(overflowMode_);
uiLabel_.SetAlign(UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT, UITextLanguageAlignment::TEXT_ALIGNMENT_CENTER);
const int32_t supportBaseLineApiVersion = 5;
uiLabel_.SetSupportBaseLine(JsAppContext::GetInstance()->GetTargetApi() >= supportBaseLineApiVersion);
return CopyFontFamily(fontFamily_, ProductAdapter::GetDefaultFontFamilyName());
}
@@ -49,6 +49,7 @@ void JSAbilityImpl::InitEnvironment(const char * const abilityPath, const char *
appContext_->SetCurrentAbilityInfo(abilityPath, bundleName, token);
appContext_->SetTopJSAbilityImpl(this);
appJsEnv->InitJsFramework();
appContext_->LoadApiVersion();
// initialize js object after engine started up
abilityModel_ = UNDEFINED;
@@ -19,6 +19,7 @@
#if (defined(__LINUX__) || defined(__LITEOS__))
#include "ace_ability.h"
#endif
#include "bundle_manager.h"
#include "component_factory.h"
#include "component_utils.h"
#include "fatal_handler.h"
@@ -296,6 +297,7 @@ void JsAppContext::ReleaseAbilityInfo()
currentJsPath_ = nullptr;
}
}
char *JsAppContext::GetResourcePath(const char *uri) const
{
if (uri == nullptr) {
@@ -339,5 +341,27 @@ char *JsAppContext::GetResourcePath(const char *uri) const
}
return RelocateResourceFilePath(currentAbilityPath_, uri);
}
void JsAppContext::LoadApiVersion()
{
BundleInfo bundle = {0};
uint8_t retCode = GetBundleInfo(currentBundleName_, false, &bundle);
if (retCode != 0) {
HILOG_ERROR(HILOG_MODULE_ACE, "fail to get api version.");
return;
}
compatibleApi_ = bundle.compatibleApi;
targetApi_ = bundle.targetApi;
}
const int32_t JsAppContext::GetCompatibleApi() const
{
return compatibleApi_;
}
const int32_t JsAppContext::GetTargetApi() const
{
return targetApi_;
}
} // namespace ACELite
} // namespace OHOS
@@ -96,6 +96,9 @@ public:
{
topJSAbilityImpl_ = object;
}
void LoadApiVersion();
const int32_t GetCompatibleApi() const;
const int32_t GetTargetApi() const;
const AppStyleManager *GetStyleManager()
{
@@ -168,6 +171,8 @@ private:
LazyLoadManager *lazyLoadManager_ = nullptr;
// record current running ability's uuid && ability path, will be release during app-cleanup
uint16_t currentToken_ = 0;
int32_t compatibleApi_ = 0;
int32_t targetApi_ = 0;
};
} // namespace ACELite
} // namespace OHOS
@@ -147,6 +147,7 @@ SOURCES += \
targets/simulator/mock/hal_sys_param.cpp \
targets/simulator/mock/message_queue_utils.cpp \ # the mocked message queue
targets/simulator/mock/mock_services.cpp \ # the mocked message queue
targets/simulator/mock/bms_interfaces/bundle_manager_mock.cpp \ # mock some BMS interfaces
targets/simulator/mock/jsthread/js_thread.cpp \
targets/simulator/mock/vsyncthread/vsync_dispatch_manager.cpp \
targets/simulator/mock/vsyncthread/vsync_thread.cpp \
@@ -157,7 +158,6 @@ SOURCES += \
HEADERS += \
$${ROOT_PATH}/foundation/graphic/ui/interfaces/kits/components/ui_view.h
INCLUDEPATH += \
$${ROOT_PATH}/foundation/graphic/ui/interfaces/innerkits \
$${ROOT_PATH}/foundation/graphic/ui/interfaces/innerkits/common \
@@ -218,6 +218,7 @@ INCLUDEPATH += \
targets/simulator/mock/vsyncthread \
targets/simulator/mock/amsthread \
targets/simulator/mock/timerthread \
targets/simulator/mock/bms_interfaces \
$${ROOT_PATH}/third_party/jerryscript/jerry-core/include \
$${ROOT_PATH}/third_party/jerryscript/jerry-ext/include/jerryscript-ext \
$${ROOT_PATH}//third_party/jerryscript/jerry-port/default/include \
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2020 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.
*/
#ifndef OHOS_BUNDLE_INFO_H
#define OHOS_BUNDLE_INFO_H
#include <cstdint>
/**
* @brief The mock defines the bundle information, please refer to the bundle_info.h file locating in
* appexecfwk_appexecfwk_lite repo.
*/
typedef struct {
/**
* Whether the application is a system application. System applications cannot be uninstalled. The value
* <b>true</b> indicates a system application, and <b>false</b> indicates a non-system application.
*/
bool isSystemApp;
/** Minimum API version required */
int32_t compatibleApi;
/** Target API version */
int32_t targetApi;
/** Version code of the application, which is the internal version number */
int32_t versionCode;
/** Pointer to the version name visible to users */
char *versionName;
/** Pointer to the bundle name of the application */
char *bundleName;
/** Pointer to the application name visible to users */
char *label;
} BundleInfo;
#endif // OHOS_BUNDLE_INFO_H
/** @} */
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2021 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.
*/
/**
* @addtogroup BundleManager
*
* @brief Provides structures and functions for managing application bundles and obtaining application information.
*
* @since 1.0
* @version 1.0
*/
/**
* @file bundle_manager.h
*
* @brief Declares functions used for managing application bundles and obtaining bundle information.
*
* You can use functions provided in this file to install, update, or uninstall an application, obtain
* {@link AbilityInfo} and {@link BundleInfo} about an application, obtain the bundle name of an application based
* on the application's user ID (UID), and obtain {@link BundleInfo} objects of all applications or keep-alive
* applications in the system.
*
* @since 1.0
* @version 1.0
*/
#ifndef OHOS_BUNDLEMANAGER_INTERFACE_H
#define OHOS_BUNDLEMANAGER_INTERFACE_H
#include "bundle_info.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
/**
* @brief Obtains the {@link BundleInfo} of an application based on the specified bundle name.
*
* @attention Before querying a {@link BundleInfo} object, you should first call <b>memset</b> on the constructed
* {@link BundleInfo} object so that each field in it can be properly initialized for carrying the
* obtained information.
* @param bundleName Indicates the pointer to the name of the application bundle to query.
* @param flags Specifies whether the obtained {@link BundleInfo} object can contain {@link AbilityInfo}. The value
* <b>1</b> indicates that it can contain {@link AbilityInfo}, and <b>0</b> indicates that it cannot.
* @param bundleInfo Indicates the pointer to the obtained {@link BundleInfo} object.
*
* @return Returns {@link ERR_OK} if this function is successfully called; returns another error code defined in
* {@link AppexecfwkErrors} otherwise.
*
* @since 1.0
* @version 1.0
*/
uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo *bundleInfo);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* OHOS_BUNDLEMANAGER_INTERFACE_H */
/** @} */
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2021 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 "bundle_manager.h"
#include "bundle_info.h"
#include "securec.h"
extern "C" {
constexpr static uint8_t MAX_BUNDLE_NAME_LENGTH = 128;
uint8_t GetBundleInfo(const char *bundleName, int32_t flags, BundleInfo *bundleInfo)
{
if ((bundleName == nullptr) || (bundleInfo == nullptr)) {
return UINT8_MAX;
}
if ((flags < 0) || (flags > 1) || (strlen(bundleName) >= MAX_BUNDLE_NAME_LENGTH)) {
return UINT8_MAX;
}
const uint8_t mockCompatibleApi = 5;
bundleInfo->compatibleApi = mockCompatibleApi;
const uint8_t mockTargetApi = 4;
bundleInfo->targetApi = mockTargetApi;
return 0;
}
}
+1
View File
@@ -118,5 +118,6 @@ all_external_includes = ace_lite_include_dirs + ace_test_includes
all_defines = ace_test_defines
if (enable_ohos_appexecfwk_feature_ability == true) {
all_defines += [ "ABILITY_WINDOW_SUPPORT" ]
all_defines += [ "OHOS_APPEXECFWK_BMS_BUNDLEMANAGER" ]
}
all_acelite_source_files = ace_lite_sources