1 /*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "Common.h"
18
19 #include <android-base/properties.h>
20
21 namespace aidl::android::hardware::graphics::composer3::impl {
22
IsCuttlefish()23 bool IsCuttlefish() {
24 return ::android::base::GetProperty("ro.product.board", "") == "cutf";
25 }
26
IsCuttlefishFoldable()27 bool IsCuttlefishFoldable() {
28 return IsCuttlefish() &&
29 ::android::base::GetProperty("ro.product.name", "").find("foldable") !=
30 std::string::npos;
31 }
32
IsInNoOpCompositionMode()33 bool IsInNoOpCompositionMode() {
34 const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
35 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
36 return mode == "noop";
37 }
38
IsInClientCompositionMode()39 bool IsInClientCompositionMode() {
40 const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
41 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
42 return mode == "client";
43 }
44
IsInNoOpDisplayFinderMode()45 bool IsInNoOpDisplayFinderMode() {
46 const std::string mode =
47 ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
48 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s",
49 __FUNCTION__, mode.c_str());
50 return mode == "noop";
51 }
52
IsInDrmDisplayFinderMode()53 bool IsInDrmDisplayFinderMode() {
54 const std::string mode =
55 ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
56 DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s",
57 __FUNCTION__, mode.c_str());
58 return mode == "drm";
59 }
60
toString(HWC3::Error error)61 std::string toString(HWC3::Error error) {
62 switch (error) {
63 case HWC3::Error::None:
64 return "None";
65 case HWC3::Error::BadConfig:
66 return "BadConfig";
67 case HWC3::Error::BadDisplay:
68 return "BadDisplay";
69 case HWC3::Error::BadLayer:
70 return "BadLayer";
71 case HWC3::Error::BadParameter:
72 return "BadParameter";
73 case HWC3::Error::NoResources:
74 return "NoResources";
75 case HWC3::Error::NotValidated:
76 return "NotValidated";
77 case HWC3::Error::Unsupported:
78 return "Unsupported";
79 case HWC3::Error::SeamlessNotAllowed:
80 return "SeamlessNotAllowed";
81 }
82 }
83
84 } // namespace aidl::android::hardware::graphics::composer3::impl
85