• 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 
16 #ifndef OHOS_SYSTEM_ABILITY_MANAGER_DEVICE_PARAM_COLLECT_H
17 #define OHOS_SYSTEM_ABILITY_MANAGER_DEVICE_PARAM_COLLECT_H
18 
19 #include "icollect_plugin.h"
20 #include "samgr_ffrt_api.h"
21 #include "system_ability_status_change_stub.h"
22 #include <set>
23 #include <list>
24 
25 namespace OHOS {
26 class DeviceParamCollect : public ICollectPlugin {
27 public:
28     explicit DeviceParamCollect(const sptr<IReport>& report);
29     ~DeviceParamCollect() = default;
30     void Init(const std::list<SaProfile>& saProfiles) override;
31     void WatchParameters();
32     bool CheckCondition(const OnDemandCondition& condition) override;
33     int32_t AddCollectEvent(const std::vector<OnDemandEvent>& events) override;
34     int32_t RemoveUnusedEvent(const OnDemandEvent& event) override;
35     int32_t OnStart() override;
36     int32_t OnStop() override;
37     const std::vector<int32_t>& GetLowMemPrepareList() override;
38 private:
39     void CheckLowMemSA(const std::string& name, int32_t saId);
40     samgr::mutex paramLock_;
41     std::set<std::string> pendingParams_;
42     std::set<std::string> params_;
43     std::vector<int32_t> lowMemPrepareList_;
44 };
45 
46 class SystemAbilityStatusChange : public SystemAbilityStatusChangeStub {
47 public:
48     void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
49     void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
50     void Init(const sptr<DeviceParamCollect>& deviceParamCollect);
51 private:
52     sptr<DeviceParamCollect> deviceParamCollect_;
53 };
54 } // namespace OHOS
55 #endif // OHOS_SYSTEM_ABILITY_MANAGER_DEVICE_PARAM_COLLECT_H