!114 Merge pull request

Merge pull request !114 from weishaoxiong/monthly_20220614
This commit is contained in:
openharmony_ci
2022-07-15 02:43:05 +00:00
committed by Gitee
10 changed files with 37 additions and 28 deletions
+2 -2
View File
@@ -144,8 +144,8 @@ wallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM).then((data) => {
js 应用接口使用说明
```
import Extension from '@ohos.application.WallpaperExtension'
import wallPaper from '@ohos.app.wallpaperability'
import Extension from '@ohos.wallpaperextension'
import wallPaper from '@ohos.wallpaper'
export default class WallpaperExtAbility extends Extension {
onCreated(want) {
+1 -1
View File
@@ -51,7 +51,7 @@
"//base/miscservices/wallpaper/frameworks/kits/extension:wallpaper_extension_module",
"//base/miscservices/wallpaper/interfaces/kits/napi/wallpaperextension:wallpaperextension_napi",
"//base/miscservices/wallpaper/interfaces/kits/napi/wallpaper_extension_context:wallpaperextensioncontext_napi",
"//base/miscservices/wallpaper/interfaces/kits/napi:wallpaperability",
"//base/miscservices/wallpaper/interfaces/kits/napi:wallpaper",
"//base/miscservices/wallpaper/utils:wallpaper_utils",
"//base/miscservices/wallpaper/frameworks/innerkitsimpl/wallpaper_manager:wallpaperdefault.jpeg",
"//base/miscservices/wallpaper/frameworks/innerkitsimpl/wallpaper_manager:wallpaperlockdefault.jpeg"
@@ -82,7 +82,7 @@ void JsWallpaperExtension::Init(const std::shared_ptr<AbilityLocalRecord> &recor
}
HILOG_INFO("JsWallpaperExtension::Init CreateJsWallpaperExtensionContext.");
NativeValue* contextObj = CreateJsWallpaperExtensionContext(engine, context);
auto shellContextRef = jsRuntime_.LoadSystemModule("application.WallpaperExtensionContext", &contextObj, ARGC_ONE);
auto shellContextRef = jsRuntime_.LoadSystemModule("WallpaperExtensionContext", &contextObj, ARGC_ONE);
contextObj = shellContextRef->Get();
HILOG_INFO("JsWallpaperExtension::Init Bind.");
context->Bind(jsRuntime_, shellContextRef.release());
+2 -2
View File
@@ -14,7 +14,7 @@
import("//base/miscservices/wallpaper/wallpaper.gni")
import("//build/ohos.gni")
ohos_shared_library("wallpaperability") {
ohos_shared_library("wallpaper") {
include_dirs = [
"//foundation/arkui/napi/interfaces/kits",
"//third_party/node/src",
@@ -53,7 +53,7 @@ ohos_shared_library("wallpaperability") {
"ipc:ipc_core",
]
relative_install_dir = "module/app"
relative_install_dir = "module"
subsystem_name = "miscservices"
part_name = "wallpaper_native"
}
+7 -4
View File
@@ -37,10 +37,14 @@ EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{
HILOG_INFO("napi_moudule Init start...");
napi_value WallpaperType = nullptr;
napi_value wpType_system = nullptr;
napi_value wpType_lockscreen = nullptr;
napi_create_int32(env, static_cast<int32_t>(WALLPAPER_SYSTEM), &wpType_system);
napi_create_int32(env, static_cast<int32_t>(WALLPAPER_LOCKSCREEN), &wpType_lockscreen);
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(WALLPAPER_SYSTEM), &wpType_system));
NAPI_CALL(env, napi_create_int32(env, static_cast<int32_t>(WALLPAPER_LOCKSCREEN), &wpType_lockscreen));
NAPI_CALL(env, napi_create_object(env, &WallpaperType));
NAPI_CALL(env, napi_set_named_property(env, WallpaperType, "WALLPAPER_SYSTEM", wpType_system));
NAPI_CALL(env, napi_set_named_property(env, WallpaperType, "WALLPAPER_LOCKSCREEN", wpType_lockscreen));
napi_property_descriptor desc[] = {
DECLARE_NAPI_FUNCTION("getColors", NAPI_GetColors),
DECLARE_NAPI_FUNCTION("getId", NAPI_GetId),
@@ -54,8 +58,7 @@ static napi_value Init(napi_env env, napi_value exports)
DECLARE_NAPI_FUNCTION("screenshotLiveWallpaper", NAPI_ScreenshotLiveWallpaper),
DECLARE_NAPI_FUNCTION("on", NAPI_On),
DECLARE_NAPI_FUNCTION("off", NAPI_Off),
DECLARE_NAPI_STATIC_PROPERTY("WALLPAPER_SYSTEM", wpType_system),
DECLARE_NAPI_STATIC_PROPERTY("WALLPAPER_LOCKSCREEN", wpType_lockscreen),
DECLARE_NAPI_STATIC_PROPERTY("WallpaperType", WallpaperType),
};
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
@@ -44,7 +44,7 @@ ohos_shared_library("wallpaperextensioncontext_napi") {
external_deps = [ "napi:ace_napi" ]
relative_install_dir = "module/application"
relative_install_dir = "module"
subsystem_name = "miscservices"
part_name = "wallpaper_native"
}
@@ -21,19 +21,19 @@ extern const char _binary_wallpaper_extension_context_abc_start[];
extern const char _binary_wallpaper_extension_context_abc_end[];
extern "C" __attribute__((constructor))
void NAPI_application_WallpaperExtensionContext_AutoRegister()
void NAPI_WallpaperExtensionContext_AutoRegister()
{
auto moduleManager = NativeModuleManager::GetInstance();
NativeModule newModuleInfo = {
.name = "application.WallpaperExtensionContext",
.fileName = "application/libwallpaperextensioncontext_napi.so/WallpaperExtensionContext.js",
.name = "WallpaperExtensionContext",
.fileName = "libwallpaperextensioncontext_napi.so/wallpaper_extension_context.js",
};
moduleManager->Register(&newModuleInfo);
}
extern "C" __attribute__((visibility("default")))
void NAPI_application_WallpaperExtensionContext_GetJSCode(const char **buf, int *bufLen)
void NAPI_WallpaperExtensionContext_GetJSCode(const char **buf, int *bufLen)
{
if (buf != nullptr) {
*buf = _binary_wallpaper_extension_context_js_start;
@@ -46,7 +46,7 @@ void NAPI_application_WallpaperExtensionContext_GetJSCode(const char **buf, int
// ability_context JS register
extern "C" __attribute__((visibility("default")))
void NAPI_application_WallpaperExtensionContext_GetABCCode(const char **buf, int *buflen)
void NAPI_WallpaperExtensionContext_GetABCCode(const char **buf, int *buflen)
{
if (buf != nullptr) {
*buf = _binary_wallpaper_extension_context_abc_start;
@@ -44,7 +44,7 @@ ohos_shared_library("wallpaperextension_napi") {
external_deps = [ "napi:ace_napi" ]
relative_install_dir = "module/application"
relative_install_dir = "module"
subsystem_name = "miscservices"
part_name = "wallpaper_native"
}
@@ -21,19 +21,19 @@ extern const char _binary_wallpaper_extension_abc_start[];
extern const char _binary_wallpaper_extension_abc_end[];
extern "C" __attribute__((constructor))
void NAPI_application_WallpaperExtension_AutoRegister()
void NAPI_WallpaperExtension_AutoRegister()
{
auto moduleManager = NativeModuleManager::GetInstance();
NativeModule newModuleInfo = {
.name = "application.WallpaperExtension",
.fileName = "application/libwallpaperextension_napi.so/WallpaperExtension.js",
.name = "WallpaperExtension",
.fileName = "libwallpaperextension_napi.so/wallpaper_extension.js",
};
moduleManager->Register(&newModuleInfo);
}
extern "C" __attribute__((visibility("default")))
void NAPI_application_WallpaperExtension_GetJSCode(const char **buf, int *bufLen)
void NAPI_WallpaperExtension_GetJSCode(const char **buf, int *bufLen)
{
if (buf != nullptr) {
*buf = _binary_wallpaper_extension_js_start;
@@ -46,7 +46,7 @@ void NAPI_application_WallpaperExtension_GetJSCode(const char **buf, int *bufLen
// wallpaper_extension JS register
extern "C" __attribute__((visibility("default")))
void NAPI_application_WallpaperExtension_GetABCCode(const char **buf, int *buflen)
void NAPI_WallpaperExtension_GetABCCode(const char **buf, int *buflen)
{
if (buf != nullptr) {
*buf = _binary_wallpaper_extension_abc_start;
+12 -6
View File
@@ -424,14 +424,20 @@ bool WallpaperService::MakeCropWallpaper(int wallpaperType)
int32_t pictrueWidth = wallpaperPixelMap->GetWidth();
int pyScrWidth = GetWallpaperMinWidth();
int pyScrHeight = GetWallpaperMinHeight();
if (pictrueHeight > pyScrHeight || pictrueWidth > pyScrWidth) {
bool needCropHeight = false;
bool needCropWidth = false;
if (pictrueHeight > pyScrHeight) {
decodeOpts.CropRect.top = (pictrueHeight - pyScrHeight)/HALF;
decodeOpts.CropRect.width = pyScrWidth;
decodeOpts.CropRect.left = (pictrueWidth - pyScrWidth)/HALF;
decodeOpts.CropRect.height = pyScrHeight;
decodeOpts.desiredSize.width = pyScrWidth;
decodeOpts.desiredSize.height = pyScrHeight;
needCropHeight = true;
}
if (pictrueWidth > pyScrWidth) {
decodeOpts.CropRect.left = (pictrueWidth - pyScrWidth)/HALF;
needCropWidth = true;
}
decodeOpts.CropRect.height = needCropHeight ? pyScrHeight : pictrueHeight;
decodeOpts.desiredSize.height = decodeOpts.CropRect.height;
decodeOpts.CropRect.width = needCropWidth ? pyScrWidth : pictrueHeight;
decodeOpts.desiredSize.width = decodeOpts.CropRect.width;
wallpaperPixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
if (errorCode != 0) {
ret = false;