1 /* 2 * Copyright (c) 2021 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 HIVIEW_SERVICE_ABILITY_H 17 #define HIVIEW_SERVICE_ABILITY_H 18 19 #include <string> 20 #include <memory> 21 22 #include "logger.h" 23 #include "system_ability.h" 24 #include "hiview_service_ability_stub.h" 25 #include "ihiview_service_ability.h" 26 #include "hiview_service.h" 27 #include "singleton.h" 28 29 namespace OHOS { 30 namespace HiviewDFX { 31 class HiviewServiceAbility : public SystemAbility, 32 public HiviewServiceAbilityStub { 33 DECLARE_SYSTEM_ABILITY(HiviewServiceAbility); 34 35 public: 36 HiviewServiceAbility(); 37 ~HiviewServiceAbility(); 38 int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override; 39 static void StartService(HiviewService *service); 40 static void StartServiceAbility(int sleepS); 41 static HiviewService* GetOrSetHiviewService(HiviewService *service = nullptr); 42 protected: 43 void OnDump() override; 44 void OnStart() override; 45 void OnStop() override; 46 }; 47 48 class HiviewServiceAbilityDeathRecipient : public IRemoteObject::DeathRecipient { 49 public: 50 HiviewServiceAbilityDeathRecipient(); 51 ~HiviewServiceAbilityDeathRecipient(); 52 void OnRemoteDied(const wptr<IRemoteObject> &object) override; 53 }; 54 } // namespace HiviewDFX 55 } // namespace OHOS 56 #endif // IHIVIEW_SERVICE_H