• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 LOCATOR_MSDP_MONITOR_MANAGER_H
17 #define LOCATOR_MSDP_MONITOR_MANAGER_H
18 #ifdef MOVEMENT_CLIENT_ENABLE
19 #include "locator_msdp_state_change_cb.h"
20 #include "movement_client.h"
21 #include "iservice_registry.h"
22 #include "location_log.h"
23 #include "system_ability_definition.h"
24 #include "system_ability_status_change_stub.h"
25 #include "locator_msdp_state_change_cb.h"
26 
27 namespace OHOS {
28 namespace Location {
29 class LocatorMsdpMonitorManager {
30 public:
31     static LocatorMsdpMonitorManager* GetInstance();
32     LocatorMsdpMonitorManager();
33     ~LocatorMsdpMonitorManager();
34     void RegisterMovementCallBack();
35     void UnRegisterMovementCallBack();
36     void UpdateStillMovementState(bool stillState);
37     bool GetStillMovementState();
38     uint64_t GetEnterStillTime();
39 
40     std::atomic_bool isDeviceStillState_;
41     std::atomic_uint64_t enterStillTime_; // utc time millsec
42 
43 private:
44     void Init();
45     sptr<DeviceMovementCallback> deviceMovementCallback_;
46     std::mutex deviceMovementEventMutex;
47     sptr<ISystemAbilityStatusChange> saStatusListener_;
48 };
49 
50 class MsdpMotionServiceStatusChange : public SystemAbilityStatusChangeStub {
51 public:
52     void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
53     void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
54 };
55 }
56 }
57 #endif // MOVEMENT_CLIENT_ENABLE
58 #endif // LOCATOR_MSDP_MONITOR_MANAGER_H