From 5b88a14c63e0e00468766a1f85f2139e03e4b650 Mon Sep 17 00:00:00 2001 From: shiyueeee Date: Thu, 10 Mar 2022 17:27:42 +0800 Subject: [PATCH] Clean codestyle issue and delete redundant files Signed-off-by: shiyueeee Change-Id: I09c6a7ccaf03493355fc6692a81747731626d6e4 --- dm/src/display.cpp | 6 ----- dmserver/BUILD.gn | 1 - dmserver/include/display_node_control.h | 25 ------------------- dmserver/src/abstract_display_controller.cpp | 19 ++++++++++---- dmserver/src/abstract_screen_controller.cpp | 4 +-- dmserver/src/display_node_control.cpp | 19 -------------- interfaces/innerkits/dm/display.h | 1 - interfaces/innerkits/dm/display_property.h | 2 +- .../kits/napi/display_runtime/js_display.cpp | 2 +- utils/include/display_info.h | 1 - utils/src/display_info.cpp | 3 +-- 11 files changed, 19 insertions(+), 64 deletions(-) delete mode 100644 dmserver/include/display_node_control.h delete mode 100644 dmserver/src/display_node_control.cpp diff --git a/dm/src/display.cpp b/dm/src/display.cpp index e23e6901..33e73c32 100644 --- a/dm/src/display.cpp +++ b/dm/src/display.cpp @@ -60,12 +60,6 @@ int32_t Display::GetHeight() const return pImpl_->GetDisplayInfo()->GetHeight(); } -uint32_t Display::GetFreshRate() const -{ - UpdateDisplayInfo(); - return pImpl_->GetDisplayInfo()->GetRefreshRate(); -} - uint32_t Display::GetRefreshRate() const { UpdateDisplayInfo(); diff --git a/dmserver/BUILD.gn b/dmserver/BUILD.gn index ca7fdfa2..018f703f 100644 --- a/dmserver/BUILD.gn +++ b/dmserver/BUILD.gn @@ -33,7 +33,6 @@ ohos_shared_library("libdms") { "src/display_manager_service.cpp", "src/display_manager_service_inner.cpp", "src/display_manager_stub.cpp", - "src/display_node_control.cpp", "src/display_power_controller.cpp", ] diff --git a/dmserver/include/display_node_control.h b/dmserver/include/display_node_control.h deleted file mode 100644 index 5da96a20..00000000 --- a/dmserver/include/display_node_control.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ - -#ifndef FOUNDATION_DMSERVER_DISPLAY_NODE_CONTROL_H -#define FOUNDATION_DMSERVER_DISPLAY_NODE_CONTROL_H - -#include - -namespace OHOS::Rosen { -class DisplayNodeControl : public RefBase { -}; -} // namespace OHOS::Rosen -#endif // FOUNDATION_DMSERVER_DISPLAY_NODE_CONTROL_H \ No newline at end of file diff --git a/dmserver/src/abstract_display_controller.cpp b/dmserver/src/abstract_display_controller.cpp index a0324151..cfd64680 100644 --- a/dmserver/src/abstract_display_controller.cpp +++ b/dmserver/src/abstract_display_controller.cpp @@ -198,6 +198,10 @@ DisplayId AbstractDisplayController::ProcessNormalScreenDisconnected( sptr absScreen, sptr screenGroup) { WLOGI("normal screen disconnect"); + if (absScreen == nullptr || screenGroup == nullptr) { + WLOGFE("Invalid params as nullptr."); + return DISPLAY_ID_INVALID; + } ScreenId defaultScreenId = abstractScreenController_->GetDefaultAbstractScreenId(); sptr defaultScreen = abstractScreenController_->GetAbstractScreen(defaultScreenId); for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) { @@ -217,7 +221,8 @@ DisplayId AbstractDisplayController::ProcessExpandScreenDisconnected( sptr absScreen, sptr screenGroup) { WLOGI("expand screen disconnect"); - if (absScreen == nullptr) { + if (absScreen == nullptr || screenGroup == nullptr) { + WLOGFE("Invalid params as nullptr."); return DISPLAY_ID_INVALID; } for (auto iter = abstractDisplayMap_.begin(); iter != abstractDisplayMap_.end(); iter++) { @@ -244,7 +249,7 @@ void AbstractDisplayController::OnAbstractScreenChange(sptr absS } else if (event == DisplayChangeEvent::DISPLAY_SIZE_CHANGED) { ProcessDisplaySizeChange(absScreen); } else { - WLOGE("unknow screen change event. id:%{public}" PRIu64" event %{public}u", absScreen->dmsId_, event); + WLOGE("unknown screen change event. id:%{public}" PRIu64" event %{public}u", absScreen->dmsId_, event); } } @@ -278,7 +283,7 @@ void AbstractDisplayController::ProcessDisplayUpdateOrientation(sptr ab bool AbstractDisplayController::UpdateDisplaySize(sptr absDisplay, sptr info) { + if (absDisplay == nullptr || info == nullptr) { + WLOGFE("invalid params."); + return false; + } if (info->height_ == static_cast(absDisplay->GetHeight()) && info->width_ == static_cast(absDisplay->GetWidth())) { - WLOGI("keep display size. display:%{public}" PRIu64"", absDisplay->GetId()); + WLOGFI("keep display size. display:%{public}" PRIu64"", absDisplay->GetId()); return false; } absDisplay->SetHeight(info->height_); absDisplay->SetWidth(info->width_); - WLOGI("update display size. id %{public}" PRIu64", size: %{public}d %{public}d", + WLOGFI("Reset H&W. id %{public}" PRIu64", size: %{public}d %{public}d", absDisplay->GetId(), absDisplay->GetWidth(), absDisplay->GetHeight()); return true; } diff --git a/dmserver/src/abstract_screen_controller.cpp b/dmserver/src/abstract_screen_controller.cpp index 395a3b71..310cbebf 100644 --- a/dmserver/src/abstract_screen_controller.cpp +++ b/dmserver/src/abstract_screen_controller.cpp @@ -337,8 +337,8 @@ bool AbstractScreenController::FillAbstractScreen(sptr& absScree sptr info = new SupportedScreenModes(); info->width_ = static_cast(rsScreenModeInfo.GetScreenWidth()); info->height_ = static_cast(rsScreenModeInfo.GetScreenHeight()); - info->refreshRate_ = rsScreenModeInfo.GetScreenFreshRate(); - absScreen->modes_.emplace_back(info); + info->refreshRate_ = rsScreenModeInfo.GetScreenRefreshRate(); + absScreen->modes_.push_back(info); WLOGD("fill screen w/h:%{public}d/%{public}d", info->width_, info->height_); } int32_t activeModeId = rsInterface_.GetScreenActiveMode(rsScreenId).GetScreenModeId(); diff --git a/dmserver/src/display_node_control.cpp b/dmserver/src/display_node_control.cpp deleted file mode 100644 index 8f821aca..00000000 --- a/dmserver/src/display_node_control.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * 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 "display_node_control.h" - -namespace OHOS::Rosen { -} // namespace OHOS::Rosen \ No newline at end of file diff --git a/interfaces/innerkits/dm/display.h b/interfaces/innerkits/dm/display.h index d516d1e8..b658d280 100644 --- a/interfaces/innerkits/dm/display.h +++ b/interfaces/innerkits/dm/display.h @@ -38,7 +38,6 @@ public: DisplayId GetId() const; int32_t GetWidth() const; int32_t GetHeight() const; - uint32_t GetFreshRate() const; uint32_t GetRefreshRate() const; ScreenId GetScreenId() const; float GetVirtualPixelRatio() const; diff --git a/interfaces/innerkits/dm/display_property.h b/interfaces/innerkits/dm/display_property.h index 74a2fd73..692eecfd 100644 --- a/interfaces/innerkits/dm/display_property.h +++ b/interfaces/innerkits/dm/display_property.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 diff --git a/interfaces/kits/napi/display_runtime/js_display.cpp b/interfaces/kits/napi/display_runtime/js_display.cpp index 0b008353..87cae811 100644 --- a/interfaces/kits/napi/display_runtime/js_display.cpp +++ b/interfaces/kits/napi/display_runtime/js_display.cpp @@ -76,7 +76,7 @@ NativeValue* CreateJsDisplayObject(NativeEngine& engine, sptr& display) object->SetProperty("id", CreateJsValue(engine, static_cast(display->GetId()))); object->SetProperty("width", CreateJsValue(engine, display->GetWidth())); object->SetProperty("height", CreateJsValue(engine, display->GetHeight())); - object->SetProperty("refreshRate", CreateJsValue(engine, display->GetFreshRate())); + object->SetProperty("refreshRate", CreateJsValue(engine, display->GetRefreshRate())); object->SetProperty("name", engine.CreateUndefined()); object->SetProperty("alive", engine.CreateUndefined()); object->SetProperty("state", engine.CreateUndefined()); diff --git a/utils/include/display_info.h b/utils/include/display_info.h index 78ecd7d1..c773f46b 100644 --- a/utils/include/display_info.h +++ b/utils/include/display_info.h @@ -36,7 +36,6 @@ public: DEFINE_VAR_DEFAULT_FUNC_GET(DisplayType, DisplayType, type, DisplayType::DEFAULT); DEFINE_VAR_DEFAULT_FUNC_GET(int32_t, Width, width, 0); DEFINE_VAR_DEFAULT_FUNC_GET(int32_t, Height, height, 0); - DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, FreshRate, freshRate, 0); DEFINE_VAR_DEFAULT_FUNC_GET(uint32_t, RefreshRate, refreshRate, 0); DEFINE_VAR_DEFAULT_FUNC_GET(ScreenId, ScreenId, screenId, SCREEN_ID_INVALID); DEFINE_VAR_DEFAULT_FUNC_GET(float, VirtualPixelRatio, virtualPixelRatio, 1.0f); diff --git a/utils/src/display_info.cpp b/utils/src/display_info.cpp index 1eed4ce8..6dea2cae 100644 --- a/utils/src/display_info.cpp +++ b/utils/src/display_info.cpp @@ -20,7 +20,7 @@ bool DisplayInfo::Marshalling(Parcel &parcel) const { return parcel.WriteUint64(id_) && parcel.WriteUint32(type_) && parcel.WriteInt32(width_) && parcel.WriteInt32(height_) && - parcel.WriteUint32(freshRate_) && parcel.WriteUint32(refreshRate_) && parcel.WriteUint64(screenId_) && + parcel.WriteUint32(refreshRate_) && parcel.WriteUint64(screenId_) && parcel.WriteFloat(virtualPixelRatio_) && parcel.WriteFloat(xDpi_) && parcel.WriteFloat(yDpi_) && parcel.WriteUint32(static_cast(rotation_)) && parcel.WriteUint32(static_cast(orientation_)); @@ -37,7 +37,6 @@ DisplayInfo *DisplayInfo::Unmarshalling(Parcel &parcel) uint32_t orientation; bool res = parcel.ReadUint64(displayInfo->id_) && parcel.ReadUint32(type) && parcel.ReadInt32(displayInfo->width_) && parcel.ReadInt32(displayInfo->height_) && - parcel.ReadUint32(displayInfo->freshRate_) && parcel.ReadUint32(displayInfo->refreshRate_) && parcel.ReadUint64(displayInfo->screenId_) && parcel.ReadFloat(displayInfo->virtualPixelRatio_) && parcel.ReadFloat(displayInfo->xDpi_) && parcel.ReadFloat(displayInfo->yDpi_) &&