1 /*
2  * Copyright (c) 2023 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 #include "location_button.h"
16 
17 #include <tuple>
18 #include "sec_comp_log.h"
19 
20 namespace OHOS {
21 namespace Security {
22 namespace SecurityComponent {
23 namespace {
24 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "LocationButton"};
25 }
26 
IsTextIconTypeValid()27 bool LocationButton::IsTextIconTypeValid()
28 {
29     if ((text_ <= UNKNOWN_TEXT) || (static_cast<LocationDesc>(text_) >= LocationDesc::MAX_LABEL_TYPE) ||
30         (icon_ <= UNKNOWN_ICON) || (static_cast<LocationIcon>(icon_) >= LocationIcon::MAX_ICON_TYPE)) {
31         return false;
32     }
33     return true;
34 }
35 
IsCorrespondenceType()36 bool LocationButton::IsCorrespondenceType()
37 {
38     return (type_ == LOCATION_COMPONENT);
39 }
40 
CompareComponentBasicInfo(SecCompBase * other,bool isRectCheck) const41 bool LocationButton::CompareComponentBasicInfo(SecCompBase *other, bool isRectCheck) const
42 {
43     if (!SecCompBase::CompareComponentBasicInfo(other, isRectCheck)) {
44         SC_LOG_ERROR(LABEL, "SecComp base not equal.");
45         return false;
46     }
47     LocationButton* otherLocationButton = reinterpret_cast<LocationButton *>(other);
48     if (otherLocationButton == nullptr) {
49         SC_LOG_ERROR(LABEL, "other is not location button.");
50         return false;
51     }
52     return (icon_ == otherLocationButton->icon_) && (text_ == otherLocationButton->text_) &&
53         (bg_ == otherLocationButton->bg_);
54 }
55 }  // namespace SecurityComponent
56 }  // namespace Security
57 }  // namespace OHOS
58