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