• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "screen_session_manager_client/include/screen_session_manager_client.h"
17 #include "session/host/include/ws_snapshot_helper.h"
18 
19 namespace OHOS::Rosen {
20 namespace {
21 const std::unordered_map<int32_t, DisplayOrientation> ROTATION_TO_DISPLAYORIENTATION_MAP = {
22     { PORTRAIT_ANGLE, DisplayOrientation::PORTRAIT },
23     { LANDSCAPE_ANGLE, DisplayOrientation::LANDSCAPE },
24     { PORTRAIT_INVERTED_ANGLE, DisplayOrientation::PORTRAIT_INVERTED },
25     { LANDSCAPE_INVERTED_ANGLE, DisplayOrientation::LANDSCAPE_INVERTED }
26 };
27 }
28 
GetScreenStatus()29 uint32_t WSSnapshotHelper::GetScreenStatus()
30 {
31     FoldStatus foldStatus = ScreenSessionManagerClient::GetInstance().GetFoldStatus();
32     return GetScreenStatus(foldStatus);
33 }
34 
35 // LCOV_EXCL_START
GetScreenStatus(FoldStatus foldStatus)36 uint32_t WSSnapshotHelper::GetScreenStatus(FoldStatus foldStatus)
37 {
38     if (foldStatus == FoldStatus::UNKNOWN || foldStatus == FoldStatus::FOLDED ||
39         foldStatus == FoldStatus::FOLD_STATE_FOLDED_WITH_SECOND_EXPAND ||
40         foldStatus == FoldStatus::FOLD_STATE_FOLDED_WITH_SECOND_HALF_FOLDED) {
41         return SCREEN_FOLDED;
42     } else if (foldStatus == FoldStatus::EXPAND || foldStatus == FoldStatus::HALF_FOLD) {
43         return SCREEN_EXPAND;
44     }
45     return SCREEN_UNKNOWN;
46 }
47 
GetDisplayOrientation(int32_t rotation)48 DisplayOrientation WSSnapshotHelper::GetDisplayOrientation(int32_t rotation)
49 {
50     auto it = ROTATION_TO_DISPLAYORIENTATION_MAP.find(rotation);
51     if (it != ROTATION_TO_DISPLAYORIENTATION_MAP.end()) {
52         return it->second;
53     }
54     return DisplayOrientation::PORTRAIT;
55 }
56 // LCOV_EXCL_STOP
57 } // namespace OHOS::Rosen