1 /* 2 * Copyright (c) 2024 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 #ifndef OHOS_ROSEN_SECONDARY_DISPLAY_FOLD_STATE_SENSOR_MANAGER_H 17 #define OHOS_ROSEN_SECONDARY_DISPLAY_FOLD_STATE_SENSOR_MANAGER_H 18 19 #include "dm_common.h" 20 #include <transaction/rs_interfaces.h> 21 #include "fold_screen_controller/fold_screen_policy.h" 22 #include "fold_screen_controller/sensor_fold_state_manager/sensor_fold_state_manager.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 class SecondaryDisplaySensorFoldStateManager : public SensorFoldStateManager { 27 public: 28 SecondaryDisplaySensorFoldStateManager(); 29 virtual ~SecondaryDisplaySensorFoldStateManager(); 30 void HandleAngleOrHallChange(const std::vector<float>& angles, const std::vector<uint16_t>& halls, 31 sptr<FoldScreenPolicy> foldScreenPolicy, bool isPostureRegistered) override; 32 private: 33 FoldStatus GetNextFoldState(const std::vector<float> &angles, const std::vector<uint16_t> &halls, 34 bool isPostureRegistered, bool isFoldScreenOn); 35 FoldStatus GetNextFoldStateHalf(float angle, uint16_t hall, FoldStatus myNextStatus, 36 int32_t allowUserSensorForLargeFoldDevice); 37 FoldStatus GetGlobalFoldState(FoldStatus PrimaryFoldState, FoldStatus SecondaryFoldState); 38 FoldStatus UpdateSwitchScreenBoundaryForLargeFoldDeviceAB(float angle, uint16_t hall, FoldStatus state); 39 FoldStatus UpdateSwitchScreenBoundaryForLargeFoldDeviceBC(float angle, uint16_t hall, FoldStatus state); 40 FoldStatus GetFoldStateUnpower(const std::vector<uint16_t> &halls); 41 void ReportSecondaryReflexion(int32_t currentStatus, int32_t nextStatus, bool isSecondaryReflexion); 42 void SendReflexionResult(bool isSecondaryReflexion); 43 FoldStatus HandleSecondaryOneStep(FoldStatus currentStatus, FoldStatus nextStatus, 44 const std::vector<float>& angles, const std::vector<uint16_t>& halls) override; 45 FoldStatus CalculateNewABFoldStatus(float previousAngle, uint16_t previousHall, float angle, uint16_t hall); 46 47 int32_t allowUserSensorForLargeFoldDeviceAB = 0; 48 int32_t allowUserSensorForLargeFoldDeviceBC = 0; 49 bool isHasReflexioned = false; 50 FoldStatus mNextStateAB = FoldStatus::UNKNOWN; 51 FoldStatus mNextStateBC = FoldStatus::UNKNOWN; 52 // used to record the current hall value between the A and B screens. 53 uint16_t curHallAB_ = 2; 54 // used to record the current hall value between the B and C screens. 55 uint16_t curHallBC_ = 2; 56 std::mutex secondaryFoldStatusMutex_; 57 }; 58 } // namespace Rosen 59 } // namespace OHOS 60 #endif