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 "paste_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, "PasteButton"};
25 }
26
IsTextIconTypeValid()27 bool PasteButton::IsTextIconTypeValid()
28 {
29 if ((text_ <= UNKNOWN_TEXT) || (static_cast<PasteDesc>(text_) >= PasteDesc::MAX_LABEL_TYPE) ||
30 (icon_ <= UNKNOWN_ICON) || (static_cast<PasteIcon>(icon_) >= PasteIcon::MAX_ICON_TYPE)) {
31 return false;
32 }
33
34 return true;
35 }
36
IsCorrespondenceType()37 bool PasteButton::IsCorrespondenceType()
38 {
39 return (type_ == PASTE_COMPONENT);
40 }
41
CompareComponentBasicInfo(SecCompBase * other,bool isRectCheck) const42 bool PasteButton::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 PasteButton* otherPasteButton = reinterpret_cast<PasteButton *>(other);
49 if (otherPasteButton == nullptr) {
50 SC_LOG_ERROR(LABEL, "other is not paste button.");
51 return false;
52 }
53 return (icon_ == otherPasteButton->icon_) && (text_ == otherPasteButton->text_) &&
54 (bg_ == otherPasteButton->bg_);
55 }
56 } // namespace SecurityComponent
57 } // namespace Security
58 } // namespace OHOS
59