已合并
DMS测试用例优化 #18008
wulong158创建于 2月6日
DMS测试用例优化 #18008
已合并
共 9 个文件变更+964-0
| @@ -0,0 +1,85 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +namespace OHOS { | ||
| 21 | +std::string system::DeviceParamMock::currentDeviceType_ = "PLR"; | ||
| 22 | +namespace Rosen { | ||
| 23 | +std::string ProductConfigMock::currentDeviceType_ = "PLR"; | ||
| 24 | + | ||
| 25 | +DmsTestBase::DmsTestBase() | ||
| 26 | +{ | ||
| 27 | + RsMockImpl::GetInstance().Init(ProductConfigMock::ResetAndGetDeviceDefaultConfig()); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +void DmsTestBase::TriggerScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason) | ||
| 31 | +{ | ||
| 32 | + RsMockImpl::GetInstance().TriggerScreenChange(screenId, screenEvent, reason); | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +void DmsTestBase::TriggerScreenConnect(ScreenId screenId) | ||
| 36 | +{ | ||
| 37 | + RsMockImpl::GetInstance().TriggerScreenChange(screenId, ScreenEvent::CONNECTED, ScreenChangeReason::DEFAULT); | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +void DmsTestBase::TriggerScreenDisconnect(ScreenId screenId) | ||
| 41 | +{ | ||
| 42 | + RsMockImpl::GetInstance().TriggerScreenChange(screenId, ScreenEvent::DISCONNECTED, ScreenChangeReason::DEFAULT); | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +bool DmsTestBase::WaitScreenConnectFinish(ScreenId screenId) | ||
| 46 | +{ | ||
| 47 | + const int32_t MAX_RETRY_CNT = 10; | ||
| 48 | + const int32_t SLEEP_TIME = 20000; | ||
| 49 | + int32_t retryCnt = 0; | ||
| 50 | + while (retryCnt < MAX_RETRY_CNT) { | ||
| 51 | + auto session = ScreenSessionManager::GetInstance().GetScreenSession(screenId); | ||
| 52 | + if (session != nullptr) { | ||
| 53 | + return true; | ||
| 54 | + } | ||
| 55 | + usleep(SLEEP_TIME); | ||
| 56 | + retryCnt++; | ||
| 57 | + }; | ||
| 58 | + | ||
| 59 | + return false; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +bool DmsTestBase::WaitScreenDisconnectFinish(ScreenId screenId) | ||
| 63 | +{ | ||
| 64 | + const int32_t MAX_RETRY_CNT = 10; | ||
| 65 | + const int32_t SLEEP_TIME = 20000; | ||
| 66 | + int32_t retryCnt = 0; | ||
| 67 | + while (retryCnt < MAX_RETRY_CNT) { | ||
| 68 | + auto session = ScreenSessionManager::GetInstance().GetScreenSession(screenId); | ||
| 69 | + if (session == nullptr) { | ||
| 70 | + return true; | ||
| 71 | + } | ||
| 72 | + usleep(SLEEP_TIME); | ||
| 73 | + retryCnt++; | ||
| 74 | + }; | ||
| 75 | + | ||
| 76 | + return false; | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +bool DmsTestBase::CreatScreen(ScreenId screenId) | ||
| 80 | +{ | ||
| 81 | + TriggerScreenConnect(screenId); | ||
| 82 | + return WaitScreenConnectFinish(screenId); | ||
| 83 | +} | ||
| 84 | +} // namespace Rosen | ||
| 85 | +} // namespace OHOS | ||
| @@ -0,0 +1,136 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +namespace OHOS { | ||
| 32 | +namespace Rosen { | ||
| 33 | + | ||
| 34 | +class ScreenSessionManagerClientMock : public IRemoteStub<IScreenSessionManagerClient> { | ||
| 35 | +public: | ||
| 36 | + MOCK_METHOD(void, SwitchUserCallback, (std::vector<int32_t> oldScbPids, int32_t currentScbPid), (override)); | ||
| 37 | + MOCK_METHOD(void, OnScreenConnectionChanged, (SessionOption option, ScreenEvent screenEvent), (override)); | ||
| 38 | + MOCK_METHOD(void, OnPropertyChanged, | ||
| 39 | + (ScreenId screenId, const ScreenProperty& property, ScreenPropertyChangeReason reason), (override)); | ||
| 40 | + MOCK_METHOD(bool, OnFoldPropertyChange, | ||
| 41 | + (ScreenId screenId, const ScreenProperty& property, ScreenPropertyChangeReason reason, | ||
| 42 | + FoldDisplayMode displayMode, ScreenProperty& midProperty), | ||
| 43 | + (override)); | ||
| 44 | + MOCK_METHOD(void, OnPowerStatusChanged, | ||
| 45 | + (DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason), (override)); | ||
| 46 | + MOCK_METHOD(void, OnSensorRotationChanged, (ScreenId screenId, float sensorRotation, bool isSwitchUser), | ||
| 47 | + (override)); | ||
| 48 | + MOCK_METHOD(void, OnHoverStatusChanged, (ScreenId screenId, int32_t hoverStatus, bool needRotate), (override)); | ||
| 49 | + MOCK_METHOD(void, OnScreenOrientationChanged, (ScreenId screenId, float screenOrientation), (override)); | ||
| 50 | + MOCK_METHOD(void, OnScreenRotationLockedChanged, (ScreenId screenId, bool isLocked), (override)); | ||
| 51 | + MOCK_METHOD(void, OnScreenExtendChanged, (ScreenId mainScreenId, ScreenId extendScreenId), (override)); | ||
| 52 | + MOCK_METHOD(void, OnSuperFoldStatusChanged, (ScreenId screenId, SuperFoldStatus superFoldStatus), (override)); | ||
| 53 | + MOCK_METHOD(void, OnSecondaryReflexionChanged, (ScreenId screenId, bool isSecondaryReflexion), (override)); | ||
| 54 | + MOCK_METHOD(void, OnBeforeScreenPropertyChanged, (FoldStatus foldStatus), (override)); | ||
| 55 | + MOCK_METHOD(void, OnDisplayStateChanged, | ||
| 56 | + (DisplayId defaultDisplayId, sptr<DisplayInfo> displayInfo, | ||
| 57 | + (const std::map<DisplayId, sptr<DisplayInfo>>&)displayInfoMap, DisplayStateChangeType type), | ||
| 58 | + (override)); | ||
| 59 | + MOCK_METHOD(void, OnScreenshot, (DisplayId displayId), (override)); | ||
| 60 | + MOCK_METHOD(void, OnImmersiveStateChanged, (ScreenId screenId, bool& immersive), (override)); | ||
| 61 | + MOCK_METHOD(void, SetDisplayNodeScreenId, (ScreenId screenId, ScreenId displayNodeScreenId), (override)); | ||
| 62 | + MOCK_METHOD(void, OnGetSurfaceNodeIdsFromMissionIdsChanged, | ||
| 63 | + (std::vector<uint64_t> & missionIds, std::vector<uint64_t>& surfaceNodeIds, | ||
| 64 | + const std::vector<uint32_t>& needWindowTypeList, bool isNeedForceCheck), | ||
| 65 | + (override)); | ||
| 66 | + MOCK_METHOD(void, OnSetSurfaceNodeIdsChanged, (DisplayId displayId, const std::vector<uint64_t>& surfaceNodeIds), | ||
| 67 | + (override)); | ||
| 68 | + MOCK_METHOD(void, OnVirtualScreenDisconnected, (DisplayId displayId), (override)); | ||
| 69 | + MOCK_METHOD(void, OnUpdateFoldDisplayMode, (FoldDisplayMode displayMode), (override)); | ||
| 70 | + MOCK_METHOD(void, SetVirtualPixelRatioSystem, (ScreenId screenId, float virtualPixelRatio), (override)); | ||
| 71 | + MOCK_METHOD(void, OnFoldStatusChangedReportUE, (const std::vector<std::string>& screenFoldInfo), (override)); | ||
| 72 | + MOCK_METHOD(void, ScreenCaptureNotify, (ScreenId mainScreenId, int32_t uid, const std::string& clientName), | ||
| 73 | + (override)); | ||
| 74 | + MOCK_METHOD(void, OnCameraBackSelfieChanged, (ScreenId screenId, bool isCameraBackSelfie), (override)); | ||
| 75 | + MOCK_METHOD(void, OnExtendScreenConnectStatusChanged, | ||
| 76 | + (ScreenId screenId, ExtendScreenConnectStatus extendScreenConnectStatus), (override)); | ||
| 77 | + MOCK_METHOD(bool, OnExtendDisplayNodeChange, (ScreenId mainScreenId, ScreenId extendScreenId), (override)); | ||
| 78 | + MOCK_METHOD(bool, OnCreateScreenSessionOnly, | ||
| 79 | + (ScreenId screenId, ScreenId rsId, const std::string& name, bool isExtend), (override)); | ||
| 80 | + MOCK_METHOD(bool, OnMainDisplayNodeChange, (ScreenId mainScreenId, ScreenId extendScreenId, ScreenId extendRSId), | ||
| 81 | + (override)); | ||
| 82 | + MOCK_METHOD(void, SetScreenCombination, | ||
| 83 | + (ScreenId mainScreenId, ScreenId extendScreenId, ScreenCombination extendCombination), (override)); | ||
| 84 | + MOCK_METHOD(std::string, OnDumperClientScreenSessions, (), (override)); | ||
| 85 | + MOCK_METHOD(void, OnScreenModeChanged, (ScreenModeChangeEvent screenModeChangeEvent), (override)); | ||
| 86 | + MOCK_METHOD(void, OnAnimationFinish, (), (override)); | ||
| 87 | + MOCK_METHOD(void, SetInternalClipToBounds, (ScreenId screenId, bool clipToBounds), (override)); | ||
| 88 | + MOCK_METHOD(void, OnTentModeChange, (TentMode tentMode), (override)); | ||
| 89 | +}; | ||
| 90 | + | ||
| 91 | +class DisplayManagerAgentMock : public IRemoteStub<IDisplayManagerAgent> { | ||
| 92 | +public: | ||
| 93 | + MOCK_METHOD(void, NotifyDisplayPowerEvent, (DisplayPowerEvent event, EventStatus status), (override)); | ||
| 94 | + MOCK_METHOD(void, NotifyDisplayStateChanged, (DisplayId id, DisplayState state), (override)); | ||
| 95 | + MOCK_METHOD(void, OnScreenConnect, (sptr<ScreenInfo> screenInfo), (override)); | ||
| 96 | + MOCK_METHOD(void, OnScreenDisconnect, (ScreenId screenId), (override)); | ||
| 97 | + MOCK_METHOD(void, OnScreenChange, (const sptr<ScreenInfo>& screenInfo, ScreenChangeEvent event), (override)); | ||
| 98 | + MOCK_METHOD(void, OnScreenGroupChange, | ||
| 99 | + (const std::string& trigger, const std::vector<sptr<ScreenInfo>>& info, ScreenGroupChangeEvent event), | ||
| 100 | + (override)); | ||
| 101 | + MOCK_METHOD(void, OnDisplayCreate, (sptr<DisplayInfo> info), (override)); | ||
| 102 | + MOCK_METHOD(void, OnDisplayDestroy, (DisplayId displayId), (override)); | ||
| 103 | + MOCK_METHOD(void, OnDisplayChange, (sptr<DisplayInfo> info, DisplayChangeEvent event), (override)); | ||
| 104 | + MOCK_METHOD(void, OnScreenshot, (sptr<ScreenshotInfo> info), (override)); | ||
| 105 | + MOCK_METHOD(void, NotifyPrivateWindowStateChanged, (bool hasPrivate), (override)); | ||
| 106 | + MOCK_METHOD(void, NotifyPrivateStateWindowListChanged, (DisplayId id, std::vector<std::string> privacyWindowList), | ||
| 107 | + (override)); | ||
| 108 | + MOCK_METHOD(void, NotifyFoldStatusChanged, (FoldStatus status), (override)); | ||
| 109 | + MOCK_METHOD(void, NotifyFoldAngleChanged, (std::vector<float> foldAngles), (override)); | ||
| 110 | + MOCK_METHOD(void, NotifyCaptureStatusChanged, (bool isCapture), (override)); | ||
| 111 | + MOCK_METHOD(void, NotifyDisplayChangeInfoChanged, (const sptr<DisplayChangeInfo>& info), (override)); | ||
| 112 | + MOCK_METHOD(void, NotifyDisplayModeChanged, (FoldDisplayMode mode), (override)); | ||
| 113 | + MOCK_METHOD(void, NotifyAvailableAreaChanged, (DMRect rect, DisplayId displayId), (override)); | ||
| 114 | + MOCK_METHOD(void, NotifyScreenMagneticStateChanged, (bool isMagneticState), (override)); | ||
| 115 | + MOCK_METHOD(void, NotifyScreenModeChange, (const std::vector<sptr<ScreenInfo>>& screenInfos), (override)); | ||
| 116 | + MOCK_METHOD(void, NotifyAbnormalScreenConnectChange, (ScreenId screenId), (override)); | ||
| 117 | + MOCK_METHOD(void, NotifyBrightnessInfoChanged, (ScreenId screenId, const ScreenBrightnessInfo& info), (override)); | ||
| 118 | + MOCK_METHOD(void, OnDisplayAttributeChange, | ||
| 119 | + (sptr<DisplayInfo> displayInfo, const std::vector<std::string>& attributes), (override)); | ||
| 120 | +}; | ||
| 121 | + | ||
| 122 | +class DmsTestBase : public testing::Test { | ||
| 123 | +public: | ||
| 124 | + DmsTestBase(); | ||
| 125 | + void TriggerScreenChange(ScreenId screenId, ScreenEvent screenEvent, ScreenChangeReason reason); | ||
| 126 | + void TriggerScreenConnect(ScreenId screenId); | ||
| 127 | + void TriggerScreenDisconnect(ScreenId screenId); | ||
| 128 | + bool WaitScreenConnectFinish(ScreenId screenId); | ||
| 129 | + bool WaitScreenDisconnectFinish(ScreenId screenId); | ||
| 130 | + | ||
| 131 | + bool CreatScreen(ScreenId screenId); | ||
| 132 | +}; | ||
| 133 | + | ||
| 134 | +} // namespace Rosen | ||
| 135 | +} // namespace OHOS | ||
| 136 | + | ||
| @@ -0,0 +1,93 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +int WatchParameter(const char* keyprefix, ParameterChgPtr callback, void* context) | ||
| 21 | +{ | ||
| 22 | + return 0; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +namespace OHOS { | ||
| 26 | +namespace system { | ||
| 27 | + | ||
| 28 | +DeviceParamMock& DeviceParamMock::GetInstance() | ||
| 29 | +{ | ||
| 30 | + static DeviceParamMock instance; | ||
| 31 | + return instance; | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +std::map<std::string, std::string> DeviceParamMock::GetDeviceParam() | ||
| 35 | +{ | ||
| 36 | + std::unique_lock<std::mutex> lock(paramMutex_); | ||
| 37 | + if (!deviceParam_.empty()) { | ||
| 38 | + return deviceParam_; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + if (currentDeviceType_ == "PLR") { | ||
| 42 | + deviceParam_ = {{"const.logsystem.versiontype", "beta"}, | ||
| 43 | + {"const.product.devicetype", "phone"}, | ||
| 44 | + {"const.product.real_device_radius", "beta"}}; | ||
| 45 | + } | ||
| 46 | + return deviceParam_; | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +void DeviceParamMock::SetDeviceParam(const std::string& key, const std::string& value) | ||
| 50 | +{ | ||
| 51 | + std::unique_lock<std::mutex> lock(paramMutex_); | ||
| 52 | + deviceParam_[key] = value; | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +std::string GetParameter(const std::string& key, const std::string& def) | ||
| 56 | +{ | ||
| 57 | + const auto& config = DeviceParamMock::GetInstance().GetDeviceParam(); | ||
| 58 | + auto findIt = config.find(key); | ||
| 59 | + if (findIt != config.end()) { | ||
| 60 | + return findIt->second; | ||
| 61 | + } | ||
| 62 | + return def; | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +bool GetBoolParameter(const std::string& key, bool def) | ||
| 66 | +{ | ||
| 67 | + return true; | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +template <typename T> | ||
| 71 | +T GetIntParameter(const std::string& key, T def, T min, T max) | ||
| 72 | +{ | ||
| 73 | + return def; | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +template <typename T> | ||
| 77 | +T GetUintParameter(const std::string& key, T def, T max) | ||
| 78 | +{ | ||
| 79 | + return def; | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +bool SetParameter(const std::string& key, const std::string& value) | ||
| 83 | +{ | ||
| 84 | + DeviceParamMock::GetInstance().SetDeviceParam(key, value); | ||
| 85 | + return true; | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +std::string GetDeviceType(void) | ||
| 89 | +{ | ||
| 90 | + return ""; | ||
| 91 | +} | ||
| 92 | +} // namespace system | ||
| 93 | +} // namespace OHOS | ||
| @@ -0,0 +1,33 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +extern "C" { | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +typedef void (*ParameterChgPtr)(const char* key, const char* value, void* context); | ||
| 25 | +int WatchParameter(const char* keyprefix, ParameterChgPtr callback, void* contex); | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| @@ -0,0 +1,58 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +namespace OHOS { | ||
| 25 | +namespace system { | ||
| 26 | + | ||
| 27 | +class DeviceParamMock { | ||
| 28 | +public: | ||
| 29 | + DeviceParamMock() = default; | ||
| 30 | + ~DeviceParamMock() = default; | ||
| 31 | + static DeviceParamMock& GetInstance(); | ||
| 32 | + std::map<std::string, std::string> GetDeviceParam(); | ||
| 33 | + void SetDeviceParam(const std::string& key, const std::string& value); | ||
| 34 | + static std::string currentDeviceType_; | ||
| 35 | + | ||
| 36 | +private: | ||
| 37 | + std::map<std::string, std::string> deviceParam_; | ||
| 38 | + std::mutex paramMutex_; | ||
| 39 | +}; | ||
| 40 | + | ||
| 41 | +std::string GetParameter(const std::string& key, const std::string& def); | ||
| 42 | + | ||
| 43 | +bool GetBoolParameter(const std::string& key, bool def); | ||
| 44 | + | ||
| 45 | +template <typename T> | ||
| 46 | +T GetIntParameter(const std::string& key, T def, T min = std::numeric_limits<T>::min(), | ||
| 47 | + T max = std::numeric_limits<T>::max()); | ||
| 48 | + | ||
| 49 | +template <typename T> | ||
| 50 | +T GetUintParameter(const std::string& key, T def, T max = std::numeric_limits<T>::max()); | ||
| 51 | + | ||
| 52 | +bool SetParameter(const std::string& key, const std::string& value); | ||
| 53 | +std::string GetDeviceType(void); | ||
| 54 | + | ||
| 55 | +} // namespace system | ||
| 56 | +} // namespace OHOS | ||
| 57 | + | ||
| 58 | + | ||
| @@ -0,0 +1,32 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +namespace OHOS { | ||
| 19 | +namespace Rosen { | ||
| 20 | +bool SceneBoardJudgement::IsSceneBoardEnabled() | ||
| 21 | +{ | ||
| 22 | + return true; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +std::ifstream& SceneBoardJudgement::SafeGetLine(std::ifstream& configFile, std::string& line) | ||
| 26 | +{ | ||
| 27 | + return configFile; | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +void SceneBoardJudgement::IintWithConfigFile(const char* filePath, bool& enabled) {} | ||
| 31 | +} // namespace Rosen | ||
| 32 | +} // namespace OHOS | ||
| @@ -0,0 +1,349 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +namespace OHOS::Rosen { | ||
| 19 | +namespace { | ||
| 20 | +constexpr uint32_t NO_EARTERFALL_DISPLAY_COMPRESSION_SIZE = 0; | ||
| 21 | +constexpr uint32_t DISPLAY_PHYSICAL_SIZE = 2; | ||
| 22 | +constexpr uint32_t SCROLLABLE_PARAM_SIZE = 2; | ||
| 23 | +enum XmlNodeElement { | ||
| 24 | + DPI = 0, | ||
| 25 | + SUB_DPI, | ||
| 26 | + IS_WATERFALL_DISPLAY, | ||
| 27 | + CURVED_SCREEN_BOUNDARY, | ||
| 28 | + CURVED_AREA_IN_LANDSCAPE, | ||
| 29 | + IS_CURVED_COMPRESS_ENABLED, | ||
| 30 | + IS_CONCURRENT_USER, | ||
| 31 | + BUILD_IN_DEFAULT_ORIENTATION, | ||
| 32 | + DEFAULT_DEVICE_ROTATION_OFFSET, | ||
| 33 | + DEFAULT_DISPLAY_CUTOUT_PATH, | ||
| 34 | + SUB_DISPLAY_CUTOUT_PATH, | ||
| 35 | + HALL_SWITCH_APP, | ||
| 36 | + PACKAGE_NAME, | ||
| 37 | + ROTATION_POLICY, | ||
| 38 | + DEFAULT_ROTATION_POLICY, | ||
| 39 | + SCREEN_SNAPSHOT_BUNDLE_NAME, | ||
| 40 | + SCREEN_SNAPSHOT_ABILITY_NAME, | ||
| 41 | + IS_RIGHT_POWER_BUTTON, | ||
| 42 | + SUPPORT_ROTATE_WITH_SCREEN, | ||
| 43 | + EXTERNAL_SCREEN_DEFAULT_MODE, | ||
| 44 | + CAST_BUNDLE_NAME, | ||
| 45 | + CAST_ABILITY_NAME, | ||
| 46 | + PHYSICAL_DISPLAY_RESOLUTION, | ||
| 47 | + SCROLLABLE_PARAM, | ||
| 48 | + IS_SUPPORT_CAPTURE, | ||
| 49 | + IS_SUPPORT_OFFSCREEN_RENDERING, | ||
| 50 | + OFF_SCREEN_PPI_THRESHOLD, | ||
| 51 | + PC_MODE_DPI, | ||
| 52 | + SUPPORT_DURING_CALL, | ||
| 53 | + HALF_FOLDED_MAX_THRESHOLD, | ||
| 54 | + CLOSE_HALF_FOLDED_MIN_THRESHOLD, | ||
| 55 | + OPEN_HALF_FOLDED_MIN_THRESHOLD, | ||
| 56 | + HALF_FOLDED_BUFFER, | ||
| 57 | + LARGER_BOUNDARY_FOR_THRESHOLD, | ||
| 58 | + POSTURE_SIZE, | ||
| 59 | + HALL_SIZE, | ||
| 60 | + WAIT_COORDINATION_READY_MAX_TIME, | ||
| 61 | +}; | ||
| 62 | +} // namespace | ||
| 63 | + | ||
| 64 | +std::map<std::string, bool> ScreenSceneConfig::enableConfig_; | ||
| 65 | +std::map<std::string, std::vector<int>> ScreenSceneConfig::intNumbersConfig_; | ||
| 66 | +std::map<std::string, std::string> ScreenSceneConfig::stringConfig_; | ||
| 67 | +std::map<std::string, std::vector<std::string>> ScreenSceneConfig::stringListConfig_; | ||
| 68 | +std::map<uint64_t, std::vector<DMRect>> ScreenSceneConfig::defaultCutoutBoundaryRectMap_; | ||
| 69 | +std::map<uint64_t, std::vector<DMRect>> ScreenSceneConfig::cutoutBoundaryRectMap_; | ||
| 70 | +std::vector<DisplayPhysicalResolution> ScreenSceneConfig::displayPhysicalResolution_; | ||
| 71 | +std::map<FoldDisplayMode, ScrollableParam> ScreenSceneConfig::scrollableParams_; | ||
| 72 | +std::vector<DisplayConfig> ScreenSceneConfig::displaysConfigs_; | ||
| 73 | +std::vector<DMRect> ScreenSceneConfig::subCutoutBoundaryRect_; | ||
| 74 | +bool ScreenSceneConfig::isWaterfallDisplay_ = false; | ||
| 75 | +bool ScreenSceneConfig::isSupportCapture_ = false; | ||
| 76 | +bool ScreenSceneConfig::isScreenCompressionEnableInLandscape_ = false; | ||
| 77 | +bool ScreenSceneConfig::isSupportOffScreenRendering_ = false; | ||
| 78 | +bool ScreenSceneConfig::isConcurrentUser_ = false; | ||
| 79 | +uint32_t ScreenSceneConfig::curvedAreaInLandscape_ = 0; | ||
| 80 | +uint32_t ScreenSceneConfig::offScreenPPIThreshold_ = 0; | ||
| 81 | +std::map<int32_t, std::string> ScreenSceneConfig::xmlNodeMap_ = { | ||
| 82 | + {DPI, "dpi"}, | ||
| 83 | + {SUB_DPI, "subDpi"}, | ||
| 84 | + {IS_WATERFALL_DISPLAY, "isWaterfallDisplay"}, | ||
| 85 | + {IS_CONCURRENT_USER, "concurrentUser"}, | ||
| 86 | + {CURVED_SCREEN_BOUNDARY, "curvedScreenBoundary"}, | ||
| 87 | + {CURVED_AREA_IN_LANDSCAPE, "waterfallAreaCompressionSizeWhenHorzontal"}, | ||
| 88 | + {IS_CURVED_COMPRESS_ENABLED, "isWaterfallAreaCompressionEnableWhenHorizontal"}, | ||
| 89 | + {BUILD_IN_DEFAULT_ORIENTATION, "buildInDefaultOrientation"}, | ||
| 90 | + {DEFAULT_DEVICE_ROTATION_OFFSET, "defaultDeviceRotationOffset"}, | ||
| 91 | + {DEFAULT_DISPLAY_CUTOUT_PATH, "defaultDisplayCutoutPath"}, | ||
| 92 | + {SUB_DISPLAY_CUTOUT_PATH, "subDisplayCutoutPath"}, | ||
| 93 | + {HALL_SWITCH_APP, "hallSwitchApp"}, | ||
| 94 | + {PACKAGE_NAME, "packageName"}, | ||
| 95 | + {ROTATION_POLICY, "rotationPolicy"}, | ||
| 96 | + {DEFAULT_ROTATION_POLICY, "defaultRotationPolicy"}, | ||
| 97 | + {SCREEN_SNAPSHOT_BUNDLE_NAME, "screenSnapshotBundleName"}, | ||
| 98 | + {SCREEN_SNAPSHOT_ABILITY_NAME, "screenSnapshotAbilityName"}, | ||
| 99 | + {IS_RIGHT_POWER_BUTTON, "isRightPowerButton"}, | ||
| 100 | + {SUPPORT_ROTATE_WITH_SCREEN, "supportRotateWithSensor"}, | ||
| 101 | + {EXTERNAL_SCREEN_DEFAULT_MODE, "externalScreenDefaultMode"}, | ||
| 102 | + {CAST_BUNDLE_NAME, "castBundleName"}, | ||
| 103 | + {CAST_ABILITY_NAME, "castAbilityName"}, | ||
| 104 | + {PHYSICAL_DISPLAY_RESOLUTION, "physicalDisplayResolution"}, | ||
| 105 | + {SCROLLABLE_PARAM, "scrollableParam"}, | ||
| 106 | + {IS_SUPPORT_CAPTURE, "isSupportCapture"}, | ||
| 107 | + {IS_SUPPORT_OFFSCREEN_RENDERING, "isSupportOffScreenRendering"}, | ||
| 108 | + {OFF_SCREEN_PPI_THRESHOLD, "offScreenPPIThreshold"}, | ||
| 109 | + {PC_MODE_DPI, "pcModeDpi"}, | ||
| 110 | + {SUPPORT_DURING_CALL, "supportDuringCall"}, | ||
| 111 | + {HALF_FOLDED_MAX_THRESHOLD, "halfFoldMaxThreshold"}, | ||
| 112 | + {CLOSE_HALF_FOLDED_MIN_THRESHOLD, "closeHalfFoldedMinThreshold"}, | ||
| 113 | + {OPEN_HALF_FOLDED_MIN_THRESHOLD, "openHalfFoldedMinThreshold"}, | ||
| 114 | + {HALF_FOLDED_BUFFER, "halfFoldedBuffer"}, | ||
| 115 | + {LARGER_BOUNDARY_FOR_THRESHOLD, "largerBoundaryForThreshold"}, | ||
| 116 | + {POSTURE_SIZE, "postureSize"}, | ||
| 117 | + {HALL_SIZE, "hallSize"}, | ||
| 118 | + {WAIT_COORDINATION_READY_MAX_TIME, "waitCoordinationReadyMaxTime"}}; | ||
| 119 | + | ||
| 120 | +std::vector<std::string> ScreenSceneConfig::Split(std::string str, std::string pattern) | ||
| 121 | +{ | ||
| 122 | + return {}; | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +bool ScreenSceneConfig::IsNumber(std::string str) | ||
| 126 | +{ | ||
| 127 | + return true; | ||
| 128 | +} | ||
| 129 | + | ||
| 130 | +std::string ScreenSceneConfig::GetConfigPath(const std::string& configFileName) | ||
| 131 | +{ | ||
| 132 | + return ""; | ||
| 133 | +} | ||
| 134 | + | ||
| 135 | +bool ScreenSceneConfig::LoadConfigXml() | ||
| 136 | +{ | ||
| 137 | + return true; | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +void ScreenSceneConfig::ParseNodeConfig(const xmlNodePtr& currNode) {} | ||
| 141 | + | ||
| 142 | +uint64_t ScreenSceneConfig::ParseStrToUll(const std::string& contentStr) | ||
| 143 | +{ | ||
| 144 | + return 0; | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +void ScreenSceneConfig::ParseDisplaysConfig(const xmlNodePtr& currNode) {} | ||
| 148 | + | ||
| 149 | +bool ScreenSceneConfig::ParseFlagsConfig(const xmlNodePtr& flagsNode, DisplayFlag& outFlag) | ||
| 150 | +{ | ||
| 151 | + return true; | ||
| 152 | +} | ||
| 153 | + | ||
| 154 | +bool ScreenSceneConfig::IsValidNode(const xmlNode& currNode) | ||
| 155 | +{ | ||
| 156 | + return true; | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +void ScreenSceneConfig::ReadIntNumbersConfigInfo(const xmlNodePtr& currNode) {} | ||
| 160 | + | ||
| 161 | +// LCOV_EXCL_START | ||
| 162 | +void ScreenSceneConfig::ReadPhysicalDisplayConfigInfo(const xmlNodePtr& currNode) {} | ||
| 163 | +// LCOV_EXCL_STOP | ||
| 164 | + | ||
| 165 | +std::vector<DisplayPhysicalResolution> ScreenSceneConfig::GetAllDisplayPhysicalConfig() | ||
| 166 | +{ | ||
| 167 | + return displayPhysicalResolution_; | ||
| 168 | +} | ||
| 169 | + | ||
| 170 | +// LCOV_EXCL_START | ||
| 171 | +FoldDisplayMode ScreenSceneConfig::GetFoldDisplayMode(uint32_t width, uint32_t height) | ||
| 172 | +{ | ||
| 173 | + return FoldDisplayMode::UNKNOWN; | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +void ScreenSceneConfig::ReadScrollableParam(const xmlNodePtr& currNode) {} | ||
| 177 | + | ||
| 178 | +std::map<FoldDisplayMode, ScrollableParam> ScreenSceneConfig::GetAllScrollableParam() | ||
| 179 | +{ | ||
| 180 | + return scrollableParams_; | ||
| 181 | +} | ||
| 182 | +// LCOV_EXCL_STOP | ||
| 183 | + | ||
| 184 | +void ScreenSceneConfig::ReadEnableConfigInfo(const xmlNodePtr& currNode) {} | ||
| 185 | + | ||
| 186 | +void ScreenSceneConfig::ReadStringConfigInfo(const xmlNodePtr& currNode) {} | ||
| 187 | + | ||
| 188 | +// LCOV_EXCL_START | ||
| 189 | +void ScreenSceneConfig::ReadStringListConfigInfo(const xmlNodePtr& rootNode, std::string name) {} | ||
| 190 | +// LCOV_EXCL_STOP | ||
| 191 | + | ||
| 192 | +const std::map<std::string, bool>& ScreenSceneConfig::GetEnableConfig() | ||
| 193 | +{ | ||
| 194 | + return enableConfig_; | ||
| 195 | +} | ||
| 196 | + | ||
| 197 | +const std::map<std::string, std::vector<int>>& ScreenSceneConfig::GetIntNumbersConfig() | ||
| 198 | +{ | ||
| 199 | + return intNumbersConfig_; | ||
| 200 | +} | ||
| 201 | + | ||
| 202 | +const std::map<std::string, std::string>& ScreenSceneConfig::GetStringConfig() | ||
| 203 | +{ | ||
| 204 | + return stringConfig_; | ||
| 205 | +} | ||
| 206 | + | ||
| 207 | +const std::map<std::string, std::vector<std::string>>& ScreenSceneConfig::GetStringListConfig() | ||
| 208 | +{ | ||
| 209 | + return stringListConfig_; | ||
| 210 | +} | ||
| 211 | + | ||
| 212 | +const std::vector<DisplayConfig>& ScreenSceneConfig::GetDisplaysConfigs() | ||
| 213 | +{ | ||
| 214 | + return displaysConfigs_; | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +void ScreenSceneConfig::DumpConfig() {} | ||
| 218 | + | ||
| 219 | +void ScreenSceneConfig::DumpDisplaysConfigs() {} | ||
| 220 | + | ||
| 221 | +// LCOV_EXCL_START | ||
| 222 | +void ScreenSceneConfig::SetCutoutSvgPath(uint64_t displayId, const std::string& svgPath) | ||
| 223 | +{ | ||
| 224 | + if (svgPath.empty()) { | ||
| 225 | + return; | ||
| 226 | + } | ||
| 227 | + defaultCutoutBoundaryRectMap_.clear(); | ||
| 228 | + defaultCutoutBoundaryRectMap_[displayId].emplace_back(CalcCutoutBoundaryRect(svgPath)); | ||
| 229 | + cutoutBoundaryRectMap_.clear(); | ||
| 230 | + cutoutBoundaryRectMap_[displayId].emplace_back(CalcCutoutBoundaryRect(svgPath)); | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +void ScreenSceneConfig::UpdateCutoutBoundRect(uint64_t displayId, float rogRatio) | ||
| 234 | +{ | ||
| 235 | + if (defaultCutoutBoundaryRectMap_.count(displayId) == 0 || cutoutBoundaryRectMap_.count(displayId) == 0) { | ||
| 236 | + return; | ||
| 237 | + } | ||
| 238 | + for (uint64_t i = 0; i < cutoutBoundaryRectMap_[displayId].size(); i++) { | ||
| 239 | + cutoutBoundaryRectMap_[displayId][i].posX_ = defaultCutoutBoundaryRectMap_[displayId][i].posX_ * rogRatio; | ||
| 240 | + cutoutBoundaryRectMap_[displayId][i].posY_ = defaultCutoutBoundaryRectMap_[displayId][i].posY_ * rogRatio; | ||
| 241 | + cutoutBoundaryRectMap_[displayId][i].width_ = defaultCutoutBoundaryRectMap_[displayId][i].width_ * rogRatio; | ||
| 242 | + cutoutBoundaryRectMap_[displayId][i].height_ = defaultCutoutBoundaryRectMap_[displayId][i].height_ * rogRatio; | ||
| 243 | + } | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | +void ScreenSceneConfig::SetSubCutoutSvgPath(const std::string& svgPath) | ||
| 247 | +{ | ||
| 248 | + if (svgPath.empty()) { | ||
| 249 | + return; | ||
| 250 | + } | ||
| 251 | + subCutoutBoundaryRect_.clear(); | ||
| 252 | + subCutoutBoundaryRect_.emplace_back(CalcCutoutBoundaryRect(svgPath)); | ||
| 253 | +} | ||
| 254 | + | ||
| 255 | +DMRect ScreenSceneConfig::CalcCutoutBoundaryRect(std::string svgPath) | ||
| 256 | +{ | ||
| 257 | + DMRect emptyRect = { 0, 0, 0, 0 }; | ||
| 258 | + return cutoutMinOuterRect; | ||
| 259 | +} | ||
| 260 | + | ||
| 261 | +std::vector<DMRect> ScreenSceneConfig::GetCutoutBoundaryRect(uint64_t displayId) | ||
| 262 | +{ | ||
| 263 | + if (cutoutBoundaryRectMap_.count(displayId) == 0) { | ||
| 264 | + return {}; | ||
| 265 | + } | ||
| 266 | + return cutoutBoundaryRectMap_[displayId]; | ||
| 267 | +} | ||
| 268 | + | ||
| 269 | +std::vector<DMRect> ScreenSceneConfig::GetSubCutoutBoundaryRect() | ||
| 270 | +{ | ||
| 271 | + return subCutoutBoundaryRect_; | ||
| 272 | +} | ||
| 273 | + | ||
| 274 | +bool ScreenSceneConfig::IsWaterfallDisplay() | ||
| 275 | +{ | ||
| 276 | + return isWaterfallDisplay_; | ||
| 277 | +} | ||
| 278 | + | ||
| 279 | +bool ScreenSceneConfig::IsSupportCapture() | ||
| 280 | +{ | ||
| 281 | + return isSupportCapture_; | ||
| 282 | +} | ||
| 283 | + | ||
| 284 | +void ScreenSceneConfig::SetCurvedCompressionAreaInLandscape() {} | ||
| 285 | + | ||
| 286 | +std::vector<int> ScreenSceneConfig::GetCurvedScreenBoundaryConfig() | ||
| 287 | +{ | ||
| 288 | + return intNumbersConfig_[xmlNodeMap_[CURVED_SCREEN_BOUNDARY]]; | ||
| 289 | +} | ||
| 290 | + | ||
| 291 | +uint32_t ScreenSceneConfig::GetCurvedCompressionAreaInLandscape() | ||
| 292 | +{ | ||
| 293 | + if (!isWaterfallDisplay_ || !isScreenCompressionEnableInLandscape_) { | ||
| 294 | + return NO_WATERFALL_DISPLAY_COMPRESSION_SIZE; | ||
| 295 | + } | ||
| 296 | + return curvedAreaInLandscape_; | ||
| 297 | +} | ||
| 298 | + | ||
| 299 | +bool ScreenSceneConfig::IsSupportRotateWithSensor() | ||
| 300 | +{ | ||
| 301 | + if (enableConfig_.count("supportRotateWithSensor") != 0) { | ||
| 302 | + return static_cast<bool>(enableConfig_["supportRotateWithSensor"]); | ||
| 303 | + } | ||
| 304 | + return false; | ||
| 305 | +} | ||
| 306 | +std::string ScreenSceneConfig::GetExternalScreenDefaultMode() | ||
| 307 | +{ | ||
| 308 | + if (stringConfig_.count("externalScreenDefaultMode") != 0) { | ||
| 309 | + return static_cast<std::string>(stringConfig_["externalScreenDefaultMode"]); | ||
| 310 | + } | ||
| 311 | + return ""; | ||
| 312 | +} | ||
| 313 | + | ||
| 314 | +uint32_t ScreenSceneConfig::GetOffScreenPPIThreshold() | ||
| 315 | +{ | ||
| 316 | + if (intNumbersConfig_[xmlNodeMap_[OFF_SCREEN_PPI_THRESHOLD]].size() != 0) { | ||
| 317 | + return static_cast<uint32_t>(intNumbersConfig_[xmlNodeMap_[OFF_SCREEN_PPI_THRESHOLD]][0]); | ||
| 318 | + } | ||
| 319 | + return offScreenPPIThreshold_; | ||
| 320 | +} | ||
| 321 | + | ||
| 322 | +bool ScreenSceneConfig::IsSupportOffScreenRendering() | ||
| 323 | +{ | ||
| 324 | + if (enableConfig_.count("isSupportOffScreenRendering") != 0) { | ||
| 325 | + return static_cast<bool>(enableConfig_["isSupportOffScreenRendering"]); | ||
| 326 | + } | ||
| 327 | + return false; | ||
| 328 | +} | ||
| 329 | + | ||
| 330 | +bool ScreenSceneConfig::IsSupportDuringCall() | ||
| 331 | +{ | ||
| 332 | + return false; | ||
| 333 | +} | ||
| 334 | + | ||
| 335 | +bool ScreenSceneConfig::IsConcurrentUser() | ||
| 336 | +{ | ||
| 337 | + return isConcurrentUser_; | ||
| 338 | +} | ||
| 339 | +// LCOV_EXCL_STOP | ||
| 340 | + | ||
| 341 | +uint32_t ScreenSceneConfig::GetNumberConfigValue(const std::string& name, const uint32_t& default_value) | ||
| 342 | +{ | ||
| 343 | + if (intNumbersConfig_.count(name) != 0) { | ||
| 344 | + return static_cast<uint32_t>(intNumbersConfig_[name][0]); | ||
| 345 | + } | ||
| 346 | + return default_value; | ||
| 347 | +} | ||
| 348 | + | ||
| 349 | +} // namespace OHOS::Rosen | ||
| @@ -0,0 +1,45 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +namespace OHOS { | ||
| 22 | +namespace Rosen { | ||
| 23 | +class MockSessionManagerService { | ||
| 24 | +public: | ||
| 25 | + static MockSessionManagerService& GetInstance() | ||
| 26 | + { | ||
| 27 | + static MockSessionManagerService instance_; | ||
| 28 | + return instance_; | ||
| 29 | + } | ||
| 30 | + void AddSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t>& persistentIds, int32_t userId) {} | ||
| 31 | + void RemoveSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t>& persistentIds, int32_t userId) {} | ||
| 32 | + void NotifyWMSConnected(int32_t userId, DisplayId screenId, bool isColdStart) {} | ||
| 33 | + void GetProcessSurfaceNodeIdByPersistentId(const int32_t pid, | ||
| 34 | + const std::vector<uint64_t>& windowIdList, std::vector<uint64_t>& surfaceNodeIds) {} | ||
| 35 | + void SetScreenPrivacyWindowTagSwitch( | ||
| 36 | + uint64_t screenId, const std::vector<std::string>& privacyWindowTags, bool enable) {} | ||
| 37 | + | ||
| 38 | +private: | ||
| 39 | + MockSessionManagerService() = default; | ||
| 40 | + ~MockSessionManagerService() = default; | ||
| 41 | +}; | ||
| 42 | +} | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | + | ||
| @@ -0,0 +1,133 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2025 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +namespace OHOS { | ||
| 19 | +namespace Rosen { | ||
| 20 | + | ||
| 21 | +bool SessionPermission::IsSystemServiceCalling(bool needPrintLog) | ||
| 22 | +{ | ||
| 23 | + return true; | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +bool SessionPermission::IsSystemCalling() | ||
| 27 | +{ | ||
| 28 | + return true; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +bool SessionPermission::IsSystemAppCall() | ||
| 32 | +{ | ||
| 33 | + return true; | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +bool SessionPermission::IsSystemAppCallByCallingTokenID(uint32_t callingTokenId) | ||
| 37 | +{ | ||
| 38 | + return true; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +bool SessionPermission::IsSACalling() | ||
| 42 | +{ | ||
| 43 | + return true; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +bool SessionPermission::VerifyCallingPermission(const std::string& permissionName) | ||
| 47 | +{ | ||
| 48 | + return true; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +bool SessionPermission::VerifyPermissionByCallerToken(const uint32_t callerToken, const std::string& permissionName) | ||
| 52 | +{ | ||
| 53 | + return true; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +bool SessionPermission::VerifySessionPermission() | ||
| 57 | +{ | ||
| 58 | + return true; | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +bool SessionPermission::JudgeCallerIsAllowedToUseSystemAPI() | ||
| 62 | +{ | ||
| 63 | + return true; | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +bool SessionPermission::IsShellCall() | ||
| 67 | +{ | ||
| 68 | + return true; | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +bool SessionPermission::IsStartByHdcd() | ||
| 72 | +{ | ||
| 73 | + return true; | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +bool SessionPermission::IsStartedByInputMethod() | ||
| 77 | +{ | ||
| 78 | + return true; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +bool SessionPermission::IsKeyboardCallingProcess(int32_t pid, uint32_t callingWindowId) | ||
| 82 | +{ | ||
| 83 | + return true; | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +bool SessionPermission::IsSameBundleNameAsCalling(const std::string& bundleName) | ||
| 87 | +{ | ||
| 88 | + return true; | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +bool SessionPermission::IsSameAppAsCalling(const std::string& bundleName, const std::string& appIdentifier) | ||
| 92 | +{ | ||
| 93 | + return true; | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +bool SessionPermission::IsStartedByUIExtension() | ||
| 97 | +{ | ||
| 98 | + return true; | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +bool SessionPermission::CheckCallingIsUserTestMode(pid_t pid) | ||
| 102 | +{ | ||
| 103 | + return true; | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +bool SessionPermission::IsBetaVersion() | ||
| 107 | +{ | ||
| 108 | + return true; | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +bool SessionPermission::IsFoundationCall() | ||
| 112 | +{ | ||
| 113 | + return true; | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +std::string SessionPermission::GetCallingBundleName() | ||
| 117 | +{ | ||
| 118 | + return ""; | ||
| 119 | +} | ||
| 120 | + | ||
| 121 | +bool SessionPermission::VerifyPermissionByBundleName( | ||
| 122 | + const std::string& bundleName, const std::string& permissionName, uint32_t userId) | ||
| 123 | +{ | ||
| 124 | + return true; | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +bool SessionPermission::IsTokenNativeOrShellType(uint32_t tokenId) | ||
| 128 | +{ | ||
| 129 | + return true; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +} // Rosen | ||
| 133 | +} // OHOS | ||