• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "save_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, "SaveButton"};
25 }
26 
IsTextIconTypeValid()27 bool SaveButton::IsTextIconTypeValid()
28 {
29     if ((text_ <= UNKNOWN_TEXT) || (static_cast<SaveDesc>(text_) >= SaveDesc::MAX_LABEL_TYPE) ||
30         (icon_ <= UNKNOWN_ICON) || (static_cast<SaveIcon>(icon_) >= SaveIcon::MAX_ICON_TYPE)) {
31         return false;
32     }
33 
34     return true;
35 }
36 
IsCorrespondenceType()37 bool SaveButton::IsCorrespondenceType()
38 {
39     return (type_ == SAVE_COMPONENT);
40 }
41 
CompareComponentBasicInfo(SecCompBase * other,bool isRectCheck) const42 bool SaveButton::CompareComponentBasicInfo(SecCompBase *other, bool isRectCheck) const
43 {
44     if (!SecCompBase::CompareComponentBasicInfo(other, isRectCheck)) {
45         SC_LOG_ERROR(LABEL, "SecComp base not equal.");
46         return false;
47     }
48     SaveButton* otherSaveButton = reinterpret_cast<SaveButton *>(other);
49     if (otherSaveButton == nullptr) {
50         SC_LOG_ERROR(LABEL, "other is not save button.");
51         return false;
52     }
53     return (icon_ == otherSaveButton->icon_) && (text_ == otherSaveButton->text_) &&
54         (bg_ == otherSaveButton->bg_);
55 }
56 }  // namespace SecurityComponent
57 }  // namespace Security
58 }  // namespace OHOS
59