• 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 #ifndef SECURITY_COMPONENT_ENTITY_H
16 #define SECURITY_COMPONENT_ENTITY_H
17 
18 #include <memory>
19 #include "accesstoken_kit.h"
20 #include "sec_comp_base.h"
21 #include "sec_comp_info.h"
22 #include "sec_comp_perm_manager.h"
23 
24 namespace OHOS {
25 namespace Security {
26 namespace SecurityComponent {
27 class SecCompEntity {
28 public:
SecCompEntity(std::shared_ptr<SecCompBase> component,AccessToken::AccessTokenID token,int32_t scId,int32_t pid,int32_t uid)29     SecCompEntity(std::shared_ptr<SecCompBase> component,
30         AccessToken::AccessTokenID token, int32_t scId, int32_t pid, int32_t uid)
31         : componentInfo_(component), tokenId_(token), scId_(scId), pid_(pid), uid_(uid) {};
32     ~SecCompEntity() = default;
33     int32_t RevokeTempPermission();
34     int32_t GrantTempPermission();
GetType()35     SecCompType GetType() const
36     {
37         if (componentInfo_ == nullptr) {
38             return UNKNOWN_SC_TYPE;
39         }
40         return componentInfo_->type_;
41     };
42 
IsGrant()43     bool IsGrant() const
44     {
45         return isGrant_;
46     }
47 
48     bool CompareComponentBasicInfo(SecCompBase* other, bool isRectCheck) const;
49     int32_t CheckClickInfo(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY,
50         const CrossAxisState crossAxisState) const;
51     bool IsInPCVirtualScreen(const CrossAxisState crossAxisState) const;
52 
53     std::shared_ptr<SecCompBase> componentInfo_;
54     AccessToken::AccessTokenID tokenId_;
55     int32_t scId_;
56     int32_t pid_;
57     int32_t uid_;
58 
59 private:
60     int32_t CheckKeyEvent(const SecCompClickEvent& clickInfo) const;
61     int32_t CheckPointEvent(SecCompClickEvent& clickInfo, int32_t superFoldOffsetY,
62         const CrossAxisState crossAxisState) const;
63     bool isGrant_ = false;
64 };
65 }  // namespace SecurityComponent
66 }  // namespace Security
67 }  // namespace OHOS
68 #endif // SECURITY_COMPONENT_ENTITY_H
69