From af1afa1c677cbed4e52b7f802bdd868d6e00a998 Mon Sep 17 00:00:00 2001 From: hid06197980 <2089450903@qq.com> Date: Wed, 30 Jul 2025 11:21:27 +0800 Subject: [PATCH] number exchange to int/long/double by object Signed-off-by: hid06197980 <2089450903@qq.com> --- .../display_ani/src/display_ani.cpp | 12 +++---- .../display_ani/src/display_ani_manager.cpp | 10 +++--- .../display_ani/src/display_ani_utils.cpp | 26 +++++++-------- .../screen_ani/src/screen_ani_manager.cpp | 8 ++--- .../screen_ani/src/screen_ani_utils.cpp | 16 +++++----- .../src/screenshot_ani_utils.cpp | 32 +++++++++---------- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp index 5ea5565237..bbe52f632f 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani.cpp @@ -50,8 +50,8 @@ void DisplayAni::GetCutoutInfo(ani_env* env, ani_object obj, ani_object cutoutIn if (ANI_OK != status) { TLOGE(WmsLogTag::DMS, "[ANI] get field bounding rects fail, ani_status = %{public}d", status); } - ani_double length; - if (ANI_OK != env->Object_GetPropertyByName_Double(static_cast(boundingRects), "length", &length)) { + ani_long length; + if (ANI_OK != env->Object_GetPropertyByName_Long(static_cast(boundingRects), "length", &length)) { TLOGE(WmsLogTag::DMS, "[ANI] get ani_array len fail"); } for (int i = 0; i < std::min(int(length), static_cast(rects.size())); i++) { @@ -73,8 +73,8 @@ void DisplayAni::GetCutoutInfo(ani_env* env, ani_object obj, ani_object cutoutIn void DisplayAni::GetAvailableArea(ani_env* env, ani_object obj, ani_object availableAreaObj) { TLOGI(WmsLogTag::DMS, "[ANI] begin"); - ani_double id; - env->Object_GetFieldByName_Double(obj, "id", &id); + ani_long id; + env->Object_GetFieldByName_Long(obj, "id", &id); auto display = SingletonContainer::Get().GetDisplayById(id); if (display == nullptr) { TLOGE(WmsLogTag::DMS, "[ANI] can not find display."); @@ -96,8 +96,8 @@ void DisplayAni::GetAvailableArea(ani_env* env, ani_object obj, ani_object avail ani_boolean DisplayAni::HasImmersiveWindow(ani_env* env, ani_object obj) { TLOGI(WmsLogTag::DMS, "[ANI] begin"); - ani_double id; - env->Object_GetFieldByName_Double(obj, "id", &id); + ani_long id; + env->Object_GetFieldByName_Long(obj, "id", &id); auto display = SingletonContainer::Get().GetDisplayById(id); if (display == nullptr) { TLOGE(WmsLogTag::DMS, "[ANI]can not find display."); diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp index 160affb2b2..ba38987f4a 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_manager.cpp @@ -106,15 +106,15 @@ void DisplayManagerAni::OnGetCurrentFoldCreaseRegion(ani_env* env, ani_object ob return; } TLOGI(WmsLogTag::DMS, "[ANI] DisplayManager GetCurrentFoldCreaseRegion success %{public}d", (int)displayId); - if (ANI_OK != env->Object_SetFieldByName_Double(obj, "displayId", (ani_double)displayId)) { + if (ANI_OK != env->Object_SetFieldByName_Long(obj, "displayId", static_cast(displayId))) { TLOGE(WmsLogTag::DMS, "[ANI] set displayId field fail"); } ani_ref creaseRectsObj{}; if (ANI_OK != env->Object_GetFieldByName_Ref(obj, "creaseRects", &creaseRectsObj)) { TLOGE(WmsLogTag::DMS, "[ANI] get ani_array len fail"); } - ani_double length; - if (ANI_OK != env->Object_GetPropertyByName_Double(static_cast(creaseRectsObj), "length", &length)) { + ani_long length; + if (ANI_OK != env->Object_GetPropertyByName_Long(static_cast(creaseRectsObj), "length", &length)) { TLOGE(WmsLogTag::DMS, "[ANI] get ani_array len fail"); } TLOGI(WmsLogTag::DMS, "[ANI] set CurrentFoldCreaseRegion property begin"); @@ -136,8 +136,8 @@ void DisplayManagerAni::GetAllDisplaysAni(ani_env* env, ani_object arrayObj) if (displays.empty()) { AniErrUtils::ThrowBusinessError(env, DmErrorCode::DM_ERROR_INVALID_SCREEN, ""); } - ani_double length; - if (ANI_OK != env->Object_GetPropertyByName_Double(arrayObj, "length", &length)) { + ani_long length; + if (ANI_OK != env->Object_GetPropertyByName_Long(arrayObj, "length", &length)) { TLOGE(WmsLogTag::DMS, "[ANI] get ani_array len fail"); } diff --git a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp index 7feeb5647c..f5b4c87da7 100644 --- a/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp +++ b/interfaces/kits/ani/display_runtime/display_ani/src/display_ani_utils.cpp @@ -54,10 +54,10 @@ void DisplayAniUtils::ConvertRect(DMRect rect, ani_object rectObj, ani_env* env) { TLOGI(WmsLogTag::DMS, "[ANI] rect area info: %{public}d, %{public}d, %{public}u, %{public}u", rect.posX_, rect.posY_, rect.width_, rect.height_); - env->Object_SetFieldByName_Double(rectObj, "left", rect.posX_); - env->Object_SetFieldByName_Double(rectObj, "width", rect.width_); - env->Object_SetFieldByName_Double(rectObj, "top", rect.posY_); - env->Object_SetFieldByName_Double(rectObj, "height", rect.height_); + env->Object_SetFieldByName_Long(rectObj, "left", rect.posX_); + env->Object_SetFieldByName_Long(rectObj, "width", rect.width_); + env->Object_SetFieldByName_Long(rectObj, "top", rect.posY_); + env->Object_SetFieldByName_Long(rectObj, "height", rect.height_); } void DisplayAniUtils::ConvertWaterArea(WaterfallDisplayAreaRects waterfallDisplayAreaRects, @@ -89,9 +89,9 @@ void DisplayAniUtils::ConvertDisplayPhysicalResolution(std::vectorObject_CallMethodByName_Ref(arrayObj, "$_get", "I:Lstd/core/Object;", &obj, (ani_int)i); env->Object_SetFieldByName_Int(static_cast(obj), "foldDisplayMode_", static_cast(displayPhysicalArray[i].foldDisplayMode_)); - env->Object_SetFieldByName_Double(static_cast(obj), "physicalWidth", + env->Object_SetFieldByName_Long(static_cast(obj), "physicalWidth", displayPhysicalArray[i].physicalWidth_); - env->Object_SetFieldByName_Double(static_cast(obj), "physicalHeight", + env->Object_SetFieldByName_Long(static_cast(obj), "physicalHeight", displayPhysicalArray[i].physicalHeight_); } } @@ -99,7 +99,7 @@ void DisplayAniUtils::ConvertDisplayPhysicalResolution(std::vector display, ani_env* env, ani_object obj) { sptr info = display->GetDisplayInfoWithCache(); - int setfieldid = env->Object_SetFieldByName_Double(obj, "id", info->GetDisplayId()); + int setfieldid = env->Object_SetFieldByName_Long(obj, "id", info->GetDisplayId()); if (ANI_OK != setfieldid) { TLOGE(WmsLogTag::DMS, "[ANI] set id failed: %{public}d", setfieldid); } @@ -115,16 +115,16 @@ ani_status DisplayAniUtils::CvtDisplay(sptr display, ani_env* env, ani_ } else { env->Object_SetFieldByName_Int(obj, "state_", 0); } - env->Object_SetFieldByName_Double(obj, "refreshRate", info->GetRefreshRate()); - env->Object_SetFieldByName_Double(obj, "rotation", static_cast(info->GetRotation())); - ani_status setfieldRes = env->Object_SetFieldByName_Double(obj, "width", + env->Object_SetFieldByName_Int(obj, "refreshRate", info->GetRefreshRate()); + env->Object_SetFieldByName_Int(obj, "rotation", static_cast(info->GetRotation())); + ani_status setfieldRes = env->Object_SetFieldByName_Long(obj, "width", static_cast(info->GetWidth())); if (ANI_OK != setfieldRes) { TLOGE(WmsLogTag::DMS, "[ANI] set failed: %{public}d, %{public}u", info->GetWidth(), setfieldRes); } - env->Object_SetFieldByName_Double(obj, "height", display->GetHeight()); - env->Object_SetFieldByName_Double(obj, "availableWidth", info->GetAvailableWidth()); - env->Object_SetFieldByName_Double(obj, "availableHeight", info->GetAvailableHeight()); + env->Object_SetFieldByName_Long(obj, "height", display->GetHeight()); + env->Object_SetFieldByName_Long(obj, "availableWidth", info->GetAvailableWidth()); + env->Object_SetFieldByName_Long(obj, "availableHeight", info->GetAvailableHeight()); env->Object_SetFieldByName_Double(obj, "densityDPI", info->GetVirtualPixelRatio() * DOT_PER_INCH); env->Object_SetFieldByName_Int(obj, "orientation_", static_cast(info->GetDisplayOrientation())); env->Object_SetFieldByName_Double(obj, "densityPixels", info->GetVirtualPixelRatio()); diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp index 3d0ec5aff5..714fc5a5b4 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_manager.cpp @@ -183,13 +183,13 @@ DMError ScreenManagerAni::UnRegisterAllScreenListenerWithType(std::string type) ani_double ScreenManagerAni::MakeMirror(ani_env* env, ani_double mainScreen, ani_object mirrorScreen) { - ani_double length = 0; + ani_long length = 0; std::vector screenIds; - env->Object_GetPropertyByName_Double(mirrorScreen, "length", &length); + env->Object_GetPropertyByName_Long(mirrorScreen, "length", &length); TLOGI(WmsLogTag::DMS, "[ANI] length %{public}d", (ani_int)length); for (uint32_t i = 0; i < length; i++) { - ani_double screenId; - if (ANI_OK != env->Object_CallMethodByName_Double(mirrorScreen, "$_get", "I:D", + ani_long screenId; + if (ANI_OK != env->Object_CallMethodByName_Long(mirrorScreen, "$_get", "I:D", &screenId, (ani_int)i)) { TLOGE(WmsLogTag::DMS, "[ANI] get ani_array index %{public}u fail", (ani_int)i); return AniErrUtils::ThrowBusinessError(env, DmErrorCode::DM_ERROR_INVALID_PARAM, "Failed to get screenId"); diff --git a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp index d3c26f9da0..8d2ee294e3 100644 --- a/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp +++ b/interfaces/kits/ani/screen_runtime/screen_ani/src/screen_ani_utils.cpp @@ -63,10 +63,10 @@ ani_status ScreenAniUtils::ConvertScreen(ani_env *env, sptr screen, ani_ { sptr info = screen->GetScreenInfo(); TLOGI(WmsLogTag::DMS, "[ANI] convert screen id %{public}u", static_cast(info->GetScreenId())); - env->Object_SetFieldByName_Double(obj, "id", static_cast(info->GetScreenId())); - env->Object_SetFieldByName_Double(obj, "parent", static_cast(info->GetParentId())); - env->Object_SetFieldByName_Double(obj, "activeModeIndex", - static_cast(info->GetModeId())); + env->Object_SetFieldByName_Long(obj, "id", static_cast(info->GetScreenId())); + env->Object_SetFieldByName_Long(obj, "parent", static_cast(info->GetParentId())); + env->Object_SetFieldByName_Long(obj, "activeModeIndex", + static_cast(info->GetModeId())); env->Object_SetFieldByName_Int(obj, "orientation_", static_cast(info->GetOrientation())); env->Object_SetFieldByName_Int(obj, "sourceMode_", static_cast(info->GetSourceMode())); std::unique_ptr screenAni = std::make_unique(screen); @@ -131,10 +131,10 @@ ani_object ScreenAniUtils::NewNativeObject(ani_env* env, const std::string& objN void ScreenAniUtils::ConvertScreenMode(ani_env* env, sptr mode, ani_object obj) { - env->Object_SetFieldByName_Double(obj, "id", static_cast(mode->id_)); - env->Object_SetFieldByName_Double(obj, "width", static_cast(mode->width_)); - env->Object_SetFieldByName_Double(obj, "height", static_cast(mode->height_)); - env->Object_SetFieldByName_Double(obj, "refreshRate", static_cast(mode->refreshRate_)); + env->Object_SetFieldByName_Long(obj, "id", static_cast(mode->id_)); + env->Object_SetFieldByName_Long(obj, "width", static_cast(mode->width_)); + env->Object_SetFieldByName_Long(obj, "height", static_cast(mode->height_)); + env->Object_SetFieldByName_Long(obj, "refreshRate", static_cast(mode->refreshRate_)); } ani_status ScreenAniUtils::ConvertScreens(ani_env *env, std::vector> screens, ani_object& screensAni) diff --git a/interfaces/kits/ani/screenshot_runtime/screenshot_ani/src/screenshot_ani_utils.cpp b/interfaces/kits/ani/screenshot_runtime/screenshot_ani/src/screenshot_ani_utils.cpp index a39e328729..5f6ef8b136 100644 --- a/interfaces/kits/ani/screenshot_runtime/screenshot_ani/src/screenshot_ani_utils.cpp +++ b/interfaces/kits/ani/screenshot_runtime/screenshot_ani/src/screenshot_ani_utils.cpp @@ -96,11 +96,11 @@ void ScreenshotAniUtils::GetScreenshotParam(ani_env *env, std::unique_ptr TLOGI(WmsLogTag::DMS, "[ANI] null param"); return; } - ani_double displayId; - env->Object_GetPropertyByName_Double(options, "displayId", &displayId); + ani_long displayId; + env->Object_GetPropertyByName_Long(options, "displayId", &displayId); param->option.displayId = static_cast(displayId); - ani_double rotation; - env->Object_GetPropertyByName_Double(options, "rotation", &rotation); + ani_int rotation; + env->Object_GetPropertyByName_Int(options, "rotation", &rotation); param->option.rotation = static_cast(rotation); ani_double isNeedNotify; env->Object_GetPropertyByName_Double(options, "isNeedNotify", &isNeedNotify); @@ -116,10 +116,10 @@ void ScreenshotAniUtils::GetScreenshotSize(ani_env *env, std::unique_ptr { ani_ref obj; env->Object_GetPropertyByName_Ref(options, "imageSize", &obj); - ani_double width; - ani_double height; - env->Object_GetPropertyByName_Double(static_cast(obj), "width", &width); - env->Object_GetPropertyByName_Double(static_cast(obj), "height", &height); + ani_long width; + ani_long height; + env->Object_GetPropertyByName_Long(static_cast(obj), "width", &width); + env->Object_GetPropertyByName_Long(static_cast(obj), "height", &height); param->option.size.width = static_cast(width); param->option.size.height = static_cast(height); TLOGI(WmsLogTag::DMS, "[ANI] get imageSize width = %{public}d, height = %{public}d", @@ -130,14 +130,14 @@ void ScreenshotAniUtils::GetScreenshotRect(ani_env *env, std::unique_ptr { ani_ref obj; env->Object_GetPropertyByName_Ref(options, "screenRect", &obj); - ani_double left; - ani_double top; - ani_double width; - ani_double height; - env->Object_GetPropertyByName_Double(static_cast(obj), "left", &left); - env->Object_GetPropertyByName_Double(static_cast(obj), "top", &top); - env->Object_GetPropertyByName_Double(static_cast(obj), "width", &width); - env->Object_GetPropertyByName_Double(static_cast(obj), "height", &height); + ani_long left; + ani_long top; + ani_long width; + ani_long height; + env->Object_GetPropertyByName_Long(static_cast(obj), "left", &left); + env->Object_GetPropertyByName_Long(static_cast(obj), "top", &top); + env->Object_GetPropertyByName_Long(static_cast(obj), "width", &width); + env->Object_GetPropertyByName_Long(static_cast(obj), "height", &height); param->option.rect.left = static_cast(left); param->option.rect.top = static_cast(top); param->option.rect.width = static_cast(width); -- Gitee