• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 DEVICESTATUS_SERVICE_H
17 #define DEVICESTATUS_SERVICE_H
18 
19 #include <memory>
20 #include <iremote_object.h>
21 #include <system_ability.h>
22 
23 #include "devicestatus_srv_stub.h"
24 #include "idevicestatus_callback.h"
25 #include "devicestatus_data_utils.h"
26 #include "devicestatus_dumper.h"
27 #include "devicestatus_manager.h"
28 #include "devicestatus_delayed_sp_singleton.h"
29 
30 namespace OHOS {
31 namespace Msdp {
32 class DevicestatusService final : public SystemAbility, public DevicestatusSrvStub {
33     DECLARE_SYSTEM_ABILITY(DevicestatusService)
34     DECLARE_DELAYED_SP_SINGLETON(DevicestatusService);
35 public:
36     virtual void OnDump() override;
37     virtual void OnStart() override;
38     virtual void OnStop() override;
39 
40     void Subscribe(const DevicestatusDataUtils::DevicestatusType& type, \
41         const sptr<IdevicestatusCallback>& callback) override;
42     void UnSubscribe(const DevicestatusDataUtils::DevicestatusType& type, \
43         const sptr<IdevicestatusCallback>& callback) override;
44     DevicestatusDataUtils::DevicestatusData GetCache(const DevicestatusDataUtils::DevicestatusType& type) override;
45     int Dump(int fd, const std::vector<std::u16string>& args) override;
46     void ReportMsdpSysEvent(const DevicestatusDataUtils::DevicestatusType& type, bool enable);
47 private:
48     bool Init();
49     bool ready_ = false;
50     std::shared_ptr<DevicestatusManager> devicestatusManager_;
51     std::shared_ptr<DevicestatusMsdpClientImpl> msdpImpl_;
52 };
53 } // namespace Msdp
54 } // namespace OHOS
55 #endif // DEVICESTATUS_SERVICE_H
56