• 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_manager.h"
27 #include "devicestatus_delayed_sp_singleton.h"
28 
29 namespace OHOS {
30 namespace Msdp {
31 class DevicestatusService final : public SystemAbility, public DevicestatusSrvStub {
32     DECLARE_SYSTEM_ABILITY(DevicestatusService)
33     DECLARE_DELAYED_SP_SINGLETON(DevicestatusService);
34 public:
35     virtual void OnStart() override;
36     virtual void OnStop() override;
37 
38     void Subscribe(const DevicestatusDataUtils::DevicestatusType& type, \
39         const sptr<IdevicestatusCallback>& callback) override;
40     void UnSubscribe(const DevicestatusDataUtils::DevicestatusType& type, \
41         const sptr<IdevicestatusCallback>& callback) override;
42     DevicestatusDataUtils::DevicestatusData GetCache(const DevicestatusDataUtils::DevicestatusType& type) override;
43     bool IsServiceReady();
44     std::shared_ptr<DevicestatusManager> GetDevicestatusManager();
45 private:
46     bool Init();
47     bool ready_ = false;
48     std::shared_ptr<DevicestatusManager> devicestatusManager_;
49     std::shared_ptr<DevicestatusMsdpClientImpl> msdpImpl_;
50 };
51 } // namespace Msdp
52 } // namespace OHOS
53 #endif // DEVICESTATUS_SERVICE_H
54