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 PASSIVE_ABILITY_H 17 #define PASSIVE_ABILITY_H 18 19 #include <mutex> 20 #include <singleton.h> 21 #include "if_system_ability_manager.h" 22 #include "system_ability.h" 23 #include "common_utils.h" 24 #include "passive_ability_skeleton.h" 25 #include "subability_common.h" 26 27 namespace OHOS { 28 namespace Location { 29 class PassiveAbility : public SystemAbility, public PassiveAbilityStub, public SubAbility, 30 DelayedSingleton<PassiveAbility> { 31 DECLEAR_SYSTEM_ABILITY(PassiveAbility); 32 33 public: 34 DISALLOW_COPY_AND_MOVE(PassiveAbility); 35 PassiveAbility(); 36 ~PassiveAbility(); 37 void OnStart() override; 38 void OnStop() override; QueryServiceState()39 ServiceRunningState QueryServiceState() const 40 { 41 return state_; 42 } 43 void SendLocationRequest(uint64_t interval, WorkRecord &workrecord) override; 44 std::unique_ptr<Location> GetCachedLocation() override; 45 void SetEnable(bool state) override; 46 int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override; 47 void RequestRecord(WorkRecord &workRecord, bool isAdded) override; 48 private: 49 bool Init(); 50 static void SaDumpInfo(std::string& result); 51 bool registerToAbility_ = false; 52 ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START; 53 }; 54 } // namespace Location 55 } // namespace OHOS 56 #endif // PASSIVE_ABILITY_H 57