From d9a804135c02d7ab34ce1dd4f5c9ef7e9593f9df Mon Sep 17 00:00:00 2001 From: xiaojianfeng Date: Mon, 1 Aug 2022 07:24:10 +0000 Subject: [PATCH] 1. delete Orientation.SENSOR, SENSOR_VERTICAL, SENSOR_HORIZONTAL in native 2. fix avoidArea native bug Signed-off-by: xiaojianfeng Change-Id: I4396c8764a774086287c1a4b546bc5766c3ada83 --- .../kits/napi/screen_runtime/api/@ohos.screen.d.ts | 3 --- .../napi/screen_runtime/napi/js_screen_manager.cpp | 5 ----- .../window_runtime/window_napi/js_window_listener.cpp | 10 +++++++++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interfaces/kits/napi/screen_runtime/api/@ohos.screen.d.ts b/interfaces/kits/napi/screen_runtime/api/@ohos.screen.d.ts index bf3812dc..25fc4e4d 100644 --- a/interfaces/kits/napi/screen_runtime/api/@ohos.screen.d.ts +++ b/interfaces/kits/napi/screen_runtime/api/@ohos.screen.d.ts @@ -235,9 +235,6 @@ declare namespace screen { HORIZONTAL = 2, REVERSE_VERTICAL = 3, REVERSE_HORIZONTAL = 4, - SENSOR = 5, - SENSOR_VERTICAL = 6, - SENSOR_HORIZONTAL = 7, } /** diff --git a/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp b/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp index a79fb29d..3f097dda 100644 --- a/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp +++ b/interfaces/kits/napi/screen_runtime/napi/js_screen_manager.cpp @@ -707,11 +707,6 @@ NativeValue* InitScreenOrientation(NativeEngine* engine) CreateJsValue(*engine, static_cast(Orientation::REVERSE_VERTICAL))); object->SetProperty("REVERSE_HORIZONTAL", CreateJsValue(*engine, static_cast(Orientation::REVERSE_HORIZONTAL))); - object->SetProperty("SENSOR", CreateJsValue(*engine, static_cast(Orientation::SENSOR))); - object->SetProperty("SENSOR_VERTICAL", - CreateJsValue(*engine, static_cast(Orientation::SENSOR_VERTICAL))); - object->SetProperty("SENSOR_HORIZONTAL", - CreateJsValue(*engine, static_cast(Orientation::SENSOR_HORIZONTAL))); return objValue; } diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp index f0bead10..211e7f10 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window_listener.cpp @@ -130,7 +130,15 @@ void JsWindowListener::OnAvoidAreaChanged(const AvoidArea avoidArea, AvoidAreaTy NativeValue* argv[] = { avoidAreaValue }; thisListener->CallJsMethod(SYSTEM_AVOID_AREA_CHANGE_CB.c_str(), argv, ArraySize(argv)); } else { - NativeValue* argv[] = { CreateJsValue(engine, static_cast(type)), avoidAreaValue }; + NativeValue *objValue = engine.CreateObject(); + NativeObject *object = ConvertNativeValueTo(objValue); + if (object == nullptr) { + WLOGFE("Failed to get object"); + return; + } + object->SetProperty("type", CreateJsValue(engine, static_cast(type))); + object->SetProperty("area", avoidAreaValue); + NativeValue* argv[] = { objValue }; thisListener->CallJsMethod(AVOID_AREA_CHANGE_CB.c_str(), argv, ArraySize(argv)); } }