• 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 PERMISSION_SEC_COMP_ENHANCE_AGENT_H
16 #define PERMISSION_SEC_COMP_ENHANCE_AGENT_H
17 
18 #include <mutex>
19 #include <vector>
20 #include "app_manager_death_callback.h"
21 #include "app_status_change_callback.h"
22 #include "nocopyable.h"
23 #include "sec_comp_enhance_data.h"
24 #include "sec_comp_monitor.h"
25 
26 namespace OHOS {
27 namespace Security {
28 namespace AccessToken {
29 #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE
30 class SecCompEnhanceAgent final {
31 public:
32     static SecCompEnhanceAgent& GetInstance();
33     virtual ~SecCompEnhanceAgent();
34 
35     int32_t RegisterSecCompEnhance(const SecCompEnhanceData& enhanceData);
36     int32_t UpdateSecCompEnhance(int32_t pid, uint32_t seqNum);
37     int32_t GetSecCompEnhance(int32_t pid, SecCompEnhanceData& enhanceData);
38     void RemoveSecCompEnhance(int pid);
39     void OnAppMgrRemoteDiedHandle();
40 
41 private:
42     SecCompEnhanceAgent();
43     void InitAppObserver();
44     DISALLOW_COPY_AND_MOVE(SecCompEnhanceAgent);
45 
46 private:
47     sptr<SecCompUsageObserver> observer_ = nullptr;
48     std::shared_ptr<SecCompAppManagerDeathCallback> appManagerDeathCallback_ = nullptr;
49     std::mutex secCompEnhanceMutex_;
50     std::vector<SecCompEnhanceData> secCompEnhanceData_;
51 };
52 #endif
53 } // namespace AccessToken
54 } // namespace Security
55 } // namespace OHOS
56 #endif // PERMISSION_SEC_COMP_ENHANCE_AGENT_H
57